public ActionResult InvItemEditDB(WarehouseInvItem model) { WarehouseInvItem item = dbEntity.WarehouseInvItems.Find(model.Gid); if (item == null || item.Deleted) { return Error("记录不存在", Url.Action("InventoryEdit", new { invID = model.InvID })); } else { item.SkuID = model.SkuID; item.ShelfID = model.ShelfID; item.TrackLot = model.TrackLot; item.Quantity = model.Quantity; item.Remark = model.Remark; dbEntity.SaveChanges(); WarehouseInventory inventory = (from s in dbEntity.WarehouseInventories.Include("InvItems") where s.Gid == item.InvID && !s.Deleted select s).Single(); inventory.Quantity = inventory.InvItems.Select(i => i.Quantity).Sum(); dbEntity.SaveChanges(); whBll = new WarehouseBLL(dbEntity); whBll.InventoryByWarehouseSku(inventory.WhID, model.SkuID); return RedirectToAction("InventoryEdit", new { invID = model.InvID }); } }
public JsonResult InvItemDeleteDB(Guid itemID) { WarehouseInvItem item = dbEntity.WarehouseInvItems.Find(itemID); if (item == null || item.Deleted) { // // To do // } else { item.Deleted = true; dbEntity.SaveChanges(); whBll = new WarehouseBLL(dbEntity); WarehouseInventory inventory = (from s in dbEntity.WarehouseInventories.Include("InvItems") where s.Gid == item.InvID && !s.Deleted select s).Single(); whBll.InventoryByWarehouseSku(inventory.WhID, item.SkuID); } return Json(true, JsonRequestBehavior.AllowGet); }
public JsonResult MoveItemDeleteDB(Guid itemID) { if (!base.CheckPrivilege("EnablePrepare"))//制表权限验证 return Json("NoPrivilege", JsonRequestBehavior.AllowGet); WarehouseMoveItem item = dbEntity.WarehouseMoveItems.Find(itemID); if (item == null || item.Deleted) { //已删除 } else { item.Deleted = true; dbEntity.SaveChanges(); WarehouseMoving moving = (from s in dbEntity.WarehouseMovings.Include("MoveItems") where s.Gid == item.MoveID && !s.Deleted select s).Single(); whBll = new WarehouseBLL(dbEntity); whBll.InventoryByWarehouseSku(moving.OldWhID, item.SkuID); whBll.InventoryByWarehouseSku(moving.NewWhID, item.SkuID); } return Json(true, JsonRequestBehavior.AllowGet); }
public ActionResult InvItemAddDB(WarehouseInvItem model) { WarehouseInvItem newItem = (from i in dbEntity.WarehouseInvItems where i.InvID == model.InvID && i.SkuID == model.SkuID && i.ShelfID == model.ShelfID select i).SingleOrDefault(); if (newItem == null) { newItem = new WarehouseInvItem { InvID = model.InvID, SkuID = model.SkuID, ShelfID = model.ShelfID, TrackLot = model.TrackLot, Quantity = model.Quantity, Remark = model.Remark }; dbEntity.WarehouseInvItems.Add(newItem); } else if (newItem.Deleted) { newItem.Deleted = false; newItem.TrackLot = model.TrackLot; newItem.Quantity = model.Quantity; newItem.Remark = model.Remark; } else { return Error("记录冲突", Url.Action("InventoryEdit", new { invID = model.InvID })); } dbEntity.SaveChanges(); WarehouseInventory inventory = (from s in dbEntity.WarehouseInventories.Include("InvItems") where s.Gid == newItem.InvID && !s.Deleted select s).Single(); inventory.Quantity = inventory.InvItems.Select(item => item.Quantity).Sum(); dbEntity.SaveChanges(); whBll = new WarehouseBLL(dbEntity); whBll.InventoryByWarehouseSku(inventory.WhID, model.SkuID); return RedirectToAction("InventoryEdit", new { invID = model.InvID }); }
public ActionResult MoveItemEditDB(WarehouseMoveItem model) { if (!base.CheckPrivilege("EnablePrepare"))//制表权限验证 return RedirectToAction("ErrorPage", "Home", new { message = "Sorry you have no privilege to visit the Page" }); WarehouseMoveItem item = dbEntity.WarehouseMoveItems.Include("Moving").SingleOrDefault(i => i.Gid == model.Gid); if (item == null || item.Deleted) { return Error("记录不存在", Url.Action("MovingEdit", new { moveID = model.MoveID })); } if (item.Moving.Mstatus == (byte)ModelEnum.MovingStatus.CONFIRMED) { return Error("已确认,不能编辑", Url.Action("MovingEdit", new { moveID = item.MoveID })); } item.SkuID = model.SkuID; item.OldShelf = model.OldShelf; item.NewShelf = model.NewShelf; item.Quantity = model.Quantity; item.TrackLot = model.TrackLot; dbEntity.SaveChanges(); WarehouseMoving moving = (from s in dbEntity.WarehouseMovings.Include("MoveItems") where s.Gid == item.MoveID && !s.Deleted select s).Single(); moving.Total = moving.MoveItems.Select(i => i.Quantity).Sum(); dbEntity.SaveChanges(); whBll = new WarehouseBLL(dbEntity); whBll.InventoryByWarehouseSku(moving.OldWhID, item.SkuID); whBll.InventoryByWarehouseSku(moving.NewWhID, item.SkuID); return RedirectToAction("MovingEdit", new { moveID = item.MoveID }); }
public RedirectToRouteResult MoveItemAddDB(WarehouseMoveItem model) { if (!base.CheckPrivilege("EnablePrepare"))//制表权限验证 return RedirectToAction("ErrorPage", "Home", new { message = "Sorry you have no privilege to visit the Page" }); WarehouseMoveItem item = new WarehouseMoveItem { SkuID = model.SkuID, OldShelf = model.OldShelf, NewShelf = model.NewShelf, Quantity = model.Quantity, TrackLot = model.TrackLot, MoveID = model.MoveID }; ///移货位数量不能大于移库单总数量判断 ////// ///// dbEntity.WarehouseMoveItems.Add(item); dbEntity.SaveChanges(); WarehouseMoving moving = (from s in dbEntity.WarehouseMovings.Include("MoveItems") where s.Gid == item.MoveID && !s.Deleted select s).Single(); moving.Total = moving.MoveItems.Select(i => i.Quantity).Sum(); dbEntity.SaveChanges(); whBll = new WarehouseBLL(dbEntity); whBll.InventoryByWarehouseSku(moving.OldWhID, item.SkuID); whBll.InventoryByWarehouseSku(moving.NewWhID, item.SkuID); return RedirectToAction("MovingEdit", new { moveID = model.MoveID }); }
public ActionResult OutItemEditDB(WarehouseOutItem model) { if (!base.CheckPrivilege("EnablePrepare"))//制表权限验证 return RedirectToAction("ErrorPage", "Home", new { message = "Sorry you have no privilege to visit the Page" }); if (model.Quantity == 0m) { return Error("数量必须大于0", Url.Action("StockOutEdit", new { outID = model.OutID })); } WarehouseOutItem temp; temp = (from o in dbEntity.WarehouseOutItems where o.Gid == model.Gid && !o.Deleted select o).SingleOrDefault(); if (temp == null) { return Error("记录不存在", Url.Action("StockOutEdit", new { outID = model.OutID })); } temp.TrackLot = model.TrackLot; temp.Quantity = model.Quantity; temp.ShelfID = model.ShelfID; dbEntity.SaveChanges(); WarehouseStockOut stockOut = (from s in dbEntity.WarehouseStockOuts.Include("StockOutItems") where s.Gid == temp.OutID && !s.Deleted select s).Single(); stockOut.Total = stockOut.StockOutItems.Select(item => item.Quantity).Sum(); dbEntity.SaveChanges(); whBll = new WarehouseBLL(dbEntity); whBll.InventoryByWarehouseSku(stockOut.WhID, model.SkuID); return RedirectToAction("StockOutEdit", new { temp.OutID }); }
public JsonResult InItemDeleteDB(Guid itemID) { if (!base.CheckPrivilege("EnablePrepare"))//制表权限验证,有制表权限就能删除明细条目,而不是根据入库单的删除权限 return Json("NoPrivilege", JsonRequestBehavior.AllowGet); WarehouseInItem inItem = dbEntity.WarehouseInItems.Find(itemID); if (inItem == null || inItem.Deleted) { //不存在记录 } else { inItem.Deleted = true; dbEntity.SaveChanges(); WarehouseStockIn stockIn = (from s in dbEntity.WarehouseStockIns.Include("StockInItems") where s.Gid == inItem.InID && !s.Deleted select s).Single(); whBll = new WarehouseBLL(dbEntity); whBll.InventoryByWarehouseSku(stockIn.WhID, inItem.SkuID); } return Json(true, JsonRequestBehavior.AllowGet); }
public ActionResult InItemEditDB(WarehouseInItem model) { if (!base.CheckPrivilege("EnablePrepare"))//制表权限验证 return RedirectToAction("ErrorPage", "Home", new { message = "Sorry you have no privilege to visit the Page" }); if (model.Quantity == 0m) { return Error("数量必须大于零", Url.Action("InItemEdit", new { itemID = model.Gid })); } WarehouseInItem inItem = dbEntity.WarehouseInItems.Find(model.Gid); if (inItem == null || inItem.Deleted) { return Error("记录不存在", Url.Action("StockIn")); } else { inItem.SkuID = model.SkuID; inItem.ShelfID = model.ShelfID; inItem.TrackLot = model.TrackLot; inItem.Quantity = model.Quantity; inItem.Guarantee = model.Guarantee; inItem.GenBarcode = model.GenBarcode; dbEntity.SaveChanges(); WarehouseStockIn stockIn = (from s in dbEntity.WarehouseStockIns.Include("StockInItems") where s.Gid == inItem.InID && !s.Deleted select s).Single(); stockIn.Total = stockIn.StockInItems.Select(item => item.Quantity).Sum(); dbEntity.SaveChanges(); whBll = new WarehouseBLL(dbEntity); whBll.InventoryByWarehouseSku(stockIn.WhID, model.SkuID); return RedirectToAction("StockInEdit", new { inID = inItem.InID }); } }