private void register_Click(object sender, EventArgs e) { ClearErrors(); bool valErrors = ValidateInputs(); if (!valErrors) { string passwordPlaintext = PasswordGenerator.Generate(); string passwordHash = PasswordHasher.ToHash(passwordPlaintext); if (SaveToDB(passwordHash)) { var message = string.Format("Record created, initial password: {0}", passwordPlaintext); MessageBox.Show(message, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); } else { MessageBox.Show("Failed to save data, please try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnGeneratePassword_Click(object sender, EventArgs e) { txtPassword.Text = PasswordGenerator.Generate(); }