/// <summary>
    /// 添加角色
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void BtnInsert_Click(object sender, EventArgs e)
    {
        if (this.TxtSrName.Text.ToString().Trim().Length > 0)
        {
            Tz888.BLL.dp.SysRoleTab   rt    = new Tz888.BLL.dp.SysRoleTab();
            Tz888.Model.dp.SysRoleTab model = new Tz888.Model.dp.SysRoleTab();
            model.SRName  = this.TxtSrName.Text;
            model.SysCode = "aa";
            model.SRDoc   = this.TxtSRDoc.Value.Trim();
            model.SRDate  = DateTime.Now;
            int a = rt.Add(model);
            if (a > 0)
            {
                Response.Write("<script>alert('添加成功!');document.location='Role.aspx'</script>");
            }
            else
            {
                // Response.Write("<script>alert('添加失败!');</script>");
                Tz888.Common.MessageBox.Show(this.Page, "添加失败");
            }
        }

        else
        {
            Tz888.Common.MessageBox.Show(this.Page, "名称不能为空!");
        }
    }
Example #2
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <Tz888.Model.dp.SysRoleTab> DataTableToList(DataTable dt)
        {
            List <Tz888.Model.dp.SysRoleTab> modelList = new List <Tz888.Model.dp.SysRoleTab>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                Tz888.Model.dp.SysRoleTab model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Tz888.Model.dp.SysRoleTab();
                    if (dt.Rows[n]["SRoleID"].ToString() != "")
                    {
                        model.SRoleID = int.Parse(dt.Rows[n]["SRoleID"].ToString());
                    }
                    model.SRName  = dt.Rows[n]["SRName"].ToString();
                    model.SRDoc   = dt.Rows[n]["SRDoc"].ToString();
                    model.SysCode = dt.Rows[n]["SysCode"].ToString();
                    if (dt.Rows[n]["SRDate"].ToString() != "")
                    {
                        model.SRDate = DateTime.Parse(dt.Rows[n]["SRDate"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
 /// <summary>
 /// 修改角色
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void ButUpdate_Click(object sender, EventArgs e)
 {
     Tz888.BLL.dp.SysRoleTab   rt    = new Tz888.BLL.dp.SysRoleTab();
     Tz888.Model.dp.SysRoleTab model = new Tz888.Model.dp.SysRoleTab();
     model.SRoleID = Convert.ToInt32(Request.QueryString["SRoleID"]);
     model.SRName  = this.TxtSrName.Text;
     model.SRDoc   = this.TxtSRDoc.Value;
     model.SysCode = "2";
     model.SRDate  = DateTime.Now;
     rt.Update(model);
     Response.Write("<script>alert('修改成功!');document.location='Role.aspx'</script>");
 }
    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.dp.SysRoleTab model = new Tz888.Model.dp.SysRoleTab();
                Tz888.BLL.dp.SysRoleTab   bll   = new Tz888.BLL.dp.SysRoleTab();
                model = bll.GetModel(id);
                this.TxtSRDoc.Value = model.SRDoc;
                this.TxtSrName.Text = model.SRName;
            }
            else
            {
                this.BtnInsert.Visible = true;
                this.ButUpdate.Visible = false;
            }
        }
    }
Example #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public void Update(Tz888.Model.dp.SysRoleTab model)
 {
     dal.Update(model);
 }
Example #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Tz888.Model.dp.SysRoleTab model)
 {
     return(dal.Add(model));
 }
Example #7
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.dp.SysPermissionTab modelpER1 = new Tz888.Model.dp.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>");
             }
         }
     }
 }