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; } }
public void ClickRightArrow(object sender, RoutedEventArgs e) { switch (stepNumber) { case 1: if (checkValidate.IsValidateEmail(TextBoxLogin.Text)) { CreateLoadAnimation(MainGridResetPassword); bool userExcl = refDALClass.SetConnectionDBCheckExcluziveUser(TextBoxLogin.Text); if (!userExcl) { refDALClass.SetConnectionDBCollectionInformationUser(TextBoxLogin.Text); Storyboard sb1 = this.FindResource("Step2") as Storyboard; sb1.Begin(); KindStep1.Foreground = Brushes.White; KindStep2.Foreground = Brushes.Chartreuse; KindStep3.Foreground = Brushes.White; ButtonArrowLeft.Visibility = Visibility.Visible; ButtonArrowRight.IsEnabled = false; stepNumber++; loadedControl.StopAnimation(); } else { BorderLoginTextBox.Background = Brushes.Red; loadedControl.StopAnimation(); } } else { BorderLoginTextBox.Background = Brushes.Red; } break; case 2: switch (ComboBoxPerson.SelectedIndex) { case 0: if (ComboBoxPerson.Text == refDALClass.userListInformantion.Status && ComboBoxNameOrGroup.Text == refDALClass.userListInformantion.Department) { Storyboard sb2 = this.FindResource("Step3") as Storyboard; sb2.Begin(); KindStep1.Foreground = Brushes.White; KindStep2.Foreground = Brushes.White; KindStep3.Foreground = Brushes.Chartreuse; stepNumber++; ButtonArrowRight.Visibility = Visibility.Hidden; ButtonresetPassword.Visibility = Visibility.Visible; ButtonresetPassword.IsEnabled = false; } else { ComboBoxPerson.Foreground = Brushes.Red; ComboBoxNameOrGroup.Foreground = Brushes.Red; } break; case 1: if (ComboBoxPerson.Text == refDALClass.userListInformantion.Status && ComboBoxNameOrGroup.Text == refDALClass.userListInformantion.Name) { Storyboard sb2 = this.FindResource("Step3") as Storyboard; sb2.Begin(); KindStep1.Foreground = Brushes.White; KindStep2.Foreground = Brushes.White; KindStep3.Foreground = Brushes.Chartreuse; stepNumber++; ButtonArrowRight.Visibility = Visibility.Hidden; ButtonresetPassword.Visibility = Visibility.Visible; ButtonresetPassword.IsEnabled = false; } else { ComboBoxPerson.Foreground = Brushes.Red; ComboBoxNameOrGroup.Foreground = Brushes.Red; } break; } break; } }