Пример #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();
        }
Пример #2
0
        private void RemoveRole()
        {
            MainSecurity ms  = new MainSecurity();
            DataTable    dt  = ms.GetRoleAsTable(lblUserName.Text, 1);
            string       ids = ",";

            foreach (DataRow dr in dt.Rows)
            {
                ids += dr[0].ToString() + ",";
            }

            if (ids.Length > 1)
            {
                ArrayList al = new ArrayList();
                foreach (ListItem li in lbxRole.Items)
                {
                    if (ids.Contains("," + li.Value + ","))
                    {
                        //al.Add(li);
                        li.Enabled = false;
                    }
                }
                if (al != null && al.Count > 0)
                {
                    foreach (ListItem item in al)
                    {
                        lbxRole.Items.Remove(item);
                    }
                }
            }
        }
Пример #3
0
        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);
        }
        }     // 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);
            }
        }
        private void CheckPemission(string userID)
        {
            MainSecurity ms = new MainSecurity();

            if (userID.Trim().ToLower() != Common.Const.TONG_BIEN_TAP)
            {
                Response.Redirect("users/" + Const.OBJECT_ERROR + ".aspx?message=" + Const.Message_BanKhongCoQuyen);
            }
        }
 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;
     }
 }
Пример #7
0
        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
            }
        }
Пример #8
0
 protected void lstCat_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lstRoles.SelectedIndex >= 0)
     {
         //string userid = Request.Params.Get("id");
         string       userid = Session["id"] != null ? Session["id"].ToString() : "";
         MainSecurity objscu = new MainSecurity();
         lstPer.DataSource     = objscu.GetPermissionAsTable(userid, 1, Int32.Parse(lstRoles.SelectedValue), Int32.Parse(lstCat.SelectedValue));
         lstPer.DataTextField  = "Permission_Name";
         lstPer.DataValueField = "Permission_ID";
         lstPer.DataBind();
     }
 }
Пример #9
0
        protected void Application_AuthenticateRequest(Object sender, EventArgs e)
        {
            if (Request.IsAuthenticated)
            {
                string[]     roles  = null;
                MainSecurity objscu = new MainSecurity();
                roles = objscu.GetRoleSymbol(HttpContext.Current.User.Identity.Name, DFISYS.API.Config.CurrentChannel);

                //ChannelUsers objUser = new ChannelUsers();
                //string[] roles = objUser.getRoles(HttpContext.Current.User.Identity.Name);//UserManagement.GetRoles(HttpContext.Current.User.Identity.Name);
                HttpContext.Current.User = new GenericPrincipal(HttpContext.Current.User.Identity, roles);
            }
        }
Пример #10
0
        protected void lstRoles_SelectedIndexChanged(object sender, EventArgs e)
        {
            //string userid=Request.Params.Get("id");
            string       userid = Session["id"] != null ? Session["id"].ToString() : "";
            MainSecurity objscu = new MainSecurity();

            //lay thong tin ve chuyen muc cua thang hien tai
            lstCat.DataTextField  = "Cat_Name";
            lstCat.DataValueField = "Cat_ID";
            lstCat.DataSource     = objscu.GetCategoryByRoleAsTable(userid, Int32.Parse(lstRoles.SelectedValue));
            lstCat.DataBind();
            //lay thong tin ve toan bo quyen
            lstPer.DataSource     = objscu.GetPermissionAsTable(userid, 1, -1);
            lstPer.DataTextField  = "Permission_Name";
            lstPer.DataValueField = "Permission_ID";
            lstPer.DataBind();
        }
Пример #11
0
 private void LoadChannel(string userID)
 {
     ddlChannel.DataTextField  = "Channel_Name";
     ddlChannel.DataValueField = "Channel_ID";
     //nếu là admin kênh thì load kênh của admin đó có
     if (userID == Const.Global_Admin || userID == Const.TONG_BIEN_TAP)
     {
         using (MainDB db = new MainDB()) {
             ddlChannel.DataSource = db.ChannelCollection.GetAllAsDataTable();
         }
     }
     else // nếu không phải admin kênh , load toàn bộ kênh
     {
         MainSecurity ms = new MainSecurity();
         ddlChannel.DataSource = ms.GetChannelAsTable(userID);
     }
     ddlChannel.DataBind();
 }
Пример #12
0
        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;
                }
            }
        }
Пример #13
0
        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);
        }
Пример #14
0
        private void LoadLtsBox()
        {
            //string userID = Request.Params.Get("id");
            string userID = Session["id"] != null ? Session["id"].ToString() : "";

            //khoi tao bien secu de lay toan bo roles cua thang hien tai
            lstRoles.Items.Clear();
            lstCat.Items.Clear();
            lstPer.Items.Clear();

            MainSecurity objscu = new MainSecurity();
            DataTable    dt     = objscu.GetRoleAsTableNoCache(userID, 1);

            if (dt.Rows.Count > 0)
            {
                lstRoles.DataSource     = dt;
                lstRoles.DataTextField  = "Role_Name";
                lstRoles.DataValueField = "Role_ID";
                lstRoles.DataBind();
            }

            //lay thong tin ve chuyen muc cua thang hien tai
            dt = objscu.getParentCategoryAssigned(userID, 1);
            if (dt.Rows.Count > 0)
            {
                lstCat.DataTextField  = "Cat_Name";
                lstCat.DataValueField = "Cat_ID";
                lstCat.DataSource     = dt;
                lstCat.DataBind();
            }

            //lay thong tin ve toan bo quyen
            dt = objscu.GetPermissionAsTable(userID, 1, -1);
            if (dt.Rows.Count > 0)
            {
                lstPer.DataSource     = dt;
                lstPer.DataTextField  = "Permission_Name";
                lstPer.DataValueField = "Permission_ID";
                lstPer.DataBind();
            }
        }
Пример #15
0
        private void LoadChannel()
        {
            ddlChannel.DataTextField  = "Channel_Name";
            ddlChannel.DataValueField = "Channel_ID";
            MainSecurity ms     = new MainSecurity();
            string       userID = ViewState["userid"].ToString();

            //nếu là admin global hoặc tổng biên tập
            if (userID == Const.Global_Admin || userID == Const.TONG_BIEN_TAP)
            {
                using (MainDB db = new MainDB())
                {
                    ddlChannel.DataSource = db.ChannelCollection.GetAllAsDataTable();
                }
            }
            else
            {
                ddlChannel.DataSource = ms.GetChannelAsTable(ViewState["userid"].ToString());
            }
            ddlChannel.DataBind();
        }
Пример #16
0
        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;
            }
        }
Пример #17
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)
        {
            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("");
            }
        }
Пример #19
0
        /// <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;
        }
        private void BindNewsEdit(long _news_id)
        {
            NewsRow      objNewsRow = NewsEditHelper.GetNewsInfo_NewsExtension(_news_id, false);
            MainSecurity objSercu   = new MainSecurity();
            Permission   objPer     = objSercu.GetPermission(Page.User.Identity.Name);

            if (objPer.isXuat_Ban_Bai)
            {
                //Kiểm tra nếu có quyền xuất bản thì sẽ hiện dầy đủ thông tin
                btnPublish.Visible = true;
                // pnControl.Visible = true;
            }
            else
            {
                btnPublish.Visible = false;
            }
            if (objNewsRow != null)
            {
                if (!objPer.isXuat_Ban_Bai && Page.User.Identity.Name.Trim().ToLower() != objNewsRow.News_Author.Trim().ToLower())
                {
                    throw new SecurityException("Bạn không có quyền truy cập vào trang này");
                    return;
                }



                ltrXuatBan.Text      = "Bài viết do \"" + objNewsRow.News_Approver.ToUpper() + "\" xuất bản lúc " + objNewsRow.News_PublishDate.ToString("dd/MM/yyyy hh:mm");
                lstCat.SelectedValue = objNewsRow.Cat_ID.ToString();
                txtTitle.Text        = objNewsRow.News_Title != null ? objNewsRow.News_Title : "";
                txtSubTitle.Text     = objNewsRow.News_Subtitle != null ? objNewsRow.News_Subtitle : "";
                txtSource.Text       = objNewsRow.News_Source != null ? objNewsRow.News_Source : "";
                txtInit.Text         = objNewsRow.News_InitialContent != null?NewsEditHelper.ReplaceImageSrcToEmoticon(objNewsRow.News_InitialContent) : "";

                txtInit.Text = txtInit.Text.Replace("<br/>", System.Environment.NewLine);
                if (Request.QueryString["redirect"] == null)
                {
                    NewsContent.Text       = objNewsRow.News_Content != null ? objNewsRow.News_Content : "";
                    Session["NewsContent"] = NewsContent.Text;
                }
                else
                {
                    NewsContent.Text = Session["NewsContent"].ToString();
                }
                chkIsFocus.Checked     = objNewsRow.IsNews_isFocusNull != true ? objNewsRow.News_isFocus : false;
                cboIsHot.SelectedValue = objNewsRow.IsNews_ModeNull != true?objNewsRow.News_Mode.ToString() : "0";

                hdRelatNews.Value      = objNewsRow.News_Relation != null ? objNewsRow.News_Relation : "";
                chkShowComment.Checked = objNewsRow.IsisCommentNull != true ? objNewsRow.isComment : false; //Cho phép hiện ảnh hay ko?
                chkShowRate.Checked    = objNewsRow.IsisUserRateNull != true ? objNewsRow.isUserRate : false;
                txtSelectedFile.Text   = objNewsRow.News_Image != null ? objNewsRow.News_Image : "";
                txtImageTitle.Text     = objNewsRow.News_ImageNote != null ? objNewsRow.News_ImageNote : "";
                txtIcon.Text           = objNewsRow.Icon != null ? objNewsRow.Icon : "";
                txtMaCP.Text           = objNewsRow.Extension1 != null ? objNewsRow.Extension1 : "";
                txtExtension2.Text     = objNewsRow.Extension2 != null ? objNewsRow.Extension2 : "";
                txtSourceLink.Text     = objNewsRow.Extension3 != null ? objNewsRow.Extension3 : "";


                ddlAuthor.SelectedValue = objNewsRow.IsExtension4Null != true?objNewsRow.Extension4.ToString() : "0";

                if (objNewsRow.Template != 0)
                {
                    ddlProvinces.SelectedValue = objNewsRow.Template.ToString();
                }

                if (objNewsRow.News_OtherCat != null)
                {
                    string[] strOthers = objNewsRow.News_OtherCat.Split(",".ToCharArray());
                    for (int i = 0; i < lstOtherCat.Items.Count; i++)
                    {
                        foreach (string strItem in strOthers)
                        {
                            if (strItem == lstOtherCat.Items[i].Value)
                            {
                                lstOtherCat.Items[i].Selected = true;
                                break;
                            }
                        }
                    }
                }

                if (!objNewsRow.IsNews_PublishDateNull)
                {
                    SetValueForCombo(cboMonth, objNewsRow.News_PublishDate.Month.ToString());
                    SetValueForCombo(cboDay, objNewsRow.News_PublishDate.Day.ToString());
                    SetValueForCombo(cboYear, objNewsRow.News_PublishDate.Year.ToString());
                    SetValueForCombo(cboSercond, objNewsRow.News_PublishDate.Second.ToString());
                    SetValueForCombo(cboMinute, objNewsRow.News_PublishDate.Minute.ToString());
                    SetValueForCombo(cboHour, objNewsRow.News_PublishDate.Hour.ToString());
                }
                else
                {
                    SetValueForCombo(cboMonth, "0");
                    SetValueForCombo(cboDay, "0");
                    SetValueForCombo(cboYear, "2000");
                    SetValueForCombo(cboSercond, "-1");
                    SetValueForCombo(cboMinute, "-1");
                    SetValueForCombo(cboHour, "-1");
                }

                if (!IsPostBack)
                {
                    hdMedia.Value = DFISYS.BO.Editoral.NewsMedia.NewsMediaHelper.Get_ObjectId_By_NewsId(_news_id);
                    DataTable dtThread = ThreadHelper.SelectThreadByNewsID(_news_id);
                    if (dtThread != null && dtThread.Rows.Count > 0)
                    {
                        hidLuongSuKien.Value = dtThread.Rows[0]["Thread_ID"].ToString();
                    }
                }


                //Load data to Combobox Tin lien quan;
                string str;
                if (hdRelatNews.Value.TrimEnd(',') != "")
                {
                    str = NewsEditHelper.Get_Media_By_ListsId("News_ID", "News_Title", "News", hdRelatNews.Value);
                    BindToDropdown(cboNews, str);
                }


                string strThread;
                if (hidLuongSuKien.Value.TrimEnd(',') != "")
                {
                    strThread = NewsEditHelper.Get_Media_By_ListsId("Thread_ID", "Title", "NewsThread", hidLuongSuKien.Value);
                    BindToDropdown(lstThread, strThread);

                    string[] arrThread = hidLuongSuKien.Value.Split(',');
                    if (arrThread != null && arrThread.Length > 0)
                    {
                        for (int i = 0; i < cblTags.Items.Count; i++)
                        {
                            foreach (string strItem in arrThread)
                            {
                                if (strItem == cblTags.Items[i].Value)
                                {
                                    cblTags.Items[i].Selected = true;
                                    break;
                                }
                            }
                        }
                    }
                }
                if (hdMedia.Value.TrimEnd(',').Length > 0)
                {
                    str = NewsEditHelper.Get_Media_By_ListsId("Object_ID", "Object_Url", "MediaObject", hdMedia.Value);
                    //BindToDropdown(cboMedia, str);
                }

                LoadAttachmentsType(_news_id);
            }
        }
Пример #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["cpmode"] != null)
            {
                string strMode = Request.QueryString["cpmode"];
                if (strMode.IndexOf(",") > 0)
                {
                    strMode = strMode.Substring(0, strMode.IndexOf(","));
                }

                Control ctrNewslist = null;

                // user cpMode to get path of usercontrol from xml config
                XmlDocument doc  = MenuCommon.getXML();
                XmlNode     node = doc.SelectSingleNode("//row[Cpmode='" + strMode + "']");
                if (node != null)
                {
                    XmlNode path = node.SelectSingleNode("path");
                    bool    ischeckpermission = bool.Parse(node.SelectSingleNode("../../@checkpermission").InnerText);

                    if (path != null)
                    {
                        if (ischeckpermission)
                        {
                            XmlNode permissionId = node.SelectSingleNode("Permission_ID");
                            // check permission in database
                            MainSecurity mainSecurity   = new MainSecurity();
                            DataTable    tblPermissions = mainSecurity.GetPermissionAsTable(HttpContext.Current.User.Identity.Name);
                            if (tblPermissions.Select("Permission_ID=" + permissionId.InnerText).Length == 1)
                            {
                                try
                                {
                                    ctrNewslist = LoadControl(path.InnerText);
                                    plcMain.Controls.Add(ctrNewslist);
                                }
                                catch (SecurityException sEx)
                                {
                                    plcMain.Controls.Clear();
                                    ctrNewslist = LoadControl("Statistic/MsgPermission.ascx");
                                    plcMain.Controls.Add(ctrNewslist);
                                }
                            }
                            else
                            {
                                ctrNewslist = LoadControl("Statistic/MsgPermission.ascx");
                                plcMain.Controls.Add(ctrNewslist);
                            }
                        }
                        else
                        {
                            try
                            {
                                ctrNewslist = LoadControl(path.InnerText);
                                plcMain.Controls.Add(ctrNewslist);
                            }
                            catch { }
                        }
                    }
                }
                if (ctrNewslist == null)
                {
                    ctrNewslist = LoadControl("OnLoad/onload.ascx");
                    plcMain.Controls.Add(ctrNewslist);
                }
            }
        }
Пример #22
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;
                }
            }
        }
Пример #23
0
        // 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();
            }
        }
Пример #24
0
        /// <summary>
        /// Check whether current user can edit the news
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static bool isHasPermission(HttpContext context)
        {
            if (context.Request.QueryString["NewsRef"] == null || context.Request.QueryString["NewsRef"] == string.Empty)
            {
                return(true);
            }
            else
            {
                string cpMode = context.Request.QueryString["cpmode"];
                if (!string.IsNullOrEmpty(cpMode))
                {
                    if (cpMode.Contains(","))
                    {
                        cpMode = cpMode.Substring(cpMode.IndexOf(",") + 1);
                    }
                    cpMode = cpMode.ToLower();

                    long   newsId   = long.Parse(context.Request.QueryString["NewsRef"]);
                    string userName = context.User.Identity.Name;
                    if (!string.IsNullOrEmpty(userName) && newsId != 0)
                    {
                        MainSecurity objsecu = new MainSecurity();
                        //Role objrole = objsecu.GetRole(context.User.Identity.Name);

                        NewsRow newsRow = NewsEditHelper.GetNewsInfo_News(newsId, false);
                        if (newsRow != null)
                        {
                            Permission permission = objsecu.GetPermission(userName);
                            MainDB     db         = new MainDB();
                            bool       toReturn   = false;
                            switch (cpMode)
                            {
                            case "templist":
                                toReturn = newsRow.News_Status == (byte)NewsStatus.LuuTam &&
                                           db.StoredProcedures.News_isLastAccessUser(newsId, userName);
                                break;

                            case "editwaitlist":
                                toReturn = newsRow.News_Status == (byte)NewsStatus.ChoBienTap &&
                                           permission.isBien_Tap_Bai &&
                                           db.StoredProcedures.News_isHasPermissionEdit(newsId, CategoryHelper.GetCatIDByUser());
                                break;

                            case "editinglist":
                                toReturn = newsRow.News_Status == (byte)NewsStatus.NhanBienTap &&
                                           permission.isBien_Tap_Bai &&
                                           db.StoredProcedures.News_isLastAccessUser(newsId, userName);
                                break;

                            case "approvalwaitlist":
                                toReturn = newsRow.News_Status == (byte)NewsStatus.ChoDuyet && permission.isDuyet_Bai &&
                                           db.StoredProcedures.News_isHasPermissionEdit(newsId, CategoryHelper.GetCatIDByUser());
                                break;

                            case "approvalwaitspeciallist":
                                toReturn = newsRow.News_Status == (byte)NewsStatus.ChoDuyet && permission.isDuyet_Bai &&
                                           db.StoredProcedures.News_isHasPermissionEdit(newsId, CategoryHelper.GetCatIDByUser());
                                break;

                            case "approvinglist":
                                toReturn = newsRow.News_Status == (byte)NewsStatus.NhanDuyet && permission.isDuyet_Bai &&
                                           db.StoredProcedures.News_isLastAccessUser(newsId, userName);
                                break;

                            case "publishedlist":
                                toReturn = newsRow.News_Status == (byte)NewsStatus.XuatBan && permission.isXuat_Ban_Bai &&
                                           db.StoredProcedures.News_isHasPermissionEdit(newsId, CategoryHelper.GetCatIDByUser());
                                break;

                            case "removedlist":
                                toReturn = newsRow.News_Status == (byte)NewsStatus.GoBo && permission.isXuat_Ban_Bai &&
                                           db.StoredProcedures.News_isHasPermissionEdit(newsId, CategoryHelper.GetCatIDByUser());
                                break;

                            case "backlist":
                                toReturn = newsRow.News_Status == (byte)NewsStatus.TraLai &&
                                           db.StoredProcedures.News_isLastAccessUser(newsId, userName);
                                break;

                            case "dellist":
                                toReturn = newsRow.News_Status == (byte)NewsStatus.XoaTam &&
                                           db.StoredProcedures.News_isLastAccessUser(newsId, userName);
                                break;
                            }
                            return(toReturn);
                        }
                    }
                }
            }
            return(false);
        }
Пример #25
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);
        }
Пример #26
0
 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);
 }
Пример #27
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";
                    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 "templist":
                    ltrLabel.Text = "Danh sách bài viết lưu tạm";
                    break;

                case "sendlist":
                    ltrLabel.Text      = "Danh sách bài viết đã gửi chờ biên tập";
                    LinkDelete.Visible = false;
                    break;

                case "sendapprovallist":
                    ltrLabel.Text      = "Danh sách bài viết đã gửi chờ duyệt";
                    LinkDelete.Visible = false;

                    break;

                case "dellist":
                    ltrLabel.Text      = "Danh sách bài viết xóa tạm";
                    LinkDelete.Visible = true;

                    break;

                case "editwaitlist":
                    ltrLabel.Text = "Danh sách bài viết chờ biên tập";

                    break;

                case "editinglist":
                    ltrLabel.Text = "Danh sách bài viết nhận biên tập";

                    break;

                case "approvinglist":
                    ltrLabel.Text = "Danh sách bài viết nhận duyệt";


                    break;

                case "approvalwaitlist":
                    ltrLabel.Text = "Danh sách bài viết chờ duyệt";



                    break;

                case "publishedlist":
                    ltrLabel.Text = "Danh sách bài viết đã xuất bản";
                    grdListNews.Columns[2].Visible = true;

                    // LinkDelete.Visible = false;

                    break;

                //voi danh sach bai tra lai.
                case "backlist":
                    ltrLabel.Text = "Danh sách bài viết trả lại";
                    break;

                //voi danh sach bai tra lai.
                case "removedlist":
                    ltrLabel.Text = "Danh sách bài viết đã gỡ bỏ";
                    break;

                case "mypublished":
                    LinkDelete.Visible = false;
                    break;

                default:
                    //xem quyen cua thang dang set

                    break;
                }
            }
        }
Пример #28
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 "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();
        }
Пример #29
0
        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;
                }
            }
        }