protected void btnAdd_Click(object sender, EventArgs e) { WFunctionData model = new WFunctionData(); WFunctionBB functionBB = new WFunctionBB(); try { if (this.State == "1") { this.SetModel(ref model); functionBB.AddRecord(model); } else if (this.State == "2") { model = functionBB.GetModel(this.IdValue); this.SetModel(ref model); functionBB.ModifyRecord(model); } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",4);", true); return; } finally { functionBB.Dispose(); } this.ClientScript.RegisterStartupScript(this.GetType(), "CloseSubmit", "CloseSubmit()", true); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Request.Params["id"] != null && Request.Params["id"].Trim() != "") { this.IdValue = Request.Params["id"]; } if (Request.Params["state"] != null && Request.Params["state"].Trim() != string.Empty) { this.State = Request.Params["state"].ToString(); switch (this.State) { case "1": //add break; case "2": //update //���ؿؼ� WFunctionBB functionBB = new WFunctionBB(); WFunctionData functionData = new WFunctionData(); try { functionData = functionBB.GetModel(this.IdValue); //����й��������˴�Ҫ��֤�Ƿ������� this.ShowInfo(this.IdValue); } finally { functionBB.Dispose(); } break; default: break; } } } }