protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Session["User"] != null)
         {
             NguoidungModel nguoidung = Session["User"] as NguoidungModel;
             if (nguoidung != null)
             {
                 if (nguoidung.PK_iNguoidungID > 0)
                 {
                     List<NguoidungModel> glstNguoidung = new TaiKhoanController().NguoidungGetbyPK(nguoidung.PK_iNguoidungID);
                     if (glstNguoidung.Count < 1)
                     {
                         Response.Redirect("~/Login.aspx");
                     }
                 }
             }
         }
         else
         {
             Response.Redirect("~/Login.aspx");
         }
     }
 }
示例#2
0
        private void hienthiTaikhoan()
        {
            List <NguoidungModel> glstNguoidung = new TaiKhoanController().NguoidungGetbyPK(0);

            glstNguoidung.Sort((nd1, nd2) => nd1.sTennguoidung.CompareTo(nd2.sTennguoidung));
            rptTaikhoan.DataSource = glstNguoidung;
            rptTaikhoan.DataBind();
        }
示例#3
0
        private void hienthiQuyen()
        {
            List <QuyenModel> glstQuyen = new TaiKhoanController().QuyenGetbyPK(0);

            ddlQuyen.DataSource     = glstQuyen;
            ddlQuyen.DataValueField = "PK_iQuyenID";
            ddlQuyen.DataTextField  = "sTenQuyen";
            ddlQuyen.DataBind();
        }
示例#4
0
        public KhoiPhuc(DangNhap dn)
        {
            InitializeComponent();
            this.dn = dn;

            tk = new TaiKhoanController();

            lblError.Text = "";
        }
示例#5
0
 public frmDangNhap()
 {
     InitializeComponent();
     m_dangnhapController = new DangNhapController();
     tkcontroller         = new TaiKhoanController();
     foreach (TextBox tb in this.Controls.OfType <TextBox>())
     {
         tb.Enter += textBox_Enter;
     }
 }
示例#6
0
        public DanhSach(DangNhap dn, string manv)
        {
            InitializeComponent();
            this.dn   = dn;
            this.manv = manv;

            dp = new DatPhongController();
            tp = new ThuePhongController();
            p  = new PhongController();
            tk = new TaiKhoanController();
            dp.huyDatPhongQuaHan();
            hienThiThongTin();
        }
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            lblRegexDangnhap.Text = "";
            NguoidungModel nguoidung = new TaiKhoanController().Login(txtTendangnhap.Text, txtPassword.Text);

            if (nguoidung != null)
            {
                Session["User"] = nguoidung;
                Response.Redirect("~/Welcome.aspx");
            }
            else
            {
                lblRegexDangnhap.Text = "Tài khoản hoặc mật khẩu không chính xác.";
            }
        }
示例#8
0
 protected void btnThem_Click(object sender, EventArgs e)
 {
     try
     {
         TaiKhoanController taikhoanController = new TaiKhoanController();
         long userID = taikhoanController.ThemTaiKhoan(txtTenDangnhap.Text, txtTenNhanvien.Text, txtMatkhau.Text);
         taikhoanController.ThemPhanquyen(Convert.ToInt32(ddlQuyen.SelectedValue), userID);
         btnHuy_Click(sender, e);
         hienthiQuyen();
         hienthiTaikhoan();
     }
     catch (Exception ex)
     {
         lblRegexTaikhoan.Text = ex.Message;
     }
 }
示例#9
0
 protected void rptTaikhoan_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "Sua")
     {
         long userID = Convert.ToInt64(e.CommandArgument);
         if (userID < 1)
         {
             lblRegexTaikhoan.Text = "Mã người dùng không hợp lệ.";
         }
         else
         {
             TaiKhoanController    taikhoanController = new TaiKhoanController();
             List <NguoidungModel> glstNguoidung      = taikhoanController.NguoidungGetbyPK(userID);
             if (glstNguoidung.Count > 0)
             {
                 List <PhanquyenModel> glstPhanquyen = taikhoanController.PhanquyenGetbyFK_iNguoidungID(glstNguoidung[0].PK_iNguoidungID);
                 if (glstPhanquyen.Count > 0)
                 {
                     List <QuyenModel> glstQuyen = taikhoanController.QuyenGetbyPK(glstPhanquyen[0].FK_iQuyenID);
                     if (glstQuyen.Count > 0)
                     {
                         ListItem item = ddlQuyen.Items.FindByValue(glstQuyen[0].PK_iQuyenID.ToString());
                         if (item != null)
                         {
                             item.Selected = true;
                         }
                     }
                 }
                 txtTenDangnhap.Text        = glstNguoidung[0].sTennguoidung;
                 txtTenNhanvien.Text        = glstNguoidung[0].sTenNhanvien;
                 txtMatkhau.Text            = "";
                 btnCapnhat.CommandArgument = userID.ToString();
                 btnThem.Visible            = false;
                 btnCapnhat.Visible         = true;
             }
         }
     }
     if (e.CommandName == "Xoa")
     {
         //tạm thời không xóa
     }
 }
示例#10
0
文件: frmLogin.cs 项目: seakBz/CNPM
 private void btnDangNhap_Click(object sender, EventArgs e)
 {
     lstTK = TaiKhoanController.getAllDataTaiKhoan();
     try
     {
         foreach (TaiKhoan tk in lstTK)
         {
             if (tk.TenTaiKhoan == txtUserName.Text.Trim() && tk.MatKhau == txtPassWord.Text.Trim())
             {
                 SingletonData.Getlates().nguoidung = new TaiKhoan()
                 {
                     TenTaiKhoan = txtUserName.Text
                 };
                 MessageBox.Show("Đăng nhập thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 if (ckLuu.Checked)
                 {
                     file.ghifileLG(pathFile, txtUserName.Text.Trim(),
                                    txtPassWord.Text.Trim());
                     lblLuu.Text         = "✓ success";
                     ckLuu.Enabled       = false;
                     btnDangNhap.Enabled = true;
                 }
                 else
                 {
                     lblLuu.Text = "X error";
                 }
                 this.Close();
                 return;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     SingletonData.Getlates().nguoidung = null;
     MessageBox.Show("Đăng nhập thất bại. Xem lại tài khoản hoặc mật khẩu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
 }
示例#11
0
 protected void rptTaikhoan_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
     {
         NguoidungModel nguoidung = e.Item.DataItem as NguoidungModel;
         if (nguoidung != null)
         {
             Literal ltrQuyen = e.Item.FindControl("ltrQuyen") as Literal;
             if (ltrQuyen != null)
             {
                 TaiKhoanController    taikhoanController = new TaiKhoanController();
                 List <PhanquyenModel> glstPhanquyen      = taikhoanController.PhanquyenGetbyFK_iNguoidungID(nguoidung.PK_iNguoidungID);
                 if (glstPhanquyen.Count > 0)
                 {
                     List <QuyenModel> glstQuyen = taikhoanController.QuyenGetbyPK(glstPhanquyen[0].FK_iQuyenID);
                     if (glstQuyen.Count > 0)
                     {
                         ltrQuyen.Text = glstQuyen[0].sTenQuyen;
                     }
                 }
             }
         }
     }
 }
示例#12
0
 public DangNhap()
 {
     InitializeComponent();
     tk = new TaiKhoanController();
 }
示例#13
0
 public TaiKhoan()
 {
     InitializeComponent();
     tkcontroller = new TaiKhoanController();
 }