本文整理汇总了C#中EntityQuery.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# EntityQuery.Insert方法的具体用法?C# EntityQuery.Insert怎么用?C# EntityQuery.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityQuery
的用法示例。
在下文中一共展示了EntityQuery.Insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveSalesInfo
/// <summary>
/// 保存销售信息
/// </summary>
/// <param name="customer">客户信息</param>
/// <param name="integral">要增加的积分</param>
/// <returns></returns>
private GoodsSellNote SaveSalesInfo(Customer customer, int integral)
{
GoodsSellNote note = new GoodsSellNote();
note.CustomerID = customer.CustomerID;
note.ManchinesNumber = this.CurrCRManchines.CashRegisterNo;
note.SalesmanID = this.CurrCashier.WorkNumber;
note.SalesType = "店内销售";
note.SellDate = DateTime.Now;
note.GoodsSellDetails = new List<GoodsSellDetail>();
AdoHelper db = MyDB.GetDBHelper();
db.BeginTransaction();
try
{
EntityQuery<GoodsSellNote> query = new EntityQuery<GoodsSellNote>(db);
if (query.Insert(note) > 0)
{
foreach (Goods goods in customer.Goodss)
{
if (goods.GoodsNumber > 0)
{
//处理详单
GoodsSellDetail detail = new GoodsSellDetail();
detail.GoodsPrice = goods.GoodsPrice;
detail.NoteID = note.NoteID;
detail.SellNumber = goods.GoodsNumber;
detail.SerialNumber = goods.SerialNumber;
note.GoodsSellDetails.Add(detail);
//更新库存
SuperMarketDAL.Entitys.GoodsStock stock = new SuperMarketDAL.Entitys.GoodsStock();
stock.GoodsID = goods.GoodsID;
stock.Stocks = goods.GoodsNumber;
OQL q = OQL.From(stock)
.UpdateSelf ('-', stock.Stocks)
.Where(stock.GoodsID)
.END;
EntityQuery<SuperMarketDAL.Entitys.GoodsStock>.ExecuteOql(q, db);
}
}
EntityQuery<GoodsSellDetail> queryDetail = new EntityQuery<GoodsSellDetail>(db);
queryDetail.Insert(note.GoodsSellDetails);
//更新会员的积分
if (integral > 0)
{
SuperMarketDAL.Entitys.CustomerContactInfo ccInfo = new CustomerContactInfo();
ccInfo.CustomerID = customer.CustomerID;
ccInfo.Integral = integral;
OQL qc = OQL.From(ccInfo)
.UpdateSelf('+', ccInfo.Integral )
.Where(ccInfo.CustomerID )
.END;
EntityQuery<SuperMarketDAL.Entitys.GoodsStock>.ExecuteOql(qc, db);
}
}
db.Commit();
}
catch (Exception ex)
{
db.Rollback();
throw new Exception("插入销售记录失败,内部错误原因:" + ex.Message);
}
return note;
}