Beispiel #1
0
        private void excutive(string strcpmode, string strCats, string strAndCat)
        {
            if (!string.IsNullOrEmpty(strCats))
            {
                strCats   = " AND (Category.Cat_ID in (" + strCats + ") OR Category.Cat_ParentID IN (" + strCats + ") )";
                strAndCat = strCats + strAndCat;
            }
            switch (strcpmode)
            {
            case "approvalwaitspeciallist":
                objListNewsSource.SelectParameters[0].DefaultValue = "News_Status=2 and isUserRate = 1 " + strAndCat;
                break;

            default:
                //xem quyen cua thang dang set
                MainSecurity objSecu = new MainSecurity();
                Role         objrole = objSecu.GetRole(Page.User.Identity.Name);

                if (objrole.isThuKyChuyenMuc || objrole.isThuKyToaSoan || objrole.isPhuTrachKenh || objrole.isTongBienTap)
                {
                    objListNewsSource.SelectParameters[0].DefaultValue = "News_Status=2 and isUserRate = 1 " + strAndCat;
                }
                break;
            }
            // objListNewsSource.Select();
            grdListNews.DataBind();
        }
        public static string GetCatIDByUser()
        {
            string strResult = HttpContext.Current.Cache.Get("GetCatIDByUser_strResult" + HttpContext.Current.User.Identity.Name) as string;


            if (string.IsNullOrEmpty(strResult))
            {
                #region Doi voi truong hop chua luu Cache
                // Doi voi truong hop chua luu cache
                //thuc hien lay danh sach cat ma nguoi hien tai duoc phep - Check neu nguoi hien tai khong phai la TBT - TKTS thi moi ap dung
                MainSecurity objSec  = new MainSecurity();
                Role         objrole = objSec.GetRole(HttpContext.Current.User.Identity.Name);
                if (objrole.isPhuTrachKenh || objrole.isThuKyToaSoan || objrole.isTongBienTap)
                {
                    strResult = LoadAllCat(null, null, null);
                }
                else
                {
                    strResult = LoadCategoryByPermission(null, null, null);
                }
                if (strResult != "")
                {
                    strResult = strResult.Substring(0, strResult.Length - 1);
                }


                HttpContext.Current.Cache.Insert("GetCatIDByUser_strResult" + HttpContext.Current.User.Identity.Name, strResult, null, DateTime.Now.AddHours(1), Cache.NoSlidingExpiration);
                #endregion
            }

            return(strResult);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         MainSecurity objSecu = new MainSecurity();
         objrole        = objSecu.GetRole(Page.User.Identity.Name);
         isSendDirectly = objrole.isBienTapVien || objrole.isThuKyToaSoan || objrole.isThuKyChuyenMuc;
         isPublished    = objrole.isThuKyToaSoan || objrole.isThuKyChuyenMuc;
     }
 }
        public static void BindCheckBoxListCat(CheckBoxList cb_Cate)
        {
            cb_Cate.Items.Clear();
            string strResult = "";


            string str_item_cache = HttpContext.Current.Cache.Get("CheckBoxList_" + HttpContext.Current.User.Identity.Name) as string;

            if (!string.IsNullOrEmpty(str_item_cache))
            {
                // Doi voi truong hop da luu Cache
                string[] strArItem = str_item_cache.Split('!');
                string[] strTextValue;
                ListItem item = new ListItem();
                foreach (string strItem in strArItem)
                {
                    item         = new ListItem();
                    strTextValue = strItem.Split('|');
                    item.Text    = strTextValue[0];
                    item.Value   = strTextValue[1];
                    cb_Cate.Items.Add(item);
                }
            }
            else
            {
                #region Doi voi truong hop chua luu cache
                //thuc hien lay danh sach cat ma nguoi hien tai duoc phep - Check neu nguoi hien tai khong phai la TBT - TKTS thi moi ap dung
                MainSecurity objSec  = new MainSecurity();
                Role         objrole = objSec.GetRole(HttpContext.Current.User.Identity.Name);
                if (objrole.isPhuTrachKenh || objrole.isThuKyToaSoan || objrole.isTongBienTap)
                {
                    strResult = LoadAllCat(null, null, cb_Cate);
                }
                else
                {
                    strResult = LoadCategoryByPermission(null, null, cb_Cate);
                }

                str_item_cache = "";
                foreach (ListItem item in cb_Cate.Items)
                {
                    str_item_cache += "!" + item.Text + "|" + item.Value;
                }

                if (str_item_cache.Trim() != "")
                {
                    str_item_cache = str_item_cache.Substring(1);
                }

                HttpContext.Current.Cache.Insert("CheckBoxList_" + HttpContext.Current.User.Identity.Name, str_item_cache, null, DateTime.Now.AddHours(1), Cache.NoSlidingExpiration);
                #endregion
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                MainSecurity objSecu       = new MainSecurity();
                Role         objRole       = objSecu.GetRole(Page.User.Identity.Name, DFISYS.API.Config.CurrentChannel);
                Permission   objPermission = objSecu.GetPermission(Page.User.Identity.Name);



                // Check permission doi voi tung loai thong ke
                if (objPermission.isXuat_Ban_Bai)
                {
                    ltrSumNewsPublished.Text = NewslistHelper.GetCountNews("publishedlist", false).ToString();
                    hplPublished.NavigateUrl = "/office/publishedlist.aspx";
                }
                else
                {
                    hplPublished.Visible = false;
                }

                if (objPermission.isDuyet_Bai)
                {
                    ltrSumNewsWaitingApprove.Text     = NewslistHelper.GetCountNews("approvalwaitlist", false).ToString();
                    hplNewsWaitingApprove.NavigateUrl = "/office/approvalwaitlist.aspx";
                }
                else
                {
                    hplNewsWaitingApprove.Visible = false;
                }


                if (objPermission.isBien_Tap_Bai)
                {
                    ltrSumNewsWaitingEdit.Text     = NewslistHelper.GetCountNews("editwaitlist", false).ToString();
                    hplNewsWaitingEdit.NavigateUrl = "/office/editwaitlist.aspx";
                }
                else
                {
                    hplNewsWaitingEdit.Visible = false;
                }
            }
        }
        private static string LoadRootCategoryByPermission(DropDownList cb_Cate, ListBox lb_Cate, CheckBoxList cbl_Cate)
        {
            string       strResult    = "";
            MainSecurity objSec       = new MainSecurity();
            Role         objrole      = objSec.GetRole(HttpContext.Current.User.Identity.Name);
            DataTable    objParentCat = objSec.getParentCategoryAssigned(HttpContext.Current.User.Identity.Name, Portal.API.Config.CurrentChannel);

            if (cb_Cate != null)
            {
                cb_Cate.Items.Add(new ListItem("-----Chọn tất cả -----", "0"));
            }
            if (lb_Cate != null)
            {
                lb_Cate.Items.Add(new ListItem("-----Chọn chuyên mục khác -----", "0"));
            }

            DataTable childRows       = new DataTable();
            DataTable childLevel3Rows = new DataTable();

            using (Portal.Core.DAL.MainDB objDB = new Portal.Core.DAL.MainDB())
            {
                foreach (DataRow objrow in objParentCat.Rows)
                {
                    childRows  = objDB.FrontEndStoreProcedure.Category_GetListByWhere(" Where Cat_ParentID=" + objrow["Cat_ID"] + "", " Order By Cat_Order ");
                    strResult += objrow["Cat_ID"] + ",";

                    if (cb_Cate != null)
                    {
                        cb_Cate.Items.Add(new ListItem("" + objrow["Cat_Name"].ToString().ToUpper() + "", objrow["Cat_ID"] + ""));
                    }
                    if (lb_Cate != null)
                    {
                        lb_Cate.Items.Add(new ListItem("" + objrow["Cat_Name"].ToString().ToUpper() + "", objrow["Cat_ID"] + ""));
                    }
                    if (cbl_Cate != null)
                    {
                        cbl_Cate.Items.Add(new ListItem("" + objrow["Cat_Name"].ToString().ToUpper() + "", objrow["Cat_ID"] + ""));
                    }
                }
            }

            return(strResult);
        }
Beispiel #7
0
        protected void LinkSendAll_Click(object sender, EventArgs e)
        {
            MainSecurity objSecu   = new MainSecurity();
            Role         objrole   = objSecu.GetRole(Page.User.Identity.Name);
            string       strcpmode = Request.QueryString["cpmode"].ToString();


            // TKTS va TKM thi Gui bai o moi cap se vao luon "Danh sách bài chờ biên tập"
            if (objrole.isThuKyToaSoan || objrole.isThuKyChuyenMuc || objrole.isPhuTrachKenh || objrole.isTongBienTap || objrole.isBienTapVien)
            {
                objListNewsSource.UpdateParameters[1].DefaultValue = "2";
            }
            else if (objrole.isPhongVien)
            {
                objListNewsSource.UpdateParameters[1].DefaultValue = "1";
            }
            // ******* End Add By Tqdat

            string value = objListNewsSource.UpdateParameters[2].DefaultValue = hdNewsID.Value;

            objListNewsSource.Update();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            itemAddCat.NavigateUrl      = "~/category/editcat.aspx";
            itemListCat.NavigateUrl     = "~/category/catlist.aspx";
            itemComeAdmin.NavigateUrl   = "~/adminportal.aspx";
            itemEditionType.NavigateUrl = "~/category/editiontype.aspx";
            itemComeOffice.NavigateUrl  = "~/office.aspx";

            String cpmode = Request.QueryString["cpmode"];

            if (cpmode.ToLower().IndexOf("editcat") >= 0)
            {
                Div1.Attributes.Remove("class");
                Div1.Attributes.Add("class", "Menuleft_Item_Select");
            }
            else if (cpmode.ToLower().IndexOf("catlist") >= 0)
            {
                Div2.Attributes.Remove("class");
                Div2.Attributes.Add("class", "Menuleft_Item_Select");
            }
            else if (cpmode.ToLower().IndexOf("editiontype") >= 0)
            {
                Div5.Attributes.Remove("class");
                Div5.Attributes.Add("class", "Menuleft_Item_Select");
            }

            MainSecurity objsec = new MainSecurity();
            //string strRoles= objsec.GetRoleAsString(Page.User.Identity.Name, Portal.API.Config.CurrentChannel);
            Role objrole = objsec.GetRole(Page.User.Identity.Name, Portal.API.Config.CurrentChannel);

            if (objrole.isAdministrator)
            {
                Div4.Visible = false;
            }
            else
            {
                Div3.Visible = false;
            }
        }
        /// <summary>
        /// Hàm kiểm tra người dùng hiện thời có quyền cao nhất hay không
        /// </summary>
        /// <returns>True: Đúng, False: Sai</returns>
        private bool IsInAdminRole()
        {
            string strCacheName = "IsInAdminRole_" + Page.User.Identity.Name;

            if (HttpContext.Current.Cache[strCacheName] == null)
            {
                string strAdminRole = Config.AdminRoles;
                if (Page.User.IsInRole(strAdminRole))
                {
                    SaveCache(strCacheName, "true");
                    return(true);
                }

                MainSecurity objSecu = new MainSecurity();
                Role         objrole = objSecu.GetRole(Page.User.Identity.Name);

                if (objrole.isTongBienTap || objrole.isQuanTriKenh)
                {
                    SaveCache(strCacheName, "true");
                    return(true);
                }

                SaveCache(strCacheName, "false");
                return(false);
            }
            else
            {
                //try
                //{
                bool isReturn = Convert.ToBoolean(HttpContext.Current.Cache[strCacheName].ToString());
                return(isReturn);
                //}
                //catch { }
            }
            //return false;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            lnkUsers.NavigateUrl    = "~/users.aspx";
            lnkEditoral.NavigateUrl = "~/office.aspx";
            //lnkCat.NavigateUrl = "~/category.aspx";
            lnkChuyenMuc.NavigateUrl = "~/chuyenmuc.aspx";

            MainSecurity objsec  = new MainSecurity();
            Role         objrole = objsec.GetRole(Page.User.Identity.Name, Portal.API.Config.CurrentChannel);

            if (objrole.isQuanTriKenh && !objrole.isAdministrator && !objrole.isTongBienTap && !objrole.isPhuTrachKenh)
            {
                div3.Visible = false;
                //div2.Visible = false;
            }

            if (!IsPostBack)
            {
                TabCtrl.Visible = false;
                BuildTree();
                SelectTab("");
                SelectTemplate("");
            }
        }
Beispiel #11
0
        public static int CpModeToNewsStatus()
        {
            string strcpmode  = HttpContext.Current.Request.QueryString["cpmode"].ToString();
            int    newsStatus = -2;

            switch (strcpmode)
            {
            case "templist":
                newsStatus = 0;
                break;

            case "sendlist":
                newsStatus = 1;
                break;

            case "sendapprovallist":
                newsStatus = 2;
                break;

            case "dellist":
                newsStatus = 6;
                break;

            //Cung la waitlist nhung voi quyen khac nhau thi status nhan dc la khac nhau:
            //Neu la BTV thi trang thai la 1 va mode la editwaitlist.
            case "editwaitlist":
                newsStatus = 1;
                break;

            case "editinglist":
                newsStatus = 1;
                break;

            case "approvinglist":
                newsStatus = 2;
                break;

            case "approvalwaitlist":
                newsStatus = 2;
                break;

            case "publishedlist":
                newsStatus = 3;
                break;

            //voi danh sach bai tra lai.
            case "backlist":
                newsStatus = 5;
                break;

            //voi danh sach bai tra lai.
            case "removedlist":
                newsStatus = 7;
                break;

            default:
                //xem quyen cua thang dang set
                MainSecurity objSecu = new MainSecurity();
                Role         objrole = objSecu.GetRole(HttpContext.Current.User.Identity.Name);
                if (objrole.isBienTapVien)
                {
                    newsStatus = 1;
                }
                if (objrole.isPhongVien)
                {
                    newsStatus = 0;
                }
                if (objrole.isThuKyChuyenMuc || objrole.isThuKyToaSoan || objrole.isPhuTrachKenh || objrole.isTongBienTap)
                {
                    newsStatus = 2;
                }
                break;

            case "mypublished":
                newsStatus = 3;
                //objListNewsSource.SelectParameters[1].DefaultValue = HttpContext.Current.User.Identity.Name;
                break;
            }
            return(newsStatus);
        }
        private void excutive(string strcpmode, string strCats, string strAndCat)
        {
            if (!string.IsNullOrEmpty(strCats))
            {
                strCats   = " AND (Category.Cat_ID in (" + strCats + ") OR Category.Cat_ParentID IN (" + strCats + ") )";
                strAndCat = strCats + strAndCat;
            }
            switch (strcpmode)
            {
            case "templist":
                objListNewsSource.SelectParameters[0].DefaultValue = "News_Status=0 " + strAndCat;
                break;

            case "sendlist":
                objListNewsSource.SelectParameters[0].DefaultValue = "News_Status=1 " + strAndCat;
                break;

            case "sendapprovallist":
                objListNewsSource.SelectParameters[0].DefaultValue = "News_Status=2 " + strAndCat;
                break;

            case "dellist":
                objListNewsSource.SelectParameters[0].DefaultValue = "News_Status=6 " + strAndCat;
                break;

            //Cung la waitlist nhung voi quyen khac nhau thi status nhan dc la khac nhau:
            //Neu la BTV thi trang thai la 1 va mode la editwaitlist.
            case "editwaitlist":
                objListNewsSource.SelectParameters[0].DefaultValue = "News_Status=1 " + strAndCat + " ";
                break;

            case "editinglist":
                objListNewsSource.SelectParameters[0].DefaultValue = "News_Status=1 " + strAndCat;
                break;

            case "approvinglist":
                objListNewsSource.SelectParameters[0].DefaultValue = "News_Status=2 " + strAndCat;
                break;

            case "approvalwaitlist":
                objListNewsSource.SelectParameters[0].DefaultValue = "News_Status=2 " + strAndCat;
                break;

            case "publishedlist":
                objListNewsSource.SelectParameters[0].DefaultValue = "News_Status=3 " + strAndCat;
                break;

            //voi danh sach bai tra lai.
            case "backlist":
                objListNewsSource.SelectParameters[0].DefaultValue = "News_Status=5 " + strAndCat;
                break;

            //voi danh sach bai tra lai.
            case "removedlist":
                objListNewsSource.SelectParameters[0].DefaultValue = "News_Status=7 " + strAndCat;
                break;

            default:
                //xem quyen cua thang dang set
                MainSecurity objSecu = new MainSecurity();
                Role         objrole = objSecu.GetRole(Page.User.Identity.Name);
                if (objrole.isBienTapVien)
                {
                    objListNewsSource.SelectParameters[0].DefaultValue = "News_Status=1 " + strAndCat;
                }
                if (objrole.isPhongVien)
                {
                    objListNewsSource.SelectParameters[0].DefaultValue = "News_Status=0 " + strAndCat;
                }
                if (objrole.isThuKyChuyenMuc || objrole.isThuKyToaSoan || objrole.isPhuTrachKenh || objrole.isTongBienTap)
                {
                    objListNewsSource.SelectParameters[0].DefaultValue = "News_Status=2 " + strAndCat;
                }
                break;

            case "mypublished":
                objListNewsSource.SelectParameters[0].DefaultValue = " News_Status=3 " + strAndCat;    // +" order by news_createDate";
                objListNewsSource.SelectParameters[1].DefaultValue = HttpContext.Current.User.Identity.Name;
                break;
            }

            objListNewsSource.Select();
            grdListNews.DataSource = objListNewsSource;
            grdListNews.DataBind();
        }
        // Loads data from the database and binds the UI controls.
        private void BindGrid(int editIndex)
        {
            MainSecurity objSercu = new MainSecurity();
            Role         objrole  = objSercu.GetRole(Page.User.Identity.Name);

            using (MainDB db = new MainDB()) {
                int    totalRows  = 0;
                int    startIndex = gridUser.CurrentPageIndex * gridUser.PageSize;
                string sort       = "";
                if (this.Sort.Length > 0)
                {
                    sort = this.Sort + " " + this.SortDirection;
                }
                string where = "";

                string strSearchName = txtSearch.Text.Trim().ToLower();

                if (ddlChannel.SelectedIndex >= 0)
                {
                    //lấy danh sách user của 1 channel
                    Channel_UserRow[] row    = db.Channel_UserCollection.GetByChannel_ID(Convert.ToInt32(ddlChannel.SelectedValue));
                    string            inuser = "";
                    if (row != null && row.Length > 0)
                    {
                        //duyệt qua danh sách user của 1 channel
                        foreach (Channel_UserRow userRow in row)
                        {
                            // Xu ly viec tim kiem theo UserName
                            // -- Neu Username nay trung voi keyword thi moi dc xu ly tiep
                            // -- Con ko co keyword thi hien thi all
                            if (strSearchName != "" && userRow.User_ID.ToLower().IndexOf(strSearchName) == -1)
                            {
                                continue;
                            }


                            // Neu la account Quan Tri kenh thi ko nhin thay account Channelvn va Admin
                            if (objrole.isQuanTriKenh && objrole.isAdministrator == false)
                            {
                                if (userRow.User_ID == "channelvn" || userRow.User_ID == "admin")
                                {
                                    continue;
                                }
                            }

                            //lọc theo role
                            if (ddlRole.SelectedIndex > 0)
                            {
                                Channel_User_RoleRow[] curr = db.Channel_User_RoleCollection.GetByCU_ID(userRow.CU_ID);
                                if (curr != null && curr.Length > 0)
                                {
                                    //duyệt qua các role 1 user có
                                    foreach (Channel_User_RoleRow roleRow in curr)
                                    {
                                        //nếu có role nào trùng với role cần lọc
                                        if (roleRow.Role_ID == Int32.Parse(ddlRole.SelectedValue))
                                        {
                                            //đưa vào danh sách cần select
                                            inuser += "'" + userRow.User_ID + "',";
                                            break;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                //đưa vào danh sách cần select
                                inuser += "'" + userRow.User_ID + "',";
                            }
                        }
                        inuser += "'" + Const.Global_Admin + "','" + Const.TONG_BIEN_TAP + "',";
                        Business.User User    = new Business.User();
                        string        inWhere = User.CheckDupplicate(inuser);
                        where = "User_ID in (" + inWhere.Remove(inWhere.Length - 1) + ")";
                    }
                    else
                    {
                        where = "User_ID in('" + Const.Global_Admin + "','" + Const.TONG_BIEN_TAP + "')";
                    }
                }

                if (objrole.isQuanTriKenh && objrole.isAdministrator == false)
                {
                    where += " AND User_ID NOT IN ('channelvn','admin') ";
                }

                DataTable table = db.UserCollection.GetAsDataTable(where, sort, startIndex, gridUser.PageSize, ref totalRows);

                int viewStateFirst = gridUser.CurrentPageIndex * gridUser.PageSize;
                int viewStateLast;

                if (gridUser.AllowPaging)
                {
                    viewStateLast = Math.Min(viewStateFirst + gridUser.PageSize, table.Rows.Count);
                }
                else
                {
                    viewStateLast = table.Rows.Count;
                }

                gridUser.VirtualItemCount = totalRows;
                gridUser.DataSource       = table;
                ViewState["dtuser"]       = table;
                gridUser.EditItemIndex    = editIndex;
                gridUser.DataBind();

                ShowHideButton();
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     itemComeOffice.NavigateUrl = "~/office.aspx";
     MainSecurity objsec  = new MainSecurity();
     Role         objrole = objsec.GetRole(Page.User.Identity.Name, DFISYS.API.Config.CurrentChannel);
 }
Beispiel #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string strcpmode = Request.QueryString["cpmode"].ToString();

            CpMode = strcpmode;
            MainSecurity objSercu = new MainSecurity();
            Permission   objPer   = null;
            Role         objrole  = null;

            //DataTable tblPermissions = objSercu.GetPermissionAsTable(HttpContext.Current.User.Identity.Name);
            //isAllowChamNhuanBut = tblPermissions.Select("Permission_ID=" + PermissionConst.ChamNhuanBut).Length == 1;
            objPer = objSercu.GetPermission(Page.User.Identity.Name);
            isAllowChamNhuanBut = objPer.isChamNhuanBut;

            if (!Page.IsPostBack)
            {
                string strUrlRefer = Request.UrlReferrer != null?Request.UrlReferrer.ToString().ToLower() : "";

                if (strUrlRefer == "" || strUrlRefer.IndexOf("add," + strcpmode) == -1)
                {
                    Session.Remove("ddlChuyenmuc");
                    Session.Remove("txtFromDate");
                    Session.Remove("txtToDate");
                    Session.Remove("txtKeyword");
                    Session.Remove("cboCategory");
                    Session.Remove("cboTieuDiem");
                    Session.Remove("cboIsHot");
                }

                txtFromDate.Attributes.Add("onkeypress", "SetReadOnly()");
                txtToDate.Attributes.Add("onkeypress", "SetReadOnly()");
                txtFromDate.Attributes.Add("onpaste", "return false");
                txtToDate.Attributes.Add("onpaste", "return false");
                txtFromDate.Attributes.Add("oncontextmenu", "return false");
                txtToDate.Attributes.Add("oncontextmenu", "return false");
                txtKeyword.Attributes.Add("onkeypress", "return trapEnterKey(event, '" + btnSearch.ClientID + "')");

                Session["cpmode"] = Request.QueryString["cpmode"];
                string strCats = CategoryHelper.Treebuild(ddlChuyenmuc);
                CategoryHelper.Treebuild(ddlChuyenmuc);

                // Init value
                ddlChuyenmuc.SelectedValue = Session["ddlChuyenmuc"] != null ? Session["ddlChuyenmuc"].ToString() : "0";
                txtToDate.Text             = Session["txtToDate"] != null ? Session["txtToDate"].ToString() : "";
                txtFromDate.Text           = Session["txtFromDate"] != null ? Session["txtFromDate"].ToString() : "";
                //cboCategory.SelectedValue = Session["cboCategory"] != null ? Session["cboCategory"].ToString() : "0";
                txtKeyword.Text = Session["txtKeyword"] != null ? Session["txtKeyword"].ToString() : "";

                //Helper.BindUser(cboApproverBy);
                //Helper.BindUser(cboCreatedBy);

                // End Init Value

                if (string.IsNullOrEmpty(strCats))
                {
                    objListNewsSource.SelectParameters[0].DefaultValue = "News_Status = -2 AND Cat_ID = -2";
                    LinkApproval.Visible    = false; ltrsec2.Visible = false;
                    LinkDisApproval.Visible = false; ltrsec3.Visible = false;
                    lnkRealDel.Visible      = false; ltrsec5.Visible = false;
                    LinkSendAll.Visible     = false;
                    LinkDelete.Visible      = false; ltrsec4.Visible = false;
                    LinkFeedBackAll.Visible = false; ltrsec1.Visible = false;
                    return;
                }

                // Tu dong Search
                if (Session["ddlChuyenmuc"] != null || (Session["txtToDate"] != null && Session["txtFromDate"] != null))
                {
                    Filter();
                    //return;
                }
                else if (Session["cboCategory"] != null || Session["txtKeyword"] != null)
                {
                    btnSearch_Click(null, null);
                    //return;
                }
                else
                {
                    excutive(strcpmode, strCats, "");
                }
                // show command button, page title depending on cp mode
                switch (strcpmode)
                {
                case "approvalwaitspeciallist":
                    ltrLabel.Text           = "Danh sách bài viết chờ duyệt";
                    LinkDisApproval.Visible = false; ltrsec3.Visible = false;
                    lnkRealDel.Visible      = false; ltrsec5.Visible = false;
                    LinkSendAll.Visible     = false;
                    LinkDisApproval.Visible = false; ltrsec3.Visible = false;
                    lnkRealDel.Visible      = false; ltrsec5.Visible = false;

                    objPer = objSercu.GetPermission(Page.User.Identity.Name);
                    if (objPer.isXuat_Ban_Bai)
                    {
                        LinkApproval.Visible = true;
                    }
                    else
                    {
                        LinkApproval.Visible = false;
                        isXuatBan            = "false";
                    }

                    break;

                default:
                    //xem quyen cua thang dang set
                    objSercu = new MainSecurity();
                    objrole  = objSercu.GetRole(Page.User.Identity.Name);
                    if (objrole.isBienTapVien)
                    {
                        LinkApproval.Visible    = false; ltrsec2.Visible = false;
                        LinkDisApproval.Visible = false; ltrsec3.Visible = false;
                        lnkRealDel.Visible      = false; ltrsec5.Visible = false;
                    }
                    if (objrole.isPhongVien)
                    {
                        LinkFeedBackAll.Visible = false; ltrsec1.Visible = false;
                        LinkApproval.Visible    = false; ltrsec2.Visible = false;
                        LinkDisApproval.Visible = false; ltrsec3.Visible = false;
                        lnkRealDel.Visible      = false; ltrsec5.Visible = false;
                    }
                    if (objrole.isThuKyChuyenMuc || objrole.isThuKyToaSoan || objrole.isPhuTrachKenh || objrole.isTongBienTap)
                    {
                        LinkDisApproval.Visible = false; ltrsec3.Visible = false;
                        lnkRealDel.Visible      = false; ltrsec5.Visible = false;
                    }
                    break;
                }
            }
        }
        }     // page load

        #endregion

        #region Page binding
        private void CheckPemission(string userID)
        {
            MainSecurity ms = new MainSecurity();

            if (userID.Trim().ToLower() != Common.Const.Global_Admin && userID.Trim().ToLower() != Common.Const.TONG_BIEN_TAP && !ms.GetRole(userID).isQuanTriKenh&& !ms.GetRole(userID).isPhuTrachKenh)
            {
                Response.Redirect("/users/" + Const.OBJECT_ERROR + ".aspx?message=" + Const.Message_BanKhongCoQuyen);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                getCurrentMenuItem();
                string       userName       = HttpContext.Current.User.Identity.Name;
                MainSecurity mainSecurity   = new MainSecurity();
                DataTable    tblPermissions = mainSecurity.GetPermissionAsTable(userName);
                bool         isClear        = Request.RawUrl == "/office.aspx" ? true : false;
                if (tblPermissions != null)
                {
                    doc = MenuCommon.getXML();
                    XmlNodeList boxes = doc.SelectNodes("boxes/box[@isvisible='true']");

                    bool        isCheckPermisson = false, isCount = false;
                    XmlNodeList rows = null;
                    string      a = string.Empty;
                    foreach (XmlNode box in boxes)
                    {
                        StringBuilder html        = new StringBuilder();
                        bool          isPermision = false;
                        StringBuilder htmlHeader  = new StringBuilder();
                        htmlHeader.AppendLine("<li class=\"\"><a href=\"javascript:;\"><i class=\"icon-folder-open\"></i><span class=\"title\">");
                        htmlHeader.AppendLine(box.SelectSingleNode("name").InnerText);
                        htmlHeader.AppendLine("</span><span class=\"arrow\"></span></a>");
                        htmlHeader.AppendLine("<ul class=\"sub-menu\">");
                        isCheckPermisson = bool.Parse(box.SelectSingleNode("@checkpermission").InnerText);
                        rows             = box.SelectNodes("rows/row");
                        foreach (XmlNode row in rows)
                        {
                            if (isCheckPermisson && tblPermissions.Select("Permission_ID=" + row.SelectSingleNode("Permission_ID").InnerText).Length == 1 || !isCheckPermisson)
                            {
                                isPermision = true;
                                html.AppendLine("<li class=\"" + ((row.Attributes["isvisible"] != null) ? "hidden" : string.Empty) + " " + (row.SelectSingleNode("Cpmode").InnerText == CurrentMenuItem ? "active" : string.Empty) + "\">");
                                isCount = bool.Parse(row.SelectSingleNode("IsCount").InnerText);
                                a       = "<a href=\"/office/{0}.aspx\">{1} {2}</a>";
                                if (isCount)
                                {
                                    a = string.Format(a, row.SelectSingleNode("Cpmode").InnerText, row.SelectSingleNode("MenuName").InnerText, "(<span>" + MenuCommon.getNewsCountStr(row.SelectSingleNode("Cpmode").InnerText, isClear) + "</span>)");
                                }
                                else
                                {
                                    a = string.Format(a, row.SelectSingleNode("Cpmode").InnerText, row.SelectSingleNode("MenuName").InnerText, string.Empty);
                                }

                                html.AppendLine(a);
                                html.AppendLine("</li>");
                            }
                        }
                        if (isPermision)
                        {
                            htmlHeader.Append(html.ToString());
                        }
                        htmlHeader.AppendLine("</ul></li>");

                        if (isPermision)
                        {
                            ltrHtml.Text += htmlHeader.ToString();
                        }
                    }
                }

                MainSecurity objSecurity = new MainSecurity();
                Role         objRole     = objSecurity.GetRole(Page.User.Identity.Name);

                if (Page.User.Identity.Name == "admin" || objRole.isAdministrator || objRole.isTongBienTap || objRole.isQuanTriKenh)
                {
                    aUser.Visible = true;
                }
            }
        }