123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- using PP_Ven_MosS.Classes;
- using PP_Ven_MosS.ModelBase;
- using PP_Ven_MosS.Pages;
- using System;
- using System.Collections.Generic;
- 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.Navigation;
- using System.Windows.Shapes;
- namespace PP_Ven_MosS
- {
- /// <summary>
- /// Логика взаимодействия для ApplicationsListUser.xaml
- /// </summary>
- public partial class ApplicationsListUser : Page
- {
-
- public ApplicationsListUser()
- {
- InitializeComponent();
-
- ApplicationList.ItemsSource = Classes.Database.entities.Applications.Where(x => x.Id_user == UserID.userid).ToList();
-
- CB_Filter_app.ItemsSource = new List<string> { "Фильтр по статусу", "Выполнен", "Не выполнен" };
- CB_Sort_app.ItemsSource = new List<string>() { "Фильтр по дате", "Не сегодня", "Сегодня" };
- CB_Sort_app.SelectedIndex = 0;
- CB_Filter_app.SelectedIndex = 0;
- CB_Filter_event.ItemsSource = new List<string>() { "Фильтр по статусу", "Проведено", "Не проведено" };
- CB_Sort_event.ItemsSource = new List<string>() { "Фильтр по дате", "Не сегодня", "Сегодня" };
- CB_Sort_event.SelectedIndex = 0;
- CB_Filter_event.SelectedIndex = 0;
- }
- private void CreateApp_Click(object sender, RoutedEventArgs e)
- {
- FrameClass.MainFrame.Navigate(new CreateApplication());
- }
- private void CreateEv_Click(object sender, RoutedEventArgs e)
- {
- FrameClass.MainFrame.Navigate(new CreateEvent());
- }
- private void Exit_Click(object sender, RoutedEventArgs e)
- {
- FrameClass.MainFrame.Navigate(new Avtorization());
- }
- private void Filter()
- {
- List<Applications> applications = Classes.Database.entities.Applications.Where(x => x.Id_user == UserID.userid).ToList();
- if (CB_Sort_app.SelectedIndex != 0)
- {
- switch (CB_Sort_app.SelectedIndex)
- {
- case 1:
- applications = applications.Where(x => x.Date_app < DateTime.Today).OrderBy(x => x.Date_app).ToList();
- break;
- case 2:
- applications = applications.Where(x => x.Date_app == DateTime.Today).OrderBy(x => x.Date_app).ToList();
- break;
- }
- }
- if (CB_Filter_app.SelectedIndex != 0)
- {
- switch (CB_Filter_app.SelectedIndex)
- {
- case 1:
- applications = applications.Where(x => x.Id_status_app == 1).ToList();
- break;
- case 2:
- applications = applications.Where(x => x.Id_status_app == 2).ToList();
- break;
- }
- }
- if (!string.IsNullOrEmpty(TB_Search_app.Text))
- {
- applications = applications.Where(x => x.Description.ToUpper().Contains(TB_Search_app.Text.ToUpper())).ToList();
- }
- ApplicationList.ItemsSource = applications;
- //Мероприятия
- List<Event> events = Database.entities.Event.ToList();
- if (CB_Sort_event.SelectedIndex != 0)
- {
- switch (CB_Sort_event.SelectedIndex)
- {
- case 1:
- events = events.Where(x => x.Date_event < DateTime.Today).OrderBy(x => x.Date_event).ToList();
- break;
- case 2:
- events = events.Where(x => x.Date_event == DateTime.Today).OrderBy(x => x.Date_event).ToList();
- break;
- }
- }
- if (CB_Filter_event.SelectedIndex != 0)
- {
- switch (CB_Filter_event.SelectedIndex)
- {
- case 1:
- events = events.Where(x => x.Id_status_event == 1).ToList();
- break;
- case 2:
- events = events.Where(x => x.Id_status_event == 2).ToList();
- break;
- }
- }
- if (!string.IsNullOrEmpty(TB_Search_event.Text))
- {
- events = events.Where(x => x.Title_event.ToUpper().Contains(TB_Search_event.Text.ToUpper())).ToList();
- }
- EventList.ItemsSource = events;
- }
- private void SortFilterChanged(object sender, SelectionChangedEventArgs e)
- {
- Filter();
- }
- private void SearchChanged(object sender, TextChangedEventArgs e)
- {
- Filter();
- }
- private void TB_Search_event_TextChanged(object sender, TextChangedEventArgs e)
- {
- Filter();
- }
- private void CB_Sort_event_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- Filter();
- }
- private void CB_Filter_event_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- Filter();
- }
- }
- }
|