private void ButtonresetPassword_Click(object sender, RoutedEventArgs e) { if (checkValidate.IsValidatePassword(PasswordBoxNewPassword.Password)) { refDALClass.SetConnectionDBChangePassword(TextBoxLogin.Text, PasswordBoxNewPassword.Password); this.Close(); } else { } }
private async void ButtonReg_Click(object sender, RoutedEventArgs e) { CheckValidateForm checkValidate = new CheckValidateForm(); switch (PersonComboBox.SelectedIndex) { case 0: if (!String.IsNullOrWhiteSpace(PasswordBoxPasswordOrigin.Password) && !String.IsNullOrWhiteSpace(TextBoxNameUser.Text)) { if (checkValidate.IsValidateEmail(TextBoxNameUser.Text)) { if (checkValidate.IsValidatePassword(PasswordBoxPasswordOrigin.Password)) { CreateLoadAnimation(MainAuthRegGrid); ReferenseDALClass refClassDAL = new ReferenseDALClass(); //await Task.Run((Action)delegate () { this.Dispatcher.BeginInvoke((ThreadStart)delegate () { var userExcl = methodsCheckUser.CheckExclusiveUser(TextBoxLogin.Text); }); }).ConfigureAwait(true); bool userExcl = refClassDAL.SetConnectionDBCheckExcluziveUser(TextBoxNameUser.Text); if (userExcl) { try { IFCore.User userLogin = new IFCore.User() { Email = TextBoxNameUser.Text, Password = cryptPassword.CalculateMD5Hash(PasswordBoxPasswordOrigin.Password).ToString() }; IFCore.UserInfo userInfo = new IFCore.UserInfo() { UserStatus = PersonComboBox.SelectedValue.ToString(), UserDepartment = TeacherNameorDepartment.SelectedValue.ToString(), UserGroup = GroupListComboBox.SelectedValue.ToString() }; await refClassDAL.SetConnectionDBRegUser(userLogin, userInfo); loadedControl.StopAnimation(); SeccessfulReg(); } catch (Exception ex) { string exs = ex.ToString(); loadedControl.StopAnimation(); ErrorReg("Ошибка регистрации!"); } } else { loadedControl.StopAnimation(); ErrorReg("Учащийся с таким e-mail, зарегистрирован!"); } } else { BorderPasswordBoxUser.Background = Brushes.Red; ErrorReg("Пароль не соотвествует требования!"); } } else { BorderTexBoxUser.Background = Brushes.Red; ErrorReg("Логин не соотвествует требования!"); } } else { if (String.IsNullOrWhiteSpace(PasswordBoxPasswordOrigin.Password)) { BorderPasswordBoxUser.Background = Brushes.Red; } if (String.IsNullOrWhiteSpace(TextBoxNameUser.Text)) { BorderTexBoxUser.Background = Brushes.Red; } } break; case 1: if (!String.IsNullOrWhiteSpace(PasswordBoxPasswordOrigin.Password) && !String.IsNullOrWhiteSpace(TextBoxNameUser.Text)) { if (checkValidate.IsValidateEmail(TextBoxNameUser.Text)) { if (checkValidate.IsValidatePassword(PasswordBoxPasswordOrigin.Password)) { CreateLoadAnimation(MainAuthRegGrid); ReferenseDALClass refClassDAL = new ReferenseDALClass(); bool userExcl = refClassDAL.SetConnectionDBCheckExcluziveUser(TextBoxNameUser.Text); if (userExcl) { try { await refClassDAL.SetConnectionDBRegUser( new User() { Email = TextBoxNameUser.Text, Password = cryptPassword.CalculateMD5Hash(PasswordBoxPasswordOrigin.Password).ToString() }, new UserInfo() { UserName = TeacherNameorDepartment.SelectedValue.ToString(), UserStatus = PersonComboBox.SelectedValue.ToString() }); loadedControl.StopAnimation(); SeccessfulReg(); } catch { loadedControl.StopAnimation(); ErrorReg("Ошибка регистрации!"); } } else { loadedControl.StopAnimation(); ErrorReg("Данный преподаватель, зарегистрирован!"); } } else { BorderPasswordBoxUser.Background = Brushes.Red; ErrorReg("Пароль не соотвествует требования!"); } } else { BorderTexBoxUser.Background = Brushes.Red; ErrorReg("Логин не соотвествует требования!"); } } else { if (String.IsNullOrWhiteSpace(PasswordBoxPasswordOrigin.Password)) { BorderPasswordBoxUser.Background = Brushes.Red; } if (String.IsNullOrWhiteSpace(TextBoxNameUser.Text)) { BorderTexBoxUser.Background = Brushes.Red; } } break; } }