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 RecoveryPassword(object sender, RoutedEventArgs e)
        {
            var employee = DataService.GetContext().Employee.FirstOrDefault(emp => emp.Email == TbEmail.Text);

            if (string.IsNullOrWhiteSpace(TbEmail.Text))
            {
                MB.MessageBoxInfo("Введите почту");
                TbEmail.Focus();
            }
            else if (employee.User == null)
            {
                MB.MessageBoxInfo("Пользователя с данной почтой не существует");
            }
            else
            {
                try
                {
                    string login    = employee.User.Login;
                    string password = employee.User.Password;
                    string email    = "*****@*****.**";
                    var    client   = new SmtpClient("smtp.mail.ru", 25);
                    client.Credentials = new NetworkCredential(email, "WASD1337");
                    client.EnableSsl   = true;
                    client.Send(email, TbEmail.Text, "Ваши данные учетной записи \"PersonnelDepartment\": ", $"Логин: {login}\nПароль: {password}");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Example #3
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 Delete(object sender, RoutedEventArgs e)
        {
            var employee = LvItems.SelectedItem as Employee;

            if (MB.MessageBoxQuestion($"Вы действительно хотите удалить сотрудника {employee.LastName} {employee.FirstName} {employee.MiddleName}?"))
            {
                employee.IsFired = true;
                DataService.GetContext().SaveChanges();

                LvItems.ItemsSource = DataService.GetContext().Employee.Where(emp => emp.IsFired != true).ToList();

                MB.MessageBoxInfo($"Вы успешно удалили сотрудника {employee.LastName} {employee.FirstName} {employee.MiddleName}");
            }
        }
        private void Delete(object sender, RoutedEventArgs e)
        {
            var applicant = LvItems.SelectedItem as Applicant;

            if (MB.MessageBoxQuestion($"Вы действительно хотите удалить соискателя {applicant.LastName} {applicant.FirstName} {applicant.MiddleName}?"))
            {
                DataService.GetContext().Applicant.Remove(applicant);
                DataService.GetContext().SaveChanges();

                LvItems.ItemsSource = DataService.GetContext().Applicant.ToList();

                MB.MessageBoxInfo($"Вы успешно удалили соискателя {applicant.LastName} {applicant.FirstName} {applicant.MiddleName}");
            }
        }
 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 #7
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 Add(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(CbUser.Text))
     {
         MB.MessageBoxInfo("Выберите логин");
         CbUser.Focus();
     }
     else
     {
         try
         {
             DataService.GetContext().SaveChanges();
             MB.MessageBoxInfo("Логин успешно присвоен");
         }
         catch
         {
             MB.MessageBoxError("Ошибка подключения к базе данных");
         }
     }
 }
Example #11
0
 private void EnterCaptcha(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(TbCaptchaEnter.Text))
     {
         MB.MessageBoxInfo("Введите капчу");
         TbCaptcha.Focus();
     }
     else if (TbCaptcha.Text == TbCaptchaEnter.Text)
     {
         TbCaptcha.Text         = string.Empty;
         TbCaptchaEnter.Text    = string.Empty;
         GridSignIn.Visibility  = Visibility.Visible;
         GridCaptcha.Visibility = Visibility.Collapsed;
         count = 0;
     }
     else
     {
         TbCaptcha.Text = string.Empty;
         TbCaptcha.Text = Captcha.GenerateString(5);
     }
 }
 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("Ошибка подключения к базе данных");
         }
     }
 }
Example #15
0
        private void SignIn(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(TbLogin.Text))
            {
                MB.MessageBoxInfo("Введите логин");
                TbLogin.Focus();
            }
            else if (string.IsNullOrWhiteSpace(PbPassword.Password))
            {
                MB.MessageBoxInfo("Введите пароль");
                PbPassword.Focus();
            }
            else
            {
                var employee = DataService.GetContext().Employee.FirstOrDefault(u => u.User.Login == TbLogin.Text);

                if (employee == null)
                {
                    MB.MessageBoxInfo("Введен неверно логин/пароль");
                    TbLogin.Focus();
                    count++;
                }
                else
                {
                    if (employee.User.Password != PbPassword.Password)
                    {
                        MB.MessageBoxInfo("Введен неверно логин/пароль");
                        TbLogin.Clear();
                        PbPassword.Clear();
                        count++;
                    }
                    else
                    {
                        Entity.CurrentEmployee = employee;
                        switch (employee.User.IdRole)
                        {
                        case 1:
                            new WinManager().Show();
                            this.Close();
                            break;

                        case 2:
                            new WinEmployee().Show();
                            this.Close();
                            break;

                        case 3:
                            new WinAdmin().Show();
                            this.Close();
                            break;
                        }
                        count = 0;
                    }
                }
                if (count >= 3)
                {
                    TbLogin.Text           = string.Empty;
                    PbPassword.Password    = string.Empty;
                    GridSignIn.Visibility  = Visibility.Hidden;
                    GridCaptcha.Visibility = Visibility.Visible;
                    TbCaptcha.Text         = Captcha.GenerateString(5);
                    return;
                }
            }
        }
 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("Ошибка подключения к базе данных");
         }
     }
 }