//--提交计算模块-- /// <summary> /// SubmitOrder函数的功能:提交订单 /// </summary> /// <param name="Oid">订单ID</param> /// <param name="price">商品价格</param> /// <param name="num">商品数量</param> public void SubmitOrderItem(int Oid, int Pid, double price, int num, DateTime time) { b_order_item_Entity I = new b_order_item_Entity(); I.B_o_id = Oid; I.P_id = Pid; I.P_price = price; I.P_num = num; Date.InsertToOrderItem(I); }
/// <summary> /// AddOrderItem函数的功能:向买家订单项目表中添加一条新的记录 /// </summary> /// <param name="Bid">订单编号</param> /// <param name="Pid">商品编号</param> /// <param name="price">商品价格</param> /// <param name="num">商品数量</param> /// <param name="time">提交时间</param> public void AddOrderItem(int Bid, int Pid, double price, int num) { b_order_item_Entity Item = new b_order_item_Entity(); Item.B_o_id = Bid; Item.P_id = Pid; Item.P_price = price; Item.P_num = num; Date.InsertToOrderItem(Item); }
//--提交计算模块-- /// <summary> /// InsertToOrderItem函数的功能:访问数据库的买家订单项目表并向表中添加一条新的记录(增) /// </summary> /// <param name="orderitem">买家订单项目对象</param> public void InsertToOrderItem(b_order_item_Entity orderitem) { b_order_item_T items = new b_order_item_T(); items.b_o_Id = orderitem.B_o_id; items.p_Id = orderitem.P_id; items.p_price = (decimal)orderitem.P_price; items.p_num = orderitem.P_num; buyerDB.b_order_item_T.InsertOnSubmit(items); buyerDB.SubmitChanges(); }
/// <summary> /// orderSearchItem函数的功能:对买家订单项目表的查询(查) /// </summary> /// <param name="orderitem">买家订单项目表对象</param> /// <returns>LINQ查询结果的集合</returns> public object orderSearchItem(b_order_item_Entity orderitem) { var results = buyerDB.b_order_item_T.Where(r => r.b_o_Id == orderitem.B_o_id).Select(r => r); return((object)results); }
protected void btnSubmit_Click1(object sender, EventArgs e) { string account = Session["UserAccount"].ToString().Trim(); double balance = (double)buyer.SearchBalance(account); int totalPrice = int.Parse(lblTotalPrice.Text); if (totalPrice <= 0) { Response.Write(MessagesBox.showMessages("请点击重新计算或选择所要购买的商品!")); } else { if (balance >= totalPrice)//判断买家余额是否足够 { if (chkIsOnline.Checked == true) { buyer.AddMoney(account, -1.0 * totalPrice);//扣除买家余额 } for (int i = 0; i < gv.Rows.Count; i++) { CheckBox chkProduct = (CheckBox)gv.Rows[i].FindControl("chkProducts"); if (chkProduct.Checked == true) { //向买家订单表插数据 b_order = new b_order_Entity(); b_order.B_account = gv.Rows[i].Cells[1].Text; b_order.S_account = gv.Rows[i].Cells[2].Text; b_order.S_storeName = gv.Rows[i].Cells[3].Text; b_order.B_o_totalprice = double.Parse(lblTotalPrice.Text); if (chkIsOnline.Checked == true) { b_order.B_order_state = "已付款"; } else { b_order.B_order_state = "未支付"; } //记录上一次的卖家和买家账号用于判断所选的是否属性同一个订单 string b_account = ""; //买家账号 string s_account = ""; //卖家账号 if (i > 0) { b_account = gv.Rows[i - 1].Cells[1].Text; s_account = gv.Rows[i - 1].Cells[2].Text; } //如果是第一个商品的话,增加一条订单记录 if (i == 0) { buyer.AddOrder(b_order.B_account, b_order.S_account, b_order.S_storeName, b_order.B_order_state, b_order.B_o_totalprice); } else { //根据买家、卖家账号判断所选商品是否属性同一个订单 if (b_account == gv.Rows[i].Cells[1].Text && s_account == gv.Rows[i].Cells[2].Text) { } else { buyer.AddOrder(b_order.B_account, b_order.S_account, b_order.S_storeName, b_order.B_order_state, b_order.B_o_totalprice); } } //向买家订单项目表插数据 int id = buyer.searchLatestBOrderId();//获取最新的订单编号 b_order_item = new b_order_item_Entity(); b_order_item.B_o_id = id; b_order_item.P_id = int.Parse(gv.Rows[i].Cells[4].Text); b_order_item.P_price = double.Parse(gv.Rows[i].Cells[6].Text); TextBox txtNum = (TextBox)gv.Rows[i].FindControl("txtNum"); b_order_item.P_num = int.Parse(txtNum.Text); //buyer.AddOrderItem(b_order_item.B_o_id, b_order_item.P_id, b_order_item.P_price, b_order_item.P_num); //向买家订单状态表插数据 b_order_state = new b_order_state_Entity(); b_order_state.B_o_id = id; b_order_state.B_o_subTime = DateTime.Now; if (chkIsOnline.Checked == true) { b_order_state.B_o_state = "已付款"; } else { b_order_state.B_o_state = "未支付"; } //buyer.AddOrderState(b_order_state.B_o_id, b_order_state.B_o_state); buyer.DeleteFromCart(Session["UserAccount"].ToString().Trim(), int.Parse(gv.Rows[i].Cells[4].Text)); } } Response.Write(MessagesBox.showMessages("提交结算成功!")); Response.Redirect("../Default.aspx"); } else { Response.Write(MessagesBox.showMessages("您的余额不足,请充值!")); Response.Redirect("../buyer/SearchBalance.aspx"); } } }