Пример #1
0
 public static bool OpenReadExcelFile()
 {
     if (_fileInfo == null)
     {
         return(false);
     }
     using (FileStream fs = _fileInfo.OpenRead())
     {
         string ext = _fileInfo.Extension;
         // для 2003 xls - Binary; 2007 xlsx - Xml
         using (var xreader = ext == ".xls" ?
                              ExcelReaderFactory.CreateBinaryReader(fs) :
                              ExcelReaderFactory.CreateOpenXmlReader(fs))
         {
             _dset = null;
             try
             {
                 _dset = xreader.AsDataSet();
             }
             catch (Exception ex)
             {
                 Inspection.CurrentException = ex;
                 Inspection.NotifyError(log, "Error processing xls-file");
                 return(false);
             }
         }
         return(true);
     }
 }
Пример #2
0
        private static void TransferEmployeeExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            bool canTransfer = IsTransferPossible();

            if (canTransfer)
            {
                CurrentEmployee.SetTransfer();
                ActivateView("PageEmployeeDetails");
                e.Handled = true;
            }
            else
            {
                var empl = CurrentEmployee;
                Inspection.NotifyError(log, $"Transfer is not possible, probation period for '{empl}' is not over");
            }
        }
Пример #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;
        }
Пример #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;
        }