private void confirmButton_Click(object sender, EventArgs e) { string password = passBox.Text; if (password.Length >= 8) { if (password == confirmBox.Text) { Valid admin = new Valid(); if (admin.UpdateAdmin("Administrator", password)) { MessageBox.Show("Administrator password has been updated successfully."); this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("An error has occured while updating Administrator password."); } } else { MessageBox.Show("Passwords do not match, please re-enter."); passBox.Clear(); confirmBox.Clear(); } } else { MessageBox.Show("Please enter a password of at least eight characters."); passBox.Clear(); confirmBox.Clear(); } }
/* * Function that manages updating passwords for the admin accounts. This allows for the updating * of all accounts in the dbo.Admins, requiring the current password for security purposes. */ private void updateButton_Click(object sender, EventArgs e) { if (updateListBox.SelectedIndex != -1) { if (oldPassBox.Text == string.Empty || updatePassBox.Text == string.Empty || confirmPassBox.Text == string.Empty) { MessageBox.Show("Please fill all password boxes."); ClearThings(); oldPassBox.Focus(); } else { Valid admin = new Valid(); if (admin.Auth(updateListBox.SelectedItem.ToString(), oldPassBox.Text)) { if (admin.UpdateAdmin(updateListBox.SelectedItem.ToString(), updatePassBox.Text)) { MessageBox.Show("Password update for " + updateListBox.SelectedItem.ToString() + " successful."); } } } } }