Example #1
0
        /// <summary>
        /// 初始化模块权限
        /// </summary>
        /// <param name="ModuleTag">模块标识</param>
        public static void InitModule(string ModuleTag)
        {
            RedGlovePermission.BLL.RGP_Modules bll     = new RedGlovePermission.BLL.RGP_Modules();
            RedGlovePermission.BLL.RGP_Roles   Rolebll = new RedGlovePermission.BLL.RGP_Roles();
            //判断模块是否启用
            if (bll.IsModule(ModuleTag))
            {
                ArrayList Mlists = new ArrayList(); //模块权限
                ArrayList Ulists = new ArrayList(); //用户的模块权限

                //读取模块权限
                int     id    = bll.GetModuleID(ModuleTag);
                DataSet MALds = bll.GetAuthorityList(id);

                for (int i = 0; i < MALds.Tables[0].Rows.Count; i++)
                {
                    Mlists.Add(MALds.Tables[0].Rows[i]["AuthorityTag"].ToString());
                }
                SessionBox.RemoveModuleList();              //先清空Session中的列表
                SessionBox.CreateModuleList(Mlists);        //登记新的列表

                //读取用户角色拥有的该模块权限
                DataSet RALds = Rolebll.GetRoleAuthorityList(SessionBox.GetUserSession().RoleID, id);
                for (int i = 0; i < RALds.Tables[0].Rows.Count; i++)
                {
                    Ulists.Add(RALds.Tables[0].Rows[i]["AuthorityTag"].ToString());
                }
                SessionBox.RemoveAuthority();
                SessionBox.CreateAuthority(Ulists);
            }
            else
            {
                throw new Exception("此功能不存在");
            }
        }
Example #2
0
        /// <summary>
        /// 初始化模块权限
        /// </summary>
        /// <param name="ModuleTag">模块标识</param>
        public static void InitModule(string ModuleTag)
        {
            RedGlovePermission.BLL.RGP_Modules bll = new RedGlovePermission.BLL.RGP_Modules();
            RedGlovePermission.BLL.RGP_Roles Rolebll = new RedGlovePermission.BLL.RGP_Roles();
            //判断模块是否启用
            if (bll.IsModule(ModuleTag))
            {
                ArrayList Mlists = new ArrayList();//模块权限
                ArrayList Ulists = new ArrayList();//用户的模块权限

                //读取模块权限
                int id = bll.GetModuleID(ModuleTag);
                DataSet MALds = bll.GetAuthorityList(id);

                for (int i = 0; i < MALds.Tables[0].Rows.Count; i++)
                {
                    Mlists.Add(MALds.Tables[0].Rows[i]["AuthorityTag"].ToString());
                }
                SessionBox.RemoveModuleList();              //先清空Session中的列表
                SessionBox.CreateModuleList(Mlists);        //登记新的列表

                //读取用户角色拥有的该模块权限
                DataSet RALds = Rolebll.GetRoleAuthorityList(SessionBox.GetUserSession().RoleID, id);
                for (int i = 0; i < RALds.Tables[0].Rows.Count; i++)
                {
                    Ulists.Add(RALds.Tables[0].Rows[i]["AuthorityTag"].ToString());
                }
                SessionBox.RemoveAuthority();
                SessionBox.CreateAuthority(Ulists);
            }
            else
            {
                throw new Exception("此功能不存在");
            }
        }
Example #3
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, ',');
            }
        }
Example #4
0
 /// <summary>
 /// 获取模块权限列表
 /// </summary>
 protected void BindModules()
 {
     if (Rid.Text != "")
     {
         RedGlovePermission.BLL.RGP_Modules Mbll = new RedGlovePermission.BLL.RGP_Modules();
         DataSet ds = Mbll.GetModuleList("ModuleDisabled=1 and ModuleTypeID=" + ModuleTypeList.SelectedValue);
         ModuleView.DataSource = ds;
         ModuleView.DataBind();
     }
     else
     {
         ModuleView.DataSource = null;
         ModuleView.DataBind();
     }
 }
 /// <summary>
 /// 获取模块权限列表
 /// </summary>
 protected void BindModules()
 {
     if (Rid.Text != "")
     {
         RedGlovePermission.BLL.RGP_Modules Mbll = new RedGlovePermission.BLL.RGP_Modules();
         DataSet ds = Mbll.GetModuleList("ModuleDisabled=1 and ModuleTypeID=" + ModuleTypeList.SelectedValue);
         ModuleView.DataSource = ds;
         ModuleView.DataBind();
     }
     else
     {
         ModuleView.DataSource = null;
         ModuleView.DataBind();
     }
 }
Example #6
0
        /// <summary>
        /// 绑定分组数据
        /// </summary>
        protected void BindModuleType()
        {
            RedGlovePermission.BLL.RGP_Modules MTbll = new RedGlovePermission.BLL.RGP_Modules();
            DataSet ds = MTbll.GetModuleTypeList("");

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                string s = ds.Tables[0].Rows[i]["ModuleTypeName"].ToString();
                if (ResourceManager.GetString(s) != "")
                {
                    ModuleTypeList.Items.Add(new ListItem(ResourceManager.GetString(s), ds.Tables[0].Rows[i]["ModuleTypeID"].ToString()));
                }
                else
                {
                    ModuleTypeList.Items.Add(new ListItem(s, ds.Tables[0].Rows[i]["ModuleTypeID"].ToString()));
                }
            }
        }
Example #7
0
        /// <summary>
        /// 获取菜单数据
        /// </summary>
        private void LoadModuleTree()
        {
            //获取当前登录的会员信息。
            UserSession user = SessionBox.GetUserSession();
            RedGlovePermission.BLL.RGP_Modules bll = new RedGlovePermission.BLL.RGP_Modules();

            //获取所有顶层模块。
            DataSet ModuleType = bll.GetModuleTypeList("");

            //增加模块分类和模块。
            if (ModuleType.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dr in ModuleType.Tables[0].Rows)
                {
                    //添加顶级分类
                    string s = ResourceManager.GetString(dr["ModuleTypeName"].ToString());
                    if (s != null)
                    {
                        s = ResourceManager.GetString(dr["ModuleTypeName"].ToString());
                    }
                    else
                    {
                        s = dr["ModuleTypeName"].ToString();
                    }
                    TreeNode masterNode = new TreeNode(s);
                    MenuTreeView.Nodes.Add(masterNode);
                    masterNode.SelectAction = TreeNodeSelectAction.Expand;
                    masterNode.Expanded = false;
                    int i = 0;
                    //增加子模块分类
                    DataSet Module = bll.GetModuleList("ModuleTypeID=" + dr["ModuleTypeID"].ToString());
                    foreach (DataRow child_dr in Module.Tables[0].Rows)
                    {
                        if ((user.IsLimit == true
                            || ((child_dr["ModuleDisabled"].ToString().ToLower() == "true") || (child_dr["ModuleDisabled"].ToString().ToLower() == "1")
                            && UserHandle.ValidationModule(int.Parse(child_dr["ModuleID"].ToString()), RGP_Tag.Browse)))
                            && (child_dr["IsMenu"].ToString().ToLower() == "true" || child_dr["IsMenu"].ToString().ToLower() == "1"))
                        {
                            string childs = ResourceManager.GetString(child_dr["ModuleName"].ToString());
                            if (childs != null)
                            {
                                childs = ResourceManager.GetString(child_dr["ModuleName"].ToString());
                            }
                            else
                            {
                                childs = child_dr["ModuleName"].ToString();
                            }
                            TreeNode childNode = new TreeNode(childs);
                            childNode.Expanded = false;
                            childNode.NavigateUrl = child_dr["ModuleURL"].ToString();
                            childNode.Target = "modulePanel";
                            childNode.ToolTip = child_dr["ModuleDescription"].ToString();
                            masterNode.ChildNodes.Add(childNode);
                            i++;
                        }
                    }
                    //删除不必要的模块分类节点。
                    if (i == 0)
                    {
                        MenuTreeView.Nodes.Remove(masterNode);
                    }
                }

                MenuTreeView.CollapseImageToolTip = "";
                MenuTreeView.ExpandImageToolTip = "";
            }
        }
Example #8
0
        /// <summary>
        /// 获取菜单数据
        /// </summary>
        private void LoadModuleTree()
        {
            //获取当前登录的会员信息。
            UserSession user = SessionBox.GetUserSession();

            RedGlovePermission.BLL.RGP_Modules bll = new RedGlovePermission.BLL.RGP_Modules();

            //获取所有顶层模块。
            DataSet ModuleType = bll.GetModuleTypeList("");

            //增加模块分类和模块。
            if (ModuleType.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dr in ModuleType.Tables[0].Rows)
                {
                    //添加顶级分类
                    string s = ResourceManager.GetString(dr["ModuleTypeName"].ToString());
                    if (s != null)
                    {
                        s = ResourceManager.GetString(dr["ModuleTypeName"].ToString());
                    }
                    else
                    {
                        s = dr["ModuleTypeName"].ToString();
                    }
                    TreeNode masterNode = new TreeNode(s);
                    MenuTreeView.Nodes.Add(masterNode);
                    masterNode.SelectAction = TreeNodeSelectAction.Expand;
                    masterNode.Expanded     = false;
                    int i = 0;
                    //增加子模块分类
                    DataSet Module = bll.GetModuleList("ModuleTypeID=" + dr["ModuleTypeID"].ToString());
                    foreach (DataRow child_dr in Module.Tables[0].Rows)
                    {
                        if ((user.IsLimit == true ||
                             ((child_dr["ModuleDisabled"].ToString().ToLower() == "true") || (child_dr["ModuleDisabled"].ToString().ToLower() == "1") &&
                              UserHandle.ValidationModule(int.Parse(child_dr["ModuleID"].ToString()), RGP_Tag.Browse))) &&
                            (child_dr["IsMenu"].ToString().ToLower() == "true" || child_dr["IsMenu"].ToString().ToLower() == "1"))
                        {
                            string childs = ResourceManager.GetString(child_dr["ModuleName"].ToString());
                            if (childs != null)
                            {
                                childs = ResourceManager.GetString(child_dr["ModuleName"].ToString());
                            }
                            else
                            {
                                childs = child_dr["ModuleName"].ToString();
                            }
                            TreeNode childNode = new TreeNode(childs);
                            childNode.Expanded    = false;
                            childNode.NavigateUrl = child_dr["ModuleURL"].ToString();
                            childNode.Target      = "modulePanel";
                            childNode.ToolTip     = child_dr["ModuleDescription"].ToString();
                            masterNode.ChildNodes.Add(childNode);
                            i++;
                        }
                    }
                    //删除不必要的模块分类节点。
                    if (i == 0)
                    {
                        MenuTreeView.Nodes.Remove(masterNode);
                    }
                }

                MenuTreeView.CollapseImageToolTip = "";
                MenuTreeView.ExpandImageToolTip   = "";
            }
        }
        /// <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, ',');
            }
        }
        /// <summary>
        /// 绑定分组数据
        /// </summary>
        protected void BindModuleType()
        {
            RedGlovePermission.BLL.RGP_Modules MTbll = new RedGlovePermission.BLL.RGP_Modules();
            DataSet ds = MTbll.GetModuleTypeList("");

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                string s = ds.Tables[0].Rows[i]["ModuleTypeName"].ToString();
                if (ResourceManager.GetString(s) != "")
                {
                    ModuleTypeList.Items.Add(new ListItem(ResourceManager.GetString(s), ds.Tables[0].Rows[i]["ModuleTypeID"].ToString()));
                }
                else
                {
                    ModuleTypeList.Items.Add(new ListItem(s, ds.Tables[0].Rows[i]["ModuleTypeID"].ToString()));
                }
            }
        }