ApplicationsListUser.xaml.cs 5.5 KB

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