public CreateUserForm() { InitializeComponent(); users = new UserList(); usersList = users.GetUserNames(); numAdmins = 0; foreach (string ele in usersList) { string userName = ele; if (users.IsAdmin(userName)) { numAdmins = numAdmins + 1; } } }
/* * Method: Login * Parameters: object sender, EventArgs s * Output: N/A * Created By: Scott Smoke * Date: 4/12/2015 * Modified By: JordanB Beck * * Description: This will grab the username and password * from their respective text boxes and see if they are valid. */ private void Login(object sender, EventArgs e) { string userName = userNameTextBox.Text; string pwd = passwordTextBox.Text; UserList users = new UserList(); //Added to reset the default admin, if he is locked out. if (userName == "HARDRESET") { users.ChangeFilePassword("AlanTuring", "06231912"); } if (users.IsUser(userName)) { if (!users.IsLocked(userName)) { if (users.TestPassword(userName, pwd)) { isAdmin = users.IsAdmin(userName); if (isAdmin) { adminMenu.Visible = true; callingForm.Show(); logedIn = true; } else { callingForm.Show(); adminMenu.Visible = false; logedIn = true; } Close(); } else { MessageBox.Show("Incorrect Password"); } } else { MessageBox.Show("User account is Locked"); } } else { MessageBox.Show("Incorrect Username"); } }