AdminFun.xaml.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 Prakticheskaya5_Venediktov
  16. {
  17. /// <summary>
  18. /// Логика взаимодействия для AdminFun.xaml
  19. /// </summary>
  20. public partial class AdminFun : Page
  21. {
  22. User users = new User();
  23. public AdminFun()
  24. {
  25. InitializeComponent();
  26. All.ItemsSource = users.usr.ToList();
  27. gender.ItemsSource = Base.database.Pol.ToList();
  28. gender.SelectedValue = "ID_Gender";
  29. gender.DisplayMemberPath = "Gender1";
  30. gender.SelectedIndex = -1;
  31. }
  32. private void sortbig_Click(object sender, RoutedEventArgs e)
  33. {
  34. All.ItemsSource = users.usr.ToList().OrderBy(x => x.Surname).ToList();
  35. }
  36. private void sortsmall_Click(object sender, RoutedEventArgs e)
  37. {
  38. All.ItemsSource = users.usr.ToList().OrderBy(x => x.Surname).Reverse().ToList();
  39. }
  40. private void gender_Selected(object sender, RoutedEventArgs e)
  41. {
  42. if (gender.SelectedIndex == -1)
  43. {
  44. All.ItemsSource = users.usr.ToList();
  45. }
  46. else
  47. {
  48. All.ItemsSource = users.usr.ToList().Where(x => x.ID_Gender == (gender.SelectedIndex + 1)).ToList();
  49. }
  50. }
  51. private void poisk_TextChanged(object sender, TextChangedEventArgs e)
  52. {
  53. if (!string.IsNullOrWhiteSpace(poisk.Text))
  54. {
  55. All.ItemsSource = users.usr.ToList().Where(x => (x.Surname.ToLower().Contains(poisk.Text.ToLower())) || (x.Name.ToLower().Contains(poisk.Text.ToLower()))).ToList();
  56. }
  57. }
  58. private void clear_Click(object sender, RoutedEventArgs e)
  59. {
  60. All.ItemsSource = users.usr.ToList();
  61. }
  62. private void glav_Click(object sender, RoutedEventArgs e)
  63. {
  64. NavigationService.Navigate(new AdminPage());
  65. }
  66. }
  67. }