private void resetPasswordButton_Click(object sender, EventArgs e) { bool error = false; if (string.IsNullOrWhiteSpace(token) || string.IsNullOrWhiteSpace(tokenTextbox.Text) || !token.Equals(tokenTextbox.Text)) { tokenErrorLabel.Visible = true; error = true; } else { tokenErrorLabel.Visible = false; } if (string.IsNullOrWhiteSpace(newPasswordTextbox.Text) || !FormatChecker.checkPasswdFormat(newPasswordTextbox.Text)) { newPasswordErrorLabel.Visible = true; error = true; } else { newPasswordErrorLabel.Visible = false; } if (string.IsNullOrWhiteSpace(confirmPasswordTextbox.Text) || !confirmPasswordTextbox.Text.Equals(confirmPasswordTextbox.Text)) { confirmPasswordErrorLabel.Visible = true; error = true; } else { confirmPasswordErrorLabel.Visible = false; } if (!error) { sup.setPassword(Security.getHash(newPasswordTextbox.Text, "SHA512", null)); int i = sda.update(sup, sup.getSupplierID(), conn); if (i > 0) { MessageBox.Show(rs.GetString("passwordChangedMsg")); sup = null; token = null; tokenTimer.Stop(); idTextbox.Text = ""; idTextbox.Enabled = true; } else { MessageBox.Show(rs.GetString("failToChangePasswdMsg"), rs.GetString("errorText"), MessageBoxButtons.OK, MessageBoxIcon.Error); } } tokenTextbox.Clear(); newPasswordTextbox.Clear(); confirmPasswordTextbox.Clear(); }
private void updateButton_Click(object sender, EventArgs e) { if (isInputCorrect()) { Supplier sup = sda.getOneSupplierByID(idTextBox.Text, conn); sup.setSupplierName(supplierNameTextBox.Text); sup.setContectNo(supplierContactNoTextBox.Text); sup.setEmail(emailTextBox.Text); sup.setAddress(supplierAddressTextBox.Text); int i = sda.update(sup, idTextBox.Text, conn); if (i > 0) { foreach (DataGridViewRow row in supplierListDataGridView.Rows) { if (idTextBox.Text.Equals(row.Cells["staffIdColumn"].Value.ToString())) { row.Cells["supplierNameColumn"].Value = sup.getSupplierName(); row.Cells["supplierContactNoColumn"].Value = sup.getContectNo(); row.Cells["supplierEmailColumn"].Value = sup.getEmail(); row.Cells["supplierAddressColumn"].Value = sup.getAddress(); } } MessageBox.Show(rs.GetString("updateSuccessMsg")); } else { MessageBox.Show(rs.GetString("failToUpdateMsg"), rs.GetString("errorText"), MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void changePasswordButton_Click(object sender, EventArgs e) { bool error = false; SupplierDA sda = new SupplierDA(); Supplier sup = sda.getOneSupplierByID(supplierID, conn); if (string.IsNullOrWhiteSpace(currentPasswordTextBox.Text) || !Security.verifyHash(currentPasswordTextBox.Text, "SHA512", sup.getPassword())) { currentPasswordErrorLabel.Visible = true; error = true; } else { currentPasswordErrorLabel.Visible = false; } if (string.IsNullOrWhiteSpace(newPasswordTextBox.Text) || !FormatChecker.checkPasswdFormat(newPasswordTextBox.Text)) { newPasswordErrorLabel.Visible = true; error = true; } else { newPasswordErrorLabel.Visible = false; } if (string.IsNullOrWhiteSpace(confirmPasswordTextBox.Text) || !newPasswordTextBox.Text.Equals(confirmPasswordTextBox.Text)) { confirmPasswordErrorLabel.Visible = true; error = true; } else { confirmPasswordErrorLabel.Visible = false; } if (!error) { sup.setPassword(Security.getHash(newPasswordTextBox.Text, "SHA512", null)); int i = sda.update(sup, sup.getSupplierID(), conn); if (i > 0) { MessageBox.Show(rs.GetString("passwordChangedMsg")); sup = null; } else { MessageBox.Show(rs.GetString("failToChangePasswdMsg"), rs.GetString("errorText"), MessageBoxButtons.OK, MessageBoxIcon.Error); } } currentPasswordTextBox.Clear(); newPasswordTextBox.Clear(); confirmPasswordTextBox.Clear(); }