Ejemplo n.º 1
0
 private void RegisterButton_Click(object sender, RoutedEventArgs e)
 {
     if (UserNameTextBox.Text == "" || PasswordBox.Password == "" || ConfirmPasswordBox.Password == "" || EmailTextBox.Text == "")
     {
         if (UserNameTextBox.Text == "")
         {
             UserNameTextBox.Background = Brushes.Red;
         }
         if (PasswordBox.Password == "")
         {
             PasswordBox.Background = Brushes.Red;
         }
         if (ConfirmPasswordBox.Password == "")
         {
             ConfirmPasswordBox.Background = Brushes.Red;
         }
         if (EmailTextBox.Text == "")
         {
             EmailTextBox.Background = Brushes.Red;
         }
         MessageBox.Show("U moet een Username en Wachtwoord invoeren!", "Let op!", MessageBoxButton.OK,
                         MessageBoxImage.Exclamation);
     }
     else
     {
         if (_userBus.UsernameExist(UserNameTextBox.Text) == false)
         {
             if (Validation.IsValidEmail(EmailTextBox.Text))
             {
                 var _user = new User();
                 _user.Username = UserNameTextBox.Text;
                 _user.Password = PasswordStorage.CreateHash(PasswordBox.Password);
                 _user.Email    = EmailTextBox.Text;
                 _user.Role     = "User";
                 _userBus.Create(_user);
                 MessageBox.Show("User created");
             }
             else
             {
                 EmailTextBox.Background = Brushes.Red;
                 EmailTextBox.SelectAll();
                 EmailTextBox.Focus();
             }
         }
         else
         {
             MessageBox.Show("Deze Username is al in gebruik!", "Let op!", MessageBoxButton.OK,
                             MessageBoxImage.Exclamation);
             UserNameTextBox.Background = Brushes.Red;
             UserNameTextBox.SelectAll();
             UserNameTextBox.Focus();
         }
     }
 }
        private void ConnectUserView_OnLoaded(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrWhiteSpace(UserNameTextBox.Text))
            {
                UserNameTextBox.Focus();
                UserNameTextBox.SelectAll();
            }
            else
            {
                PasswordTextBox.Focus();
                PasswordTextBox.SelectAll();
            }

            var viewModel = (PrincipalViewModel)DataContext;

            if (viewModel.CanAutoConnect)
            {
                viewModel.SignInCommand.Execute(null);
            }
        }
Ejemplo n.º 3
0
        //
        // Misc Events
        //

        private void UserNameTextBox_PreviewMouseUp(object sender, MouseButtonEventArgs e)
        {
            UserNameTextBox.Focus();
            UserNameTextBox.SelectAll();
        }