using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; namespace veloprokat2 { /// /// Логика взаимодействия для Window1.xaml /// public partial class SpisRab : Window { public SpisRab() { InitializeComponent(); SqlConnection connection = new SqlConnection("server=mssql; Trusted_Connection=YES;DataBase=gr692_kaa;"); connection.Open(); string cmd = "select id as '№ сотрудника', Login as 'Логин',Password as 'Пароль',LName 'Фамилия',Fname 'Имя',Mname 'Отчество',Email 'Почта',Phone 'Телефон',FORMAT(Dr, 'dd/MM/yyyy') as 'День рожджения' from InfoRab"; SqlCommand createcommand = new SqlCommand(cmd, connection); createcommand.ExecuteNonQuery(); SqlDataAdapter sql = new SqlDataAdapter(createcommand); DataTable dt = new DataTable("InfoRab"); sql.Fill(dt); prodinfo.ItemsSource = dt.DefaultView; connection.Close(); } private void Vixod(object sender, RoutedEventArgs e) { MainWindowAdm MWA = new MainWindowAdm(); MWA.Show(); Close(); } private void Button_Search(object sender, RoutedEventArgs e) { if (Search.Text.Length > 0) { SqlConnection connection = new SqlConnection("server=mssql; Trusted_Connection=YES;DataBase=gr692_kaa;"); connection.Open(); string cmd = "select ID as '№ сотрудника', Login as 'Логин',Password as 'Пароль',LName 'Фамилия',Fname 'Имя',Mname 'Отчество',Email 'Почта',Phone 'Телефон',FORMAT(Dr, 'dd/MM/yyyy') as 'День рожджения' from InfoRab" + " where ( Login like '%" + Search.Text + "%' or Password like '%" + Search.Text + "%' or LName like '%" + Search.Text + "%' or FName like '%" + Search.Text + "%' or Mname like '%" + Search.Text + "%' or Email like '%" + Search.Text + "%' or Phone like '%" + Search.Text + "%' or Dr like '%" + Search.Text + "%')"; SqlCommand createcommand = new SqlCommand(cmd, connection); createcommand.ExecuteNonQuery(); SqlDataAdapter sql = new SqlDataAdapter(createcommand); DataTable dt = new DataTable("SpisProk"); sql.Fill(dt); prodinfo.ItemsSource = dt.DefaultView; connection.Close(); } else if (Search.Text.Length == 0) { SqlConnection connection = new SqlConnection("server=mssql; Trusted_Connection=YES;DataBase=gr692_kaa;"); connection.Open(); string cmd = "select ID as '№ сотрудника', Login as 'Логин',Password as 'Пароль',LName 'Фамилия',Fname 'Имя',Mname 'Отчество',Email 'Почта',Phone 'Телефон',FORMAT(Dr, 'dd/MM/yyyy') as 'День рожджения' from InfoRab"; SqlCommand createcommand = new SqlCommand(cmd, connection); createcommand.ExecuteNonQuery(); SqlDataAdapter sql = new SqlDataAdapter(createcommand); DataTable dt = new DataTable("SpisProk"); sql.Fill(dt); prodinfo.ItemsSource = dt.DefaultView; connection.Close(); } } private void Delete(object sender, RoutedEventArgs e) { DeleteRab DR = new DeleteRab(); DR.Show(); Close(); } } }