private void Add(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(TbLogin.Text))
     {
         MB.MessageBoxInfo("Введите логин");
         TbLogin.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbPassword.Text))
     {
         MB.MessageBoxInfo("Введите пароль");
         TbPassword.Focus();
     }
     else if (string.IsNullOrWhiteSpace(CbRole.Text))
     {
         MB.MessageBoxInfo("Выберите роль");
         CbRole.Focus();
     }
     else
     {
         try
         {
             DataService.GetContext().User.Add(user);
             DataService.GetContext().SaveChanges();
             MB.MessageBoxInfo("Пользователь успешно добавлен");
         }
         catch
         {
             MB.MessageBoxError("Ошибка подключения к базе данных");
         }
     }
 }
Example #2
0
 private void Edit(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(TbName.Text))
     {
         MB.MessageBoxInfo("Введите наименование отдела");
         TbName.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbDaysWorking.Text))
     {
         MB.MessageBoxInfo("Введите рабочие дни");
         TbDaysWorking.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbTimeWorking.Text))
     {
         MB.MessageBoxInfo("Введите время работы");
         TbTimeWorking.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbTotalAmount.Text))
     {
         MB.MessageBoxInfo("Введите общее количество мест");
         TbTotalAmount.Focus();
     }
     else
     {
         try
         {
             DataService.GetContext().SaveChanges();
             MB.MessageBoxInfo("Вы успешно изменили отдел");
         }
         catch (Exception ex)
         {
             MB.MessageBoxError(ex.Message);
         }
     }
 }
 private void Transfer(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(CbDepartment.Text))
     {
         MB.MessageBoxInfo("Выберите отдел");
         CbDepartment.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbSalary.Text))
     {
         MB.MessageBoxInfo("Введите зарплату");
         TbSalary.Focus();
     }
     else
     {
         try
         {
             var applicant = Entity.Applicant;
             var employee  = new Data.Employee()
             {
                 Address            = applicant.Address,
                 BirthDate          = applicant.BirthDate,
                 Department         = CbDepartment.SelectedItem as Department,
                 Gender             = applicant.Gender,
                 Education          = applicant.Education,
                 Email              = applicant.Email,
                 FirstName          = applicant.FirstName,
                 INN                = applicant.INN,
                 LastName           = applicant.LastName,
                 MedicalCertificate = applicant.MedicalCertificate,
                 MiddleName         = applicant.MiddleName,
                 MilitaryId         = applicant.MilitaryId,
                 PassportNumber     = applicant.PassportNumber,
                 PassportSeries     = applicant.PassportSeries,
                 PhoneNumber        = applicant.PhoneNumber,
                 Photo              = applicant.Photo,
                 Position           = applicant.Position,
                 Salary             = Convert.ToDecimal(TbSalary.Text),
                 SNILS              = applicant.SNILS
             };
             DataService.GetContext().Employee.Add(employee);
             DataService.GetContext().SaveChanges();
             MB.MessageBoxInfo($"Вы успешно перевели сотрудника {employee.LastName} {employee.FirstName} {employee.MiddleName} на работу");
         }
         catch
         {
             MB.MessageBoxError("Ошибка подключения к базе данных");
         }
     }
 }
Example #4
0
 private void Delete(object sender, RoutedEventArgs e)
 {
     try
     {
         var user = DgUser.SelectedItem as User;
         if (MB.MessageBoxQuestion($"Вы действительно хотите удалить пользователя {user.Login}?"))
         {
             DataService.GetContext().User.Remove(user);
         }
         MB.MessageBoxInfo($"Пользователь {user.Login} успешно удален");
     }
     catch
     {
         MB.MessageBoxError("Ошибка подключения к базе данных");
     }
 }
        private void EmployeeRecovery(object sender, RoutedEventArgs e)
        {
            try
            {
                var employee = LvFiredEmployees.SelectedItem as Employee;
                employee.IsFired = false;
                DataService.GetContext().SaveChanges();
                MB.MessageBoxInfo($"Сотрудник {employee.LastName} {employee.FirstName} {employee.MiddleName} успешно восстановлен");

                LvFiredEmployees.ItemsSource = DataService.GetContext().Employee.Where(emp => emp.IsFired == true).ToList();
                LvItems.ItemsSource          = DataService.GetContext().Employee.Where(emp => emp.IsFired != true).ToList();
            }
            catch
            {
                MB.MessageBoxError("Ошибка подключения к базе данных");
            }
        }
 private void Delete(object sender, RoutedEventArgs e)
 {
     try
     {
         var department = DgDepartment.SelectedItem as Department;
         if (MB.MessageBoxQuestion($"Вы дейстивтельно хотите удалить отдел {department.Name}?"))
         {
             DataService.GetContext().Department.Remove(department);
             DataService.GetContext().SaveChanges();
             DgDepartment.ItemsSource = DataService.GetContext().Department.ToList();
             MB.MessageBoxInfo($"Отдел: {department.Name} успешно удален");
         }
     }
     catch
     {
         MB.MessageBoxError("Ошибка подключения к базе данных");
     }
 }
        private void Transfer(object sender, RoutedEventArgs e)
        {
            Entity.Applicant = LvItems.SelectedItem as Applicant;

            new WinTransfer().ShowDialog();

            try
            {
                DataService.GetContext().Applicant.Remove(LvItems.SelectedItem as Applicant);
                DataService.GetContext().SaveChanges();
            }
            catch
            {
                MB.MessageBoxError("Ошибка подключения к базе данных");
            }

            LvItems.ItemsSource = DataService.GetContext().Applicant.ToList();
        }
 private void Add(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(CbUser.Text))
     {
         MB.MessageBoxInfo("Выберите логин");
         CbUser.Focus();
     }
     else
     {
         try
         {
             DataService.GetContext().SaveChanges();
             MB.MessageBoxInfo("Логин успешно присвоен");
         }
         catch
         {
             MB.MessageBoxError("Ошибка подключения к базе данных");
         }
     }
 }
 private void Add(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(TbAddress.Text))
     {
         MB.MessageBoxInfo("Введите должность");
         TbAddress.Focus();
     }
     else
     {
         try
         {
             DataService.GetContext().Address.Add(new Data.Address()
             {
                 Name = TbAddress.Text
             });
             DataService.GetContext().SaveChanges();
             MB.MessageBoxInfo("Вы успешно добавили адрес");
         }
         catch
         {
             MB.MessageBoxError("Ошибка подключения к базе данных");
         }
     }
 }
 private void Edit(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(TbEducation.Text))
     {
         MB.MessageBoxInfo("Заполните образование");
         TbEducation.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbEmail.Text))
     {
         MB.MessageBoxInfo("Заполните почту");
         TbEmail.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbINN.Text))
     {
         MB.MessageBoxInfo("Заполните ИНН");
         TbINN.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbLastName.Text))
     {
         MB.MessageBoxInfo("Заполните фамилию");
         TbLastName.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbFirstName.Text))
     {
         MB.MessageBoxInfo("Заполните имя");
         TbFirstName.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbNumberPhone.Text))
     {
         MB.MessageBoxInfo("Заполните телефон");
         TbNumberPhone.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbPassportNumber.Text))
     {
         MB.MessageBoxInfo("Заполните номер паспорта");
         TbPassportNumber.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbPassportSeries.Text))
     {
         MB.MessageBoxInfo("Заполните серию паспорта");
         TbPassportSeries.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbSalary.Text))
     {
         MB.MessageBoxInfo("Заполните зарплату");
         TbSalary.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbSNILS.Text))
     {
         MB.MessageBoxInfo("Заполните СНИЛС");
         TbSNILS.Focus();
     }
     else if (string.IsNullOrWhiteSpace(CbAdress.Text))
     {
         MB.MessageBoxInfo("Заполните адрес");
         CbAdress.Focus();
     }
     else if (string.IsNullOrWhiteSpace(CbDepartment.Text))
     {
         MB.MessageBoxInfo("Заполните отдел");
         CbDepartment.Focus();
     }
     else if (string.IsNullOrWhiteSpace(CbGender.Text))
     {
         MB.MessageBoxInfo("Заполните пол");
         CbGender.Focus();
     }
     else if (string.IsNullOrWhiteSpace(CbPosition.Text))
     {
         MB.MessageBoxInfo("Заполните должность");
         CbPosition.Focus();
     }
     else
     {
         try
         {
             DataService.GetContext().SaveChanges();
             MB.MessageBoxInfo("Сотрудник успешно изменен");
         }
         catch
         {
             MB.MessageBoxError("Ошибка подключения к базе данных");
         }
     }
 }
 private void Add(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(TbEducation.Text))
     {
         MB.MessageBoxInfo("Заполните образование");
         TbEducation.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbEmail.Text))
     {
         MB.MessageBoxInfo("Заполните почту");
         TbEmail.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbINN.Text))
     {
         MB.MessageBoxInfo("Заполните ИНН");
         TbINN.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbLastName.Text))
     {
         MB.MessageBoxInfo("Заполните фамилию");
         TbLastName.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbFirstName.Text))
     {
         MB.MessageBoxInfo("Заполните имя");
         TbFirstName.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbNumberPhone.Text))
     {
         MB.MessageBoxInfo("Заполните телефон");
         TbNumberPhone.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbPassportNumber.Text))
     {
         MB.MessageBoxInfo("Заполните номер паспорта");
         TbPassportNumber.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbPassportSeries.Text))
     {
         MB.MessageBoxInfo("Заполните серию паспорта");
         TbPassportSeries.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbSNILS.Text))
     {
         MB.MessageBoxInfo("Заполните СНИЛС");
         TbSNILS.Focus();
     }
     else if (string.IsNullOrWhiteSpace(CbAdress.Text))
     {
         MB.MessageBoxInfo("Заполните адрес");
         CbAdress.Focus();
     }
     else if (string.IsNullOrWhiteSpace(CbGender.Text))
     {
         MB.MessageBoxInfo("Заполните пол");
         CbGender.Focus();
     }
     else if (string.IsNullOrWhiteSpace(CbPosition.Text))
     {
         MB.MessageBoxInfo("Заполните должность");
         CbPosition.Focus();
     }
     else if (CbGender.Text == "Мужчина" && flagMID == false)
     {
         MB.MessageBoxInfo("Добавьте фотографию военного билета");
         BtnMilitaryId.Focus();
     }
     else if (flagMC == false)
     {
         MB.MessageBoxInfo("Добавьте фотографию медицинской карты");
         BtnMedicalCertificate.Focus();
     }
     else if (flagCOGC == false)
     {
         MB.MessageBoxInfo("Добавьте фотографию справку о судимости");
         BtnCertificateOfGoodConduct.Focus();
     }
     else if (flagNC == false)
     {
         MB.MessageBoxInfo("Добавьте фотографию наркологическую справку");
         BtnNarcologicalCertificate.Focus();
     }
     else
     {
         try
         {
             DataService.GetContext().Applicant.Add(applicant);
             DataService.GetContext().SaveChanges();
             MB.MessageBoxInfo("Соискатель успешно добавлен");
         }
         catch
         {
             MB.MessageBoxError("Ошибка подключения к базе данных");
         }
     }
 }
 private void Add(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(TbEducation.Text))
     {
         MB.MessageBoxInfo("Заполните образование");
         TbEducation.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbEmail.Text))
     {
         MB.MessageBoxInfo("Заполните почту");
         TbEmail.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbINN.Text))
     {
         MB.MessageBoxInfo("Заполните ИНН");
         TbINN.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbLastName.Text))
     {
         MB.MessageBoxInfo("Заполните фамилию");
         TbLastName.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbFirstName.Text))
     {
         MB.MessageBoxInfo("Заполните имя");
         TbFirstName.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbNumberPhone.Text))
     {
         MB.MessageBoxInfo("Заполните телефон");
         TbNumberPhone.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbPassportNumber.Text))
     {
         MB.MessageBoxInfo("Заполните номер паспорта");
         TbPassportNumber.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbPassportSeries.Text))
     {
         MB.MessageBoxInfo("Заполните серию паспорта");
         TbPassportSeries.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbSalary.Text))
     {
         MB.MessageBoxInfo("Заполните зарплату");
         TbSalary.Focus();
     }
     else if (string.IsNullOrWhiteSpace(TbSNILS.Text))
     {
         MB.MessageBoxInfo("Заполните СНИЛС");
         TbSNILS.Focus();
     }
     else if (string.IsNullOrWhiteSpace(CbAdress.Text))
     {
         MB.MessageBoxInfo("Заполните адрес");
         CbAdress.Focus();
     }
     else if (string.IsNullOrWhiteSpace(CbDepartment.Text))
     {
         MB.MessageBoxInfo("Заполните отдел");
         CbDepartment.Focus();
     }
     else if (string.IsNullOrWhiteSpace(CbGender.Text))
     {
         MB.MessageBoxInfo("Заполните пол");
         CbGender.Focus();
     }
     else if (string.IsNullOrWhiteSpace(CbPosition.Text))
     {
         MB.MessageBoxInfo("Заполните должность");
         CbPosition.Focus();
     }
     else if (CbGender.Text == "Мужчина" && flagMID == false)
     {
         MB.MessageBoxInfo("Добавьте фотографию военного билета");
         BtnMilitaryId.Focus();
     }
     else if (flagMC == false)
     {
         MB.MessageBoxInfo("Добавьте фотографию медицинской карты");
         BtnMedicalCertificate.Focus();
     }
     else
     {
         try
         {
             DataService.GetContext().Employee.Add(employee);
             DataService.GetContext().SaveChanges();
             MB.MessageBoxInfo("Сотрудник успешно добавлен");
         }
         catch
         {
             MB.MessageBoxError("Ошибка подключения к базе данных");
         }
     }
 }