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 BtnAdd_Click(object sender, RoutedEventArgs e)
        {
            if (DpDateTimeLeadCreated.SelectedDate.ToString() == "")
            {
                FolderClass.ClassMB.MBError("Введите дату создания лида");
                DpDateTimeLeadCreated.Focus();
            }
            else if (string.IsNullOrEmpty(TbNumberPhone.Text))
            {
                FolderClass.ClassMB.MBError("Введите контактные данные лида");
                TbNumberPhone.Focus();
            }
            else if (string.IsNullOrEmpty(TbMasteringSalesSkills.Text))
            {
                FolderClass.ClassMB.MBError("Введите овладение навыками продаж");
                TbMasteringSalesSkills.Focus();
            }
            else if (string.IsNullOrEmpty(TbWorkingWithObjections.Text))
            {
                FolderClass.ClassMB.MBError("Введите работу с возражениями");
                TbWorkingWithObjections.Focus();
            }
            else if (string.IsNullOrEmpty(TbKnowledgeOfCompanysProducts.Text))
            {
                FolderClass.ClassMB.MBError("Введите знания продуктов компании");
                TbKnowledgeOfCompanysProducts.Focus();
            }
            else if (CbStatus.SelectedValue.ToString() == "")
            {
                FolderClass.ClassMB.MBError("Введите статус");
                CbStatus.Focus();
            }

            else
            {
                FolderClass.ClassStatusLead.IdStatus = Int32.Parse(CbStatus.SelectedValue.ToString());
                try
                {
                    sqlConnection.Open();
                    sqlCommand = new SqlCommand("Insert into dbo.Lead " +
                                                "(DateTimeLeadCreated, NumberPhoneLead, " +
                                                "Comment, MasteringSalesSkills, WorkingWithObjections, " +
                                                "KnowledgeOfCompanysProducts, IdStatus) " +
                                                "Values " +
                                                "(@DateTimeLeadCreated, " +
                                                "@NumberPhoneLead, " +
                                                "@Comment, " +
                                                "@MasteringSalesSkills, " +
                                                "@WorkingWithObjections, " +
                                                "@KnowledgeOfCompanysProducts, " +
                                                "@IdStatus)", sqlConnection);

                    sqlCommand.Parameters.AddWithValue("DateTimeLeadCreated", DpDateTimeLeadCreated.SelectedDate.GetValueOrDefault());
                    sqlCommand.Parameters.AddWithValue("NumberPhoneLead", TbNumberPhone.Text);
                    sqlCommand.Parameters.AddWithValue("Comment", TbComment.Text);
                    sqlCommand.Parameters.AddWithValue("MasteringSalesSkills", TbMasteringSalesSkills.Text);
                    sqlCommand.Parameters.AddWithValue("WorkingWithObjections", TbWorkingWithObjections.Text);
                    sqlCommand.Parameters.AddWithValue("KnowledgeOfCompanysProducts", TbKnowledgeOfCompanysProducts.Text);
                    sqlCommand.Parameters.AddWithValue("IdStatus", FolderClass.ClassStatusLead.IdStatus);
                    sqlCommand.ExecuteNonQuery();

                    FolderClass.ClassMB.MBInformation("Добавление лида прошло успешно");
                }
                catch (Exception ex)
                {
                    FolderClass.ClassMB.MBError(ex);
                }
                finally
                {
                    sqlConnection.Close();
                }
            }
        }
 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("Ошибка подключения к базе данных");
         }
     }
 }