PageNearNote.xaml.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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.Navigation;
  14. using System.Windows.Shapes;
  15. using System.Windows.Threading;
  16. namespace School
  17. {
  18. /// <summary>
  19. /// Логика взаимодействия для PageNearNote.xaml
  20. /// </summary>
  21. public partial class PageNearNote : Page
  22. {
  23. public PageNearNote()
  24. {
  25. InitializeComponent();
  26. DateTime date = DateTime.Today;
  27. DateTime data = date.AddDays(2);
  28. List<ClientService> ser = DBase.DB.ClientService.Where(x => x.StartTime >= DateTime.Today && x.StartTime < data).ToList();
  29. ClassNote.ItemsSource = ser.OrderBy(x => x.StartTime).ToList();
  30. loadedData();
  31. DispatcherTimer dispatcherTimer = new DispatcherTimer();
  32. dispatcherTimer.Interval = TimeSpan.FromSeconds(30);
  33. dispatcherTimer.Tick += dtTicker;
  34. dispatcherTimer.Start();
  35. }
  36. private void loadedData()
  37. {
  38. List<ClientService> clientServices = DBase.DB.ClientService.ToList();
  39. clientServices = clientServices.Where(x => x.StartTime >= DateTime.Now).ToList(); // Фильтрация по дате начала
  40. DateTime endDateTime = DateTime.Today.AddDays(2).AddTicks(-1); // Конец завтрашнего дня
  41. clientServices = clientServices.Where(x => x.StartTime < endDateTime).ToList(); // Фильтрация по дате окончания
  42. clientServices.Sort((x, y) => x.StartTime.CompareTo(y.StartTime));
  43. ClassNote.ItemsSource = clientServices;
  44. }
  45. private void dtTicker(object sender, EventArgs e)
  46. {
  47. loadedData();
  48. }
  49. private void Home_Click(object sender, RoutedEventArgs e)
  50. {
  51. ClassFrame.newFrame.Navigate(new HomePage("0000"));
  52. }
  53. }
  54. }