Raspisaniye.xaml.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Shapes;
  14. using System.Windows.Navigation;
  15. using System.Data.SqlClient;
  16. using System.Data;
  17. namespace KursachMukha692gr
  18. {
  19. /// <summary>
  20. /// Логика взаимодействия для Raspisaniye.xaml
  21. /// </summary>
  22. public partial class Raspisaniye : Window
  23. {
  24. //KURSACH1Entities2 db;
  25. public Raspisaniye()
  26. {
  27. InitializeComponent();
  28. SqlConnection connection = new SqlConnection("server=mssql; Trusted_Connection=YES;DataBase=gr692_mkm;");
  29. connection.Open();
  30. string cmd = "select RASPISANIYE.id as 'Код',den_nedeli.dennedeli as 'День недели',vremya_zanyatiya.nachalo as 'Начало занятия', vremya_zanyatiya.konec as 'Конец занятия', fk_gruppi_id as 'Номер группы',disciplina.disciplina as 'Дисциплина',zal_trenerovki.zal as 'Зал',CONCAT(infotrener.familiyaTrener,' ',left(infotrener.imyaTrener,1) ,'.',left(infotrener.otchestvoTrener,1),'.') as 'ФИО тренера',corpus.corpus as 'Корпус'from den_nedeli,vremya_zanyatiya,RASPISANIYE,disciplina,zal_trenerovki,infotrener,corpus,gruppa where den_nedeli.id = RASPISANIYE.fk_den_nedeli_id and vremya_zanyatiya.id = RASPISANIYE.fk_vremya_zanyatiya_id and gruppa.id = RASPISANIYE.fk_gruppi_id and disciplina.id = RASPISANIYE.fk_disciplina_id and zal_trenerovki.id = RASPISANIYE.fk_zal_trenirovki_id and infotrener.id = RASPISANIYE.fk_trener_id and corpus.id = RASPISANIYE.fk_corpus_id";
  31. SqlCommand createcommand = new SqlCommand(cmd, connection);
  32. createcommand.ExecuteNonQuery();
  33. SqlDataAdapter sql = new SqlDataAdapter(createcommand);
  34. DataTable dt = new DataTable("raspisaniyes");
  35. sql.Fill(dt);
  36. raspisaniyegrid.ItemsSource = dt.DefaultView;
  37. connection.Close();
  38. }
  39. /*private void Load()
  40. {
  41. raspisaniyegrid.ItemsSource = Helper.context.RASPISANIYEs.ToList();
  42. }*/
  43. private void Button_Click_Back(object sender, RoutedEventArgs e)
  44. {
  45. KabinetAdmina kab = new KabinetAdmina();
  46. kab.Show();
  47. Close();
  48. }
  49. private void Button_Click_delete(object sender, RoutedEventArgs e)
  50. {
  51. DeleteRaspisaniye delete = new DeleteRaspisaniye();
  52. delete.Show();
  53. Close();
  54. }
  55. private void Button_Click_add(object sender, RoutedEventArgs e)
  56. {
  57. AddRaspisaniye raspisaniye = new AddRaspisaniye();
  58. raspisaniye.Show();
  59. Close();
  60. }
  61. private void Button_Click_update(object sender, RoutedEventArgs e)
  62. {
  63. ViborUpdateRaspisaniye updateRaspisaniye = new ViborUpdateRaspisaniye();
  64. updateRaspisaniye.Show();
  65. Close();
  66. }
  67. private void Button_Click_Search(object sender, RoutedEventArgs e)
  68. {
  69. if (search.Text.Length > 0)
  70. {
  71. SqlConnection connection = new SqlConnection("server=mssql; Trusted_Connection=YES;DataBase=gr692_mkm;");
  72. connection.Open();
  73. string cmd = "select RASPISANIYE.id as 'Код',den_nedeli.dennedeli as 'День недели',vremya_zanyatiya.nachalo as 'Начало занятия', vremya_zanyatiya.konec as 'Конец занятия', fk_gruppi_id as 'Номер группы',disciplina.disciplina as 'Дисциплина',zal_trenerovki.zal as 'Зал',CONCAT(infotrener.familiyaTrener,' ',left(infotrener.imyaTrener,1) ,'.',left(infotrener.otchestvoTrener,1),'.') as 'ФИО тренера',corpus.corpus as 'Корпус'from den_nedeli,vremya_zanyatiya,RASPISANIYE,disciplina,zal_trenerovki,infotrener,corpus,gruppa where den_nedeli.id = RASPISANIYE.fk_den_nedeli_id and vremya_zanyatiya.id = RASPISANIYE.fk_vremya_zanyatiya_id and gruppa.id = RASPISANIYE.fk_gruppi_id and disciplina.id = RASPISANIYE.fk_disciplina_id and zal_trenerovki.id = RASPISANIYE.fk_zal_trenirovki_id and infotrener.id = RASPISANIYE.fk_trener_id and corpus.id = RASPISANIYE.fk_corpus_id " +
  74. " and ( RASPISANIYE.id like '%" + search.Text + "%' or den_nedeli.dennedeli like '%" + search.Text + "%' or vremya_zanyatiya.nachalo like '%" + search.Text + "%' or vremya_zanyatiya.konec like '%" + search.Text + "%' or fk_gruppi_id like '%" + search.Text + "%' or disciplina.disciplina like '%" + search.Text + "%' or zal_trenerovki.zal like '%" + search.Text + "%' or CONCAT(infotrener.familiyaTrener,' ',left(infotrener.imyaTrener,1) ,'.',left(infotrener.otchestvoTrener,1)) like '%" + search.Text + "%' or corpus.corpus like '%" + search.Text + "%' )";
  75. SqlCommand createcommand = new SqlCommand(cmd, connection);
  76. createcommand.ExecuteNonQuery();
  77. SqlDataAdapter sql = new SqlDataAdapter(createcommand);
  78. DataTable dt = new DataTable("sorevi");
  79. sql.Fill(dt);
  80. raspisaniyegrid.ItemsSource = dt.DefaultView;
  81. connection.Close();
  82. }
  83. else if (search.Text.Length == 0)
  84. {
  85. SqlConnection connection = new SqlConnection("server=mssql; Trusted_Connection=YES;DataBase=gr692_mkm;");
  86. connection.Open();
  87. string cmd = "select RASPISANIYE.id as 'Код',den_nedeli.dennedeli as 'День недели',vremya_zanyatiya.nachalo as 'Начало занятия', vremya_zanyatiya.konec as 'Конец занятия', fk_gruppi_id as 'Номер группы',disciplina.disciplina as 'Дисциплина',zal_trenerovki.zal as 'Зал',CONCAT(infotrener.familiyaTrener,' ',left(infotrener.imyaTrener,1) ,'.',left(infotrener.otchestvoTrener,1),'.') as 'ФИО тренера',corpus.corpus as 'Корпус'from den_nedeli,vremya_zanyatiya,RASPISANIYE,disciplina,zal_trenerovki,infotrener,corpus,gruppa where den_nedeli.id = RASPISANIYE.fk_den_nedeli_id and vremya_zanyatiya.id = RASPISANIYE.fk_vremya_zanyatiya_id and gruppa.id = RASPISANIYE.fk_gruppi_id and disciplina.id = RASPISANIYE.fk_disciplina_id and zal_trenerovki.id = RASPISANIYE.fk_zal_trenirovki_id and infotrener.id = RASPISANIYE.fk_trener_id and corpus.id = RASPISANIYE.fk_corpus_id";
  88. SqlCommand createcommand = new SqlCommand(cmd, connection);
  89. createcommand.ExecuteNonQuery();
  90. SqlDataAdapter sql = new SqlDataAdapter(createcommand);
  91. DataTable dt = new DataTable("sorevi");
  92. sql.Fill(dt);
  93. raspisaniyegrid.ItemsSource = dt.DefaultView;
  94. connection.Close();
  95. }
  96. }
  97. private void search_TextChanged(object sender, TextChangedEventArgs e)
  98. {
  99. }
  100. }
  101. }