private void signInButton_Click(object sender, EventArgs e) { try { Validations(); PasswordHashing passwordHashing = new PasswordHashing(); UsersRepository usersRepository = new UsersRepository(); if (usersRepository.UserLogin(usernameBox.Text, passwordBox.Text) != null) { User user = usersRepository.UserLogin(usernameBox.Text, passwordBox.Text); if (passwordHashing.comparePassword(passwordBox.Text, user.password) == true) { DialogResult dialog = MessageBox.Show("You signed in successfully!", "OK", MessageBoxButtons.OK); if (dialog == DialogResult.OK) { MainWindow.loggedInUser = user; LoggedIn loggedIn = new LoggedIn(); loggedIn.ShowDialog(); } } else { throw new Exception("Incorrect password! Please try again."); } } else { throw new Exception("User not found"); } } catch (Exception exc) { MessageBox.Show(exc.Message); } }