public ActionResult _FilterPost(PurchaseOrderAmendmentFilterViewModel vm)
        {
            List <PurchaseOrderRateAmendmentLineViewModel> temp = _PurchaseOrderRateAmendmentLineService.GetPurchaseOrderLineForMultiSelect(vm).ToList();
            PurchaseOrderAmendmentMasterDetailModel        svm  = new PurchaseOrderAmendmentMasterDetailModel();

            svm.PurchaseOrderRateAmendmentLineViewModel = temp;
            return(PartialView("_Results", svm));
        }
        public ActionResult _ForOrder(int id, int?sid)
        {
            PurchaseOrderAmendmentFilterViewModel vm = new PurchaseOrderAmendmentFilterViewModel();

            vm.PurchaseOrderAmendmentHeaderId = id;
            vm.SupplierId = sid;
            return(PartialView("_Filters", vm));
        }
Esempio n. 3
0
        public IEnumerable <PurchaseOrderRateAmendmentLineViewModel> GetPurchaseOrderLineForMultiSelect(PurchaseOrderAmendmentFilterViewModel svm)
        {
            string[] ProductIdArr = null;
            if (!string.IsNullOrEmpty(svm.ProductId))
            {
                ProductIdArr = svm.ProductId.Split(",".ToCharArray());
            }
            else
            {
                ProductIdArr = new string[] { "NA" };
            }

            string[] SaleOrderIdArr = null;
            if (!string.IsNullOrEmpty(svm.PurchaseOrderId))
            {
                SaleOrderIdArr = svm.PurchaseOrderId.Split(",".ToCharArray());
            }
            else
            {
                SaleOrderIdArr = new string[] { "NA" };
            }

            string[] ProductGroupIdArr = null;
            if (!string.IsNullOrEmpty(svm.ProductGroupId))
            {
                ProductGroupIdArr = svm.ProductGroupId.Split(",".ToCharArray());
            }
            else
            {
                ProductGroupIdArr = new string[] { "NA" };
            }

            string[] Dim1Id = null;
            if (!string.IsNullOrEmpty(svm.ProductGroupId))
            {
                Dim1Id = svm.ProductGroupId.Split(",".ToCharArray());
            }
            else
            {
                Dim1Id = new string[] { "NA" };
            }

            string[] Dim2Id = null;
            if (!string.IsNullOrEmpty(svm.ProductGroupId))
            {
                Dim2Id = svm.ProductGroupId.Split(",".ToCharArray());
            }
            else
            {
                Dim2Id = new string[] { "NA" };
            }

            var temp = (from p in db.ViewPurchaseOrderBalanceForInvoice
                        join t3 in db.PurchaseOrderLine on p.PurchaseOrderLineId equals t3.PurchaseOrderLineId into table3
                        from tab3 in table3.DefaultIfEmpty()
                        join t2 in db.PurchaseOrderHeader on p.PurchaseOrderHeaderId equals t2.PurchaseOrderHeaderId
                        join product in db.Product on p.ProductId equals product.ProductId into table2
                        from tab2 in table2.DefaultIfEmpty()
                        join AL in db.PurchaseOrderRateAmendmentLine on p.PurchaseOrderLineId equals AL.PurchaseOrderLineId into ALTable
                        from AlTab in ALTable.DefaultIfEmpty()
                        where (string.IsNullOrEmpty(svm.ProductId) ? 1 == 1 : ProductIdArr.Contains(p.ProductId.ToString())) &&
                        (string.IsNullOrEmpty(svm.PurchaseOrderId) ? 1 == 1 : SaleOrderIdArr.Contains(p.PurchaseOrderHeaderId.ToString())) &&
                        (string.IsNullOrEmpty(svm.ProductGroupId) ? 1 == 1 : ProductGroupIdArr.Contains(tab2.ProductGroupId.ToString())) &&
                        (string.IsNullOrEmpty(svm.Dimension1Id) ? 1 == 1 : Dim1Id.Contains(p.Dimension1Id.ToString())) &&
                        (string.IsNullOrEmpty(svm.Dimension2Id) ? 1 == 1 : Dim2Id.Contains(p.Dimension2Id.ToString())) &&
                        p.BalanceQty > 0 && ((svm.SupplierId.HasValue && svm.SupplierId.Value > 0) ? p.SupplierId == svm.SupplierId : 1 == 1) &&
                        (svm.UpToDate.HasValue ? t2.DocDate <= svm.UpToDate : 1 == 1)
                        orderby t2.DocDate, t2.DocNo, tab3.Sr
                        select new PurchaseOrderRateAmendmentLineViewModel
            {
                Dimension1Name = tab3.Dimension1.Dimension1Name,
                Dimension2Name = tab3.Dimension2.Dimension2Name,
                UnitName = tab2.Unit.UnitName,
                DealUnitName = tab3.DealUnit.UnitName,
                DealQty = p.BalanceQty * tab3.UnitConversionMultiplier,
                UnitConversionMultiplier = tab3.UnitConversionMultiplier,
                PurchaseOrderRate = p.Rate,
                AmendedRate = (svm.Rate == 0 ? p.Rate : svm.Rate),
                Qty = p.BalanceQty,
                PurchaseOrderDocNo = p.PurchaseOrderNo,
                ProductName = tab2.ProductName,
                ProductId = p.ProductId,
                PurchaseOrderAmendmentHeaderId = svm.PurchaseOrderAmendmentHeaderId,
                PurchaseOrderLineId = p.PurchaseOrderLineId,
                unitDecimalPlaces = tab2.Unit.DecimalPlaces,
                dealUnitDecimalPlaces = tab3.DealUnit.DecimalPlaces,
                AAmended = (AlTab == null ? false : true)
            }
                        );

            return(temp);
        }