/* #region Validation * string ValidateInputs(string username, string password, string confirmPassword) * { * string errorMessage = ""; * var naV = new NewAccountValidation(username, password, confirmPassword); * errorMessage += UsernameValidation.ValidateUsername(username); * errorMessage += PasswordValidation.ValidatePassword(password); * errorMessage += ConfirmPasswordValidation.ValidateConfirmPassword(password, confirmPassword); * return errorMessage; * } * void IsInputValid(string errorMessage, string username, string password) * { * //If no error is found * if (errorMessage == "") * { * //stores username and hashed password * CreateNewAccountService.Instance.username = username; * CreateNewAccountService.Instance.password = UserAccount.stringToHashString(password); * * var ui = UICreatePage.GetAdminDetailsPage(); * CreateNewAccountService.Instance.Window.Content = ui; * } * else * { * ErrorTxt.Text = errorMessage; * ClearInputFields(); * } * } #endregion*/ #region Utility methods void ClearInputFields() { //Clear all fields on the view UsernameTxt.Clear(); passwordBox.Clear(); ConfirmPasswordBox.Clear(); }
private void RegisterButton_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrEmpty(PhoneTextBox.Text) && !string.IsNullOrEmpty(NameTextBox.Text) && !string.IsNullOrEmpty(PasswordBox.Password) && !string.IsNullOrEmpty(ConfirmPasswordBox.Password)) { if (PasswordBox.Password == ConfirmPasswordBox.Password) { if (!service.SignUpEmployee(NameTextBox.Text, PhoneTextBox.Text, PasswordBox.Password, "default", out string message, out Employee user)) { Close(); } else { PhoneTextBox.Clear(); NameTextBox.Clear(); PasswordBox.Clear(); ConfirmPasswordBox.Clear(); } } else { MessageBox.Show("Passwords in to fields should be equal"); PasswordBox.Clear(); ConfirmPasswordBox.Clear(); PasswordBox.Focus(); } }
private void ConfirmPasswordTxt_GotFocus(object sender, RoutedEventArgs e) { var confirmPasswordTxt = (TextBox)sender; //remove the textbox, and focus on password box behind confirmPasswordTxt.Visibility = Visibility.Hidden; ConfirmPasswordBox.Visibility = Visibility.Visible; ConfirmPasswordBox.Focus(); }
/// <summary> /// Shows the message. /// </summary> /// <param name="message">The message.</param> /// <param name="controlName">Name of the control.</param> public void ShowMessage(string message, ControlNames controlName) { if (!string.IsNullOrEmpty(message)) { ErrorMessageTextBlock.Text = message; ErrorMessageTextBlock.Visibility = Visibility.Visible; switch (controlName) { case ControlNames.ConfirmPassword: { ConfirmPasswordBox.DelayedFocus(); break; } case ControlNames.Password: { PasswordBox.DelayedFocus(); break; } case ControlNames.ZipCode: { ZipCodeTextBox.DelayedFocus(); break; } case ControlNames.LastName: { LastNameTextBox.DelayedFocus(); break; } case ControlNames.FirstName: { FirstNameTextBox.DelayedFocus(); break; } case ControlNames.Email: { EmailTextBox.DelayedFocus(); break; } case ControlNames.GetEmail: { GetEmailCheckBox.DelayedFocus(); break; } } } else { ErrorMessageTextBlock.Visibility = Visibility.Collapsed; } }
/// <summary> /// Clears this instance. /// </summary> public void Clear() { ErrorMessageTextBlock.Visibility = Visibility.Collapsed; FirstNameTextBox.Clear(); LastNameTextBox.Clear(); EmailTextBox.Clear(); PasswordBox.Clear(); ConfirmPasswordBox.Clear(); ZipCodeTextBox.Clear(); }
/// <summary> /// Handles the Click event of the NoButton control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param> private void NoButton_Click(object sender, RoutedEventArgs e) { FirstNameTextBox.Clear(); LastNameTextBox.Clear(); EmailTextBox.Clear(); PasswordBox.Clear(); ConfirmPasswordBox.Clear(); ZipCodeTextBox.Clear(); GetEmailCheckBox.IsChecked = null; this.NavigationService.GoBack(); }
private void ShowPasswordCharsCheckBox_Unchecked2(object sender, RoutedEventArgs e) { PasswordBox2.Visibility = System.Windows.Visibility.Visible; TextBox2.Visibility = System.Windows.Visibility.Collapsed; PasswordBox2.Password = TextBox2.Text; ConfirmPasswordBox.Visibility = System.Windows.Visibility.Visible; ConfirmTextBox.Visibility = System.Windows.Visibility.Collapsed; ConfirmPasswordBox.Password = ConfirmTextBox.Text; ConfirmPasswordBox.Focus(); PasswordBox2.Focus(); }
private void ConfirmOrCompletePasscode() { if (PasswordBox.IsFocused) { if (PasswordBox.Length > 0) { ConfirmPasswordBox.Focus(); } } else if (ConfirmPasswordBox.IsFocused) { ViewModel.ChangePassword(); } }
/// <summary> /// Відображає пароль для підтвердження /// </summary> private void ShowConfirmPassword_OnClick(object sender, RoutedEventArgs e) { if (ShowConfirmPasswordToggleButton.IsChecked is true) { ConfirmPasswordBox.Visibility = Visibility.Collapsed; ShowConfirmPasswordBox.Text = ConfirmPasswordBox.Password; ShowConfirmPasswordBox.Visibility = Visibility.Visible; ShowConfirmPasswordBox.Focus(); } else { ConfirmPasswordBox.Visibility = Visibility.Visible; ShowConfirmPasswordBox.Visibility = Visibility.Collapsed; ConfirmPasswordBox.Focus(); } }
private void TransitionerBackToUser_OnClick(object sender, RoutedEventArgs e) { if (LoginTransitioner.SelectedIndex != 0) { LoginTransitioner.SelectedIndex = 0; } PasswordBox.Clear(); ShowPasswordBox.Clear(); LoginPasswordBox.Clear(); ShowLoginPasswordBox.Clear(); ConfirmPasswordBox.Clear(); ShowConfirmPasswordBox.Clear(); MonobankApiKey.Clear(); ForgotPasswordCheckMonobankApiKey.Clear(); Transitioner.SelectedIndex = 1; }
public void EnterUserDetails(IWebDriver driver, string preferredTitle, string firstName, string lastName, string mobileNumber, string password, string confirmPassword) { // Select Title from dropdown list var title = driver.FindElement(By.Id("title")); var selectElement = new SelectElement(title); selectElement.SelectByValue(preferredTitle); // Enter First Name FirstNameBox.SendKeys(firstName); // Select Last Name LastNameBox.SendKeys(lastName); // Enter mobile number MobileNumberBox.SendKeys(mobileNumber); // Enter password PasswordBox.SendKeys(password); // Confirm password ConfirmPasswordBox.SendKeys(confirmPassword); }
private bool SubmitBtn() { bool ret = true; { try { if (Emailbox.Text == "") { lblNameIsRequired.Visible = true; ret = false; } else { lblNameIsRequired.Visible = false; } if (CurrentPasswordBox.Text == "") { lblEmailIsRequired.Visible = true; ret = false; } else { lblEmailIsRequired.Visible = false; } if (NewPasswordBox.Text == "") { lblPasswordIsRequired.Visible = true; ret = false; } else { lblPasswordIsRequired.Visible = false; } if (ConfirmPasswordBox.Text == "") { lblConfirmPasswordIsRequired.Visible = true; ret = false; } else { lblConfirmPasswordIsRequired.Visible = false; } //if (NewPasswordBox.Text != "" && ConfirmPasswordBox.Text != "") //{ // if (NewPasswordBox != ConfirmPasswordBox) // { // lblConfirmPasswordAndPasswordSame.Visible = true; // ret = false; // } //} //else //{ // lblConfirmPasswordAndPasswordSame.Visible = false; //} if ((Emailbox.Text != "") && (CurrentPasswordBox.Text != "") && (NewPasswordBox.Text != "") && (ConfirmPasswordBox.Text != "")) { //this is connection check email is exist if condtion is true so then check current password is exist into the database SqlCommand cmd = new SqlCommand("Select Count(*) From Admin Where E_mail = @E_mail", conn.connect); cmd.Parameters.AddWithValue("@E_mail", Emailbox.Text); conn.connect.Open(); int Result = (int)cmd.ExecuteScalar(); if (Result == 1) { //this connection is check that current password is exist SqlCommand cmd2 = new SqlCommand("Select Count(*) From Admin Where Password = @Password AND E_mail = @Email", conn.connect); cmd2.Parameters.AddWithValue("@Email", Emailbox.Text); cmd2.Parameters.AddWithValue("@Password", CurrentPasswordBox.Text); //conn.connect.Open(); int Result2 = (int)cmd2.ExecuteScalar(); //conn.connect.Close(); if (Result2 == 1) { if (NewPasswordBox.Text == ConfirmPasswordBox.Text) { SqlCommand cmd3 = new SqlCommand("update Admin Set Password=@Password where E_mail=@E_mail", conn.connect); cmd3.Parameters.AddWithValue("@E_mail", Emailbox.Text); cmd3.Parameters.AddWithValue("@Password", ConfirmPasswordBox.Text); cmd3.ExecuteNonQuery(); DialogResult Dr = MessageBox.Show("Password have changed", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information); if (Dr == DialogResult.OK) { CurrentPasswordBox.Clear(); NewPasswordBox.Clear(); ConfirmPasswordBox.Clear(); } conn.connect.Close(); } else { lblConfirmPasswordIsRequired.Text = "Password does not match"; lblConfirmPasswordIsRequired.Visible = true; conn.connect.Close(); } } else { lblEmailIsRequired.Text = "Password does not exist"; lblEmailIsRequired.Visible = true; CurrentPasswordBox.Clear(); NewPasswordBox.Clear(); ConfirmPasswordBox.Clear(); conn.connect.Close(); } } else { lblNameIsRequired.Text = "Email does not exist"; lblNameIsRequired.Visible = true; Emailbox.Clear(); CurrentPasswordBox.Clear(); NewPasswordBox.Clear(); ConfirmPasswordBox.Clear(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } return(ret); } }
private void Register_Click(object sender, RoutedEventArgs e) { if (ShowPasswordCharsCheckBox2.IsChecked == true) { TextBox2.Text = PasswordBox2.Password; ConfirmTextBox.Text = ConfirmPasswordBox.Password; } if (Email.Text.Length == 0) { ErrorMessage.Visibility = Visibility.Visible; ErrorMessage.Background = Brushes.Yellow; ErrorMessage.Text = "Enter an email!"; Email.Focus(); } else if (!Regex.IsMatch(Email.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.Visibility = Visibility.Visible; ErrorMessage.Background = Brushes.Yellow; ErrorMessage.Text = "Enter a valid email!"; Email.Select(0, Email.Text.Length); Email.Focus(); } else { string username = Username.Text; string email = Email.Text; string password = PasswordBox2.Password; if (PasswordBox2.Password.Length == 0) { ErrorMessage.Visibility = Visibility.Visible; ErrorMessage.Background = Brushes.Yellow; ErrorMessage.Text = "Enter password!"; PasswordBox2.Focus(); } else if (ConfirmPasswordBox.Password.Length == 0) { ErrorMessage.Visibility = Visibility.Visible; ErrorMessage.Background = Brushes.Yellow; ErrorMessage.Text = "Enter Confirm password!"; ConfirmPasswordBox.Focus(); } else if (PasswordBox2.Password != ConfirmPasswordBox.Password) { ErrorMessage.Visibility = Visibility.Visible; ErrorMessage.Background = Brushes.Yellow; ErrorMessage.Text = "Confirm password must be same as password!"; ConfirmPasswordBox.Focus(); } else { ErrorMessage.Visibility = Visibility.Visible; ErrorMessage.Background = Brushes.Green; ErrorMessage.Text = "Adding your Profile..."; SqlConnection con = new SqlConnection("Data Source = BMWP2; Initial Catalog = M120_Database; Integrated Security = True"); con.Open(); SqlCommand cmd = new SqlCommand("Insert into Users (Username,Email,Password) values('" + username + "','" + email + "','" + password + "')", con); cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); con.Close(); ErrorMessage.Text = "You have Registered successfully."; Reset(); } } }