コード例 #1
0
        /// <summary>
        /// 模块分类数据绑定
        /// </summary>
        protected void ModuleView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                RedGlovePermission.BLL.RGP_AuthorityDir AD        = new RedGlovePermission.BLL.RGP_AuthorityDir();
                RedGlovePermission.BLL.RGP_Modules      Modulebll = new RedGlovePermission.BLL.RGP_Modules();
                RedGlovePermission.BLL.RGP_Roles        Rolebll   = new RedGlovePermission.BLL.RGP_Roles();

                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(ResourceManager.GetString(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)
                        {
                            if (AuthorityList.Items[l].Enabled)
                            {
                                vstate[l] = "1";//权限存在
                            }
                            AuthorityList.Items[l].Selected = true;
                            break;
                        }
                    }
                }

                lab_Verify.Text = RedGlovePermission.Lib.TypeParse.StringArrayToString(vstate, ',');
            }
        }
コード例 #2
0
ファイル: AuthorityPage.aspx.cs プロジェクト: guangxb/learn
        /// <summary>
        /// 将数据绑定到DataSet
        /// </summary>
        public void BindOrder()
        {
            DataSet ds = bll.GetAuthorityList("", "order by AuthorityOrder asc");

            if (ds.Tables[0].Rows.Count == 0)
            {
                GridViewMsg.InnerText = ResourceManager.GetString("Pub_Msg_norecord");
            }
            else
            {
                GridViewMsg.InnerText = ResourceManager.GetString("Pub_Lab_gy") + ds.Tables[0].Rows.Count + ResourceManager.GetString("Pub_Lab_tjl");
            }

            AuthorityLists.DataSource = ds;
            AuthorityLists.DataBind();
        }
コード例 #3
0
ファイル: ModulesPage.aspx.cs プロジェクト: guangxb/learn
        /// <summary>
        /// 更新时初始化权限
        /// </summary>
        /// <param name="ModuleID"></param>
        public void BindPermissionUpdate(int ModuleID)
        {
            #region 模块数据绑定

            RedGlovePermission.Model.RGP_Modules model = new RedGlovePermission.Model.RGP_Modules();
            model     = bll.GetModuleModel(ModuleID);
            M_ID.Text = model.ModuleID.ToString();
            ModuleType.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(); //对比状态

            RedGlovePermission.BLL.RGP_AuthorityDir Abll = new RedGlovePermission.BLL.RGP_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 = ResourceManager.GetString("Pub_Msg_norecord");
            }
            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\">" + ResourceManager.GetString(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\">" + ResourceManager.GetString("Pub_State_enabled") + "</label></td><td>"
                                            + "<input id=\"Alist" + i.ToString() + "_1\" type=\"radio\" name=\"Alist" + i.ToString() + "\" value=\"0\" />"
                                            + "<label for=\"Alist" + i.ToString() + "_1\">" + ResourceManager.GetString("Pub_State_disable") + "</label></td></tr></table></td>");
                            strVerify.Append("1,");
                        }
                        else
                        {
                            strState.Append("<tr><td width=\"50\"><span class=\"RoleTitle\">" + ResourceManager.GetString(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\">" + ResourceManager.GetString("Pub_State_enabled") + "</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\">" + ResourceManager.GetString("Pub_State_disable") + "</label></td></tr></table></td>");
                            strVerify.Append("0,");
                        }
                        #endregion
                    }
                    else
                    {
                        #region 右边
                        if (v)//是否为可以使用的权限
                        {
                            strState.Append("<td width=\"50\"><span class=\"RoleTitle\">" + ResourceManager.GetString(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\">" + ResourceManager.GetString("Pub_State_enabled") + "</label></td><td>"
                                            + "<input id=\"Alist" + i.ToString() + "_1\" type=\"radio\" name=\"Alist" + i.ToString() + "\" value=\"0\" />"
                                            + "<label for=\"Alist" + i.ToString() + "_1\">" + ResourceManager.GetString("Pub_State_disable") + "</label></td></tr></table></td></tr>");
                            strVerify.Append("1,");
                        }
                        else
                        {
                            strState.Append("<td width=\"50\"><span class=\"RoleTitle\">" + ResourceManager.GetString(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\">" + ResourceManager.GetString("Pub_State_enabled") + "</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\">" + ResourceManager.GetString("Pub_State_disable") + "</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
        }
コード例 #4
0
ファイル: ModulesPage.aspx.cs プロジェクト: guangxb/learn
        /// <summary>
        /// 添加时初始化权限
        /// </summary>
        public void BindPermission()
        {
            StringBuilder strState = new StringBuilder();
            StringBuilder strTag   = new StringBuilder();

            RedGlovePermission.BLL.RGP_AuthorityDir Abll = new RedGlovePermission.BLL.RGP_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 = ResourceManager.GetString("Pub_Msg_norecord");
            }
            else
            {
                strState.Append("<table width=\"200\" 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\">" + ResourceManager.GetString(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\">" + ResourceManager.GetString("Pub_State_enabled") + "</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\">" + ResourceManager.GetString("Pub_State_disable") + "</label></td></tr></table></td>");

                        #endregion
                    }
                    else
                    {
                        #region 左边
                        strState.Append("<td width=\"50\"><span class=\"RoleTitle\">" + ResourceManager.GetString(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\">" + ResourceManager.GetString("Pub_State_enabled") + "</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\">" + ResourceManager.GetString("Pub_State_disable") + "</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();
            }
        }
コード例 #5
0
        /// <summary>
        /// 更新时初始化权限
        /// </summary>
        /// <param name="ModuleID"></param>
        public void BindPermissionUpdate(int ModuleID)
        {
            #region 模块数据绑定

            RedGlovePermission.Model.RGP_Modules model = new RedGlovePermission.Model.RGP_Modules();
            model = bll.GetModuleModel(ModuleID);
            M_ID.Text = model.ModuleID.ToString();
            ModuleType.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();//对比状态            

            RedGlovePermission.BLL.RGP_AuthorityDir Abll = new RedGlovePermission.BLL.RGP_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 = ResourceManager.GetString("Pub_Msg_norecord");
            }
            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\">" + ResourceManager.GetString(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\">" + ResourceManager.GetString("Pub_State_enabled") + "</label></td><td>"
                                + "<input id=\"Alist" + i.ToString() + "_1\" type=\"radio\" name=\"Alist" + i.ToString() + "\" value=\"0\" />"
                                + "<label for=\"Alist" + i.ToString() + "_1\">" + ResourceManager.GetString("Pub_State_disable") + "</label></td></tr></table></td>");
                            strVerify.Append("1,");
                        }
                        else
                        {
                            strState.Append("<tr><td width=\"50\"><span class=\"RoleTitle\">" + ResourceManager.GetString(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\">" + ResourceManager.GetString("Pub_State_enabled") + "</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\">" + ResourceManager.GetString("Pub_State_disable") + "</label></td></tr></table></td>");
                            strVerify.Append("0,");
                        }
                        #endregion
                    }
                    else
                    {
                        #region 右边
                        if (v)//是否为可以使用的权限
                        {
                            strState.Append("<td width=\"50\"><span class=\"RoleTitle\">" + ResourceManager.GetString(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\">" + ResourceManager.GetString("Pub_State_enabled") + "</label></td><td>"
                                + "<input id=\"Alist" + i.ToString() + "_1\" type=\"radio\" name=\"Alist" + i.ToString() + "\" value=\"0\" />"
                                + "<label for=\"Alist" + i.ToString() + "_1\">" + ResourceManager.GetString("Pub_State_disable") + "</label></td></tr></table></td></tr>");
                            strVerify.Append("1,");
                        }
                        else
                        {
                            strState.Append("<td width=\"50\"><span class=\"RoleTitle\">" + ResourceManager.GetString(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\">" + ResourceManager.GetString("Pub_State_enabled") + "</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\">" + ResourceManager.GetString("Pub_State_disable") + "</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
        }
コード例 #6
0
        /// <summary>
        /// 添加时初始化权限
        /// </summary>
        public void BindPermission()
        {
            StringBuilder strState = new StringBuilder();
            StringBuilder strTag = new StringBuilder();            

            RedGlovePermission.BLL.RGP_AuthorityDir Abll = new RedGlovePermission.BLL.RGP_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 = ResourceManager.GetString("Pub_Msg_norecord");
            }
            else
            {
                strState.Append("<table width=\"200\" 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\">" + ResourceManager.GetString(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\">" + ResourceManager.GetString("Pub_State_enabled") + "</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\">" + ResourceManager.GetString("Pub_State_disable") + "</label></td></tr></table></td>");
                        
                        #endregion
                    }
                    else
                    {
                        #region 左边
                        strState.Append("<td width=\"50\"><span class=\"RoleTitle\">" + ResourceManager.GetString(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\">" + ResourceManager.GetString("Pub_State_enabled") + "</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\">" + ResourceManager.GetString("Pub_State_disable") + "</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();
            }
        }
コード例 #7
0
        /// <summary>
        /// 模块分类数据绑定
        /// </summary>
        protected void ModuleView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                RedGlovePermission.BLL.RGP_AuthorityDir AD = new RedGlovePermission.BLL.RGP_AuthorityDir();
                RedGlovePermission.BLL.RGP_Modules Modulebll = new RedGlovePermission.BLL.RGP_Modules();
                RedGlovePermission.BLL.RGP_Roles Rolebll = new RedGlovePermission.BLL.RGP_Roles();

                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(ResourceManager.GetString(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)
                        {
                            if (AuthorityList.Items[l].Enabled)
                                vstate[l] = "1";//权限存在
                                AuthorityList.Items[l].Selected = true;
                            break;
                        }
                    }
                }

                lab_Verify.Text = RedGlovePermission.Lib.TypeParse.StringArrayToString(vstate, ',');
            }
        }