コード例 #1
0
        /// <summary>
        /// 更新时初始化权限
        /// </summary>
        /// <param name="ModuleID"></param>
        public void BindPermissionUpdate(int ModuleID)
        {
            #region 模块数据绑定

            Entity.BASE_MODULE model = new Entity.BASE_MODULE();
            model                = bll.GetModuleModel(ModuleID);
            M_ID.Text            = model.ModuleID.ToString();
            txt_MT.SelectedValue = model.ModuleTypeID.ToString();
            txt_name.Text        = model.ModuleName;
            txt_tag.Text         = model.ModuleTag;
            txt_url.Text         = model.ModuleURL;
            if (model.ModuleDisabled)
            {
                txt_state.SelectedIndex = 0;
            }
            else
            {
                txt_state.SelectedIndex = 1;
            }

            txt_order.Text       = model.ModuleOrder.ToString();
            txt_Description.Text = model.ModuleDescription;

            if (model.IsMenu)
            {
                IsMenu.SelectedIndex = 0;
            }
            else
            {
                IsMenu.SelectedIndex = 1;
            }

            #endregion

            #region 权限数据绑定

            StringBuilder strState  = new StringBuilder(); //状态
            StringBuilder strTag    = new StringBuilder(); //标识
            StringBuilder strVerify = new StringBuilder(); //对比状态

            BLL.BASE_AUTHORITYDIR Abll = new BLL.BASE_AUTHORITYDIR();
            DataSet MALDS = bll.GetAuthorityList(ModuleID);
            DataSet ds    = Abll.GetAuthorityList("", "order by AuthorityOrder asc");

            int rcount = ds.Tables[0].Rows.Count;
            AuthorityNum.Text = rcount.ToString();
            if (rcount == 0)
            {
                divstate.InnerHtml = "暂无记录";
            }
            else
            {
                strVerify.Append("<input type=\"hidden\" name=\"verifystate\" id=\"verifystate\" value=\"");
                strState.Append("<table width=\"340\" border=\"0\" cellpadding=\"0\" cellspacing=\"2\">");
                for (int i = 0; i < rcount; i++)
                {
                    bool v = false;
                    for (int k = 0; k < MALDS.Tables[0].Rows.Count; k++)
                    {
                        if (MALDS.Tables[0].Rows[k]["AuthorityTag"].ToString() == ds.Tables[0].Rows[i]["AuthorityTag"].ToString())
                        {
                            v = true;
                            break;
                        }
                    }
                    if ((i + 1) % 2 != 0)
                    {
                        #region 左边
                        if (v)//是否为可以使用的权限
                        {
                            strState.Append("<tr><td width=\"50\"><span class=\"RoleTitle\">" + ds.Tables[0].Rows[i]["AuthorityName"].ToString()
                                            + "</span></td><td width=\"100\"><table id=\"Alist" + i.ToString()
                                            + "\" border=\"0\"><tr><td><input id=\"Alist" + i.ToString()
                                            + "_0\" type=\"radio\" name=\"Alist" + i.ToString() + "\" value=\"1\" checked=\"checked\" />"
                                            + "<label for=\"Alist" + i.ToString() + "_0\">允许</label></td><td>"
                                            + "<input id=\"Alist" + i.ToString() + "_1\" type=\"radio\" name=\"Alist" + i.ToString() + "\" value=\"0\" />"
                                            + "<label for=\"Alist" + i.ToString() + "_1\">拒绝</label></td></tr></table></td>");
                            strVerify.Append("1,");
                        }
                        else
                        {
                            strState.Append("<tr><td width=\"50\"><span class=\"RoleTitle\">" + ds.Tables[0].Rows[i]["AuthorityName"].ToString()
                                            + "</span></td><td width=\"100\"><table id=\"Alist" + i.ToString()
                                            + "\" border=\"0\"><tr><td><input id=\"Alist" + i.ToString()
                                            + "_0\" type=\"radio\" name=\"Alist" + i.ToString() + "\" value=\"1\" />"
                                            + "<label for=\"Alist" + i.ToString() + "_0\">允许</label></td><td>"
                                            + "<input id=\"Alist" + i.ToString() + "_1\" type=\"radio\" name=\"Alist" + i.ToString() + "\" value=\"0\" checked=\"checked\" />"
                                            + "<label for=\"Alist" + i.ToString() + "_1\">拒绝</label></td></tr></table></td>");
                            strVerify.Append("0,");
                        }
                        #endregion
                    }
                    else
                    {
                        #region 右边
                        if (v)//是否为可以使用的权限
                        {
                            strState.Append("<td width=\"50\"><span class=\"RoleTitle\">" + ds.Tables[0].Rows[i]["AuthorityName"].ToString()
                                            + "</span></td><td width=\"100\"><table id=\"Alist" + i.ToString()
                                            + "\" border=\"0\"><tr><td><input id=\"Alist" + i.ToString()
                                            + "_0\" type=\"radio\" name=\"Alist" + i.ToString() + "\" value=\"1\" checked=\"checked\" />"
                                            + "<label for=\"Alist" + i.ToString() + "_0\">允许</label></td><td>"
                                            + "<input id=\"Alist" + i.ToString() + "_1\" type=\"radio\" name=\"Alist" + i.ToString() + "\" value=\"0\" />"
                                            + "<label for=\"Alist" + i.ToString() + "_1\">拒绝</label></td></tr></table></td></tr>");
                            strVerify.Append("1,");
                        }
                        else
                        {
                            strState.Append("<td width=\"50\"><span class=\"RoleTitle\">" + ds.Tables[0].Rows[i]["AuthorityName"].ToString()
                                            + "</span></td><td width=\"100\"><table id=\"Alist" + i.ToString()
                                            + "\" border=\"0\"><tr><td><input id=\"Alist" + i.ToString()
                                            + "_0\" type=\"radio\" name=\"Alist" + i.ToString() + "\" value=\"1\" />"
                                            + "<label for=\"Alist" + i.ToString() + "_0\">允许</label></td><td>"
                                            + "<input id=\"Alist" + i.ToString() + "_1\" type=\"radio\" name=\"Alist" + i.ToString() + "\" value=\"0\" checked=\"checked\" />"
                                            + "<label for=\"Alist" + i.ToString() + "_1\">拒绝</label></td></tr></table></td></tr>");
                            strVerify.Append("0,");
                        }
                        #endregion
                    }
                    //写入标识
                    strTag.Append("<input type=\"hidden\" name=\"Atag" + i.ToString() + "\" id=\"Atag" + i.ToString() + "\" value=\"" + ds.Tables[0].Rows[i]["AuthorityTag"] + "\" />");
                }

                strVerify.Append("\" />");

                if ((rcount) % 2 == 0)
                {
                    strState.Append("</table>");
                }
                else
                {
                    strState.Append("<td width=\"50\">&nbsp;</td><td width=\"100\">&nbsp;</td></tr></table>");
                }

                divstate.InnerHtml = strState.ToString() + strTag.ToString() + strVerify.ToString();
            }
            #endregion
        }
コード例 #2
0
        /// <summary>
        /// 模块分类数据绑定
        /// </summary>
        protected void ModuleView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                BLL.BASE_AUTHORITYDIR AD        = new BLL.BASE_AUTHORITYDIR();
                BLL.BASE_MODULE       Modulebll = new BLL.BASE_MODULE();
                BLL.BASE_ROLE         Rolebll   = new BLL.BASE_ROLE();

                CheckBoxList AuthorityList = (CheckBoxList)e.Row.FindControl("AuthorityList");
                Label        lab_ID        = (Label)e.Row.FindControl("lab_ID");
                Label        lab_Verify    = (Label)e.Row.FindControl("lab_Verify");

                DataSet ds    = AD.GetAuthorityList("", "order by AuthorityOrder asc");
                DataSet MALDS = Modulebll.GetAuthorityList(int.Parse(lab_ID.Text));
                DataSet RALDS = Rolebll.GetRoleAuthorityList(int.Parse(Rid.Text), int.Parse(lab_ID.Text));

                int n = ds.Tables[0].Rows.Count;//系统权限个数

                string[] vstate = new string[n];

                //获取系统配置的权限列表,如果模块没有该权限,则禁用该权限
                for (int i = 0; i < n; i++)
                {
                    AuthorityList.Items.Add(new ListItem(ds.Tables[0].Rows[i]["AuthorityName"].ToString(), ds.Tables[0].Rows[i]["AuthorityTag"].ToString()));
                    AuthorityList.Items[i].Enabled = false;
                    for (int k = 0; k < MALDS.Tables[0].Rows.Count; k++)
                    {
                        if (ds.Tables[0].Rows[i]["AuthorityTag"].ToString() == MALDS.Tables[0].Rows[k]["AuthorityTag"].ToString())
                        {
                            AuthorityList.Items[i].Enabled = true;
                            break;
                        }
                    }
                    vstate[i] = "0";//初始状态数组;
                }
                AuthorityList.DataBind();

                //将模块权限付值
                for (int j = 0; j < RALDS.Tables[0].Rows.Count; j++)
                {
                    for (int l = 0; l < AuthorityList.Items.Count; l++)
                    {
                        if (RALDS.Tables[0].Rows[j]["AuthorityTag"].ToString() == AuthorityList.Items[l].Value && RALDS.Tables[0].Rows[j]["Flag"].ToString().ToLower() == "true")
                        {
                            if (AuthorityList.Items[l].Enabled)
                            {
                                vstate[l] = "1";//权限存在
                            }
                            AuthorityList.Items[l].Selected = true;
                            break;
                        }
                    }
                }

                lab_Verify.Text = Smart.Utility.TypeParse.StringArrayToString(vstate, ',');
                if (!Code.UserHandle.ValidationHandle(Code.Tag.Grant))//是否有编辑权限
                {
                    ModuleView.Columns[2].Visible = false;
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// 添加时初始化权限
        /// </summary>
        public void BindPermission()
        {
            StringBuilder strState = new StringBuilder();
            StringBuilder strTag   = new StringBuilder();

            SmartPoms.BLL.BASE_AUTHORITYDIR Abll = new BLL.BASE_AUTHORITYDIR();
            DataSet ds = Abll.GetAuthorityList("", "order by AuthorityOrder asc");

            int rcount = ds.Tables[0].Rows.Count;

            AuthorityNum.Text = rcount.ToString();
            if (rcount == 0)
            {
                divstate.InnerHtml = "暂无记录";
            }
            else
            {
                strState.Append("<table width=\"340\" border=\"0\" cellpadding=\"0\" cellspacing=\"2\">");
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    if ((i + 1) % 2 != 0)
                    {
                        #region 左边
                        strState.Append("<tr><td width=\"50\"><span class=\"RoleTitle\">" + ds.Tables[0].Rows[i]["AuthorityName"].ToString()
                                        + "</span></td><td width=\"100\"><table id=\"Alist" + i.ToString()
                                        + "\" border=\"0\"><tr><td><input id=\"Alist" + i.ToString()
                                        + "_0\" type=\"radio\" name=\"Alist" + i.ToString() + "\" value=\"1\" />"
                                        + "<label for=\"Alist" + i.ToString() + "_0\">允许</label></td><td>"
                                        + "<input id=\"Alist" + i.ToString() + "_1\" type=\"radio\" name=\"Alist" + i.ToString() + "\" value=\"0\" checked=\"checked\" />"
                                        + "<label for=\"Alist" + i.ToString() + "_1\">拒绝</label></td></tr></table></td>");

                        #endregion
                    }
                    else
                    {
                        #region 左边
                        strState.Append("<td width=\"50\"><span class=\"RoleTitle\">" + ds.Tables[0].Rows[i]["AuthorityName"].ToString()
                                        + "</span></td><td width=\"100\"><table id=\"Alist" + i.ToString()
                                        + "\" border=\"0\"><tr><td><input id=\"Alist" + i.ToString()
                                        + "_0\" type=\"radio\" name=\"Alist" + i.ToString() + "\" value=\"1\" />"
                                        + "<label for=\"Alist" + i.ToString() + "_0\">允许</label></td><td>"
                                        + "<input id=\"Alist" + i.ToString() + "_1\" type=\"radio\" name=\"Alist" + i.ToString() + "\" value=\"0\" checked=\"checked\" />"
                                        + "<label for=\"Alist" + i.ToString() + "_1\">拒绝</label></td></tr></table></td></tr>");

                        #endregion
                    }

                    //写入标识
                    strTag.Append("<input type=\"hidden\" name=\"Atag" + i.ToString() + "\" id=\"Atag" + i.ToString() + "\" value=\"" + ds.Tables[0].Rows[i]["AuthorityTag"] + "\" />");
                }

                if ((rcount) % 2 == 0)
                {
                    strState.Append("</table>");
                }
                else
                {
                    strState.Append("<td width=\"50\">&nbsp;</td><td width=\"100\">&nbsp;</td></tr></table>");
                }

                divstate.InnerHtml = strState.ToString() + strTag.ToString();
            }
        }