private void resetPasswordToolStripMenuItem_Click(object sender, EventArgs e) { if (ClassDBUtils.IsAllowed(ClassGenLib.username, "RESET USER PASSWORD") == false) { MessageBox.Show("Access denied! Insufficient rights to perform the function.", "Falcon", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } string usr = ""; for (int i = 0; i < vwUsers.RowCount; i++) { if (vwUsers.IsRowSelected(i)) { usr = vwUsers.GetRowCellValue(i, "LOGIN").ToString(); break; } } UserResetPassword rest = new UserResetPassword(usr); rest.ShowDialog(); }
private void simpleButton1_Click(object sender, EventArgs e) { if (txtAnswer.Text == "") { MessageBox.Show("Please supply the response to the question!", "Falcon", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } using (SqlConnection conn = new SqlConnection(ClassDBUtils.DBConnString)) { try { conn.Open(); //compare answer supplied to value obtained from database if (txtAnswer.Text == answer) { UserResetPassword ureset = new UserResetPassword(loginUser); ureset.ShowDialog(); } else { MessageBox.Show("Incorrect answer to security question!", "Falcon", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } catch (Exception ex) { MessageBox.Show("Error connecting to database! Reason " + ex.Message, "Falcon", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (conn != null) { conn.Close(); } } } }