Beispiel #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            int id = DataConverter.CLng(Request.QueryString["id"]);

            if (id > 0)
            {
                string Item = Request.Form["Item"] == null ? "" : Request.Form["Item"];
                if (Item != "")
                {
                    if (Item.IndexOf(",") > -1)
                    {
                        string[] str = Item.Split(new string[] { "," }, StringSplitOptions.None);
                        for (int i = 0; i < str.Length; i++)
                        {
                            int          spid   = DataConverter.CLng(str[i]);
                            M_Permission pinfo  = pll.GetSelect(spid);
                            string       Ugroup = pinfo.UserGroup;
                            if (Ugroup != "")//不为空
                            {
                                //判断是否存在
                                string newgroup = Ugroup;
                                if (newgroup.IndexOf("," + id + ",") < 0)
                                {
                                    Ugroup = Ugroup + "," + id + ",";
                                }
                            }
                            else //为空
                            {
                                Ugroup = "," + id.ToString() + ",";
                            }
                            pinfo.UserGroup = Ugroup;
                            pll.GetUpdate(pinfo);
                        }
                    }
                    else
                    {
                        int          spid   = DataConverter.CLng(Item);
                        M_Permission pinfo  = pll.GetSelect(spid);
                        string       Ugroup = pinfo.UserGroup;
                        if (Ugroup != "")//不为空
                        {
                            string newgroup = Ugroup;
                            if (newgroup.IndexOf("," + id + ",") < 0)
                            {
                                Ugroup = Ugroup + "," + id + ",";
                            }
                        }
                        else //为空
                        {
                            Ugroup = "," + id.ToString() + ",";
                        }
                        pinfo.UserGroup = Ugroup;
                        pll.GetUpdate(pinfo);
                    }
                }
            }
            Response.Write("<script language=javascript>window.close();opener.location.reload();</script>");
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!B_ARoleAuth.Check(ZLEnum.Auth.user, "UserManage"))
            {
                function.WriteErrMsg("没有权限进行此项操作");
            }
            string menu = Request.QueryString["menu"];
            int    id   = DataConverter.CLng(Request.QueryString["id"]);

            if (!IsPostBack)
            {
                nodelistload(0);
                tdtext.Visible = false;
                tdlist.Visible = false;
                if (menu == "edit")
                {
                    M_Permission pinfo = pll.GetSelect(id);
                    this.txtID.Value        = pinfo.ID.ToString();
                    this.txtRoleName.Text   = pinfo.RoleName.ToString();
                    this.txtInfo.Text       = pinfo.Info.ToString();
                    this.txtPrecedence.Text = pinfo.Precedence.ToString();
                    DataSet ds = function.XmlToTable(pinfo.Perlist);
                    if (ds.Tables.Count > 0)
                    {
                        #region 设置选择节点
                        string nodelistvalues = ds.Tables[0].Rows[0]["Nodelist"].ToString();
                        nodelistvalues = nodelistvalues.TrimEnd(new char[] { ',' });
                        nodelistvalues = nodelistvalues.TrimStart(new char[] { ',' });
                        //节点默认选中
                        SelectList(Nodelist_LB, nodelistvalues);
                        #endregion
                        #region 设置选择模型字段
                        fieldlistvalues = ds.Tables[0].Rows[0]["Fieldlist"].ToString();
                        fieldlistvalues = fieldlistvalues.TrimEnd(new char[] { ',' });
                        fieldlistvalues = fieldlistvalues.TrimStart(new char[] { ',' });
                        Modellistload();
                        #endregion
                        #region 设置模型表
                        string datalistvalues = ds.Tables[0].Rows[0]["DataList"].ToString();
                        datalistvalues = datalistvalues.TrimEnd(new char[] { ',' });
                        datalistvalues = datalistvalues.TrimStart(new char[] { ',' });
                        //数据库列表默认选中
                        SelectList(DataList_LB, datalistvalues);
                        #endregion
                        #region 设置时段浏览
                        if (DataConverter.CLng(ds.Tables[0].Rows[0]["Time"].ToString()) == 1)
                        {
                            rblTime.SelectedIndex = 0;
                            rblTime_SelectedIndexChanged(null, null);
                            //月份
                            string Month = ds.Tables[0].Rows[0]["Month"].ToString();
                            Month = Month.TrimEnd(new char[] { ',' });
                            Month = Month.TrimStart(new char[] { ',' });
                            SelectList(cblMonth, Month);
                            //日期
                            string Day = ds.Tables[0].Rows[0]["Day"].ToString();
                            Day = Day.TrimEnd(new char[] { ',' });
                            Day = Day.TrimStart(new char[] { ',' });
                            SelectList(cblDay, Day);
                            //小时
                            string Hour = ds.Tables[0].Rows[0]["Hour"].ToString();
                            Hour = Hour.TrimEnd(new char[] { ',' });
                            Hour = Hour.TrimStart(new char[] { ',' });
                            SelectList(cblHour, Hour);
                            //星期
                            string Weeks = ds.Tables[0].Rows[0]["Weeks"].ToString();
                            Weeks = Weeks.TrimEnd(new char[] { ',' });
                            Weeks = Weeks.TrimStart(new char[] { ',' });
                            SelectList(cblWeeks, Weeks);
                        }
                        else
                        {
                            rblTime.SelectedIndex = 1;
                            rblTime_SelectedIndexChanged(null, null);
                        }


                        #endregion
                        #region 设置内容操作
                        //允许内容浏览
                        if (ds.Tables[0].Rows[0]["ViewContent"].ToString() == "1")
                        {
                            this.ViewContent.SelectedValue = "1";
                        }
                        else
                        {
                            this.ViewContent.SelectedValue = "0";
                        }
                        //允许列表浏览
                        if (ds.Tables[0].Rows[0]["ListContent"].ToString() == "1")
                        {
                            this.ListContent.SelectedValue = "1";
                        }
                        else
                        {
                            this.ListContent.SelectedValue = "0";
                        }
                        //允许新增发布
                        if (ds.Tables[0].Rows[0]["AddContent"].ToString() == "1")
                        {
                            this.AddContent.SelectedValue = "1";
                        }
                        else
                        {
                            this.AddContent.SelectedValue = "0";
                        }
                        //允许编辑修改
                        if (ds.Tables[0].Rows[0]["ModefiyContent"].ToString() == "1")
                        {
                            this.ModefiyContent.SelectedValue = "1";
                        }
                        else
                        {
                            this.ModefiyContent.SelectedValue = "0";
                        }
                        //允许删除内容
                        if (ds.Tables[0].Rows[0]["DeleteContent"].ToString() == "1")
                        {
                            this.DeleteContent.SelectedValue = "1";
                        }
                        else
                        {
                            this.DeleteContent.SelectedValue = "0";
                        }
                        //允许评论权限
                        if (ds.Tables[0].Rows[0]["AddComm"].ToString() == "1")
                        {
                            this.AddComm.SelectedValue = "1";
                        }
                        else
                        {
                            this.AddComm.SelectedValue = "0";
                        }
                        #endregion
                    }
                    if (pinfo.IsTrue == true)
                    {
                        this.txtIsTrue.SelectedValue = "1";
                    }
                    else
                    {
                        this.txtIsTrue.SelectedValue = "0";
                    }
                    this.type         = "修改角色";
                    this.Button1.Text = "修改角色";
                }
                else
                {
                    Modellistload();
                }
                this.txtID.Value = id.ToString();
                Call.SetBreadCrumb(Master, "<li><a href='" + CustomerPageAction.customPath2 + "Main.aspx'>工作台</a></li><li><a href='UserManage.aspx'>用户管理</a></li><li><a href='PermissionInfo.aspx'>角色管理</a></li><li>添加角色</li>");
            }
        }