private void NameBox_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { PasswordBox1.Focus(); } }
private void UsernameBox_KeyUp(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e) { if (e.Key == VirtualKey.Enter) { PasswordBox1.Focus(FocusState.Programmatic); } }
private void ShowPasswordCharsCheckBox_Unchecked1(object sender, RoutedEventArgs e) { PasswordBox1.Visibility = System.Windows.Visibility.Visible; TextBox1.Visibility = System.Windows.Visibility.Collapsed; PasswordBox1.Password = TextBox1.Text; PasswordBox1.Focus(); }
private void Submit_Click(object sender, RoutedEventArgs e) { if (TextBoxEmail.Text.Length == 0) { Errormessage.Text = "Enter an email."; TextBoxEmail.Focus(); } else if (!Regex.IsMatch(TextBoxEmail.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."; TextBoxEmail.Select(0, TextBoxEmail.Text.Length); TextBoxEmail.Focus(); } else { string firstname = TextBoxFirstName.Text; string lastname = TextBoxLastName.Text; string email = TextBoxEmail.Text; string password = PasswordBox1.Password; if (PasswordBox1.Password.Length == 0) { Errormessage.Text = "Enter password."; PasswordBox1.Focus(); } else if (PasswordBoxConfirm.Password.Length == 0) { Errormessage.Text = "Enter Confirm password."; PasswordBoxConfirm.Focus(); } else if (PasswordBox1.Password != PasswordBoxConfirm.Password) { Errormessage.Text = "Confirm password must be same as password."; PasswordBoxConfirm.Focus(); } else { Errormessage.Text = ""; User newUser = new User() { Pass = password, Email = email, FirstName = firstname, LastName = lastname, RegistrationDate = DateTime.Now }; if (SaveToDatabase(newUser)) { Errormessage.Text = "You have Registered successfully."; RedirectToLoginPage(newUser); Reset(); } } } }
private void ButtonSubmit_Click(object sender, RoutedEventArgs e) { if (TextBoxEmail.Text.Length == 0) { ErrorMessage.Text = "Enter an email."; TextBoxEmail.Focus(); } else if (!Regex.IsMatch(TextBoxEmail.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."; TextBoxEmail.Select(0, TextBoxEmail.Text.Length); TextBoxEmail.Focus(); } else { string firstName = TextBoxFirstName.Text; string lastName = TextBoxLastName.Text; string email = TextBoxEmail.Text; string password = PasswordBox1.Password; if (PasswordBox1.Password.Length == 0) { ErrorMessage.Text = "Enter password."; PasswordBox1.Focus(); } else if (PasswordBoxConfirm.Password.Length == 0) { ErrorMessage.Text = "Enter Confirm password."; PasswordBoxConfirm.Focus(); } else if (PasswordBox1.Password != PasswordBoxConfirm.Password) { ErrorMessage.Text = "Confirm password must be same as password."; PasswordBoxConfirm.Focus(); } else { ErrorMessage.Text = ""; _registerController.CreateNewUser(firstName, lastName, email, password); ErrorMessage.Text = "You have Registered successfully."; Reset(); FrameMain.Navigate(new ShowItemsView()); } } }
private void BtnLogin_Click(object sender, RoutedEventArgs e) { if (!String.IsNullOrWhiteSpace(tbUsername.Text) && !String.IsNullOrWhiteSpace(PasswordBox1.Password)) { try { User pom = (from s in DC.Users where s.Username == tbUsername.Text && s.Password == PasswordBox1.Password select s).First(); if (pom != null) { LoginUserData.UserNameLOG = pom.Username; LoginUserData.UseridLOG = pom.UserID; LoginUserData.UserPassLOG = pom.Password; MainWindow novi = new MainWindow(); novi.Show(); this.Close(); } else { MessageBox.Show("Your username and password do not match", "Check your input", MessageBoxButton.OK, MessageBoxImage.Error); } } catch (Exception) { MessageBox.Show("Username and password do not match", "Check your input", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Please fill up login form."); if (String.IsNullOrEmpty(tbUsername.Text)) { tbUsername.Focus(); } else if (String.IsNullOrEmpty(PasswordBox1.Password)) { PasswordBox1.Focus(); } } }