public bool SaveSalesOrderItem(OM_OrderItem saleOrderItem) { if (DbRepository.Add(saleOrderItem) > 0) { return(true); } return(false); }
public bool UpdateSalesOrderItem(OM_OrderItem saleOrderItem) { if (DbRepository.Update(saleOrderItem) > 0) { return(true); } return(false); }
/// <summary> /// 保存 /// </summary> /// <param name="salesOrder"></param> /// <returns></returns> public bool SaveSalesOrder(OM_SalesOrderDataObject salesOrder) { OM_Order order = salesOrder.ToDTO(); var user = DbRepository.GetModel <OM_User>(s => s.Account.ToUpper() == salesOrder.CardCode.ToUpper() && s.IsDel == false); if (user == null) { throw new GenericException("客户代码不存在,保持草稿失败"); } order.DocStatus = ((int)OM_DocStatusEnum.未提交).ToString(); order.TotalPrice = salesOrder.TotalPrice; order.DocEntry = GetLastDocEntry(); order.NoteNotice = GetShortRemarks(order.Remarks, 5); var salesOrderHead = DbRepository.Add(order); if (salesOrderHead <= 0) { throw new GenericException("保存草稿失败"); } var orderResult = DbRepository.GetModel <OM_Order>(s => s.Guid == order.Guid); List <OM_OrderItem> items = new List <OM_OrderItem>(); foreach (var item in salesOrder.SalesOrderLine) { OM_OrderItem oi = new OM_OrderItem() { Guid = Guid.NewGuid().ToString().ToUpper(), Currency = item.Currency, ItemCode = item.ItemCode, ItemName = item.ItemName, Price = item.Price, Quantity = item.Quantity, TotalPrice = (item.CustomerPrice ?? item.Price) * item.Quantity, Remarks = item.Remarks, Order_Guid = orderResult.Guid, DocEntry = orderResult.DocEntry, InnerPrice = item.InnerPrice, CustomerPrice = item.CustomerPrice, ItemStandard = item.ItemStandard, ItemUnit = item.ItemUnit }; items.Add(oi); } var salesOrderLine = DbRepository.AddRange(items); if (salesOrderLine <= 0) { throw new GenericException("保存草稿失败"); } return(true); }