Exemple #1
0
        private bool IsValid()
        {
            TbName.GetBindingExpression(TextBox.TextProperty).UpdateSource();
            CbGender.GetBindingExpression(ComboBox.SelectedValueProperty).UpdateSource();

            return(!Validation.GetHasError(TbName) && !Validation.GetHasError(CbGender));
        }
Exemple #2
0
        private bool IsValid(bool isEdit)
        {
            if (!isEdit)
            {
                TbUsername.GetBindingExpression(TextBox.TextProperty).UpdateSource();
                PbPassword.GetBindingExpression(PasswordHelper.PasswordProperty).UpdateSource();
            }
            CbGender.GetBindingExpression(ComboBox.SelectedValueProperty).UpdateSource();
            DpBirthDate.GetBindingExpression(DatePicker.SelectedDateProperty).UpdateSource();
            TbName.GetBindingExpression(TextBox.TextProperty).UpdateSource();
            TbEmail.GetBindingExpression(TextBox.TextProperty).UpdateSource();
            TbPhoneNumber.GetBindingExpression(TextBox.TextProperty).UpdateSource();
            TbAddress.GetBindingExpression(TextBox.TextProperty).UpdateSource();

            return(!Validation.GetHasError(CbGender) && !Validation.GetHasError(DpBirthDate) && !Validation.GetHasError(TbName) &&
                   !Validation.GetHasError(TbEmail) && !Validation.GetHasError(TbPhoneNumber) && !Validation.GetHasError(TbAddress) &&
                   (!isEdit || (!Validation.GetHasError(TbUsername) && !Validation.GetHasError(PbPassword))));
        }
 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("Ошибка подключения к базе данных");
         }
     }
 }