Esempio n. 1
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);
                }
            }
        }
Esempio n. 2
0
 private void BtnSubmit_Click(object sender, RoutedEventArgs e)
 {
     if (TbEmail.Text.Length == 0)
     {
         Errormessage.Text = "Enter an email.";
         TbEmail.Focus();
     }
     else if (!Regex.IsMatch(TbEmail.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"))
     {
         Errormessage.Text = "Enter a valid email.";
         TbEmail.Select(0, TbEmail.Text.Length);
         TbEmail.Focus();
     }
     else
     {
         email = TbEmail.Text;
         var login    = TbLogin.Text;
         var name     = TbName.Text;
         var surname  = TbSurname.Text;
         var password = Passb.Password;
         if (Passb.Password.Length == 0)
         {
             Errormessage.Text = "Enter password.";
             Passb.Focus();
         }
         else if (ConfirmPassb.Password.Length == 0)
         {
             Errormessage.Text = "Enter Confirm password.";
             ConfirmPassb.Focus();
         }
         else if (Passb.Password != ConfirmPassb.Password)
         {
             Errormessage.Text = "Confirm password must be same as password.";
             ConfirmPassb.Focus();
         }
         else
         {
             Errormessage.Text = "";
             SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["InternetShop.Properties.Settings.DbCarConnectionString"].ConnectionString);
             con.Open();
             var cmd =
                 new SqlCommand(
                     "Insert into Users (email, login,name,surname,password) values('" + email + "','" + login +
                     "','" + name + "','" + surname + "','" + password + "')", con)
             {
                 CommandType = CommandType.Text
             };
             cmd.ExecuteNonQuery();
             con.Close();
             Errormessage.Text = "You have Registered successfully.";
             Reset();
         }
     }
 }
        private void BtnSubmit_Click(object sender, RoutedEventArgs e)
        {
            if (TbEmail.Text.Length == 0)
            {
                Errormessage.Text = "Enter an email.";
                TbEmail.Focus();
            }
            else if (!Regex.IsMatch(TbEmail.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"))
            {
                Errormessage.Text = "Enter a valid email.";
                TbEmail.Select(0, TbEmail.Text.Length);
                TbEmail.Focus();
            }
            else
            {
                string        email    = TbEmail.Text;
                string        password = Passb.Password;
                SqlConnection con      = new SqlConnection(ConfigurationManager.ConnectionStrings["InternetShop.Properties.Settings.DbCarConnectionString"].ConnectionString);
                con.Open();
                SqlCommand cmd = new SqlCommand("Select * from Users where email='" + email + "'  and password='******'", con);
                cmd.CommandType = CommandType.Text;
                SqlDataAdapter adapter = new SqlDataAdapter();
                adapter.SelectCommand = cmd;
                DataSet dataSet = new DataSet();
                adapter.Fill(dataSet);
                if (dataSet.Tables[0].Rows.Count > 0)
                {
                    string username = dataSet.Tables[0].Rows[0]["name"].ToString() + " " + dataSet.Tables[0].Rows[0]["surname"].ToString();
                    // FACTORY METHOD and Proxy

                    //for proxy // create some features for some users
                    var features = new FeaturesOperator();

                    // Pattern MEMENTO  // save state that user is authorizate
                    originator.State  = email;
                    caretaker.Memento = originator.CreateMemento();

                    var t = new ShowProductsWindow(caretaker, features); // Session for concrete creator ( for email and login);
                    t.Show();                                            // t.FactoryMethod();


                    //welcome.TextBlockName.Text = username;//Sending value from one form to another form.
                    Close();
                }
                else
                {
                    Errormessage.Text = "Sorry! Please enter existing emailid/password.";
                }
                con.Close();
            }
        }
Esempio n. 4
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("Ошибка подключения к базе данных");
         }
     }
 }
Esempio n. 6
0
 public bool IsEmailTBDisplayedAndEnable()
 {
     return(TbEmail.isDisplayed() && TbEmail.isEnabled());
 }
 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("Ошибка подключения к базе данных");
         }
     }
 }