private void btnXacNhan_Click(object sender, EventArgs e) { tblNhanVien nhanvien = nvController.LayThongTin(username, txtMKCu.Text); if (nhanvien.sMaNV != null && nhanvien.sMaNV.Length > 0) { string mkMoi = txtMKMoi.Text; string nhapLai = txtNhapLai.Text; if (mkMoi.Equals(nhapLai)) { nvController.doiMatKhau(username, mkMoi); MessageBox.Show("Đổi mật khẩu cho tài khoản " + username + " thành công!", "Đổi mật khẩu thành công!", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Hide(); } else { MessageBox.Show("Mật khẩu nhập lại không chính xác", "Đổi mật khẩu không thành công!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Mật khẩu cũ không chính xác", "Đổi mật khẩu không thành công!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
private void btnResetMatKhau_Click(object sender, EventArgs e) { if ((MessageBox.Show("Xác nhập reset mật khẩu cho tài khoản " + txtUsername.Text + "?", "Reset mật khẩu!", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)) { string newPass = RandomString(6); MessageBox.Show("Mật khẩu mới cho tài khoản " + txtUsername.Text + " là : \"" + newPass, "Đặt lại khoản thành công!", MessageBoxButtons.OK, MessageBoxIcon.Information); nhanvienController.doiMatKhau(txtUsername.Text, newPass); } }