public void btnDangNhap_Click(object sender, EventArgs e) { if (txtTaiKhoan.Text == "") { MessageBox.Show("Bạn chưa nhập thông tin tài khoản", "Thông báo"); } else if (txtMatKhau.Text == "") { MessageBox.Show("Bạn chưa nhập mật khẩu", "Thông báo"); } else { NguoiDungBUS nguoiDung = new NguoiDungBUS(); string userName = txtTaiKhoan.Text; string passWord = txtMatKhau.Text; if (nguoiDung.Login(userName, passWord) == true) { frmManHinhChinh f = new frmManHinhChinh(); this.Hide(); f.ShowDialog(); this.Show(); } //NHỚ CHECK CSDL ??? else { MessageBox.Show("Sai tên tài khoản hoặc mật khẩu!"); } } }
private void btn_DangKi_Click(object sender, EventArgs e) { if (!kiemTraDoDaiHopLe()) { MessageBox.Show("Bạn mắc 1 trong các lỗi sau:\n - Bạn chưa nhập tên đăng nhập hoặc mật khẩu hoặc email.\n" + " - Bạn đã nhập tên đăng nhập hoặc mật khẩu dài hơn 10 kí tự.\n - Bạn đã nhập họ tên hoặc email " + "dài hơn 50 kí tự.\n - Bạn đã nhập số điện thoại nhiều hơn 11 chữ số.\nVui lòng kiểm tra lại.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { String strTDN = tbx_TenDangNhap.Text; String strMK = tbx_MatKhau.Text; String strHT = tbx_HoTen.Text; DateTime dtNS = dtpick.Value; String strEmail = tbx_Email.Text; String strDT = tbx_DienThoai.Text; NguoiDungBUS bus = new NguoiDungBUS(); if (!bus.kiemTraNguoiDung(strTDN, strMK)) { NguoiDungDTO dto = new NguoiDungDTO(strTDN, strMK, strHT, dtNS, strEmail, strDT, 0); bus.themNguoiDung(dto); //if (bus.kiemTraNguoiDung(strTDN, strMK)) MessageBox.Show("Chúc mừng " + strTDN + " đã đăng kí thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); } else { MessageBox.Show("Tên đăng nhập hoặc email đã tồn tại. Vui lòng chọn lại.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnDoi_Click(object sender, EventArgs e) { string oldpass = "", newpass = ""; foreach (DataRow row in NguoiDungBUS.DangNhap(username).Rows) { oldpass = row["Password"].ToString(); } if (txtMKCu.Text == oldpass) { newpass = txtMKmoi.Text; if (NguoiDungBUS.ChangePassword(username, newpass) == true) { MessageBox.Show("Thay đổi thành công.", "Imformation", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("Thay đổi mật khẩu thất bại.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtMKCu.ResetText(); txtMKmoi.ResetText(); } } else { MessageBox.Show("Mật khẩu cũ không đúng.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMKCu.ResetText(); txtMKmoi.ResetText(); } }
protected void btnSubmit_Click(object sender, EventArgs e) { try { NguoiDungDTO ndDTO = new NguoiDungDTO(); ndDTO.Username = txtID.Text; Session["Username"] = txtID.Text; ndDTO.Pass = txtPassword.Text; ndDTO.Mail = txtEmail.Text; ndDTO.LoaiND = int.Parse(DropDownList1.SelectedItem.Value.ToString()); bool ktra = NguoiDungBUS.ktraTonTai(ndDTO); if (ktra == false) { NguoiDungBUS.AdminThemNguoiDung(ndDTO); lblThongBao.Text = "Thêm thành công"; } else { lblThongBao.Text = "Tài khoản đã tồn tại"; } BindItemsList(); } catch (Exception ex) { } }
public frmThemNV() { InitializeComponent(); txtMaNV.Text = NguoiDungBUS.GetIDNguoidung(); cboGioiTinh.SelectedItem = "Nam"; cboPhanQuyen.SelectedItem = "Admin"; }
private void btnQuanLyNguoiDung_Sua_Click(object sender, EventArgs e) { string tenDangNhap = dgvQuanLyNguoiDung_DanhSachNguoiDung.SelectedRows[0].Cells[0].Value.ToString(); if (txtTenDangNhap.TextLength > 0 && txtEmail.TextLength > 0 && txtMatKhau.TextLength > 0) { bool ketQua = NguoiDungBUS.suaNguoiDung(new NguoiDungDTO(tenDangNhap, txtMatKhau.Text, txtEmail.Text)); if (ketQua) { MessageBox.Show("Sửa người dùng thành công", "Thong bao", MessageBoxButtons.OK, MessageBoxIcon.Information); dgvQuanLyNguoiDung_DanhSachNguoiDung.DataSource = NguoiDungBUS.hienThiTatCaNguoiDung(); txtTenDangNhap.Text = txtMatKhau.Text = txtEmail.Text = ""; txtTenDangNhap.ReadOnly = false; } else { MessageBox.Show("Sửa người dùng thất bại", "Loi", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Vui lòng click chọn bảng bên dưới để sửa\nVà điền đầy đủ thông tin", "Thong bao", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { try { GridView gv = (GridView)sender; GridViewRow row = GridView1.Rows[e.RowIndex]; string sUserName = gv.DataKeys[e.RowIndex]["TenDangNhap"].ToString(); string sNewPass = ((TextBox)(row.Cells[1].Controls[0])).Text; string sNewType = ((TextBox)(row.Cells[2].Controls[0])).Text; string sNewMail = ((TextBox)(row.Cells[3].Controls[0])).Text; NguoiDungDTO ndDTO = new NguoiDungDTO(); ndDTO.Username = sUserName; ndDTO.Newpass = sNewPass; ndDTO.LoaiND = int.Parse(sNewType); ndDTO.Mail = sNewMail; NguoiDungBUS.SuaThongTin(ndDTO); GridView1.EditIndex = -1; BindItemsList(); } catch (Exception ex) { Response.Write("<script type='text/javascript'>" + "alert('Có lỗi xảy ra. Vui Lòng điền đúng kiểu dữ liệu yêu cầu !!!');" + "</script>"); } }
private void btnQuanLyNguoiDung_ThemMoi_Click(object sender, EventArgs e) { int ketQua = 0; // 0: Thêm thất bại // 1: Thêm thành công //-1: Đã tồn tại người dùng đó if (txtTenDangNhap.TextLength > 0 && txtMatKhau.TextLength > 0 && txtEmail.TextLength > 0) { ketQua = NguoiDungBUS.themNguoiDung(new NguoiDungDTO(txtTenDangNhap.Text, txtMatKhau.Text, txtEmail.Text)); if (ketQua == 1) { MessageBox.Show("Thêm người dùng mới thành công", "Thong bao", MessageBoxButtons.OK, MessageBoxIcon.Information); dgvQuanLyNguoiDung_DanhSachNguoiDung.DataSource = NguoiDungBUS.hienThiTatCaNguoiDung(); txtTenDangNhap.Text = txtMatKhau.Text = txtEmail.Text = ""; } else if (ketQua == 0) { MessageBox.Show("Thêm người dùng mới thất bại", "Loi", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Đã tồn tại tên đăng nhập đó\nVui lòng nhập tên khác", "Loi", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Vui lòng điền tên đầy đủ thông tin", "Thong bao", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void txtTimKiem_TextChanged(object sender, TextChangedEventArgs e) { DataTable dataTable = new DataTable(); if (txtTimKiem.Text.Length >= 1 && txtTimKiem.Text != "Tìm Kiếm...") { switch (type_timkiem) { case 0: { dataTable = NguoiDungBUS.TimTheoMaND(txtTimKiem.Text.ToString()); } break; case 1: { dataTable = NguoiDungBUS.TimTheoHoTenNguoiDung(txtTimKiem.Text.ToString()); } break; } } else if (txtTimKiem.Text.Length == 0) { dataTable = NguoiDungBUS.LoadDSND(); } Load_Data(dataTable); }
private void GuiMail() { string Username = (string)Request["Username"]; string subject = (string)Request["subject"]; string body = (string)Request["msgpost"]; NguoiDungBUS ndBus = new NguoiDungBUS(); NguoiDungDTO dto = ndBus.LayThongTinNguoiDung(Username); bool flag = Utilities.SendMail("*****@*****.**", dto.Email, subject, body) == ""; NoiDungEmailDTO ndedto = new NoiDungEmailDTO(); NoiDungEmailBUS bus = new NoiDungEmailBUS(); ndedto.TieuDe = subject; ndedto.NoiDung = body; ndedto.Email = dto.Email; ndedto.NgayGui = DateTime.Now; ndedto.Username = Username; bool kq = bus.ThemNoiDungEmail(ndedto); // XL_THE the = new XL_THE("goc"); // XL_THUOC_TINH thuoctinh = new XL_THUOC_TINH("kq", flag ? "1" : "0"); // the.Danh_sach_thuoc_tinh.Add(thuoctinh); // string chuoi = the.Chuoi(); string str = flag && kq ? "Gửi mail thành công" : "Không thực hiện được do lỗi server"; Response.Write("<script type=\"text/javascript\"> alert('" + str + "'); </script>"); }
protected void btnDangNhap_Click(object sender, EventArgs e) { if (IsValid) { NguoiDungDTO nguoiDung = new NguoiDungDTO(); NguoiDungBUS nguoiDungBUS = new NguoiDungBUS(); nguoiDung.TenDangNhap = textUsername.Value; nguoiDung.MatKhau = textMatKhau.Value; nguoiDungBUS._nguoiDung = nguoiDung; nguoiDungBUS.LoginWithUser(); //labelMessage.Text = "Đăng nhập thành công!"; if (nguoiDungBUS.IsInvalid) { base._NguoiDungHienTai = nguoiDungBUS._nguoiDung; Label lblWelcome = (Label)Master.FindControl("lblchao"); lblWelcome.Text = "Xin chào, " + base._NguoiDungHienTai.HoTen; if (Request.Cookies["ReturnURL"].Value == "add-bill") { Response.Redirect(Request.Cookies["ReturnURL"].Value); } else { Response.Redirect("~/customer/invoice"); } } else { //labelMessage.Text = "Đăng nhập không thành công!"; } } }
private void btnThem_Click(object sender, EventArgs e) { if (KiemTra() == "") { NguoiDungDTO ND = new NguoiDungDTO(); ND.MaND = txtMaNV.Text; ND.HoTen = txtHoTen.Text; ND.Username = txtUsername.Text; ND.Password = "******"; ND.DiaChi = txtDiaChi.Text; ND.SoCMND = txtCMND.Text; ND.PhanQuyen = cboPhanQuyen.SelectedItem.ToString(); ND.DienThoai = txtDienThoai.Text; ND.GioiTinh = cboGioiTinh.SelectedItem.ToString(); if (NguoiDungBUS.ThemND(ND) == true) { MessageBox.Show("Thêm thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); txtMaNV.Text = NguoiDungBUS.GetIDNguoidung(); txtHoTen.ResetText(); txtUsername.ResetText(); txtDiaChi.ResetText(); txtCMND.ResetText(); txtDienThoai.ResetText(); } else { MessageBox.Show("Thêm thất bại.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show(string.Format("{0}", KiemTra()), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btn_DangNhap_Click(object sender, EventArgs e) { if (!kiemTraDoDaiHopLe()) { MessageBox.Show("Bạn chưa nhập tên đăng nhập hoặc mật khẩu.\n" + "Vui lòng kiểm tra lại.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (!kiemTraTenDangNhap()) { MessageBox.Show("Tên đăng nhập không tồn tại", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (!kiemTraMatKhau()) { MessageBox.Show("Sai mật khẩu!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { NguoiDungBUS bus = new NguoiDungBUS(); dto = bus.layThongTinNguoiDung(tbx_TenDangNhap.Text, tbx_MatKhau.Text); DialogResult = DialogResult.OK; } } } }
private void LayDanhSachNguoiDung() { NguoiDungBUS itemBUS = new NguoiDungBUS(); BindingList<NguoiDungDTO> danhSach = itemBUS.LayDanhSach(); //danhSach.AllowEdit = danhSach.AllowNew = danhSach.AllowRemove = true; gcNguoiDung.DataSource = danhSach; }
private void GuiLaiMatKhau() { string Username = (string)Request["Username"]; byte[] arr = new byte[10]; Random r = new Random((int)DateTime.Now.ToBinary()); r.NextBytes(arr); string pass = Utilities.ConvertToHexa(arr); NguoiDungBUS ndBus = new NguoiDungBUS(); NguoiDungDTO dto = ndBus.LayThongTinNguoiDung(Username); int maNguoiDung = dto.Ma_nguoi_dung; bool flag = Utilities.SendMail("*****@*****.**", dto.Email, "(OFFS) Reset mật khẩu", "Mật khẩu mới: <strong>" + pass + "</strong>") == ""; string passSHA1 = Utilities.SHA1(pass).ToLower(); bool kq = ndBus.CapNhatThongTinMatKhau(passSHA1, maNguoiDung); XL_THE the = new XL_THE("goc"); XL_THUOC_TINH thuoctinh = new XL_THUOC_TINH("kq", flag && kq ? "1" : "0"); the.Danh_sach_thuoc_tinh.Add(thuoctinh); string chuoi = the.Chuoi(); XL_CHUOI.XuatChuoi(Response, chuoi); }
private void LayDanhSachNguoiDung() { NguoiDungBUS itemBUS = new NguoiDungBUS(); BindingList <NguoiDungDTO> danhSach = itemBUS.LayDanhSach(); danhSach.AllowEdit = danhSach.AllowNew = danhSach.AllowRemove = true; gcDanhMucNguoiDung.DataSource = danhSach; ChucDanhBUS chucDanhBUS = new ChucDanhBUS(); BindingList <ChucDanhDTO> dsChucDanh = chucDanhBUS.LayDanhSach(); RepositoryItemLookUpEdit repositoryItem = new RepositoryItemLookUpEdit(); repositoryItem.DataSource = dsChucDanh; repositoryItem.PopulateColumns(); foreach (LookUpColumnInfo col in repositoryItem.Columns) { if (col.FieldName == "Id" || col.FieldName == "GhiChu") { col.Visible = false; } } repositoryItem.DisplayMember = "TenChucDanh"; repositoryItem.ValueMember = "Id"; gvDanhMucNguoiDung.Columns["IdChucDanh"].ColumnEdit = repositoryItem; }
private void DangNhap() { NguoiDungDTO nd = new NguoiDungDTO(); string pass = "", username = "", phanquyen = "", hinhanh = ""; username = txtTaiKhoan.Text; if (NguoiDungBUS.DangNhap(username).Rows.Count > 0) { foreach (DataRow row in NguoiDungBUS.DangNhap(username).Rows) { pass = row["Password"].ToString(); phanquyen = row["MaPQ"].ToString(); hinhanh = row["HinhAnh"].ToString(); } if (ch == true && txtMatKhau.Password != pass) { if (txtMatKhau.Password != "") { tbThongbao.Text = "※Sai mật khẩu※"; dispatcherTimer.Start(); } } if (ch == false && txtTaiKhoan.Text == username) { TransitioningContent transitioningContent = new TransitioningContent(); TransitionEffect effect = new TransitionEffect(); effect.Kind = TransitionEffectKind.ExpandIn; transitioningContent.OpeningEffect = effect; object avatarContent; ell.Height = 150; ell.Width = 150; ell.Stroke = Brushes.Transparent; ell.StrokeThickness = 1; ell.Fill = new ImageBrush(new BitmapImage(new Uri(@"..\..\Resources\Images\Avatar\" + hinhanh, UriKind.RelativeOrAbsolute))); avatarContent = ell; transitioningContent.Content = avatarContent; avatarContentControl.Content = transitioningContent; ch = true; transitionerField.SelectedIndex = 1; FocusManager.SetFocusedElement(gridSumary, txtMatKhau); } if (ch == true && txtMatKhau.Password == pass) { Account = username; Avatar = hinhanh; MainWindow mainWindow = new MainWindow(); mainWindow.Show(); this.Close(); } } else { if (txtTaiKhoan.Text != "") { tbThongbao.Text = "※Tài khoản không tồn tại※"; dispatcherTimer.Start(); } } }
void LoadData() { tsbtnXoa.Enabled = false; tsbtnSua.Enabled = false; dgvDanhSach.DataSource = NguoiDungBUS.LoadDSNhanVien(); Custom(); dgvDanhSach.ClearSelection(); }
public FrmQLNguoiDung() { InitializeComponent(); _nguoiDungBUS = new NguoiDungBUS(); _giaoVienBUS = new GiaoVienBUS(); _loaiNguoiDungBUS = new LoaiNguoiDungBUS(); _isAddButton = _isDeleteButton = true; }
private void BindItemsList() { NguoiDungDTO ndDTO = new NguoiDungDTO(); ndDTO.Username = Session["Username"].ToString(); GridView1.DataSource = NguoiDungBUS.LayThongTinNguoiDungVuaDangKi(ndDTO); GridView1.DataBind(); }
private void LayDanhSachNguoiDung() { NguoiDungBUS itemBUS = new NguoiDungBUS(); BindingList <NguoiDungDTO> danhSach = itemBUS.LayDanhSach(); //danhSach.AllowEdit = danhSach.AllowNew = danhSach.AllowRemove = true; gcNguoiDung.DataSource = danhSach; }
public FrmMain() { InitializeComponent(); _nguoiDungBUS = new NguoiDungBUS(); SkinHelper.InitSkinGallery(ribbonGalleryBarItemGiaoDien, true); UserLookAndFeel.Default.SkinName = Settings.Default.ApplicationSkinName; _nguoiDungBUS = new NguoiDungBUS(); }
private void btn_QuanLyChung_Click(object sender, EventArgs e) { panelQuanLyPhong.Visible = false; panelChoThuePhong.Visible = false; panelThongKe.Visible = false; panelTraCuu.Visible = false; panelQuanLyChung.Visible = true; dgvQuanLyNguoiDung_DanhSachNguoiDung.DataSource = NguoiDungBUS.hienThiTatCaNguoiDung(); }
void form_LoginEvent(string tenDangNhap) { this.ribbon.Visible = true; NguoiDungBUS nguoiDungBUS = new NguoiDungBUS(); nguoiDungDTO = nguoiDungBUS.LayThongTinNguoiDungByMa(tenDangNhap); this.bsiTenNguoiDung.Caption = nguoiDungDTO.TenNguoiDung.ToString(); }
private void txtTimKiem_LostFocus(object sender, RoutedEventArgs e) { if (txtTimKiem.Text == "") { txtTimKiem.Text = "Tìm Kiếm..."; DataTable dataTable = new DataTable(); dataTable = NguoiDungBUS.LoadDSND(); Load_Data(dataTable); } }
private void GridNguoiDung_Loaded(object sender, RoutedEventArgs e) { KhongChoNhap(); DataTable dataTable = new DataTable(); dataTable = NguoiDungBUS.LoadDSND(); Load_Data(dataTable); panelTimKiem.Visibility = btnHuy_Sua.Visibility = Visibility.Hidden; }
private void btnDangNhap_Click(object sender, EventArgs e) { NguoiDungDTO nd = new NguoiDungDTO(); string pass = "", hoten = "", username = "", phanquyen = ""; if (ValidateChildren(ValidationConstraints.Enabled)) { while (true) { username = txtUsername.Text; foreach (DataRow row in NguoiDungBUS.DangNhap(username).Rows) { pass = row["Password"].ToString(); hoten = row["HoTen"].ToString(); phanquyen = row["PhanQuyen"].ToString(); } if (txtPassword.Text == pass) { if (phanquyen == "Admin") { this.Hide(); frmMain frm = new frmMain(hoten, username, phanquyen); frm.ShowDialog(); this.Show(); txtPassword.ResetText(); break; } else if (phanquyen == "User ") { this.Hide(); frmUser frm = new frmUser(hoten, username, phanquyen); frm.ShowDialog(); this.Show(); txtPassword.ResetText(); break; } } else { if (dem == 3) { MessageBox.Show("Bạn nhập sai quá 3 lần cho phép.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); break; } dem++; MessageBox.Show("Sai tên đăng nhập hoặc mật khẩu.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtPassword.ResetText(); txtUsername.ResetText(); break; } } } }
private void gvDanhMucNguoiDung_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e) { if (gvDanhMucNguoiDung.FocusedRowHandle > -1) { try { NguoiDungDTO itemDTO = new NguoiDungDTO(); NguoiDungBUS itemBUS = new NguoiDungBUS(); MD5 maHoa = new MD5(); itemDTO.MaNguoiDung = gvDanhMucNguoiDung.GetFocusedRowCellValue("MaNguoiDung").ToString(); itemDTO.TenNguoiDung = gvDanhMucNguoiDung.GetFocusedRowCellValue("TenNguoiDung").ToString(); itemDTO.MatKhau = maHoa.md5(gvDanhMucNguoiDung.GetFocusedRowCellValue("MatKhau").ToString()); itemDTO.VoHieu = bool.Parse(gvDanhMucNguoiDung.GetFocusedRowCellValue("VoHieu").ToString()); itemDTO.IdChucDanh = int.Parse(gvDanhMucNguoiDung.GetFocusedRowCellValue("IdChucDanh").ToString()); itemDTO.DiaChi = gvDanhMucNguoiDung.GetFocusedRowCellValue("DiaChi").ToString(); itemDTO.DienThoai = gvDanhMucNguoiDung.GetFocusedRowCellValue("DienThoai").ToString(); itemDTO.NgayBatDau = DateTime.Parse(gvDanhMucNguoiDung.GetFocusedRowCellValue("NgayBatDau").ToString()); itemDTO.NgayKetThuc = DateTime.Parse(gvDanhMucNguoiDung.GetFocusedRowCellValue("NgayKetThuc").ToString()); itemDTO.GhiChu = gvDanhMucNguoiDung.GetFocusedRowCellValue("GhiChu").ToString(); itemDTO.Id = int.Parse(gvDanhMucNguoiDung.GetFocusedRowCellValue("Id").ToString()); if (this.flagThem && gvDanhMucNguoiDung.FocusedRowHandle == gvDanhMucNguoiDung.RowCount - 2) { if (itemDTO.MaNguoiDung.Length > 0) { DialogResult hopThoai = MessageBox.Show("Bạn chắc chắn muốn thêm mới?", "Thêm mới", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (hopThoai == DialogResult.Yes) { itemBUS.Them(itemDTO); this.flagThem = false; } } else { MessageBox.Show("Bạn chưa nhập mã!", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { DialogResult hopThoai = MessageBox.Show("Bạn chắc chắn muốn cập nhật?", "Cập nhật", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (hopThoai == DialogResult.Yes) { itemBUS.Sua(itemDTO); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } this.LayDanhSachNguoiDung(); } }
private void btnThayDoi_Click(object sender, EventArgs e) { MD5 mahoa = new MD5(); string tenDangNhap = nguoiDungDTO.MaNguoiDung; string matKhau = mahoa.md5(txtMatKhauCu.Text.Trim()); NguoiDungBUS nguoiDungBUS = new NguoiDungBUS(); bool ketQua = nguoiDungBUS.KiemTraDangNhap(tenDangNhap, matKhau); if (ketQua == false) { MessageBox.Show("Mật khẩu cũ không chính xác", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } else { if (this.txtMatKhauMoi.Text.Length < 6 && this.txtMatKhauMoi.Text.Length > 0) { MessageBox.Show("Mật khẩu có ít nhất 6 ký tự", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } else if (this.txtMatKhauMoi.Text != this.txtMatKhauNhapLai.Text && this.txtMatKhauMoi.Text.Length > 0) { MessageBox.Show("Mật khẩu mới nhập lại không trùng khớp", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } else { if (this.txtDiaChi.Text.Length == 0 || this.txtSoDienThoai.Text.Length == 0) { MessageBox.Show("Điện thoại và địa chỉ không được bỏ trống", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } else { try { nguoiDungDTO.DiaChi = this.txtDiaChi.Text; nguoiDungDTO.DienThoai = this.txtSoDienThoai.Text; if (this.txtMatKhauMoi.Text.Length > 0) { nguoiDungDTO.MatKhau = mahoa.md5(txtMatKhauMoi.Text.Trim()); } nguoiDungBUS.Sua(nguoiDungDTO); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } } } }
private void btnReload_Click(object sender, EventArgs e) { frmMatKhau frm = new frmMatKhau(); frm.truyen += new frmMatKhau.TruyenMatKhau(GetMatKhau); if (frm.ShowDialog() == DialogResult.OK) { NguoiDungBUS.ThietLapLaiMatKhau(txtTenDangNhap.Text, matKhau); NguoiDungBUS.LuuThayDoi(); log.GhiFile("Thiết lập lại mật khẩu của người dùng " + txtTenDangNhap.Text); MsgboxUtil.Success("Đã thiết lập lại mật khẩu cho \"" + txtTenDangNhap.Text + "\""); } }
private void btnXoa_Click(object sender, RoutedEventArgs e) { MessageBoxResult result = MessageBox.Show("Bạn có chắc chắn muốn xóa người dùng này không?", "Thông Báo", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { NguoiDungBUS.Xoa(txtMaND.Text); MessageBox.Show("Xóa người dùng thành công", "Thông Báo"); } DataTable dataTable = new DataTable(); dataTable = NguoiDungBUS.LoadDSND(); Load_Data(dataTable); }
private void btnThayDoi_Click(object sender, EventArgs e) { MD5 mahoa = new MD5(); string tenDangNhap = nguoiDungDTO.MaNguoiDung; string matKhau = mahoa.md5(txtMatKhauCu.Text.Trim()); NguoiDungBUS nguoiDungBUS = new NguoiDungBUS(); bool ketQua = nguoiDungBUS.KiemTraDangNhap(tenDangNhap, matKhau); if(ketQua == false) { MessageBox.Show("Mật khẩu cũ không chính xác", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } else { if (this.txtMatKhauMoi.Text.Length < 6 && this.txtMatKhauMoi.Text.Length > 0) { MessageBox.Show("Mật khẩu có ít nhất 6 ký tự", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } else if (this.txtMatKhauMoi.Text != this.txtMatKhauNhapLai.Text && this.txtMatKhauMoi.Text.Length > 0) { MessageBox.Show("Mật khẩu mới nhập lại không trùng khớp", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } else { if (this.txtDiaChi.Text.Length == 0 || this.txtSoDienThoai.Text.Length ==0) { MessageBox.Show("Điện thoại và địa chỉ không được bỏ trống", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } else { try { nguoiDungDTO.DiaChi = this.txtDiaChi.Text; nguoiDungDTO.DienThoai = this.txtSoDienThoai.Text; if (this.txtMatKhauMoi.Text.Length > 0) nguoiDungDTO.MatKhau = mahoa.md5(txtMatKhauMoi.Text.Trim()); nguoiDungBUS.Sua(nguoiDungDTO); this.Close(); } catch(Exception ex) { MessageBox.Show(ex.ToString()); } } } } }
private void btnDangNhap_Click(object sender, EventArgs e) { MD5 mahoa = new MD5(); string tenDangNhap = tboxTenDangNhap.Text.Trim(); string matKhau = mahoa.md5(tboxMatKhau.Text.Trim()); NguoiDungBUS itemBUS = new NguoiDungBUS(); bool ketQua = itemBUS.KiemTraDangNhap(tenDangNhap, matKhau); if(ketQua == false) { MessageBox.Show("Đăng nhập không thành công! Bạn bị một trong các lỗi sau:\n - Sai tên đăng nhập hoặc mật khẩu.\n - Tài khoản của bạn đã hết hạn sử dụng hệ thống.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } else { MessageBox.Show("Đăng nhập thành công", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); LoginEvent(tenDangNhap); this.Close(); } }