/// <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.Sys.SysRoleTab rt = new Tz888.BLL.Sys.SysRoleTab(); Tz888.Model.Sys.SysRoleTab model = new Tz888.Model.Sys.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, "名称不能为空!"); } }
/// <summary> /// 绑定GridView /// </summary> private void GetRoleTable() { Tz888.BLL.Sys.SysRoleTab bll = new Tz888.BLL.Sys.SysRoleTab(); DataSet dt = bll.GetList(""); this.GridRoleTab.DataSource = dt; this.GridRoleTab.DataBind(); }
/// <summary> /// 删除角色 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void LinkDelete_Click(object sender, EventArgs e) { LinkButton link = sender as LinkButton; int id = Convert.ToInt32(link.CommandArgument.ToString()); Tz888.BLL.Sys.SysRoleTab bll = new Tz888.BLL.Sys.SysRoleTab(); bll.Delete(id); // Response.Write("<script>alert('删除成功!');</script>"); Tz888.Common.MessageBox.Show(this.Page, "删除成功!"); GetRoleTable(); }
/// <summary> /// 修改角色 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ButUpdate_Click(object sender, EventArgs e) { Tz888.BLL.Sys.SysRoleTab rt = new Tz888.BLL.Sys.SysRoleTab(); Tz888.Model.Sys.SysRoleTab model = new Tz888.Model.Sys.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) { id = Convert.ToInt16(Request.QueryString["id"].ToString()); //31为超级管理员,不能删除 if (id != 31) { Tz888.BLL.Sys.SysRoleTab bll = new Tz888.BLL.Sys.SysRoleTab(); bll.Delete(id); } Response.Redirect("Role.aspx"); //Tz888.Common.MessageBox.Show(Role.aspx, "删除成功!"); }
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; } } }