コード例 #1
0
        protected void BindRole()
        {
            BLL.BASE_USER bll = new BLL.BASE_USER();
            RoleList.Items.Clear();
            ArrayList rid      = bll.GetUserRoleArray(int.Parse(UID.Text));
            string    strwhere = "";

            for (int i = 0; i < rid.Count; i++)
            {
                string[] r = rid[i].ToString().Split(',');
                RoleList.Items.Add(new ListItem(r[1], r[0]));
                strwhere += r[0] + ",";
            }
            if (strwhere != "")
            {
                OldRoleList.Text = strwhere.Substring(0, strwhere.Length - 1);
                strwhere         = "not RoleID in(" + OldRoleList.Text + ")";
            }

            BLL.BASE_ROLE bll2 = new BLL.BASE_ROLE();
            FromRoleList.DataSource     = bll2.GetRoleList(strwhere, "");
            FromRoleList.DataTextField  = "RoleName";
            FromRoleList.DataValueField = "RoleID";
            FromRoleList.DataBind();
        }
コード例 #2
0
        protected void btn_AllSave_Click(object sender, EventArgs e)
        {
            BLL.BASE_ROLE Rolebll = new BLL.BASE_ROLE();

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

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

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

            if (Rolebll.UpdateUserAuthority(list))
            {
                BindModules();
                strinfo.InnerHtml = Smart.Utility.JScript.errinfo("设置成功!");
                strinfo.Visible   = true;
            }
            else
            {
                strinfo.InnerHtml = Smart.Utility.JScript.errinfo("设置操作失败!");
                strinfo.Visible   = true;
            }
        }
コード例 #3
0
        /// <summary>
        /// 获取角色列表
        /// </summary>
        protected void BindRoles()
        {
            BLL.BASE_ROLE Rolsebll = new BLL.BASE_ROLE();
            DataSet       ds       = Rolsebll.GetRoleList("RoleGroupID=" + GroupList.SelectedValue, "");

            RoleView.DataSource = ds;
            RoleView.DataBind();
        }
コード例 #4
0
        /// <summary>
        /// 更新设置
        /// </summary>
        protected void ModuleView_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            ArrayList list = new ArrayList();//建立事务列表

            BLL.BASE_ROLE Rolebll    = new BLL.BASE_ROLE();
            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();
                strinfo.InnerHtml = Smart.Utility.JScript.errinfo("更新成功!");
                strinfo.Visible   = true;
            }
            else
            {
                strinfo.InnerHtml = Smart.Utility.JScript.errinfo("更新失败!");
                strinfo.Visible   = true;
            }
        }
コード例 #5
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;
                }
            }
        }