private void btnLogIn_Click(object sender, RoutedEventArgs e) { try { var hashedPassword = DbAccess.GetUserPasswordHashByUserName(txtUser.Text); if (DbAccess.GetUserPasswordHashByUserName(txtUser.Text).Any()) { if (PasswordHashing.ValidatePassword(pssPassword.Password, hashedPassword)) { if (DbAccess.IsUserNameIsAcivated(txtUser.Text)) { //set the global value for userid Globals.LogInID = DbAccess.GetUserIDByUserName(txtUser.Text); MainWindow nwMain = new MainWindow(); nwMain.Show(); this.Close(); } else { MessageBox.Show("Your Account has not been activated\n Please contact system admin", "ACOOUNT INACTIVE", MessageBoxButton.OK, MessageBoxImage.Exclamation); txtUser.Text = string.Empty; pssPassword.Password = string.Empty; } } else { txtUser.Text = string.Empty; pssPassword.Password = string.Empty; MessageBox.Show("User Name and Password does not match", "PASSWORD MISMATCH", MessageBoxButton.OK, MessageBoxImage.Exclamation); } } } catch (Exception) { MessageBox.Show("User not in the system", "USER NOT REGISTERED", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }