Ejemplo n.º 1
0
        public PartialViewResult _AddPalletes()
        {
            int?receivedQty = 0;

            if (!string.IsNullOrEmpty(Request.Params["rec_qty"]))
            {
                receivedQty = int.Parse(Request.Params["rec_qty"]);
            }

            ViewBag.QuantityEnabled = true;
            int qty = int.Parse(Request.Params["qty"]);

            ViewBag.ProcessedQuantity = receivedQty;
            int prodId = int.Parse(Request.Params["pid"]);

            ViewBag.RequiredQuantity = qty - receivedQty;
            ViewBag.PalletPerCase    = _productServices.GetProductMasterById(prodId).ProductsPerCase ?? 1;
            decimal caseperpallet = ((decimal)ViewBag.RequiredQuantity / (decimal?)ViewBag.PalletPerCase ?? 1);

            if (ViewBag.RequiredQuantity < 0)
            {
                ViewBag.RequiredQuantity = 0;
            }
            if (caseperpallet < 0)
            {
                caseperpallet = 0;
            }
            ViewBag.cases = caseperpallet;
            if (Request.UrlReferrer.AbsolutePath.Contains("PurchaseOrders"))
            {
                ViewBag.Locations       = new SelectList(_productLookupService.GetAllValidProductLocations(CurrentTenantId, CurrentWarehouseId), "LocationId", "LocationCode");
                ViewBag.QuantityEnabled = false;
            }

            if (Request.UrlReferrer.AbsolutePath.Contains("SalesOrders") || Request.UrlReferrer.AbsolutePath.Contains("WorksOrders"))
            {
                ViewBag.QuantityEnabled = false;
                var palletTracking = _tenantLocationServices.GetTenantLocationById(CurrentWarehouseId);
                if (palletTracking != null)
                {
                    ViewBag.palletTracking   = palletTracking.PalletTrackingScheme;
                    ViewBag.palletTrackingId = (int)palletTracking.PalletTrackingScheme;
                    int palletTrackingIds = (int)palletTracking.PalletTrackingScheme;
                    if (palletTrackingIds == 3)
                    {
                        var date = _salesServices.GetSerialByPalletTrackingScheme(prodId, palletTrackingIds, CurrentTenantId, CurrentWarehouseId)?.ExpiryDate;
                        if (date != null)
                        {
                            ViewBag.MoYy    = date.Value.Day + "/" + date.Value.Month + "/" + date.Value.Year;
                            ViewBag.expDate = date;
                        }
                    }
                    if (palletTrackingIds == 4)
                    {
                        var date = _salesServices.GetSerialByPalletTrackingScheme(prodId, palletTrackingIds, CurrentTenantId, CurrentWarehouseId)?.ExpiryDate;
                        if (date != null)
                        {
                            ViewBag.MoYy    = date.Value.ToString("MMMM", CultureInfo.InvariantCulture) + "-" + date.Value.Year;
                            ViewBag.expDate = date;
                        }
                    }
                    else
                    {
                        ViewBag.Serial = _salesServices.GetSerialByPalletTrackingScheme(prodId, palletTrackingIds, CurrentTenantId, CurrentWarehouseId)?.PalletSerial;
                    }
                }
            }


            ViewBag.product = _productServices.GetProductMasterById(prodId);
            return(PartialView());
        }