WindowChangePriority.xaml.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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.Shapes;
  14. using DemoexamUser11.classes;
  15. namespace DemoexamUser11.windows
  16. {
  17. /// <summary>
  18. /// Логика взаимодействия для WindowChangePriority.xaml
  19. /// </summary>
  20. public partial class WindowChangePriority : Window
  21. {
  22. List<Agent> agents;
  23. public WindowChangePriority(List<Agent> agents)
  24. {
  25. InitializeComponent();
  26. this.agents = agents;
  27. agents.Sort(delegate (Agent a1, Agent a2)
  28. {
  29. return a1.Priority.CompareTo(a2.Priority);
  30. });
  31. textBoxValue.Text = agents.Last().Priority.ToString();
  32. }
  33. private void buttonBack_Click(object sender, RoutedEventArgs e)
  34. {
  35. Close();
  36. }
  37. private void buttonSave_Click(object sender, RoutedEventArgs e)
  38. {
  39. if (textBoxValue.Text.Replace(" ", "") != "")
  40. {
  41. try
  42. {
  43. foreach (Agent agent in agents)
  44. {
  45. BaseConnector.BaseConnect.Agent.FirstOrDefault(x => x.ID == agent.ID).Priority = Convert.ToInt32(textBoxValue.Text);
  46. }
  47. MessageBox.Show("Успех!");
  48. }
  49. catch
  50. {
  51. MessageBox.Show("Не удалось изменить приоритеты! Введите число");
  52. }
  53. }
  54. }
  55. }
  56. }