ApplicationsListUser.xaml.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. using PP_Ven_MosS.Classes;
  2. using PP_Ven_MosS.ModelBase;
  3. using PP_Ven_MosS.Pages;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Net;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows;
  11. using System.Windows.Controls;
  12. using System.Windows.Data;
  13. using System.Windows.Documents;
  14. using System.Windows.Input;
  15. using System.Windows.Media;
  16. using System.Windows.Media.Imaging;
  17. using System.Windows.Navigation;
  18. using System.Windows.Shapes;
  19. namespace PP_Ven_MosS
  20. {
  21. /// <summary>
  22. /// Логика взаимодействия для ApplicationsListUser.xaml
  23. /// </summary>
  24. public partial class ApplicationsListUser : Page
  25. {
  26. public ApplicationsListUser()
  27. {
  28. InitializeComponent();
  29. ApplicationList.ItemsSource = Database.entities.Applications.Where(x => x.Id_user == UserID.userid).ToList();
  30. CB_Filter_app.ItemsSource = new List<string> { "Фильтр по статусу", "Выполнен", "Не выполнен" };
  31. CB_Sort_app.ItemsSource = new List<string>() { "Фильтр по дате", "Не сегодня", "Сегодня" };
  32. CB_Sort_app.SelectedIndex = 0;
  33. CB_Filter_app.SelectedIndex = 0;
  34. CB_Filter_event.ItemsSource = new List<string>() { "Фильтр по статусу", "Проведено", "Не проведено" };
  35. CB_Sort_event.ItemsSource = new List<string>() { "Фильтр по дате", "Не сегодня", "Сегодня" };
  36. CB_Sort_event.SelectedIndex = 0;
  37. CB_Filter_event.SelectedIndex = 0;
  38. }
  39. private void GoToCheckReport_Click(object sender, RoutedEventArgs e)
  40. {
  41. FrameClass.MainFrame.Navigate(new CheckReport());
  42. }
  43. private void CreateApp_Click(object sender, RoutedEventArgs e)
  44. {
  45. FrameClass.MainFrame.Navigate(new CreateApplication());
  46. }
  47. private void CreateEv_Click(object sender, RoutedEventArgs e)
  48. {
  49. FrameClass.MainFrame.Navigate(new CreateEvent());
  50. }
  51. private void Exit_Click(object sender, RoutedEventArgs e)
  52. {
  53. FrameClass.MainFrame.Navigate(new Avtorization());
  54. }
  55. private void Filter()
  56. {
  57. List<Applications> applications = Database.entities.Applications.Where(x => x.Id_user == UserID.userid).ToList();
  58. if (CB_Sort_app.SelectedIndex != 0)
  59. {
  60. switch (CB_Sort_app.SelectedIndex)
  61. {
  62. case 1:
  63. applications = applications.Where(x => x.Date_app < DateTime.Today).OrderBy(x => x.Date_app).ToList();
  64. break;
  65. case 2:
  66. applications = applications.Where(x => x.Date_app == DateTime.Today).OrderBy(x => x.Date_app).ToList();
  67. break;
  68. }
  69. }
  70. if (CB_Filter_app.SelectedIndex != 0)
  71. {
  72. switch (CB_Filter_app.SelectedIndex)
  73. {
  74. case 1:
  75. applications = applications.Where(x => x.Id_status_app == 1).ToList();
  76. break;
  77. case 2:
  78. applications = applications.Where(x => x.Id_status_app == 2).ToList();
  79. break;
  80. }
  81. }
  82. if (!string.IsNullOrEmpty(TB_Search_app.Text))
  83. {
  84. applications = applications.Where(x => x.Description.ToUpper().Contains(TB_Search_app.Text.ToUpper())).ToList();
  85. }
  86. ApplicationList.ItemsSource = applications;
  87. //Мероприятия
  88. List<Event> events = Database.entities.Event.ToList();
  89. if (CB_Sort_event.SelectedIndex != 0)
  90. {
  91. switch (CB_Sort_event.SelectedIndex)
  92. {
  93. case 1:
  94. events = events.Where(x => x.Date_event < DateTime.Today).OrderBy(x => x.Date_event).ToList();
  95. break;
  96. case 2:
  97. events = events.Where(x => x.Date_event == DateTime.Today).OrderBy(x => x.Date_event).ToList();
  98. break;
  99. }
  100. }
  101. if (CB_Filter_event.SelectedIndex != 0)
  102. {
  103. switch (CB_Filter_event.SelectedIndex)
  104. {
  105. case 1:
  106. events = events.Where(x => x.Id_status_event == 1).ToList();
  107. break;
  108. case 2:
  109. events = events.Where(x => x.Id_status_event == 2).ToList();
  110. break;
  111. }
  112. }
  113. if (!string.IsNullOrEmpty(TB_Search_event.Text))
  114. {
  115. events = events.Where(x => x.Title_event.ToUpper().Contains(TB_Search_event.Text.ToUpper())).ToList();
  116. }
  117. EventList.ItemsSource = events;
  118. }
  119. private void SortFilterChanged(object sender, SelectionChangedEventArgs e)
  120. {
  121. Filter();
  122. }
  123. private void SearchChanged(object sender, TextChangedEventArgs e)
  124. {
  125. Filter();
  126. }
  127. private void TB_Search_event_TextChanged(object sender, TextChangedEventArgs e)
  128. {
  129. Filter();
  130. }
  131. private void CB_Sort_event_SelectionChanged(object sender, SelectionChangedEventArgs e)
  132. {
  133. Filter();
  134. }
  135. private void CB_Filter_event_SelectionChanged(object sender, SelectionChangedEventArgs e)
  136. {
  137. Filter();
  138. }
  139. private void TextBlock_Loaded(object sender, RoutedEventArgs e)
  140. {
  141. TextBlock tb = (TextBlock)sender;
  142. Event @event = Database.entities.Event.FirstOrDefault(X => X.Id_event.ToString() == tb.Uid);
  143. if(@event != null)
  144. {
  145. tb.Text = @event.media;
  146. }
  147. else
  148. {
  149. tb.Visibility = Visibility.Collapsed;
  150. }
  151. }
  152. }
  153. }