以下是引用片段: 核心代码如下: protected void Page_Load(object sender, EventArgs e) { // 在此处放置用户代码以初始化页面 if (!Page.IsPostBack) { DataTable tmpda = new DataTable(); tmpda = DataBase.Get_Table("select * from gwcxx,spxx where gwcxx.spbh=spxx.spbh and gwcxx.hydlm='" + Session["UserID"].ToString() + "'"); this.GridView1.DataSource = tmpda; this.GridView1.DataBind(); this.GridView1.Columns[1].Visible = false; tmpda = DataBase.Get_Table("select * from hyxx where hydlm='" + Session["UserID"].ToString() + "'"); if (tmpda.Rows.Count > 0) { this.TextBox5.Text = tmpda.Rows[0]["ljycj"].ToString(); } //从数据库中计算出预订单中当前人员的总数量和总金额 tmpda = DataBase.Get_Table("select sum(gwcxx.sl),sum(gwcxx.sl * spxx.spjg) from gwcxx,spxx where gwcxx.spbh=spxx.spbh and gwcxx.hydlm='" + Session["UserID"].ToString() + "'"); if (tmpda.Rows.Count > 0) { this.TextBox3.Text = tmpda.Rows[0][0].ToString(); this.TextBox4.Text = tmpda.Rows[0][1].ToString(); } //初始化显示控件内容 this.TextBox1.Text = Guid.NewGuid().ToString(); this.TextBox2.Text = Session["UserID"].ToString(); this.TextBox6.Text = DateTime.Now.Date.ToShortDateString(); this.LinkButton2.Attribut", "return confirm('订单生成以后只能等待确认,您不能再继续操作,是否确认生成订单?');"); } } protected void LinkButton1_Click(object sender, EventArgs e) { Response.Redirect("GwcList.aspx"); } protected void LinkButton2_Click(object sender, EventArgs e) { if (Convert.ToDecimal(this.TextBox4.Text) > Convert.ToDecimal(this.TextBox5.Text)) { Page.ClientScrip('你的预付金不足,请充值!'>"); return; } if (this.GridView1.Rows.Count > 0) { //循环保存预订单中的记录到订单明细表中 for (int i = 0; i < this.GridView1.Rows.Count; i++) { string aa = "insert into hyddmx(ddbh,spbh,sl,je) values('" + this.TextBox1.Text + "'," + Convert.ToInt32(this.GridView1.Rows[i].Cells[1].Text) + "," + Convert.ToDecimal(this.GridView1.Rows[i].Cells[4].Text) + "," + Convert.ToDecimal(this.GridView1.Rows[i].Cells[3].Text) * Convert.ToDecimal(this.GridView1.Rows[i].Cells[4].Text) + ")"; DataBase.ExecSql("insert into hyddmx(ddbh,spbh,sl,je) values('" + this.TextBox1.Text + "'," + Convert.ToInt32(this.GridView1.Rows[i].Cells[1].Text) + "," + Convert.ToDecimal(this.GridView1.Rows[i].Cells[4].Text) + "," + Convert.ToDecimal(this.GridView1.Rows[i].Cells[3].Text) * Convert.ToDecimal(this.GridView1.Rows[i].Cells[4].Text) + ")"); } //保存订单主表信息 DataBase.ExecSql("insert into hyddhz(ddbh,hydlm,zsl,zje,ddrq) values('" + this.TextBox1.Text + "','" + Session["UserID"].ToString() + "'," + Convert.ToDecimal(this.TextBox3.Text) + "," + Convert.ToDecimal(this.TextBox4.Text) + ",'" + this.TextBox6.Text + "')"); //删除预订单记录 DataBase.ExecSql("delete from gwcxx where hydlm='" + Session["UserID"].ToString() + "'"); } }
|