123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- 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
- {
- /// <summary>
- /// Логика взаимодействия для Window1.xaml
- /// </summary>
- 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();
- }
- }
- }
|