Main.xaml.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 PleasantRustle.Class;
  16. namespace PleasantRustle.Pages
  17. {
  18. /// <summary>
  19. /// Логика взаимодействия для Main.xaml
  20. /// </summary>
  21. public partial class Main : Page
  22. {
  23. public static class Agents
  24. {
  25. public static Frame frm;
  26. }
  27. List<Agent> agents = BaseConnect.baseConnect.Agent.ToList();
  28. List<AgentType> agentstype = BaseConnect.baseConnect.AgentType.ToList();
  29. public Main()
  30. {
  31. InitializeComponent();
  32. listboxPleasant.ItemsSource = agents;
  33. }
  34. private void Search_TextChanged(object sender, TextChangedEventArgs e)
  35. {
  36. if (Search.Text != "")
  37. {
  38. List<Agent> agents1 = agents.Where(x => x.Title.Contains(Search.Text)).ToList();
  39. listboxPleasant.ItemsSource = agents1;
  40. }
  41. else
  42. {
  43. listboxPleasant.ItemsSource = agents;
  44. }
  45. }
  46. private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  47. {
  48. ComboBox comboBox = sender as ComboBox;
  49. switch (comboBox.SelectedIndex)
  50. {
  51. case 0:
  52. agents = agents.OrderBy(x => x.Title).ToList();
  53. break;
  54. case 1:
  55. agents = agents.OrderBy(x => x.Title).ToList();
  56. agents.Reverse();
  57. break;
  58. case 2:
  59. agents = agents.OrderBy(x => x.Title).ToList();
  60. break;
  61. case 3:
  62. agents = agents.OrderBy(x => x.Title).ToList();
  63. agents.Reverse();
  64. break;
  65. case 4:
  66. agents = agents.OrderBy(x => x.Priority).ToList();
  67. break;
  68. case 5:
  69. agents = agents.OrderBy(x => x.Priority).ToList();
  70. agents.Reverse();
  71. break;
  72. }
  73. listboxPleasant.ItemsSource = agents;
  74. }
  75. private void ComboBox_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
  76. {
  77. ComboBox comboBox = sender as ComboBox;
  78. int agentType = (int)comboBox.SelectedIndex+1;
  79. if (agentType != 1)
  80. {
  81. List<Agent> agents1 = agents.Where(x => x.AgentTypeID == agentType).ToList();
  82. listboxPleasant.ItemsSource = agents1;
  83. }
  84. else
  85. {
  86. listboxPleasant.ItemsSource = agents;
  87. }
  88. }
  89. private void buttonAdd_Click(object sender, RoutedEventArgs e)
  90. {
  91. Add add = new Add();
  92. add.ShowDialog();
  93. }
  94. private void buttonUpdate_Click(object sender, RoutedEventArgs e)
  95. {
  96. }
  97. }
  98. }