private void btnLuu_Click(object sender, EventArgs e) { var tk = phanQuyen.KiemTraDangNhap(txtTaiKhoan.Text); if (string.IsNullOrEmpty(txtMatKhauCu.Text.Trim())) { MessageBox.Show("Bạn chưa nhập mật khẩu cũ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); this.txtMatKhauCu.Focus(); return; } if (string.IsNullOrEmpty(txtMatKhauMoi.Text)) { MessageBox.Show("Bạn chưa nhập mật khẩu mới", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); this.txtMatKhauMoi.Focus(); return; } if (string.IsNullOrEmpty(txtXacNhanMK.Text)) { MessageBox.Show("Bạn chưa nhập xác nhận mật khẩu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); this.txtXacNhanMK.Focus(); return; } if (txtMatKhauMoi.Text.Length < 6 || txtXacNhanMK.Text.Length < 6) { MessageBox.Show("Mật khẩu phải có 6 kí tự trở lên", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); LamMoi(); this.txtMatKhauMoi.Focus(); return; } if (!txtMatKhauMoi.Text.Equals(txtXacNhanMK.Text)) { MessageBox.Show("Xác nhận mật khẩu không khớp", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); LamMoi(); this.txtMatKhauMoi.Focus(); return; } if (!tk.MatKhau.Equals(txtMatKhauCu.Text)) { MessageBox.Show("Mật khẩu cũ sai", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); LamMoi(); this.txtMatKhauCu.Focus(); return; } TaiKhoanNV taiKhoanNV = new TaiKhoanNV(); taiKhoanNV.TaiKhoan = txtTaiKhoan.Text; taiKhoanNV.MatKhau = txtMatKhauMoi.Text; taiKhoanNV.TinhTrang = 1; if (phanQuyen.SuaTaiKhoan(taiKhoanNV)) { MessageBox.Show("Đổi mật khẩu thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } }
private void FrmDangNhap_Load(object sender, EventArgs e) { var tk1 = phanQuyen.KiemTraDangNhap(txtTenDangNhap.Text); }