Beispiel #1
0
        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();
        }
        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();
        }
Beispiel #3
0
 private void ConfirmOrCompletePasscode()
 {
     if (PasswordBox.IsFocused)
     {
         if (PasswordBox.Length > 0)
         {
             ConfirmPasswordBox.Focus();
         }
     }
     else if (ConfirmPasswordBox.IsFocused)
     {
         ViewModel.ChangePassword();
     }
 }
Beispiel #4
0
 /// <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 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();
                }
            }
        }