private void SubmitUsernameButton_Click(object sender, EventArgs e) { UserDatabase userDB = new UserDatabase(); string[] forgotPasswordDetails = userDB.getForgotPassword(UsernameETF.Text); QuestionLabel.Text = forgotPasswordDetails[0]; QuestionLabel.Visible = true; AnswerETF.Visible = true; SubmitAnswerButton.Visible = true; expectedAnswer = forgotPasswordDetails[1]; username = UsernameETF.Text; }
// When the Submit Username Button is clicked private void SubmitUsernameButton_Click(object sender, EventArgs e) { if (UsernameETF.Text.Equals("")) // If no username has been entered { MessageBox.Show("Please enter a Username"); // Show a message box describing the error return; // Stop this method } UserDatabase userDB = new UserDatabase(); // Create a new instance of the User Database. This can be read from and written to a file try { string[] forgotPasswordDetails = userDB.getForgotPassword(UsernameETF.Text); // Exctract and store the ForgotPasswordDetails about the username entered in the Username Expanding Text Field QuestionLabel.Text = forgotPasswordDetails[0]; // Update the QuestionLabel's Text to display the Username's saved Forgot Password Question QuestionLabel.Visible = true; // Make sure that the Question Label is visible (It starts off invisible) AnswerETF.Visible = true; // Make sure that the Answer Expanding Text Field is visible (It starts off invisible) SubmitAnswerButton.Visible = true; // Make sure that the Sumbit Answer Button is visible (It starts off invisible) expectedAnswer = forgotPasswordDetails[1]; // Store the expected Answer as the Forgotten Password Answer which was stored for this username username = UsernameETF.Text; // Store the Username about which the Forgot Password Details have been extracted } catch (Exception ex) { MessageBox.Show(ex.Message + ""); } }