Esempio n. 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("此功能不存在");
            }
        }
Esempio n. 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("此功能不存在");
            }
        }
 /// <summary>
 /// 获取角色列表
 /// </summary>
 protected void BindRoles()
 {
     RedGlovePermission.BLL.RGP_Roles Rolsebll = new RedGlovePermission.BLL.RGP_Roles();
     DataSet ds = Rolsebll.GetRoleList("RoleGroupID=" + GroupList.SelectedValue, "");
     RoleView.DataSource = ds;
     RoleView.DataBind();
 }
Esempio n. 4
0
        /// <summary>
        /// 获取角色列表
        /// </summary>
        protected void BindRoles()
        {
            RedGlovePermission.BLL.RGP_Roles Rolsebll = new RedGlovePermission.BLL.RGP_Roles();
            DataSet ds = Rolsebll.GetRoleList("RoleGroupID=" + GroupList.SelectedValue, "");

            RoleView.DataSource = ds;
            RoleView.DataBind();
        }
Esempio n. 5
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, ',');
            }
        }
Esempio n. 6
0
 /// <summary>
 /// 判断是否有模块访问权限
 /// </summary>
 /// <param name="ModuleID">模块ID</param>
 /// <param name="AuthorityTag">权限标识</param>
 /// <returns></returns>
 public static bool ValidationModule(int ModuleID, string AuthorityTag)
 {
     RedGlovePermission.BLL.RGP_Roles bll = new RedGlovePermission.BLL.RGP_Roles();
     RedGlovePermission.Model.RGP_RoleAuthorityList model = new RedGlovePermission.Model.RGP_RoleAuthorityList();
     model.UserID       = 0;
     model.RoleID       = SessionBox.GetUserSession().RoleID;
     model.ModuleID     = ModuleID;
     model.AuthorityTag = AuthorityTag;
     return(bll.RoleAuthorityExists(model));
 }
Esempio n. 7
0
        /// <summary>
        /// 保存所有修改的权限
        /// </summary>
        protected void btn_AllSave_Click(object sender, EventArgs e)
        {
            RedGlovePermission.BLL.RGP_Roles Rolebll = new RedGlovePermission.BLL.RGP_Roles();

            ArrayList list = new ArrayList();//建立事务列表

            for (int i = 0; i <= ModuleView.Rows.Count - 1; i++)
            {
                CheckBoxList cal        = (CheckBoxList)this.ModuleView.Rows[i].Cells[1].FindControl("AuthorityList");
                Label        lab_Verify = (Label)this.ModuleView.Rows[i].Cells[0].FindControl("lab_Verify");
                string[]     vstate     = lab_Verify.Text.Split(',');//获取原始状态

                for (int j = 0; j < cal.Items.Count; j++)
                {
                    if (cal.Items[j].Enabled)
                    {
                        if (cal.Items[j].Selected)
                        {
                            if (vstate[j] != "1")//检查数据有没有变化
                            {
                                string item = string.Empty;
                                item = item + Rid.Text + "|"
                                       + this.ModuleView.DataKeys[i].Values[0].ToString() + "|"
                                       + cal.Items[j].Value + "|1";//设置为1,加入权限
                                list.Add(item);
                            }
                        }
                        else
                        {
                            if (vstate[j] != "0")//检查数据有没有变化
                            {
                                string item = string.Empty;
                                item = item + Rid.Text + "|"
                                       + this.ModuleView.DataKeys[i].Values[0].ToString() + "|"
                                       + cal.Items[j].Value + "|0";//设置为0,删除删除
                                list.Add(item);
                            }
                        }
                    }
                }
            }

            if (Rolebll.UpdateRoleAuthority(list))
            {
                BindModules();
                ScriptManager.RegisterClientScriptBlock(CustomPanel1, this.GetType(), "MsgBox", "alert('设置成功!')", true);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(CustomPanel1, this.GetType(), "MsgBox", "alert('设置操作失败!')", true);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 更新设置
        /// </summary>
        protected void ModuleView_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            ArrayList list = new ArrayList();//建立事务列表

            RedGlovePermission.BLL.RGP_Roles Rolebll = new RedGlovePermission.BLL.RGP_Roles();
            CheckBoxList cal        = (CheckBoxList)this.ModuleView.Rows[e.NewSelectedIndex].Cells[1].FindControl("AuthorityList");
            Label        lab_Verify = (Label)this.ModuleView.Rows[e.NewSelectedIndex].Cells[0].FindControl("lab_Verify");

            string[] vstate = lab_Verify.Text.Split(',');//获取原始状态

            for (int i = 0; i < cal.Items.Count; i++)
            {
                if (cal.Items[i].Enabled)
                {
                    if (cal.Items[i].Selected)
                    {
                        if (vstate[i] != "1")//检查数据有没有变化
                        {
                            string item = string.Empty;
                            item = item + Rid.Text + "|"
                                   + this.ModuleView.DataKeys[e.NewSelectedIndex].Values[0].ToString() + "|"
                                   + cal.Items[i].Value + "|1";//设置为1,加入权限
                            list.Add(item);
                        }
                    }
                    else
                    {
                        if (vstate[i] != "0")//检查数据有没有变化
                        {
                            string item = string.Empty;
                            item = item + Rid.Text + "|"
                                   + this.ModuleView.DataKeys[e.NewSelectedIndex].Values[0].ToString() + "|"
                                   + cal.Items[i].Value + "|0";//设置为0,删除删除
                            list.Add(item);
                        }
                    }
                }
            }

            if (Rolebll.UpdateRoleAuthority(list))
            {
                BindModules();
                ScriptManager.RegisterClientScriptBlock(CustomPanel1, this.GetType(), "MsgBox", "alert('" + ResourceManager.GetString("Pub_Msg_update_true") + "')", true);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(CustomPanel1, this.GetType(), "MsgBox", "alert('" + ResourceManager.GetString("Pub_Msg_update_false") + "')", true);
            }
        }
Esempio n. 9
0
 /// <summary>
 /// 判断是否有模块访问权限
 /// </summary>
 /// <param name="ModuleID">模块ID</param>
 /// <param name="AuthorityTag">权限标识</param>
 /// <returns></returns>
 public static bool ValidationModule(int ModuleID, string AuthorityTag)
 {
     RedGlovePermission.BLL.RGP_Roles bll = new RedGlovePermission.BLL.RGP_Roles();
     RedGlovePermission.Model.RGP_RoleAuthorityList model= new RedGlovePermission.Model.RGP_RoleAuthorityList();
     model.UserID = 0;
     model.RoleID = SessionBox.GetUserSession().RoleID;
     model.ModuleID = ModuleID;
     model.AuthorityTag = AuthorityTag;
     return bll.RoleAuthorityExists(model);
 }
        /// <summary>
        /// 更新设置
        /// </summary>
        protected void ModuleView_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            ArrayList list = new ArrayList();//建立事务列表
            RedGlovePermission.BLL.RGP_Roles Rolebll = new RedGlovePermission.BLL.RGP_Roles();
            CheckBoxList cal = (CheckBoxList)this.ModuleView.Rows[e.NewSelectedIndex].Cells[1].FindControl("AuthorityList");
            Label lab_Verify = (Label)this.ModuleView.Rows[e.NewSelectedIndex].Cells[0].FindControl("lab_Verify");
            string[] vstate = lab_Verify.Text.Split(',');//获取原始状态

            for (int i = 0; i < cal.Items.Count; i++)
            {
                if (cal.Items[i].Enabled)
                {
                    if (cal.Items[i].Selected)
                    {
                        if (vstate[i] != "1")//检查数据有没有变化
                        {
                            string item = string.Empty;
                            item = item + Rid.Text + "|"
                                + this.ModuleView.DataKeys[e.NewSelectedIndex].Values[0].ToString() + "|"
                                + cal.Items[i].Value + "|1";//设置为1,加入权限
                            list.Add(item);
                        }
                    }
                    else
                    {
                        if (vstate[i] != "0")//检查数据有没有变化
                        {
                            string item = string.Empty;
                            item = item + Rid.Text + "|"
                                + this.ModuleView.DataKeys[e.NewSelectedIndex].Values[0].ToString() + "|"
                                + cal.Items[i].Value + "|0";//设置为0,删除删除
                            list.Add(item);
                        }
                    }
                }
            }

            if (Rolebll.UpdateRoleAuthority(list))
            {
                BindModules();
                ScriptManager.RegisterClientScriptBlock(CustomPanel1, this.GetType(), "MsgBox", "alert('" + ResourceManager.GetString("Pub_Msg_update_true") + "')", true);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(CustomPanel1, this.GetType(), "MsgBox", "alert('" + ResourceManager.GetString("Pub_Msg_update_false") + "')", true);
            }

        }
        /// <summary>
        /// 保存所有修改的权限
        /// </summary>
        protected void btn_AllSave_Click(object sender, EventArgs e)
        {
            RedGlovePermission.BLL.RGP_Roles Rolebll = new RedGlovePermission.BLL.RGP_Roles();

            ArrayList list = new ArrayList();//建立事务列表
            for (int i = 0; i <= ModuleView.Rows.Count - 1; i++)
            {
                CheckBoxList cal = (CheckBoxList)this.ModuleView.Rows[i].Cells[1].FindControl("AuthorityList");
                Label lab_Verify = (Label)this.ModuleView.Rows[i].Cells[0].FindControl("lab_Verify");
                string[] vstate = lab_Verify.Text.Split(',');//获取原始状态

                for (int j = 0; j < cal.Items.Count; j++)
                {
                    if (cal.Items[j].Enabled)
                    {
                        if (cal.Items[j].Selected)
                        {
                            if (vstate[j] != "1")//检查数据有没有变化
                            {
                                string item = string.Empty;
                                item = item + Rid.Text + "|"
                                    + this.ModuleView.DataKeys[i].Values[0].ToString() + "|"
                                    + cal.Items[j].Value + "|1";//设置为1,加入权限
                                list.Add(item);
                            }
                        }
                        else
                        {
                            if (vstate[j] != "0")//检查数据有没有变化
                            {
                                string item = string.Empty;
                                item = item + Rid.Text + "|"
                                    + this.ModuleView.DataKeys[i].Values[0].ToString() + "|"
                                    + cal.Items[j].Value + "|0";//设置为0,删除删除
                                list.Add(item);
                            }
                        }
                    }
                }
            }

            if (Rolebll.UpdateRoleAuthority(list))
            {
                BindModules();
                ScriptManager.RegisterClientScriptBlock(CustomPanel1, this.GetType(), "MsgBox", "alert('设置成功!')", true);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(CustomPanel1, this.GetType(), "MsgBox", "alert('设置操作失败!')", true);
            }
        }
        /// <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, ',');
            }
        }