Workers.xaml.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. using LR1.Entities;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Collections.ObjectModel;
  5. //using System.Data.Entity.Core.Objects;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Data;
  12. using System.Windows.Documents;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Imaging;
  16. using System.Windows.Navigation;
  17. using System.Windows.Shapes;
  18. namespace LR1
  19. {
  20. /// <summary>
  21. /// Логика взаимодействия для Workers.xaml
  22. /// </summary>
  23. public partial class Workers : Page
  24. {
  25. public static WorkersEntities DataEntitiesEmployee { get; set; }
  26. public static ObservableCollection<Employee> ListEmployee;
  27. public Workers()
  28. {
  29. DataEntitiesEmployee = new WorkersEntities();
  30. InitializeComponent();
  31. ListEmployee = new ObservableCollection<Employee>();
  32. }
  33. private bool isDirty = true;
  34. private bool isLoaded = false;
  35. private void UndoCommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
  36. {
  37. e.CanExecute = isLoaded;
  38. }
  39. private void UndoCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
  40. {
  41. MessageBox.Show("Отмена");
  42. isDirty = true;
  43. isLoaded = false;
  44. }
  45. private void DeleteCommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
  46. {
  47. e.CanExecute = isDirty;
  48. }
  49. private void DeleteCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
  50. {
  51. MessageBox.Show("Удаление");
  52. isDirty = false;
  53. isLoaded = true;
  54. }
  55. private void AddCommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
  56. {
  57. e.CanExecute = isDirty;
  58. }
  59. private void AddCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
  60. {
  61. MessageBox.Show("Создание");
  62. isDirty = false;
  63. isLoaded = true;
  64. }
  65. private void EditCommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
  66. {
  67. e.CanExecute = isDirty;
  68. }
  69. private void EditCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
  70. {
  71. MessageBox.Show("Редактирование");
  72. isDirty = false;
  73. isLoaded = true;
  74. }
  75. private void FindCommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
  76. {
  77. e.CanExecute = isDirty;
  78. }
  79. private void FindCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
  80. {
  81. MessageBox.Show("Поиск");
  82. isDirty = false;
  83. isLoaded = true;
  84. }
  85. private void SaveCommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
  86. {
  87. e.CanExecute = isLoaded;
  88. }
  89. private void SaveCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
  90. {
  91. MessageBox.Show("Сохра");
  92. isDirty = true;
  93. isLoaded = false;
  94. }
  95. private void Page_Loaded(object sender, RoutedEventArgs e)
  96. {
  97. var queryEmployee = DataEntitiesEmployee.Employees.OrderBy(Employee => Employee.Surname);
  98. foreach (Employee emp in queryEmployee)
  99. {
  100. ListEmployee.Add(emp);
  101. }
  102. DataGridEmployee.ItemsSource = ListEmployee;
  103. }
  104. }
  105. }