Ejemplo n.º 1
0
        public void grdList_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
        {
            Label lblSTT = (Label)e.Item.FindControl("lblSTT");

            if (lblSTT != null)
            {
                lblSTT.Text = (pages.PageIndex * pages.PageSize + e.Item.ItemIndex + 1).ToString();
            }
            ImageButton btnDelete = (ImageButton)e.Item.FindControl("btnDelete");

            if (btnDelete != null)
            {
                ChuyenmucDAL _dal = new ChuyenmucDAL();
                int          _id  = Convert.ToInt32(grdListCate.DataKeys[e.Item.ItemIndex].ToString());
                if (_dal.CheckExists_ChuyenMuc(_id) == 1)
                {
                    btnDelete.Attributes.Add("onclick", "return alert(\"Chuyên mục này đang được sử dụng\");");
                }
                else
                {
                    btnDelete.Attributes.Add("onclick", "return confirm(\"Bạn có chắc chắn muốn xóa không?\");");
                }
            }
            if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
            {
                e.Item.Attributes.Add("onmouseover", "currColor=this.style.backgroundColor;this.style.backgroundColor='" + CommonLib.HPCOnmouseoverGrid() + "'");
                e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=currColor");
            }
        }
Ejemplo n.º 2
0
 public void grdList_EditCommand(object source, DataGridCommandEventArgs e)
 {
     #region GhiLog
     Lichsu_Thaotac_HethongDAL actionDAL = new Lichsu_Thaotac_HethongDAL();
     T_Lichsu_Thaotac_Hethong  action    = new T_Lichsu_Thaotac_Hethong();
     action.Ma_Nguoidung = _user.UserID;
     action.TenDaydu     = _user.UserFullName;
     action.HostIP       = IpAddress();
     action.NgayThaotac  = DateTime.Now;
     #endregion
     ChuyenmucDAL obj_Cate = new ChuyenmucDAL();
     int          catID    = Convert.ToInt32(this.grdListCate.DataKeys[e.Item.ItemIndex].ToString());
     if (e.CommandArgument.ToString().ToLower() == "edit")
     {
         Response.Redirect("~/Danhmuc/EditChuyenMuc.aspx?Menu_ID=" + Page.Request["Menu_ID"].ToString() + "&ID=" + catID);
     }
     if (e.CommandArgument.ToString().ToLower() == "editdisplay")
     {
         bool check = obj_Cate.GetOneFromT_ChuyenmucByID(catID).HoatDong;
         if (check)
         {
             obj_Cate.UpdateFromT_ChuyenMucDynamic(" Hoatdong = 0, Ngaysua = Getdate(), Nguoisua=" + _user.UserID.ToString() + " Where Ma_ChuyenMuc = " + catID);
             action.Thaotac = "[Update T_ChuyenMuc]-->[Hoatdong = 0]";
         }
         else
         {
             obj_Cate.UpdateFromT_ChuyenMucDynamic(" Hoatdong = 1, Ngaysua = Getdate(), Nguoisua=" + _user.UserID.ToString() + " Where Ma_ChuyenMuc = " + catID);
             action.Thaotac = "[Update T_ChuyenMuc]-->[Hoatdong = 1]";
         }
     }
     if (e.CommandArgument.ToString().ToLower() == "active_bdt")
     {
         bool check = obj_Cate.GetOneFromT_ChuyenmucByID(catID).HienThi_BDT;
         if (check)
         {
             obj_Cate.UpdateFromT_ChuyenMucDynamic(" HienThi_BDT = 0, Ngaysua = Getdate(), Nguoisua=" + _user.UserID.ToString() + " Where Ma_ChuyenMuc = " + catID);
             action.Thaotac = "[Update T_ChuyenMuc]-->[HienThi_BDT = 0]";
         }
         else
         {
             obj_Cate.UpdateFromT_ChuyenMucDynamic(" HienThi_BDT = 1, Ngaysua = Getdate(), Nguoisua=" + _user.UserID.ToString() + " Where Ma_ChuyenMuc = " + catID);
             action.Thaotac = "[Update T_ChuyenMuc]-->[HienThi_BDT = 1]";
         }
     }
     if (e.CommandArgument.ToString().ToLower() == "delete")
     {
         if (obj_Cate.CheckExists_ChuyenMuc(catID) == 0)
         {
             obj_Cate.DeleteFromT_ChuyenmucByID(catID);
             action.Thaotac = "[Xóa T_ChuyenMuc]-->[Thao tác Xóa Trong Bảng T_ChuyenMuc][ID:" + this.grdListCate.DataKeys[e.Item.ItemIndex].ToString() + " ]";
         }
         else
         {
             FuncAlert.AlertJS(this, "chuyên mục đã được sử dung biên tập tin bài!");
             return;
         }
     }
     Danhsach_ChuyenMuc();
 }