以下是引用片段:
核心代码如下: protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) {
if (Request.QueryString["ID"] != null) { //显示当前的商品信息 DataTable tmpda = new DataTable(); tmpda = Database.GetData("select * from 党员信息 where 学号='" + Request.QueryString["ID"] + "'"); if (tmpda.Rows.Count > 0) { txtXH.ReadOnly = true; this.txtXH.Text = tmpda.Rows[0]["学号"].ToString(); this.Txtxm.Text = tmpda.Rows[0]["姓名"].ToString(); this.txtSFZ.Text = tmpda.Rows[0]["身份证号"].ToString(); this.DropDownList1.SelectedItem.Text = tmpda.Rows[0]["性别"].ToString(); this.TxtCDRQ.Text = tmpda.Rows[0]["出生日期"].ToString(); this.txtMZ.Text = tmpda.Rows[0]["民族"].ToString(); this.TxtJG.Text = tmpda.Rows[0]["籍贯"].ToString(); this.TxtRDRQ.Text = tmpda.Rows[0]["入党日期"].ToString(); this.TxtLXFS.Text = tmpda.Rows[0]["联系方式"].ToString(); this.txtBZ.Text = tmpda.Rows[0]["备注"].ToString(); } } } } protected void Button2_Click(object sender, EventArgs e) { Response.Redirect("DYList.aspx"); } protected void Button1_Click(object sender, EventArgs e) { if (Request.QueryString["ID"] != null) { Database.Execute("UPDATE [党员信息] set [学号] = '" + txtXH.Text + "',[姓名] = '" + Txtxm.Text + "',[身份证号] = '" + txtSFZ.Text + "',[性别] = '" + DropDownList1.SelectedValue + "',[出生日期] = '" + TxtCDRQ.Text + "',[民族] = '" + txtMZ.Text + "',[籍贯] ='" + TxtJG.Text + "',[入党日期] = '" + TxtRDRQ.Text + "',[联系方式] ='" + TxtLXFS.Text + "',[备注] ='" + txtBZ.Text + "' WHERE 学号='" + Request.QueryString["ID"] + "'"); } else { Database.Execute("INSERT INTO [党员信息] ( [学号] ,[姓名] ,[身份证号] ,[性别] ,[出生日期] ,[民族] ,[籍贯] ,[入党日期] ,[联系方式] ,[备注] ,[密码] ) VALUES ('" + txtXH.Text + "','" + Txtxm.Text + "','" + txtSFZ.Text + "','" + DropDownList1.SelectedValue + "','" + TxtCDRQ.Text + "','" + txtMZ.Text + "','" + TxtJG.Text + "','" + TxtRDRQ.Text + "','" + TxtLXFS.Text + "','" + txtBZ.Text + "','000000')");
} Page.ClientScript.RegisterStartupScript(this.GetType(), "info", ""); }
|