private void LoginButton_Click(object sender, EventArgs e) { _ = new User(); User_Service userService = new User_Service(); if ((UsernameTxtBox.Text.Length < 1) || (PasswordTxtBox.Text.Length < 1)) { MessageBox.Show("Missing credentials!"); } else { if (userService.IsUsernamePresent(UsernameTxtBox.Text)) { User user = userService.GetUserByName(UsernameTxtBox.Text); if (PasswordTxtBox.Text.Equals(user.password)) { this.Hide(); new Dashboard(user).Show(); user.rememberMe = RememberMeBox.Checked; } else { MessageBox.Show("Incorrect username or password"); //password doesn't match } } else { MessageBox.Show("Incorrect username or password"); //username does not exist in the db } } }
private User CheckUser() //checks if user with username is { //present in db and returns User object _ = new User(); User_Service userService = new User_Service(); if (userService.IsUsernamePresent(UsernameTxtBox.Text)) { User user = userService.GetUserByName(UsernameTxtBox.Text); return(user); } else { return(null); } }