Beispiel #1
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
     }
 }
Beispiel #2
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;
                     }
                 }
             }
         }
     }
 }