pageServiceNearRecord.xaml.cs 1.8 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. /// Логика взаимодействия для pageServiceNearRecord.xaml
  20. /// </summary>
  21. public partial class pageServiceNearRecord : Page
  22. {
  23. DispatcherTimer timer = new DispatcherTimer();
  24. public pageServiceNearRecord()
  25. {
  26. InitializeComponent();
  27. timer.Interval = new TimeSpan(0,0,30); //таймер на 30 секунд
  28. timer.Tick += update;
  29. init();
  30. timer.Start();
  31. }
  32. private void update(object sender, EventArgs e)
  33. {
  34. init();
  35. }
  36. private void init()
  37. {
  38. DateTime now = DateTime.Now;
  39. DateTime tomorrow = DateTime.Today.AddDays(2); //конец завтрашнего дня
  40. List<ClientService> list = baseConnect.thisBase.ClientService.Where(tb => tb.StartTime > now && tb.StartTime < tomorrow).OrderBy(tb=>tb.StartTime).ToList();
  41. if(list.Count > 0)
  42. {
  43. DGRecords.ItemsSource = list;
  44. }
  45. else
  46. {
  47. MessageBox.Show("Соответствующие записи не были найдены");
  48. }
  49. }
  50. private void BtnBackClick(object sender, RoutedEventArgs e)
  51. {
  52. dataFrame.mainFrame.Navigate(new pageServicesList());
  53. }
  54. }
  55. }