123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- using LR1.Entities;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- //using System.Data.Entity.Core.Objects;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace LR1
- {
- /// <summary>
- /// Логика взаимодействия для Workers.xaml
- /// </summary>
-
- public partial class Workers : Page
- {
- public static WorkersEntities DataEntitiesEmployee { get; set; }
- public static ObservableCollection<Employee> ListEmployee;
- public Workers()
- {
- DataEntitiesEmployee = new WorkersEntities();
- InitializeComponent();
- ListEmployee = new ObservableCollection<Employee>();
- }
- private bool isDirty = true;
- private bool isLoaded = false;
- private void UndoCommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
- {
- e.CanExecute = isLoaded;
- }
- private void UndoCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
- {
- MessageBox.Show("Отмена");
- isDirty = true;
- isLoaded = false;
- }
- private void DeleteCommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
- {
- e.CanExecute = isDirty;
- }
- private void DeleteCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
- {
- MessageBox.Show("Удаление");
- isDirty = false;
- isLoaded = true;
- }
- private void AddCommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
- {
- e.CanExecute = isDirty;
- }
- private void AddCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
- {
- MessageBox.Show("Создание");
- isDirty = false;
- isLoaded = true;
- }
- private void EditCommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
- {
- e.CanExecute = isDirty;
- }
- private void EditCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
- {
- MessageBox.Show("Редактирование");
- DataGridEmployee.IsReadOnly = false;
- DataGridEmployee.BeginEdit();
- isDirty = false;
- isLoaded = true;
- }
- private void FindCommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
- {
- e.CanExecute = isDirty;
- }
- private void FindCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
- {
- MessageBox.Show("Поиск");
- isDirty = false;
- isLoaded = true;
- }
- private void SaveCommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
- {
- e.CanExecute = isLoaded;
- }
- private void SaveCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
- {
- MessageBox.Show("Сохра");
- DataEntitiesEmployee.SaveChanges();
- isDirty = true;
- DataGridEmployee.IsReadOnly=true;
- isLoaded = false;
- }
- private void Page_Loaded(object sender, RoutedEventArgs e)
- {
- var queryEmployee = DataEntitiesEmployee.Employees.OrderBy(Employee => Employee.Surname);
- foreach (Employee emp in queryEmployee)
- {
- ListEmployee.Add(emp);
- }
- DataGridEmployee.ItemsSource = ListEmployee;
- }
- }
- }
|