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); } }
public Storage LockBar(Cell cell, Product product) { Storage storage = null; if (Lock(cell)) { try { if (cell.Storages.Count == 1) { storage = cell.Storages.Where(s => s.ProductCode == product.ProductCode || string.IsNullOrEmpty(s.ProductCode)) .FirstOrDefault(); if (storage != null) { if (string.IsNullOrEmpty(storage.LockTag)) { storage.LockTag = this.LockKey; } else storage = null; } } else if (cell.Storages.Count == 0) { storage = new Storage() { Cell = cell, StorageCode = Guid.NewGuid().ToString(), CellCode = cell.CellCode, IsLock = "0", LockTag = this.LockKey, IsActive = "0", StorageTime = DateTime.Now, UpdateTime = DateTime.Now }; cell.Storages.Add(storage); } StorageRepository.SaveChanges(); } catch (Exception) { if (storage != null) { StorageRepository.Detach(storage); } storage = null; } } UnLock(cell); return storage; }
public Storage LockStorage(Storage storage, Product product) { var cell = storage.Cell; if (Lock(cell)) { if (string.IsNullOrEmpty(storage.LockTag) && storage.ProductCode == product.ProductCode) { try { storage.LockTag = this.LockKey; StorageRepository.SaveChanges(); } catch (Exception) { if (storage != null) { StorageRepository.Detach(storage); } storage = null; } } else { storage = null; } } else { storage = null; } UnLock(cell); return storage; }
/// <summary> /// 用于选择可出库目标库存记录 /// </summary> /// <param name="storage">目标库存记录</param> /// <param name="product">要出库的产品</param> /// <returns>可出库的库存记录</returns> public Storage LockNoEmptyStorage(Storage storage, Product product) { try { if (storage != null && string.IsNullOrEmpty(storage.LockTag) && storage.ProductCode == product.ProductCode && storage.Quantity - storage.OutFrozenQuantity > 0) { return storage; } else return null; } catch (Exception) { return null; } }
public Storage LockNoEmpty(Cell cell,Product product) { Storage storage = null; if (Lock(cell)) { try { storage = cell.Storages.Where(s => s.ProductCode == product.ProductCode && s.Quantity - s.OutFrozenQuantity > 0) .FirstOrDefault(); if (storage != null) { storage.LockTag = this.LockKey; StorageRepository.SaveChanges(); } } catch (Exception) { if (storage != null) { StorageRepository.Detach(storage); } storage = null; } } UnLock(cell); return storage; }
public ActionResult Edit(Product product) { bool bResult = ProductService.Save(product); string msg = bResult ? "修改成功" : "修改失败"; return Json(JsonMessageHelper.getJsonMessage(bResult, msg, null), "text", JsonRequestBehavior.AllowGet); }
public ActionResult Create(Product product) { bool bResult = ProductService.Add(product); string msg = bResult ? "新增成功" : "新增失败"; return Json(JsonMessageHelper.getJsonMessage(bResult, msg, null), "text", JsonRequestBehavior.AllowGet); }
public Storage LockPiece(Cell cell, Product product) { Storage storage = null; if (Lock(cell)) { try { if (cell.Storages.Count == 1) { storage = cell.Storages.Where(s => (s.ProductCode == product.ProductCode && (s.Cell.MaxQuantity * product.Unit.Count - s.Quantity - s.InFrozenQuantity + s.OutFrozenQuantity) > 0) || string.IsNullOrEmpty(s.ProductCode) || (s.Quantity == 0 && s.InFrozenQuantity == 0)) .FirstOrDefault(); if (storage != null) { if (string.IsNullOrEmpty(storage.LockTag)){storage.LockTag = this.LockKey;} else storage = null; } } else if (cell.Storages.Count == 0) { storage = new Storage() { Cell=cell, StorageCode = Guid.NewGuid().ToString(), CellCode = cell.CellCode, IsLock = "0", LockTag = this.LockKey, IsActive = "1", StorageTime = DateTime.Now, UpdateTime = DateTime.Now }; cell.Storages.Add(storage); } StorageRepository.SaveChanges(); } catch (Exception) { if (storage != null) { StorageRepository.Detach(storage); } storage = null; } } UnLock(cell); return storage; }