コード例 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Request.QueryString["SRoleID"] != null)//窗体加载ID为空则为添加角色,不为空则为修改角色
            {
                this.BtnInsert.Visible = false;
                this.ButUpdate.Visible = true;

                int id = Convert.ToInt32(Request.QueryString["SRoleID"]);
                Tz888.Model.Sys.SysRoleTab model = new Tz888.Model.Sys.SysRoleTab();
                Tz888.BLL.Sys.SysRoleTab   bll   = new Tz888.BLL.Sys.SysRoleTab();
                model = bll.GetModel(id);
                this.TxtSRDoc.Value = model.SRDoc;
                this.TxtSrName.Text = model.SRName;
            }
            else
            {
                this.BtnInsert.Visible = true;
                this.ButUpdate.Visible = false;
            }
        }
    }
コード例 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.QueryString["SRoleID"] != "" && Request.QueryString["SRoleID"] != null)
         {
             roleID           = Convert.ToInt32(Request.QueryString["SRoleID"].ToString());
             roleModel        = roleBll.GetModel(roleID);
             lblUserPriv.Text = roleModel.SRName.ToString();
             DataSet ds1 = new DataSet();
             ds1       = GetDataList();
             MenuCount = ds1.Tables[0].Rows.Count;
             //int SParentCode = 0;
             //MenuCount = bll.GetList().Count;
             DataRow[] dr1 = ds1.Tables[0].Select("SParentCode=0");
             DataSet   ds2 = new DataSet();
             ds2 = ds1.Clone();
             ds2.Merge(dr1);
             //rptMain.DataSource = bll.GetList(SParentCode, "desc");//第一级菜单
             rptMain.DataSource = ds2;
             rptMain.DataBind();
             ds2.Dispose();
             ds2 = null;
             ds1.Dispose();
             ds1 = null;
         }
         else
         {
             Response.Redirect("Role.aspx");
         }
     }
     else
     {
         string funstr = lblFuncIdStr.Value;
         string fun    = "";
         if (funstr.EndsWith(","))
         {
             fun = funstr.Substring(0, funstr.Length - 1);
         }
         else
         {
             fun = funstr;
         }
         modelpER = sysBll.GetModel1(int.Parse(Request.QueryString["SRoleID"].ToString()));
         if (modelpER != null)
         {
             modelpER.SPCode = fun;
             if (sysBll.Update(modelpER))
             {
                 Response.Write("<script>alert('权限编辑成功');location.href='Role.aspx';</script>");
             }
         }
         else
         {
             Tz888.Model.Sys.SysPermissionTab modelpER1 = new Tz888.Model.Sys.SysPermissionTab();
             int roleid = int.Parse(Request.QueryString["SRoleID"].ToString());
             modelpER1.RoleID = roleid;
             modelpER1.SPCode = fun;
             modelpER1.SPDate = DateTime.Now;
             if (sysBll.Add(modelpER1) > 0)
             {
                 Response.Write("<script>alert('权限编辑成功');location.href='Role.aspx';</script>");
             }
         }
     }
 }