Beispiel #1
0
        private static Guid WarehouseGuidSelected; //选中的仓库

        #endregion Fields

        #region Constructors

        //
        // GET: /Order/
        public OrderController()
        {
            warehouseBll = new WarehouseBLL(dbEntity);
            orderBll = new OrderBLL(dbEntity);
        }
 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 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 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 JsonResult MovingDeleteDB(Guid moveID)
 {
     if (!base.CheckPrivilege("EnableDelete"))//制表权限验证
         return Json("NoPrivilege", JsonRequestBehavior.AllowGet);
     whBll = new WarehouseBLL(dbEntity);
     int state = whBll.MovingDiscard(moveID, CurrentSession.UserID);
     bool result = (state == 0);
     return Json(result, JsonRequestBehavior.AllowGet);
 }
 public JsonResult MovingConfirmDB(Guid moveID)
 {
     if (!base.CheckPrivilege("EnableApprove"))//权限验证
         return Json("NoPrivilege", JsonRequestBehavior.AllowGet);
     whBll = new WarehouseBLL(dbEntity);
     int result = whBll.MoveingConfirm(moveID, CurrentSession.UserID);
     return Json(result, JsonRequestBehavior.AllowGet);
 }
Beispiel #10
0
 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 });
 }
Beispiel #11
0
 /// <summary>
 /// 确认出库单到数据库
 /// </summary>
 /// <param name="outID">出库单ID</param>
 /// <returns></returns>0 1 2 3 4 5 11:确认成功,订单用户无订阅消息12:邮件提醒消息队列添加失败13:短信提醒消息队列添加失败
 public JsonResult StockOutConfirmDB(Guid outID)
 {
     if (!base.CheckPrivilege("EnableApprove"))//确认出库单权限验证
         return Json("NoPrivilege", JsonRequestBehavior.AllowGet);
     whBll = new WarehouseBLL(dbEntity);
     int result = whBll.StockOutConfirm(outID, CurrentSession.UserID);
     //add by tianyou 2011/10/25 设置消息队列
     int _SetMessagePending ;//判断消息队列设置返回值
     if (result == 0)
     {
         //验证单据类型是否为订单 RefType==0?
         WarehouseStockOut oStockOut = dbEntity.WarehouseStockOuts.Where(o => o.Gid == outID && o.RefType == (byte)ModelEnum.NoteType.ORDER && o.Deleted == false).FirstOrDefault();
         if (oStockOut != null)
         {//如果是订单 则判断用户是否订阅发货消息
             OrderInformation oOrder = dbEntity.OrderInformations.Where(o => o.Deleted == false && o.Gid == oStockOut.RefID).FirstOrDefault();
             if (oOrder != null)
             { 
                 //设置消息队列
                 _SetMessagePending = whBll.DeliveryMessageSet(oOrder.UserID, 1, oOrder.Gid,CurrentSession.Culture);
                 result = _SetMessagePending;
             }
         }
     }
     return Json(result, JsonRequestBehavior.AllowGet);
 }
Beispiel #12
0
 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);
 }
Beispiel #13
0
 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 });
     }
 }
Beispiel #14
0
        public string outWare()
        {
            Guid? userid = CurrentSession.UserID;
            Guid gInWareId;
            WarehouseBLL oWarehouseBLL = new WarehouseBLL(dbEntity);
            int nResult = oWarehouseBLL.GenerateStockInFromPurchase(gPurId, userid, out gInWareId);
            if (nResult == 0)
            {
                string sInCode = (from s in dbEntity.WarehouseStockIns
                                  where s.Gid == gInWareId
                                  select s.Code).FirstOrDefault();

            }
            else
            {

            }
            return "success";
        }