以下是引用片段:
其主要代码实现如下: protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Request.QueryString["ID"] != null) { //显示当前的公司货运车辆信息 DataTable tmprs = new DataTable(); tmprs = DataBase.Get_Table("select * from 公司货运车辆 where 车辆编号 ='" + Request.QueryString["ID"] + "'"); if (tmprs.Rows.Count > 0) { this.txtID.Text = tmprs.Rows[0]["车辆名称"].ToString(); this.txtXm.Text = tmprs.Rows[0]["车辆牌照"].ToString(); this.TextBox5.Text = tmprs.Rows[0]["车辆主要用途"].ToString(); this.TextBox2.Text = tmprs.Rows[0]["驾驶人员"].ToString(); this.TextBox1.Text = tmprs.Rows[0]["车辆承载"].ToString(); this.txtID.Enabled = false; this.TextBox4.Text = tmprs.Rows[0]["备注"].ToString(); } } } } protected void Button1_Click(object sender, EventArgs e) { //跳转页面 Response."); } protected void Button2_Click(object sender, EventArgs e) { if (Request.QueryString["ID"] == null) { //判断信息是否正确 if (this.txtID.Text == "") { this.Terr.>"; return; } //添加公司货运车辆信息 DataBase.ExecSql("insert into 公司货运车辆(车辆名称,车辆牌照,车辆主要用途,驾驶人员,车辆承载,备注) values('" + this.txtID.Text + "','" + this.txtXm.Text + "','" + TextBox5.Text + "','" + TextBox2.Text + "','" + TextBox1.Text + "','" + TextBox4.Text + "')"); } else { //修改货运车辆信息 DataBase.ExecSql("update 公司货运车辆 set 车辆名称='" + txtID.Text + "',车辆牌照='" + this.txtXm.Text + "',车辆主要用途='" + TextBox5.Text + "',驾驶人员='" + TextBox2.Text + "',车辆承载='" + TextBox1.Text + "',备注='" + TextBox4.Text + "' where 车辆编号='" + Request.QueryString["ID"] + "'"); } Response."); } }
|