protected void btn_Submit_Click(object sender, EventArgs e) { string Oid = "DD" + DateTime.Now.ToString("yyyyMMddMMss"); Orders order = new Orders() { OID = Oid, MID = Convert.ToInt32(Session["Mid"]), ODate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")), OConsignee = this.consignee_0.Value, OAddress = this.oaddress.Value, OTelephone = this.tel_0.Value, OSumPrice = Convert.ToInt32(this.txtSumPrice.Value), OState = 1, }; bool ck = OrderBLL.AddOrder(order) > 0? true :false; if (ck) { RepeaterItemCollection items = repgoods.Items; foreach (RepeaterItem item in items) { Label bid = (Label)item.FindControl("bBID"); Label tid = (Label)item.FindControl("bTID"); Label price = (Label)item.FindControl("price"); TextBox lbcount = (TextBox)item.FindControl("lbcount"); OrderDetails o = new OrderDetails() { OID = Oid, BID = Convert.ToInt32(bid.Text), BPrice = Convert.ToDouble(price.Text), BCount = Convert.ToInt32(lbcount.Text) }; bool cko = OrderBLL.AddOrderDetails(o) > 0 ? true : false; if (cko) { bool ckd = OrderBLL.DeleteTrade(Convert.ToInt32(tid.Text)) > 0 ? true : false; if (ckd) { OrderBLL.UpdateBcount(Convert.ToInt32(lbcount.Text), Convert.ToInt32(bid.Text)); } } } Response.Redirect("done.aspx?oid=" + Oid); } }