private void LoginButton_Click(object sender, RoutedEventArgs e) { var sInput = UsernameTextBox.Text; var sPassword = PasswordTextBox.Password; if (sInput == null || sInput.Equals("")) { _dialogService.CallMessageModal(this, "", SSS_Library.Properties.Resources.IncorrectLoginDetailsMessage); UsernameTextBox.Clear(); PasswordTextBox.Clear(); UsernameTextBox.Focus(); } else { if (sPassword.Equals("HereBeDragons") && (sInput.Equals("Admin") || sInput.Equals("admin") || sInput.Equals("Administrator") || sInput.Equals("administrator"))) { MetroWindow adminShow = new Administrator.Administrator(); adminShow.Owner = this; adminShow.Show(); this.Hide(); } else if (!SSS_Library.DataServices.StringHandler.CheckIfStringANumber(sInput) || !sPassword.Equals("HereBeDragons") && (sInput.Equals("Admin") || sInput.Equals("admin") || sInput.Equals("Administrator") || sInput.Equals("administrator"))) { _dialogService.CallMessageModal(this, "", SSS_Library.Properties.Resources.IncorrectLoginDetailsMessage); PasswordTextBox.Clear(); UsernameTextBox.Clear(); UsernameTextBox.Focus(); } else { _userId = Convert.ToInt32(sInput); var userProfile = _userProfileTableAdapter.GetData().FindByuser_id(_userId); if (userProfile == null) { _dialogService.CallMessageModal(this, "", SSS_Library.Properties.Resources.IncorrectLoginDetailsMessage); UsernameTextBox.Clear(); PasswordTextBox.Clear(); UsernameTextBox.Focus(); } else { if (userProfile.resetPassword) { CreatePassword(userProfile); } else { var doILogin = CheckPassword(userProfile, sPassword); if (doILogin) { //coordinator role = 2 if (userProfile.user_roles_id == 2) { MetroWindow coordinatorShow = new Coordinator(_userId); coordinatorShow.Owner = this; coordinatorShow.Show(); this.Hide(); } //student role = 4 else if (userProfile.user_roles_id == 4) { MetroWindow studentShow = new Student(_userId); studentShow.Owner = this; studentShow.Show(); this.Hide(); } //tutor role = 3 else if (userProfile.user_roles_id == 3) { MetroWindow tutorShow = new Tutor(_userId); tutorShow.Owner = this; tutorShow.Show(); this.Hide(); } } } } } } }