Пример #1
0
        public JsonResult RemoveTransferDetail(int id)
        {
            var item = InventoryTransferDetail.Find(id);

            using (var scope = new TransactionScope()) {
                item.DeleteAndFlush();
            }

            return(Json(new {
                id = id,
                result = true
            }));
        }
Пример #2
0
        public ActionResult AddTransferItems(int id, string value)
        {
            var        entity         = InventoryTransfer.Find(id);
            SalesOrder sales_order    = null;
            int        sales_order_id = 0;
            int        count          = 0;

            if (entity.IsCompleted || entity.IsCancelled)
            {
                Response.StatusCode = 400;
                return(Content(Resources.ItemAlreadyCompletedOrCancelled));
            }

            if (int.TryParse(value, out sales_order_id))
            {
                sales_order = SalesOrder.TryFind(sales_order_id);
            }

            if (sales_order == null)
            {
                Response.StatusCode = 400;
                return(Content(Resources.SalesOrderNotFound));
            }

            using (var scope = new TransactionScope()) {
                foreach (var x in sales_order.Details)
                {
                    if (!x.Product.IsStockable)
                    {
                        continue;
                    }

                    var item = new InventoryTransferDetail {
                        Transfer    = entity,
                        Product     = x.Product,
                        ProductCode = x.ProductCode,
                        ProductName = x.ProductName,
                        Quantity    = x.Quantity,
                    };

                    item.Create();
                    count++;
                }
            }

            return(Json(new {
                id = id,
                value = string.Empty,
                itemsChanged = count
            }));
        }
Пример #3
0
        public JsonResult EditTransferDetailQuantity(int id, decimal value)
        {
            var detail = InventoryTransferDetail.Find(id);

            if (value >= 0)
            {
                detail.Quantity = value;

                using (var scope = new TransactionScope()) {
                    detail.UpdateAndFlush();
                }
            }

            return(Json(new {
                id = id,
                value = detail.Quantity
            }));
        }
Пример #4
0
        public JsonResult AddTransferDetail(int movement, int product)
        {
            var p = Product.Find(product);

            var item = new InventoryTransferDetail {
                Transfer    = InventoryTransfer.Find(movement),
                Product     = p,
                ProductCode = p.Code,
                ProductName = p.Name,
                Quantity    = 1
            };

            using (var scope = new TransactionScope()) {
                item.CreateAndFlush();
            }

            return(Json(new {
                id = item.Id
            }));
        }
Пример #5
0
 public ActionResult GetTransferItem(int id)
 {
     return(PartialView("Transfers/_DetailEditView", InventoryTransferDetail.Find(id)));
 }
Пример #6
0
        public ActionResult AddTransferItems(int id, string value)
        {
            var entity = InventoryTransfer.Find (id);
            SalesOrder sales_order = null;
            int sales_order_id = 0;
            int count = 0;

            if (entity.IsCompleted || entity.IsCancelled) {
                Response.StatusCode = 400;
                return Content (Resources.ItemAlreadyCompletedOrCancelled);
            }

            if (int.TryParse (value, out sales_order_id)) {
                sales_order = SalesOrder.TryFind (sales_order_id);
            }

            if (sales_order == null) {
                Response.StatusCode = 400;
                return Content (Resources.SalesOrderNotFound);
            }

            using (var scope = new TransactionScope ()) {
                foreach (var x in sales_order.Details) {
                    if (!x.Product.IsStockable)
                        continue;

                    var item = new InventoryTransferDetail {
                        Transfer = entity,
                        Product = x.Product,
                        ProductCode = x.ProductCode,
                        ProductName = x.ProductName,
                        Quantity = x.Quantity,
                    };

                    item.Create ();
                    count++;
                }
            }

            return Json (new {
                id = id,
                value = string.Empty,
                itemsChanged = count
            });
        }
Пример #7
0
        public JsonResult AddTransferDetail(int movement, int product)
        {
            var p = Product.Find (product);

            var item = new InventoryTransferDetail {
                Transfer = InventoryTransfer.Find (movement),
                Product = p,
                ProductCode = p.Code,
                ProductName = p.Name,
                Quantity = 1
            };

            using (var scope = new TransactionScope ()) {
                item.CreateAndFlush ();
            }

            return Json (new {
                id = item.Id
            });
        }