AdminData.xaml.cs 4.5 KB

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