/* * Method: FillTable * Parameters: N/A * Output: N/A * Created By: Riley Smith * Date: 4/13/2015 * Modified By: Riley Smith * * Description: Fills the Users Table with a list of users. */ private void FillTable() { userList = new UserList(); ArrayList users = userList.GetUserNames(); int line = 0; foreach (string ele in users) { usersGridView.Rows.Add(); usersGridView.Rows[line].Cells[0].Value = ele; DataGridViewRow row = usersGridView.Rows[line]; if (userList.IsLocked(ele)) { row.DefaultCellStyle.BackColor = Color.Red; } line++; } }
/* * 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"); } }
/* * Method: ResetPasswordButton_Click * Parameters: object Sender, EventArgs e * Output: N/A * Created By: Riley Smith * Date: 4/13/2015 * Modified By: Riley Smith * * Description: Event handler for the Reset Password Button. */ private void ResetPasswordButton_Click(object sender, EventArgs e) { if (usersGridView.CurrentCell != null) { userList = new UserList(); string userName = usersGridView.CurrentCell.Value.ToString(); GetNewPasswordForm setPassword = new GetNewPasswordForm(userName); setPassword.StartPosition = FormStartPosition.CenterParent; setPassword.ShowDialog(); int selectedIndex = usersGridView.CurrentCell.RowIndex; DataGridViewRow row = usersGridView.Rows[selectedIndex]; if (!userList.IsLocked(userName)) { row.DefaultCellStyle.BackColor = Color.White; } } }