本文整理汇总了C#中DataClasses1DataContext.insertOrder方法的典型用法代码示例。如果您正苦于以下问题:C# DataClasses1DataContext.insertOrder方法的具体用法?C# DataClasses1DataContext.insertOrder怎么用?C# DataClasses1DataContext.insertOrder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataClasses1DataContext
的用法示例。
在下文中一共展示了DataClasses1DataContext.insertOrder方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PublishOrder
//发布订单16 ok
public List<Order> PublishOrder(List<Commodity> commodityList, String userFrom)
{
List<Order> OrderList = new List<Order>();
Dictionary<String,int> SellerNameAndOderIDList = new Dictionary<string,int>();
//把商品按商家归类
foreach (Commodity commodity in commodityList)
{
if (!SellerNameAndOderIDList.Keys.Contains(commodity.UserName))
{
SellerNameAndOderIDList.Add(commodity.UserName,0);
}
}
//数据访存器
DatabaseAccess.DataClasses1DataContext DBAccessor = new DataClasses1DataContext();
//以卖家为单位插入订单,并返回订单号
foreach (String Seller in SellerNameAndOderIDList.Keys)
{
try
{
int OderID = DBAccessor.insertOrder(userFrom,Seller);
SellerNameAndOderIDList[Seller] = OderID;
}
catch (Exception e)
{
}
}
//以订单号为单位插入商品
foreach (String SellerName in SellerNameAndOderIDList.Keys)
{
//订单
Order order = new Order();
try
{
foreach (Commodity commodity in commodityList)
{
if (commodity.UserName == SellerName)
{
DBAccessor.insertOrderCommodity(SellerNameAndOderIDList[SellerName], commodity.ID);
order.userTo.UserName = SellerName;
order.commodityList.Add(commodity);//加入订单的商品列表中
order.ID = SellerNameAndOderIDList[SellerName];//订单号
}
}
}
catch (Exception e)
{
}
OrderList.Add(order);
}
return OrderList;
}