/// <summary> /// Click behavior for the login button /// Opens the main window and passes the user's chosen name. /// ** Pre: Dialog Box for Log In exists. /// ** Post: A valid username is accepted and passed to an instance of User to save the user related data, and then to Main Window for other options /// </summary> /// <param name="sender">The sending winforms object.</param> /// <param name="e">Winforms event arguments.</param> private void loginButton_Click(object sender, EventArgs e) { //block the user from progressing from the login popup if they haven't entered a name if (usernameBox.TextLength != 0 && userPasswordBox.TextLength != 0) { String userName = usernameBox.Text; String password = userPasswordBox.Text; List <string> empty = new List <string>(); //Call to User to save user related data User login = new User(userName, 0, password, empty, empty); login.Login(login, this);// :) } else { MessageBox.Show("Password or Username not entered!"); } }
private void button1_Click(object sender, EventArgs e) { string username; string password; username = TB_username.Text; password = TB_password.Text; if (User.Login(username, password)) { Globals._Login = true; // Close login form this.Dispose(false); } else { MessageBox.Show("Login Failed"); } }