public void getOrderGoods(int orderId) { //将OrderGoods添加到数据库中 List <OrderGoods> ogList = new List <OrderGoods>(); //从session["cartTemp"]中取出信息存储到OrderGoods List <CartTemp> cTemp = (List <CartTemp>)Session["cartTemp"]; //遍历购物车 foreach (CartTemp ct in cTemp) { OrderGoods ogs = new OrderGoods(); ogs.OrderID = orderId; ogs.GoodsID = ct.GoodsID; ogs.GoodsNumber = ct.GoodsNumber; ogList.Add(ogs); } //添加信息到数据库OrderGoods int rows = ob.AddOrderGoods(ogList); }