Acount.xaml.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using PP_Ven_MosS.Classes;
  2. using PP_Ven_MosS.ModelBase;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Data.Entity;
  6. using System.Linq;
  7. using System.Security.RightsManagement;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows;
  11. using System.Windows.Controls;
  12. using System.Windows.Data;
  13. using System.Windows.Documents;
  14. using System.Windows.Input;
  15. using System.Windows.Media;
  16. using System.Windows.Media.Imaging;
  17. using System.Windows.Navigation;
  18. using System.Windows.Shapes;
  19. namespace PP_Ven_MosS.Pages
  20. {
  21. /// <summary>
  22. /// Логика взаимодействия для Acount.xaml
  23. /// </summary>
  24. public partial class Acount : Page
  25. {
  26. public Acount()
  27. {
  28. InitializeComponent();
  29. UserList.ItemsSource = Classes.Database.entities.User.ToList();
  30. CB_Filter_user.ItemsSource = new List<string> { "Роли", "Сотрудники", "Пользователи" };
  31. CB_Filter_user.SelectedIndex = 0;
  32. }
  33. private void CB_Filter_user_SelectionChanged(object sender, SelectionChangedEventArgs e)
  34. {
  35. Filter();
  36. }
  37. private void TB_Search_app_TextChanged(object sender, TextChangedEventArgs e)
  38. {
  39. Filter();
  40. }
  41. private void Filter()
  42. {
  43. List<User> users = Classes.Database.entities.User.ToList();
  44. if (CB_Filter_user.SelectedIndex != 0)
  45. {
  46. switch (CB_Filter_user.SelectedIndex)
  47. {
  48. case 1:
  49. users = users.Where(x => x.Id_role == 1 || x.Id_role == 2).ToList();
  50. break;
  51. case 2:
  52. users = users.Where(x => x.Id_role == 3).ToList();
  53. break;
  54. }
  55. }
  56. if (!string.IsNullOrEmpty(TB_Search_app.Text))
  57. {
  58. users = users.Where(x => x.Surname.ToUpper().Contains(TB_Search_app.Text.ToUpper())).ToList();
  59. }
  60. UserList.ItemsSource = users;
  61. }
  62. private void Exit_Click(object sender, RoutedEventArgs e)
  63. {
  64. FrameClass.MainFrame.Navigate(new MenuAdmin());
  65. }
  66. }
  67. }