示例#1
0
        public ActionResult ConfirmLotSerialNumbers(int id)
        {
            var entity = LotSerialRequirement.Find(id);
            var qry    = from x in LotSerialTracking.Queryable
                         where x.Source == entity.Source &&
                         x.Reference == entity.Reference &&
                         x.Warehouse.Id == entity.Warehouse.Id &&
                         x.Product.Id == entity.Product.Id
                         select x;
            decimal sum = qry.Count() > 0 ? qry.Sum(x => x.Quantity) : 0;

            if (entity.Quantity != sum)
            {
                Response.StatusCode = 400;
                return(Content(Resources.ValidationFailed));
            }

            using (var scope = new TransactionScope()) {
                if (entity.Source == TransactionType.InventoryTransfer)
                {
                    var transfer = InventoryTransfer.Find(entity.Reference);

                    foreach (var serial in qry)
                    {
                        var item = new LotSerialTracking {
                            Source         = serial.Source,
                            Reference      = serial.Reference,
                            Date           = serial.Date,
                            Warehouse      = transfer.To,
                            Product        = serial.Product,
                            Quantity       = -serial.Quantity,
                            LotNumber      = serial.LotNumber,
                            ExpirationDate = serial.ExpirationDate,
                            SerialNumber   = serial.SerialNumber
                        };

                        item.Create();
                    }
                }

                entity.DeleteAndFlush();
            }

            return(Json(new {
                id = id,
                result = true
            }));
        }
示例#2
0
        public ActionResult EditTransfer(int id)
        {
            var item = InventoryTransfer.Find(id);

            if (item.IsCompleted || item.IsCancelled)
            {
                return(RedirectToAction("Transfer", new {
                    id = item.Id
                }));
            }

            if (Request.IsAjaxRequest())
            {
                return(PartialView("Transfers/_MasterEditView", item));
            }
            else
            {
                return(View("Transfers/Edit", item));
            }
        }
示例#3
0
        public ViewResult PrintTransfer(int id)
        {
            var item = InventoryTransfer.Find(id);

            return(View("Transfers/Print", item));
        }