//添加订单 public boolean addOrder(OrderInfo order){ StringBuilder sb = new StringBuilder(); //第一部分SQL语句 sb.append("insert into OrderInfo values (") .append(order.getCustomer().getId()) .append(",") .append(order.getStatus()) .append(",getdate()) "); //第二部分SQL语句 sb.append("declare @orderId int ") .append("select @orderId=@@identity "); ArrayList<OrderGoodsInfo> goodsList = order.getOrderDetails(); for(OrderGoodsInfo goodsDetail : goodsList){ sb.append("insert into OrderGoodsInfo values (@orderId,") .append(goodsDetail.getGoodsId().getGoodsId()) .append(",") .append(goodsDetail.getQuantity()) .append(") "); }
添加回答
举报
0/150
提交
取消