PageUserList.xaml.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using MyWpfApp.models;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. namespace MyWpfApp.Pages
  17. {
  18. /// <summary>
  19. /// Логика взаимодействия для PageUserList.xaml
  20. /// </summary>
  21. public partial class PageUserList : Page
  22. {
  23. List<UserTable> users = Globals.MyGlobalConnection.UserTable.ToList();
  24. public PageUserList()
  25. {
  26. InitializeComponent();
  27. LB1.ItemsSource = users;
  28. cbRoleFind.ItemsSource = Globals.MyGlobalConnection.Roles.ToList();
  29. cbRoleFind.SelectedValuePath = "ID";
  30. cbRoleFind.DisplayMemberPath = "Role";
  31. }
  32. private void Button_Click(object sender, RoutedEventArgs e)
  33. {
  34. Button btn = (Button)sender;
  35. int ID = Convert.ToInt32(btn.Uid);
  36. LoginedTable user = Globals.MyGlobalConnection.LoginedTable.FirstOrDefault(x=>x.ID == ID);
  37. if (user != null)
  38. {
  39. Globals.MyGlobalFrame.Navigate(new PageUserInfo(user));
  40. }
  41. }
  42. private void BtnAddUser_Click(object sender, RoutedEventArgs e)
  43. {
  44. Globals.MyGlobalFrame.Navigate(new PageUserInfo());
  45. }
  46. private void txtSurnameFind_TextChanged(object sender, TextChangedEventArgs e)
  47. {
  48. LB1.ItemsSource = users.Where(x=>x.Surname.StartsWith(txtSurnameFind.Text)).ToList();
  49. }
  50. private void cbRoleFind_SelectionChanged(object sender, SelectionChangedEventArgs e)
  51. {
  52. LB1.ItemsSource = users.Where(x=>x.LoginedTable.IDRole == (int)cbRoleFind.SelectedValue).ToList();
  53. }
  54. private void btnResetFilters_Click(object sender, RoutedEventArgs e)
  55. {
  56. LB1.ItemsSource = users;
  57. }
  58. }
  59. }