protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindTv(); //判断模板ID是否为否,不为空则显示该对象 if (Request.QueryString["id"] != null) { int id = Convert.ToInt32(Request.QueryString["id"]); //根据模板ID获取模板对象 Tunnel.Model.Tunnel_ModelType report = reportManage.GetReportById(id); //绑定数据 txtNum.Text = report.Re_Num.ToString(); txtName.Text = report.Re_Name; ddlType.SelectedValue = report.Re_ParentId.ToString(); } } }
/// <summary> /// 新增模板类型 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnAdd_Click(object sender, EventArgs e) { if (IsValid) { Tunnel.Model.Tunnel_ModelType r = new Tunnel.Model.Tunnel_ModelType(); r.Re_Name = txtName.Text; r.Re_Num = Convert.ToInt32(txtNum.Text); r.Re_ParentId = Convert.ToInt32(ddlType.SelectedValue); if (reportManage.AddReport(r) != 0) { //Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('新增成功');location.herf='Re_add.aspx'</script>"); Response.Write("新增成功!"); Response.Redirect("Re_add.aspx"); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('新增失败')</script>"); return; } } }
/// <summary> /// 新增模块分类 /// </summary> /// <returns></returns> public int AddReport(Tunnel.Model.Tunnel_ModelType r) { return(report.AddReport(r)); }