private void btDongY_Click(object sender, EventArgs e) { if (this.CheckValid()) { if (Utilities.TTNguoiDungDangNhap.MatKhau != this.txtMatKhauCu.Text) { MessageBox.Show("Bạn nhập sai mật khẩu cũ! \nYêu cầu nhập lại mật khẩu cũ!", "Đổi mật khẩu", MessageBoxButtons.OK, MessageBoxIcon.Error); this.txtMatKhauCu.Focus(); } else if (this.txtMatKhauMoi.Text != this.txtNhapLaiMatKhauMoi.Text) { MessageBox.Show("Xác nhận mật khẩu sai! \nYêu cầu nhập lại mật khẩu mới và xác nhận!", "Đổi mật khẩu", MessageBoxButtons.OK, MessageBoxIcon.Error); this.txtNhapLaiMatKhauMoi.Text = ""; this.txtMatKhauMoi.Text = ""; this.txtMatKhauMoi.Focus(); } else { if (this.CtrlNguoiDung == null) { this.CtrlNguoiDung = new NguoiDungController(); } if (this.CtrlNguoiDung.Update(Utilities.TTNguoiDungDangNhap, this.txtMatKhauMoi.Text)) { Utilities.TTNguoiDungDangNhap.MatKhau = this.txtMatKhauMoi.Text; MessageBox.Show("Mật khẩu đã được cập nhật!", "Đổi mật khẩu", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Dispose(); } } } }
private void gr_btn_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { if (e.Button.Caption.ToUpper().Equals("DELETE")) { int introw = gridView1.FocusedRowHandle; string strNguoiDungID = string.Empty; if (introw >= 0) { strNguoiDungID = gridView1.GetRowCellValue(introw, "NguoiDungID").ToString(); } if ((strNguoiDungID != string.Empty) && (!strNguoiDungID.ToUpper().Equals("ADMIN"))) { if (MessageBox.Show("Bạn muốn xóa người sử dụng này?", "Xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { NguoiDungController.Del(strNguoiDungID); gridControl1.DataSource = NguoiDungController.GetList(); //if ((gridView1.RowCount>introw )&&(introw>0)) //{ // gridView1.FocusedRowHandle = introw - 1; //} } } else { if (strNguoiDungID.ToUpper().Equals("ADMIN")) { MessageBox.Show("Không được xóa user ADMIN", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void frmNguoiDung_Load(object sender, EventArgs e) { if (this.Controller == null) { this.Controller = new NguoiDungController(); } //Hien thi combobox loai nguoi dung LoaiNguoiDungController ctrlLoaiNguoiDung = new LoaiNguoiDungController(); ctrlLoaiNguoiDung.HienThiComboBox(this.cmbLoaiNguoiDung); ctrlLoaiNguoiDung.HienThiDataGridViewComboBoxColumn(this.colLoaiNguoiDung); //Hien thi combox giao vien GiaoVienController ctrlGiaoVien = new GiaoVienController(); ctrlGiaoVien.HienThiComboBox(this.cmbGiaoVien); //Them mot dong co ma giao vien la null de khi chon loai nguoi dung k phai la giao vien DataRow row = ctrlGiaoVien.Data.DataService.NewRow(); row["MaGiaoVien"] = DBNull.Value; row["HoTen"] = "Khác..."; ctrlGiaoVien.Data.DataService.Rows.Add(row); //An combobox giao vien this.lbGiaoVien.Visible = false; this.cmbGiaoVien.Visible = false; //Dat vi tri combobox giao vien trung voi ten nguoi dung this.lbGiaoVien.Location = this.lbTenNguoiDung.Location; this.cmbGiaoVien.Location = this.txtTenNguoiDung.Location; this.Controller.HienThiDS(this.dgvDS, this.bnDS, this.txtTenDangNhap, this.txtMatKhau, this.cmbLoaiNguoiDung, this.txtTenNguoiDung, this.cmbGiaoVien); }
protected void btn_login_Click(object sender, EventArgs e) { NguoiDungController kt = new NguoiDungController(); string ad = txt_user.Text; NguoiDungInfo info = kt.Check_Login(txt_user.Text, txt_pass.Text); if (info != null) { if (info.Quyen) { Session["TenDangNhap"] = info.TenDangNhap; Response.Redirect("~/Admin/ADIndex.aspx"); } else { Session["TenDangNhap"] = info.TenDangNhap; } Session["Email"] = info.Email; Session["HoTen"] = info.HoTen; Session["SDT"] = info.SDT; Session["DiaChi"] = info.DiaChi; Session["quyen"] = info.Quyen; Response.Redirect("~/Home.aspx"); } else { tb.Text = "Sai Tên Hoặc Mật Khẩu!"; } }
private void frmCauHinh_Load(object sender, EventArgs e) { KhoiTaoLuoi(); gridControl1.DataSource = NguoiDungController.GetList(); setTrangThaiNut(); // LayThongTinShop(); // load roles cbbRoles.Properties.Items.Add(Utility.QUANLY); cbbRoles.Properties.Items.Add(Utility.NHANVIEN); }
private void ProcessLogin() { if (txtUserNameOrEmail.Text != "" && txtPassWord.Text != "") { DHQB_NguoiDung user = NguoiDungController.GetUserByLoginName(txtUserNameOrEmail.Text.Trim()); try { if (user != null) { if ((bool)user.IsBlock) { lblError.Text = "Tài khoản này đang khóa."; return; } if (user.MatKhau != txtPassWord.Text.Trim()) { lblError.Visible = true; lblError.Text = "Mật khẩu đăng nhập không đúng."; lblError.ForeColor = System.Drawing.Color.Red; return; } AppSessionInfo.CurrentUser = user; AppSessionInfo.sesionID = ""; if (AppRequestInfo.RETURL_URL != "-1" && AppRequestInfo.RETURL_URL.Length > 0) { Response.Redirect(HttpUtility.UrlDecode(AppRequestInfo.RETURL_URL)); } else { Response.Redirect("Default.aspx?catid=1"); } } else { lblError.Visible = true; lblError.Text = "Tài khoản đăng nhập không hợp lệ."; lblError.ForeColor = System.Drawing.Color.Red; return; } } catch (Exception ex) { throw ex; } } else { } }
protected void btn_DangKy_Click(object sender, EventArgs e) { NguoiDungInfo nd = layDuLieuForm(); NguoiDungController taikhoan = new NguoiDungController(); bool kt = taikhoan.NguoiDung_Insert(nd); if (kt) { lbTB.Text = "Đăng ký thành công"; Response.Redirect("~/HienThi.aspx"); } else { lbTB.Text = "Đăng ký thất bại"; } }
private void GhiThongTinNGuoiDung() { NguoiDung itemNguoiDung = new NguoiDung(); itemNguoiDung.NguoiDungID = txtNguoiDungID.Text.Trim(); itemNguoiDung.MatKhau = txtMatKhau.Text.Trim(); itemNguoiDung.TenNguoiDung = txtTenNguoiDung.Text.Trim(); itemNguoiDung.Roles = cbbRoles.EditValue.ToString(); if (strMode.ToUpper().Equals("ADD")) { NguoiDungController.Add(itemNguoiDung); } else { if (strMode.ToUpper().Equals("EDIT")) { NguoiDungController.Edit(itemNguoiDung); } } gridControl1.DataSource = NguoiDungController.GetList(); }
protected void btn_DangNhap_Click(object sender, EventArgs e) { NguoiDungController kt = new NguoiDungController(); string ten = txtTen.Text; NguoiDungInfo info = kt.Check_Login(txtTen.Text, txtMatKhau.Text); if (info != null) { Session["TenDN"] = info.TenDN; Session["HoTen"] = info.HoTen; Session["NgaySinh"] = info.NgaySinh; Session["GioiTinh"] = info.GioiTinh; Session["DiaChi"] = info.DiaChi; Session["Email"] = info.Email; Response.Redirect("~/Home.aspx"); } else { lbTB.Text = "Sai Tên Hoặc Mật Khẩu!"; } }
/// <summary> /// Kiem tra thong tin dang nhap va neu dang nhap thanh cong thi hien thi theo phan quyen /// </summary> /// <param name="username"></param> /// <param name="password"></param> /// <returns></returns> public int CheckLogin(string tendangnhap, string matkhau) { //QLDiemSoHocSinhTHPT.Controlller.UserControl ctrlUser = new QLHocSinh.Control.UserControl(); NguoiDungController ctrlNguoiDung = new NguoiDungController(); NguoiDungInfo infoNguoiDung = ctrlNguoiDung.LayNguoiDung(tendangnhap); //Neu tim thay username if (infoNguoiDung != null) { //Neu password dung if (infoNguoiDung.MatKhau == matkhau) { //Gan thong tin user vua dang nahp vao bien toan cuc de tien su dung Utilities.TTNguoiDungDangNhap = infoNguoiDung; //Disable Dang nhap va Enable Dang xuat this.miDangNhap.Enabled = false; this.miDangXuat.Enabled = true; this.tiDangNhap.Enabled = false; this.tiDangXuat.Enabled = true; this.btDangNhap.Enabled = false; this.btDangXuat.Enabled = true; //Hien thi theo phan quyen this.AuthorityShow(); return(0); } else //Password sai { Utilities.TTNguoiDungDangNhap = null; return(1); } } else //Khong ton tai username { Utilities.TTNguoiDungDangNhap = null; return(2); } }
private void DangNhap() { NguoiDung item = new NguoiDung(); item = NguoiDungController.ChungThuc(txtTenDangNhap.Text.Trim(), txtMatKhau.Text.Trim()); if (item == null) { MessageBox.Show("Chứng thực lỗi, vui lòng kiểm tra lại tên và mật khẩu"); txtTenDangNhap.Focus(); txtTenDangNhap.SelectAll(); return; } else { Utility.NguoiSuDung = item; frmMain f = new frmMain(); f.Show(); this.Hide(); //this.Close(); } //item = }
private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) { int introw = gridView1.FocusedRowHandle; string strNguoiDungID = string.Empty; if (introw >= 0) { strNguoiDungID = gridView1.GetRowCellValue(introw, "NguoiDungID").ToString(); } if (strNguoiDungID != string.Empty) { NguoiDung selectUser = NguoiDungController.GetItem(strNguoiDungID); if (selectUser != null) { txtNguoiDungID.Text = selectUser.NguoiDungID; txtMatKhau.Text = selectUser.MatKhau; txtTenNguoiDung.Text = selectUser.TenNguoiDung; cbbRoles.EditValue = selectUser.Roles == null ? null : selectUser.Roles; //strMode = "edit"; //setTrangThaiNut(); } } }
private void btnOk_Click(object sender, EventArgs e) { if (!Utility.NguoiSuDung.MatKhau.Equals(txtPassOld.Text.Trim())) { MessageBox.Show("Mật khẩu cũ không đúng, xin kiểm tra lại"); return; } else { if (!txtPassNew.Text.Trim().Equals(txtPassNew2.Text.Trim())) { MessageBox.Show("Mật khẩu mới nhập lần 1 và 2 không tương thích, xin nhập lại "); txtPassNew2.SelectAll(); return; } else { NguoiDungController.DoiPass(Utility.NguoiSuDung.NguoiDungID, txtPassNew2.Text.Trim()); MessageBox.Show("Đã thay đổi mật khẩu mới, lưu ý cho lần đăng nhập tiếp theo"); this.Close(); } } }
private void frmNguoiDung_Load(object sender, EventArgs e) { KhoiTaoLuoi(); gridControl1.DataSource = NguoiDungController.GetList(); }