UpdateData.aspx.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. public partial class UpdateData : System.Web.UI.Page
  12. {
  13. LYS.UserData1 mydata = new LYS.UserData1();
  14. protected void Page_Load(object sender, EventArgs e)
  15. {
  16. Session["ModifySQL"] = "Select * from TKJL";
  17. string myURL = mydata.GetAddressUrl();
  18. if (myURL.LastIndexOf("KeyF")<0)
  19. {
  20. Response.Write("<script>alert('错误!参数不正确!不能正常显示')</script>");
  21. Response.End();
  22. }
  23. string sql= Session["ModifySQL"] + " where ID= " + Request.QueryString["KeyF"];
  24. mydata.BuildModifyForm(Panel1, sql , 8);
  25. }
  26. protected void ModifyData_Click(object sender, EventArgs e)
  27. {
  28. try
  29. {
  30. string sql = Session["ModifySQL"] + " where ID= " + Request.QueryString["KeyF"];
  31. mydata.ModifyToDB(sql, Session["ModifyTableName"].ToString());
  32. Response.Write("<script>alert('数据修改成功!')</script>");
  33. }
  34. catch (Exception ex)
  35. { Response.Write("<script>alert('出现无法预料的错误!可能数据类型不一致或者有些数据输入不完整(日期数据不能为空)!"+ex.Message+"')</script>"); }
  36. finally
  37. { }
  38. }
  39. }