Esempio n. 1
0
        private static void UndoEmployeeExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            CurrentEmployee.Restore();
            var empl = CurrentEmployee;

            Inspection.NotifySuccess(log, $"Employee {empl} restore!");
            e.Handled = true;
        }
Esempio n. 2
0
        async private static void SelectExcelFileExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            if (ExcelImporter.SelectExcelFile())
            {
                if (ExcelImporter.OpenReadExcelFile())
                {
                    ProgressBar.Visibility = Visibility.Visible;
                    var progressReport = new Progress <int>(percent => ProgressBar.Value = percent);
                    await ExcelImporter.ProceedEmployeesRecordsAsync(progressReport);

                    ProgressBar.Visibility = Visibility.Hidden;
                    Inspection.NotifySuccess(log, "Xls import completed!");
                    Data.ResetListEmployees();
                }
            }
            e.Handled = true;
        }
Esempio n. 3
0
        async private static void UpdateEmployeeExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            Employee empl = CurrentEmployee.ApplyChanges();

            if (empl.Id != 0)
            {
                bool isDone = await Data.UpdateEmployee(empl);

                if (isDone)
                {
                    CurrentEmployee.Wrap(empl);
                    CurrentEmployee.SetEdit();
                    Inspection.NotifySuccess(log, $"Employee {empl} Updated!");
                }
                else
                {
                    Inspection.NotifyError(log, "Сan't update!");
                }
            }
            e.Handled = true;
        }
Esempio n. 4
0
        async private static void SaveEmployeeExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            if (CurrentEmployee.Skill.Level > 2)
            {
                Inspection.NotifyError(log, "A new employee can not be assigned a level above 2!");
                return;
            }
            Employee empl = CurrentEmployee.ApplyChanges();

            if (empl.Id == 0)
            {
                if (IsDepartmentAlreadyFull(empl))
                {
                    MessageBoxResult res =
                        MessageBox.Show("The Department is already full \r\n"
                                        + "Please, confirm the appointment of the employee as a Director",
                                        "Warning",
                                        MessageBoxButton.YesNo,
                                        MessageBoxImage.Warning);
                    if (res == MessageBoxResult.No)
                    {
                        return;
                    }
                }
                bool isDone = await Data.AddEmployeeAsync(empl);

                if (isDone)
                {
                    CurrentEmployee.Wrap(empl);
                    CurrentEmployee.SetEdit();
                    Inspection.NotifySuccess(log, $"Employee {empl} Saved!");
                }
                else
                {
                    Inspection.NotifyError(log, "Can't save!");
                }
            }
            e.Handled = true;
        }