ViewEmployees.xaml.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Linq;
  5. using System.Runtime.Remoting.Lifetime;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Data;
  11. using System.Windows.Documents;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Navigation;
  16. using System.Windows.Shapes;
  17. namespace Детский_сад
  18. {
  19. /// <summary>
  20. /// Логика взаимодействия для ViewEmployees.xaml
  21. /// </summary>
  22. public partial class ViewEmployees : Page
  23. {
  24. public ViewEmployees()
  25. {
  26. InitializeComponent();
  27. dg.ItemsSource = Base.KE.Employees.ToList();
  28. tboxFind.Visibility = Visibility.Collapsed;
  29. }
  30. private void rbSortAsc_Click(object sender, RoutedEventArgs e)
  31. {
  32. dg.ItemsSource = Base.KE.Employees.OrderBy(x => x.Surname).ToList();
  33. }
  34. private void rbSortDesc_Click(object sender, RoutedEventArgs e)
  35. {
  36. dg.ItemsSource = Base.KE.Employees.OrderByDescending(x => x.Surname).ToList();
  37. }
  38. private void btnDefault_Click(object sender, RoutedEventArgs e)
  39. {
  40. rbSortAsc.IsChecked = false;
  41. rbSortDesc.IsChecked = false;
  42. rbMale.IsChecked = false;
  43. rbFemale.IsChecked = false;
  44. rbFindSurname.IsChecked = false;
  45. rbFindName.IsChecked = false;
  46. tboxFind.Visibility = Visibility.Collapsed;
  47. dg.ItemsSource = Base.KE.Employees.ToList();
  48. }
  49. private void rbMale_Click(object sender, RoutedEventArgs e)
  50. {
  51. dg.ItemsSource = Base.KE.Employees.Where(x => x.Genders.Id_gender == 1).ToList();
  52. }
  53. private void rbFemale_Click(object sender, RoutedEventArgs e)
  54. {
  55. dg.ItemsSource = Base.KE.Employees.Where(x => x.Genders.Id_gender == 2).ToList();
  56. }
  57. private void rbFindSurname_Click(object sender, RoutedEventArgs e)
  58. {
  59. tboxFind.Visibility = Visibility.Visible;
  60. }
  61. private void tboxFind_TextChanged(object sender, TextChangedEventArgs e)
  62. {
  63. List<Employees> list = new List<Employees>();
  64. if (rbFindSurname.IsChecked == true)
  65. {
  66. foreach (Employees emp in Base.KE.Employees)
  67. {
  68. if (emp.Surname.Substring(0, tboxFind.Text.Length) == tboxFind.Text)
  69. {
  70. list.Add(emp);
  71. }
  72. }
  73. }
  74. else
  75. {
  76. foreach (Employees emp in Base.KE.Employees)
  77. {
  78. if (emp.Names.Substring(0, tboxFind.Text.Length) == tboxFind.Text)
  79. {
  80. list.Add(emp);
  81. }
  82. }
  83. }
  84. dg.ItemsSource = list;
  85. }
  86. private void btnBack_Click(object sender, RoutedEventArgs e)
  87. {
  88. Base.mainFrame.Navigate(new Account());
  89. }
  90. }
  91. }