SpisokUchenikov.xaml.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1.  using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Data.SqlClient;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Data;
  11. using System.Windows.Documents;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Shapes;
  16. namespace KursachMukha692gr
  17. {
  18. /// <summary>
  19. /// Логика взаимодействия для SpisokUchenikov.xaml
  20. /// </summary>
  21. public partial class SpisokUchenikov : Window
  22. {
  23. public SpisokUchenikov()
  24. {
  25. InitializeComponent();
  26. SqlConnection connection = new SqlConnection("server=WIN-2CL665KE0ED; Trusted_Connection=YES;DataBase=KURSACH1;");
  27. connection.Open();
  28. string cmd = "select id,familiya as 'Фамилия', imya as 'Имя', otchestvo as 'Отчество' , dataUchenik as 'Дата рождения',fk_disciplina_id as 'id дисциплины', fk_gruppa_id as 'Номер группы',fk_pol_id as 'id пола', telephonenumUchenik as 'Номер телефона' from infouchenik";
  29. SqlCommand createcommand = new SqlCommand(cmd, connection);
  30. createcommand.ExecuteNonQuery();
  31. SqlDataAdapter sql = new SqlDataAdapter(createcommand);
  32. DataTable dt = new DataTable("ucheniki");
  33. sql.Fill(dt);
  34. uchenikigrid.ItemsSource = dt.DefaultView;
  35. connection.Close();
  36. }
  37. private void Button_Click_add(object sender, RoutedEventArgs e)
  38. {
  39. AddUchenik uchenik = new AddUchenik();
  40. uchenik.Show();
  41. Close();
  42. }
  43. private void Button_Click_delete(object sender, RoutedEventArgs e)
  44. {
  45. DeleteSpisokUchenikov spisokUchenikov = new DeleteSpisokUchenikov();
  46. spisokUchenikov.Show();
  47. Close();
  48. }
  49. private void Button_Click_Back(object sender, RoutedEventArgs e)
  50. {
  51. KabinetAdmina kabinet = new KabinetAdmina();
  52. kabinet.Show();
  53. Close();
  54. }
  55. private void Button_Click_update(object sender, RoutedEventArgs e)
  56. {
  57. ViborUchenikUpdate uchenikUpdate = new ViborUchenikUpdate();
  58. uchenikUpdate.Show();
  59. Close();
  60. }
  61. private void Button_Click_Search(object sender, RoutedEventArgs e)
  62. {
  63. if (search.Text.Length > 0)
  64. {
  65. SqlConnection connection = new SqlConnection("server=WIN-2CL665KE0ED; Trusted_Connection=YES;DataBase=KURSACH1;");
  66. connection.Open();
  67. string cmd = "select id,familiya as 'Фамилия', imya as 'Имя', otchestvo as 'Отчество' , dataUchenik as 'Дата рождения',fk_disciplina_id as 'id дисциплины', fk_gruppa_id as 'Номер группы',fk_pol_id as 'id пола', telephonenumUchenik as 'Номер телефона' from infouchenik" +
  68. " where id like '%" + search.Text + "%' or familiya like '%" + search.Text + "%' or otchestvo like '%" + search.Text + "%' or dataUchenik like '%" + search.Text + "%' or fk_disciplina_id like '%" + search.Text + "%' or fk_gruppa_id like '%" + search.Text + "%' or fk_pol_id like '%" + search.Text + "%' or telephonenumUchenik like '%" + search.Text + "%'" ;
  69. SqlCommand createcommand = new SqlCommand(cmd, connection);
  70. createcommand.ExecuteNonQuery();
  71. SqlDataAdapter sql = new SqlDataAdapter(createcommand);
  72. DataTable dt = new DataTable("sorevi");
  73. sql.Fill(dt);
  74. uchenikigrid.ItemsSource = dt.DefaultView;
  75. connection.Close();
  76. }
  77. else if (search.Text.Length == 0)
  78. {
  79. SqlConnection connection = new SqlConnection("server=WIN-2CL665KE0ED; Trusted_Connection=YES;DataBase=KURSACH1;");
  80. connection.Open();
  81. string cmd = "select id,familiya as 'Фамилия', imya as 'Имя', otchestvo as 'Отчество' , dataUchenik as 'Дата рождения',fk_disciplina_id as 'id дисциплины', fk_gruppa_id as 'Номер группы',fk_pol_id as 'id пола', telephonenumUchenik as 'Номер телефона' from infouchenik";
  82. SqlCommand createcommand = new SqlCommand(cmd, connection);
  83. createcommand.ExecuteNonQuery();
  84. SqlDataAdapter sql = new SqlDataAdapter(createcommand);
  85. DataTable dt = new DataTable("sorevi");
  86. sql.Fill(dt);
  87. uchenikigrid.ItemsSource = dt.DefaultView;
  88. connection.Close();
  89. }
  90. }
  91. private void search_TextChanged(object sender, TextChangedEventArgs e)
  92. {
  93. }
  94. }
  95. }