|
@@ -28,7 +28,14 @@ namespace InvestTracker.VM
|
|
|
/// </summary>
|
|
|
public bool GridBlocked { get; set; }
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Контекст БД
|
|
|
+ /// </summary>
|
|
|
private InvestContext _dbContext;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Определяет состояние приложения
|
|
|
+ /// </summary>
|
|
|
private bool isDirty = false;
|
|
|
|
|
|
/// <summary>
|
|
@@ -41,6 +48,11 @@ namespace InvestTracker.VM
|
|
|
/// </summary>
|
|
|
public ObservableCollection<Title> AllTitles { get; set; }
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Выбранный на данный момент сотрудник
|
|
|
+ /// </summary>
|
|
|
+ public Employee SelectedEmployee { get; set; }
|
|
|
+
|
|
|
public EmployeeBrowseVM()
|
|
|
{
|
|
|
UndoCommand = new DelegateCommand(Undo_Executed, WhenDirty);
|
|
@@ -100,7 +112,22 @@ namespace InvestTracker.VM
|
|
|
/// </summary>
|
|
|
private void Delete_Executed()
|
|
|
{
|
|
|
- MessageBox.Show("Deleting...");
|
|
|
+ if (SelectedEmployee != null)
|
|
|
+ {
|
|
|
+ MessageBoxResult result = MessageBox.Show(
|
|
|
+ $"Удалить сотрудника: {SelectedEmployee.Surname} {SelectedEmployee.Name} {SelectedEmployee.Patronymic}",
|
|
|
+ "Предупреждение",
|
|
|
+ MessageBoxButton.OKCancel);
|
|
|
+
|
|
|
+ if (result == MessageBoxResult.OK)
|
|
|
+ {
|
|
|
+ _dbContext.DeleteObject(SelectedEmployee);
|
|
|
+ _dbContext.SaveChanges();
|
|
|
+ } else
|
|
|
+ {
|
|
|
+ MessageBox.Show("Не выбрана строка для удаления");
|
|
|
+ }
|
|
|
+ }
|
|
|
isDirty = true;
|
|
|
}
|
|
|
|