private void AllotPallet(OutBillMaster billMaster, OutBillDetail billDetail, IOrderedQueryable <Storage> ss, System.Threading.CancellationToken cancellationToken, ProgressState ps) { foreach (var s in ss.ToArray()) { if (!cancellationToken.IsCancellationRequested && (billDetail.BillQuantity - billDetail.AllotQuantity) > 0) { decimal allotQuantity = s.Quantity - s.OutFrozenQuantity; decimal billQuantity = Math.Floor((billDetail.BillQuantity - billDetail.AllotQuantity) / billDetail.Product.Unit.Count) * billDetail.Product.Unit.Count; if (billQuantity >= allotQuantity) { Allot(billMaster, billDetail, s, Locker.LockNoEmptyStorage(s, billDetail.Product), allotQuantity, ps); } else if (billQuantity >= 300000) { allotQuantity = allotQuantity < billQuantity ? allotQuantity : billQuantity; Allot(billMaster, billDetail, s, Locker.LockNoEmptyStorage(s, billDetail.Product), allotQuantity, ps); } else { break; } } else { break; } } }
//修改细单 // POST: /StockOutBill/editOutBillDelete public ActionResult editOutBillDelete(OutBillDetail outBillDetail) { string errorInfo = string.Empty; bool bResult = OutBillDetailService.Save(outBillDetail, out errorInfo); string msg = bResult ? "修改成功" : "修改失败"; return(Json(JsonMessageHelper.getJsonMessage(bResult, msg, errorInfo), "text", JsonRequestBehavior.AllowGet)); }
public bool DownOutBillMaster(string beginDate, string endDate, out string errorInfo) { errorInfo = string.Empty; bool result = false; string outBillStr = ""; string outBillMasterStr = ""; try { var outBillNos = OutBillMasterRepository.GetQueryable().Where(i => i.BillNo == i.BillNo).Select(i => new { i.BillNo }).ToArray(); for (int i = 0; i < outBillNos.Length; i++) { outBillStr += outBillNos[i].BillNo + ","; } OutBillMaster[] outBillMasterList = OutBillMasterDownService.GetOutBillMaster(outBillStr); foreach (var master in outBillMasterList) { var outBillMaster = new OutBillMaster(); outBillMaster.BillNo = master.BillNo; outBillMaster.BillDate = master.BillDate; outBillMaster.BillTypeCode = master.BillTypeCode; outBillMaster.WarehouseCode = master.WarehouseCode; outBillMaster.Status = "1"; outBillMaster.IsActive = master.IsActive; outBillMaster.UpdateTime = DateTime.Now; OutBillMasterRepository.Add(outBillMaster); outBillMasterStr += master.BillNo + ","; } if (outBillMasterStr != string.Empty) { OutBillDetail[] outBillDetailList = OutBillMasterDownService.GetOutBillDetail(outBillMasterStr); foreach (var detail in outBillDetailList) { var outBillDetail = new OutBillDetail(); outBillDetail.BillNo = detail.BillNo; outBillDetail.ProductCode = detail.ProductCode; outBillDetail.UnitCode = detail.UnitCode; outBillDetail.Price = detail.Price; outBillDetail.BillQuantity = detail.BillQuantity; outBillDetail.AllotQuantity = detail.AllotQuantity; outBillDetail.RealQuantity = detail.RealQuantity; outBillDetail.Description = detail.Description; OutBillDetailRepository.Add(outBillDetail); } } OutBillMasterRepository.SaveChanges(); result = true; } catch (Exception e) { errorInfo = "出错,原因:" + e.Message; } return(result); }
public void AddToOutBillDetail(OutBillMaster outBillMaster, Product product, decimal price, decimal quantity) { if (quantity > 0) { Locker.LockKey = outBillMaster.BillNo; OutBillDetail detail = new OutBillDetail(); detail.BillNo = outBillMaster.BillNo; detail.ProductCode = product.ProductCode; detail.UnitCode = product.UnitCode; detail.Price = price; detail.BillQuantity = quantity; detail.AllotQuantity = 0; detail.RealQuantity = 0; outBillMaster.OutBillDetails.Add(detail); } }
private void Allot(OutBillMaster billMaster, OutBillDetail billDetail, Storage storage, Storage p, decimal allotQuantity, ProgressState ps) { if (storage != null && allotQuantity > 0) { OutBillAllot billAllot = null; billDetail.AllotQuantity += allotQuantity; storage.OutFrozenQuantity += allotQuantity; billAllot = new OutBillAllot() { BillNo = billMaster.BillNo, OutBillDetailId = billDetail.ID, ProductCode = billDetail.ProductCode, CellCode = storage.CellCode, StorageCode = storage.StorageCode, UnitCode = billDetail.UnitCode, AllotQuantity = allotQuantity, RealQuantity = 0, Status = "0" }; billMaster.OutBillAllots.Add(billAllot); decimal sumBillQuantity = billMaster.OutBillDetails.Sum(d => d.BillQuantity); decimal sumAllotQuantity = billMaster.OutBillDetails.Sum(d => d.AllotQuantity); decimal sumBillProductQuantity = billMaster.OutBillDetails.Where(d => d.ProductCode == billDetail.ProductCode) .Sum(d => d.BillQuantity); decimal sumAllotProductQuantity = billMaster.OutBillDetails.Where(d => d.ProductCode == billDetail.ProductCode) .Sum(d => d.AllotQuantity); ps.State = StateType.Processing; ps.TotalProgressName = "分配出库单:" + billMaster.BillNo; ps.TotalProgressValue = (int)(sumAllotQuantity / sumBillQuantity * 100); ps.CurrentProgressName = "分配卷烟:" + billDetail.Product.ProductName; ps.CurrentProgressValue = (int)(sumAllotProductQuantity / sumBillProductQuantity * 100); NotifyConnection(ps.Clone()); } }