private void btThuchien_Click(object sender, EventArgs e) { if (txtMKcu.Text.Trim().Length == 0) { MessageBox.Show("Bạn chưa nhập mật khẩu cũ"); return; } else if (txtMKmoi.Text.Trim().Length == 0) { MessageBox.Show("Bạn chưa nhập mật khẩu mới"); return; } else if (txtXNMK.Text.Trim().Length == 0) { MessageBox.Show("Bạn chưa xác nhận lại mật khẩu"); return; } else if (txtMKmoi.Text.Trim() != txtXNMK.Text.Trim()) { MessageBox.Show("Mật khẩu mới và mật khẩu xác nhận không trung nhau"); return; } else { if (MessageBox.Show("Bạn có chắc muốn cập nhật mật khẩu", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { string matkhaumoi = busNhanVien.encryption(txtMKmoi.Text); string matkhaucu = busNhanVien.encryption(txtMKcu.Text); if (busNhanVien.UpdateMatKhau(txtEmailDMK.Text, matkhaucu, matkhaumoi)) { Main.profile = 1; Main.session = 0; MessageBox.Show("Cập nhật mật khẩu thành công, bạn cần phải đăng nhập lại"); //this.Close(); Visible = false; ShowInTaskbar = false; Main main = new Main(txtEmailDMK.Text); main.Activate(); main.Show(); } else { MessageBox.Show("Mật khẩu cũ không đúng"); txtMKcu.Text = null; txtMKmoi.Text = null; txtXNMK.Text = null; } } else { txtMKcu.Text = null; txtMKmoi.Text = null; txtXNMK.Text = null; } } }
private void btn_quenMatKhau_Click(object sender, EventArgs e) { if (txt_EmailDangNhap.Text != "") { if (BUS_NHANVIEN.QuenMatKhau(txt_EmailDangNhap.Text)) { StringBuilder builder = new StringBuilder(); builder.Append(RandomString(4, true)); builder.Append(RandomNumber(1000, 9990)); builder.Append(RandomString(2, false)); MessageBox.Show(builder.ToString()); string matkhaumoi = BUS_NHANVIEN.encryption(builder.ToString()); BUS_NHANVIEN.TaoMatKhauMoi(txt_EmailDangNhap.Text, matkhaumoi); SendMail(txt_EmailDangNhap.Text, matkhaumoi); } else { MessageBox.Show("Email Không tồn tại"); } } else { MessageBox.Show("bạn cần nhập email để phục hồi mật khẩu"); txt_EmailDangNhap.Focus(); } }
private void btDangnhap_Click(object sender, EventArgs e) { DTO_NHANVIEN nv = new DTO_NHANVIEN(); nv.EMAIL = txtEmail.Text; nv.MATKHAU = busNhanvien.encryption(txtMatkhau.Text); if (busNhanvien.NhanVienDangNhap(nv)) { Main.mail = nv.EMAIL; DataTable dt = busNhanvien.VaiTroNhanVien(nv.EMAIL); MessageBox.Show("Đăng nhập thành công"); Visible = false; ShowInTaskbar = false; Main main = new Main(); main.Show(); } else { MessageBox.Show("Đăng nhập không thành công, vui lòng kiểm tra lại Email hoặc mật khẩu"); } }
private void btn_doiMatKhau_Click(object sender, EventArgs e) { if (txt_MatKhauCu.Text == "") { MessageBox.Show("Mật khẩu cũ không được để trống!"); return; } DTO_NHANVIEN nv = new DTO_NHANVIEN(); nv.Email = txt_EmailNhanVien.Text; nv.matKhau = txt_MatKhauCu.Text; if (!BUS.BUS_NHANVIEN.DangNhap(nv)) { MessageBox.Show("Đổi mật khẩu không thành công! Mật khẩu cũ sai!"); return; } string matKhauMoi = BUS_NHANVIEN.encryption(txt_matKhauMoi.Text); string matKhauCu = BUS_NHANVIEN.encryption(txt_MatKhauCu.Text); if (txt_matKhauMoi.Text == "" || txt_nhapLaiMatKhauMoi.Text == "") { MessageBox.Show("Không được để trống!"); return; } if (txt_matKhauMoi.Text.Length < 6 || txt_nhapLaiMatKhauMoi.Text.Length < 6) { MessageBox.Show("Độ dài của mâ khẩu phải lớn hơn hoặc bằng 6 ký tự"); return; } if (txt_matKhauMoi.Text != txt_nhapLaiMatKhauMoi.Text) { MessageBox.Show("Mật khẩu mới không trùng khớp"); return; } if (BUS_NHANVIEN.DoimatKhau(txt_EmailNhanVien.Text, matKhauCu, matKhauMoi)) { cache.profile = 1; cache.session = 0; sendMail(txt_EmailNhanVien.Text, txt_nhapLaiMatKhauMoi.Text); MessageBox.Show("Đổi mật khẩu thành công vui lòng đăng nhập lại để thực hiện chức năng!"); return; } else { MessageBox.Show("Đổi mật khẩu không thành công!"); } }