Example #1
0
        private void buttonLoadFromBackup_Click(object sender, EventArgs e)
        {
            try
            {
                using (var dialog = new OpenFileDialog {
                    Filter = ".zip|*.zip"
                })
                {
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        var employees = componentLoadXml.LoadXml <EmployeeViewModel>(dialog.FileName);
                        foreach (var employee in employees)
                        {
                            employeeService.CreateOrUpdate(new EmployeeBindingModel
                            {
                                Fio           = employee.Fio,
                                VacationStart = employee.VacationStart,
                                Position      = employee.Position,
                                Subdivision   = employee.Subdivision,
                                WorkPhone     = employee.WorkPhone
                            });
                        }

                        MessageBox.Show("Сохранение прошло успешно");
                        LoadData();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Не удалось получить данные\n" + ex.Message);
            }
        }
Example #2
0
 private void saveButton_Click(object sender, EventArgs e)
 {
     try
     {
         employeeService.CreateOrUpdate(new EmployeeBindingModel
         {
             Fio           = fioTextBox.Text,
             Position      = (Position)controlSelectedComboBoxEnum.SelectedItem,
             VacationStart = DateTime.Now,
             Subdivision   = (Subdivision)controlSelectedComboBoxEnumSubvision.SelectedItem,
             WorkPhone     = textBoxWorkForm.Text
         });
         MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
         DialogResult = DialogResult.OK;
         Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }