示例#1
0
    //保存
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (this.Session["uid"].ToString() == "")
            this.Response.Redirect("../login.aspx");

        string uid = txtuid.Text;

        TPortalClass.JpRoles Roles = new TPortalClass.JpRoles();

        string cidlist = this.txtcids.Text;
        string[] cids = cidlist.Split(',');

        string authlist = this.txtauths.Text;
        string[] auths = authlist.Split(',');

        string editlist = this.txtedits.Text;
        string[] edits = editlist.Split(',');

        int rowcnt = 0;

        foreach (string cid in cids)
        {
            //版主
            if (edits[rowcnt] == "1")
            {
                Roles.role = "editor";
                Roles.uid = uid;
                Roles.cid = cid;
                Roles.Delete();
                Roles.Insert();
            }
            else
            {
                Roles.role = "editor";
                Roles.uid = uid;
                Roles.cid = cid;
                Roles.Delete();
            }

            //作者
            if (auths[rowcnt] == "1")
            {
                Roles.role = "author";
                Roles.uid = uid;
                Roles.cid = cid;
                Roles.Delete();
                Roles.Insert();
            }
            else
            {
                Roles.role = "author";
                Roles.uid = uid;
                Roles.cid = cid;
                Roles.Delete();
            }
            rowcnt = rowcnt + 1;
        }

        TPortalClass.JpCommon JpCommon = new TPortalClass.JpCommon();
        string pageUrl = JpCommon.CombUrlTxt("main_columnrole.aspx", "page={0}&rnd={1}&cid={2}&uid={3}",
            "" + this.txtPage.Text + "", "" + System.Guid.NewGuid().ToString() + "", this.txtcid.Text, this.txtuid.Text);

        //写系统日志
        string userip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
        if (userip == null || userip == "")
        {
            userip = Request.ServerVariables["REMOTE_ADDR"];
        }
        JpCommon.WriteLog(userip, "保存人员授权", "批量保存人员授权", Session["uid"].ToString(), Session["uname"].ToString());

        Response.Write("<script>alert('保存人员授权成功!');window.location='" + pageUrl + "';</script>");
    }