AdminData.xaml.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. namespace SneakersSkakunov
  16. {
  17. /// <summary>
  18. /// Логика взаимодействия для AdminData.xaml
  19. /// </summary>
  20. public partial class AdminData : Page
  21. {
  22. private void Revert(object sender, RoutedEventArgs e)
  23. {
  24. MainFrame.mframe.Navigate(new AdminPage());
  25. }
  26. public AdminData()
  27. {
  28. InitializeComponent();
  29. using (Sniker DB = new Sniker())
  30. {
  31. List<Users> u = DB.Users.ToList();
  32. foreach (Users us in u)
  33. {
  34. if (us.id_Gender == 1)
  35. {
  36. us.Gender.Gender1 = "Мужской";
  37. }
  38. else
  39. {
  40. us.Gender.Gender1 = "Женский";
  41. }
  42. }
  43. Data.ItemsSource = u;
  44. }
  45. }
  46. private void SortAZ(object sender, RoutedEventArgs e)
  47. {
  48. using (Sniker DB = new Sniker())
  49. {
  50. List<Users> u = DB.Users.OrderBy(x => x.Surname).ToList();
  51. foreach (Users us in u)
  52. {
  53. if (us.id_Gender == 1)
  54. {
  55. us.Gender.Gender1 = "Мужской";
  56. }
  57. else
  58. {
  59. us.Gender.Gender1 = "Женский";
  60. }
  61. }
  62. Data.ItemsSource = u;
  63. }
  64. }
  65. private void SortZA(object sender, RoutedEventArgs e)
  66. {
  67. using (Sniker DB = new Sniker())
  68. {
  69. List<Users> u = DB.Users.OrderByDescending(x => x.Surname).ToList();
  70. foreach (Users us in u)
  71. {
  72. if (us.id_Gender == 1)
  73. {
  74. us.Gender.Gender1 = "Мужской";
  75. }
  76. else
  77. {
  78. us.Gender.Gender1 = "Женский";
  79. }
  80. }
  81. Data.ItemsSource = u;
  82. }
  83. }
  84. private void FindM(object sender, RoutedEventArgs e)
  85. {
  86. using (Sniker DB = new Sniker())
  87. {
  88. List<Users> u = DB.Users.Where(x => x.id_Gender == 1).ToList();
  89. foreach (Users us in u)
  90. {
  91. if (us.id_Gender == 1)
  92. {
  93. us.Gender.Gender1 = "Мужской";
  94. }
  95. else
  96. {
  97. us.Gender.Gender1 = "Женский";
  98. }
  99. }
  100. Data.ItemsSource = u;
  101. }
  102. }
  103. private void FindW(object sender, RoutedEventArgs e)
  104. {
  105. using (Sniker DB = new Sniker())
  106. {
  107. List<Users> u = DB.Users.Where(x => x.id_Gender == 2).ToList();
  108. foreach (Users us in u)
  109. {
  110. if (us.id_Gender == 1)
  111. {
  112. us.Gender.Gender1 = "Мужской";
  113. }
  114. else
  115. {
  116. us.Gender.Gender1 = "Женский";
  117. }
  118. }
  119. Data.ItemsSource = u;
  120. }
  121. }
  122. private void Search(object sender, RoutedEventArgs e)
  123. {
  124. using (Sniker DB = new Sniker())
  125. {
  126. string SeText = SearchString.Text;
  127. List<Users> u = DB.Users.Where(x => x.Surname.StartsWith(SeText) || x.Name.StartsWith(SeText)).ToList();
  128. foreach (Users us in u)
  129. {
  130. if (us.id_Gender == 1)
  131. {
  132. us.Gender.Gender1 = "Мужской";
  133. }
  134. else
  135. {
  136. us.Gender.Gender1 = "Женский";
  137. }
  138. }
  139. Data.ItemsSource = u;
  140. }
  141. }
  142. }
  143. }