Ejemplo n.º 1
0
        protected void rptCategoryTop_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater rptCatalogChild = (Repeater)e.Item.FindControl("rptCategoryChild");


                DataRowView rowv = (DataRowView)e.Item.DataItem;
                //提取分类ID
                string CategorieId = Convert.ToString(rowv["CatalogID"]);
                //根据分类ID查询该分类下的产品,并绑定产品Repeater
                rptCatalogChild.DataSource = Catalog.GetCatalogTableByParentId(new Guid(CategorieId));
                rptCatalogChild.DataBind();

                HiddenField hf = (HiddenField)e.Item.FindControl("topCatId");
                hf.Value = CategorieId;



                Role role = new Role(new Guid(this.hiRoleId.Value));

                Guid            catId       = new Guid(CategorieId);
                ISecurityObject securityObj = new SecurityObject(catId, SecurityObjectType.Items);

                CheckBox       chb    = (CheckBox)e.Item.FindControl("funTopReadChk");
                OperatorMethod method = OperatorMethod.Deny;
                ObjectRule     rule   = new ObjectRule(securityObj, role, method);
                rule.CheckValidate();
                chb.Checked = rule.IsValidate;

                chb    = (CheckBox)e.Item.FindControl("funTopUpChk");
                method = OperatorMethod.Write;
                rule   = new ObjectRule(securityObj, role, method);
                rule.CheckValidate();
                chb.Checked = rule.IsValidate;

                chb    = (CheckBox)e.Item.FindControl("funTopEditChk");
                method = OperatorMethod.Modify;
                rule   = new ObjectRule(securityObj, role, method);
                rule.CheckValidate();
                chb.Checked = rule.IsValidate;

                chb    = (CheckBox)e.Item.FindControl("funTopDownChk");
                method = OperatorMethod.Download;
                rule   = new ObjectRule(securityObj, role, method);
                rule.CheckValidate();
                chb.Checked = rule.IsValidate;
            }
        }
Ejemplo n.º 2
0
        protected void rptCategoryChild_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DataRowView rowv        = (DataRowView)e.Item.DataItem;
                string      CategorieId = Convert.ToString(rowv["CatalogID"]);
                Role        role        = new Role(new Guid(this.hiRoleId.Value));

                HiddenField hf = (HiddenField)e.Item.FindControl("childCatId");
                hf.Value = CategorieId;

                Guid            catId       = new Guid(CategorieId);
                ISecurityObject securityObj = new SecurityObject(catId, SecurityObjectType.Items);

                CheckBox       chb    = (CheckBox)e.Item.FindControl("funChildReadChk");
                OperatorMethod method = OperatorMethod.Deny;
                ObjectRule     rule   = new ObjectRule(securityObj, role, method);
                rule.CheckValidate();
                chb.Checked = rule.IsValidate;

                chb    = (CheckBox)e.Item.FindControl("funChildUpChk");
                method = OperatorMethod.Write;
                rule   = new ObjectRule(securityObj, role, method);
                rule.CheckValidate();
                chb.Checked = rule.IsValidate;

                chb    = (CheckBox)e.Item.FindControl("funChildEditChk");
                method = OperatorMethod.Modify;
                rule   = new ObjectRule(securityObj, role, method);
                rule.CheckValidate();
                chb.Checked = rule.IsValidate;

                chb    = (CheckBox)e.Item.FindControl("funChildDownChk");
                method = OperatorMethod.Download;
                rule   = new ObjectRule(securityObj, role, method);
                rule.CheckValidate();
                chb.Checked = rule.IsValidate;
            }
        }