private void btnGetPassword_Click(object sender, EventArgs e) { try { string currentPassword = userProvider.GetPassword(txtUsername.Text, txtPasswordAnswer.Text); if (!string.IsNullOrEmpty(currentPassword)) { txtPassword.Text = currentPassword; txtPassword.BackColor = System.Drawing.Color.Red; txtPassword.ForeColor = System.Drawing.Color.White; MessageBox.Show("User password retreived successfully, look at in password field in UI", "Retreive user password", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Failed to retreive user password", "Retreive user password", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (ArgumentException ex) { MessageBox.Show("Failed to retreive user password, " + ex.Message, "Retreive user password", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } catch (SqlException ex) { MessageBox.Show("Failed to retreive user password, " + ex.Message, "Retreive user password", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } catch (Exception ex) { MessageBox.Show("Failed to retreive user password, " + ex.Message, "Retreive user password", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }