コード例 #1
0
ファイル: LCMValuationMaint.cs プロジェクト: JeffJave/Ipevo
        public IEnumerable detailsView()
        {
            //var lastFinPeriod = DateTime.Now.AddMonths(-1).ToString("yyyyMM");

            var filter = MasterViewFilter.Current?.FinPeriodID;

            if (filter == null)
            {
                filter = ((DateTime)Accessinfo.BusinessDate).AddMonths(-1).ToString("yyyyMM");
            }

            PXSelectBase <LCMValuation> command = new SelectFrom <LCMValuation> .View.ReadOnly(this);

            var result = new PXDelegateResult();

            foreach (PXResult <LCMValuation> row in command.Select())
            {
                if (((LCMValuation)row).FinPeriodID == filter)
                {
                    result.Add(row);
                }
            }

            return(result);
        }
コード例 #2
0
        protected virtual IEnumerable viewHandler()
        {
            if (intView == null)
            {
                intView = CreateIntView(View.Graph);
            }
            int startRow = PXView.StartRow;
            int num      = 0;
            PXDelegateResult pXDelegateResult = new PXDelegateResult();

            foreach (object obj in intView.Select(null, null, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startRow, PXView.MaximumRows, ref num))
            {
                var statu  = PXResult.Unwrap <RowToSelect>(obj);
                var statu1 = statu;
                var statu2 = (Cache.Locate(statu) as RowToSelect);
                if (statu2 != null)
                {
                    bool?value = (Cache.GetValue(statu2, Selected) as bool?);
                    if (value.GetValueOrDefault() & value.HasValue)
                    {
                        Cache.RestoreCopy(statu2, statu);
                        Cache.SetValue(statu2, Selected, true);
                        statu1 = statu2;
                    }
                }
                pXDelegateResult.Add(statu1);
            }
            PXView.StartRow = 0;
            if (PXView.ReverseOrder)
            {
                pXDelegateResult.Reverse();
            }
            pXDelegateResult.IsResultSorted = true;
            return(pXDelegateResult);
        }
コード例 #3
0
        protected virtual IEnumerable result()
        {
            var filter = Filter.Current;

            if (!ValidateFilter(filter))
            {
                return(new LumDeadStockEnqResult[0]);
            }

            GetStartDates(filter, out DateTime? inStockSince, out DateTime? noSalesSince);
            PXSelectBase <INSiteStatus> command = CreateCommand();
            var parameters = AddFilters(filter, command, inStockSince, noSalesSince);

            var singleRow = GetRowByPrimaryKeys(command, filter, inStockSince, noSalesSince);

            if (singleRow != null)
            {
                return new LumDeadStockEnqResult[] { singleRow }
            }
            ;

            bool userSortsFilters = ValidateViewSortsFilters();

            var result = new PXDelegateResult();

            result.IsResultFiltered = !userSortsFilters;
            result.IsResultSorted   = !userSortsFilters;
            int resultCounter = 0;

            foreach (PXResult <INSiteStatus> row in command.Select(parameters.ToArray()))
            {
                LumDeadStockEnqResult newResult = MakeResult(row, inStockSince, noSalesSince);

                if (newResult == null)
                {
                    continue;
                }

                result.Add(new PXResult <LumDeadStockEnqResult, InventoryItem>(newResult, row.GetItem <InventoryItem>()));
                resultCounter++;

                if (!userSortsFilters && (PXView.StartRow + PXView.MaximumRows) <= resultCounter)
                {
                    break;
                }
            }

            return(result);
        }
コード例 #4
0
        public virtual IEnumerable Storages()
        {
            var result = new PXDelegateResult();

            result.IsResultSorted    = true;
            result.IsResultTruncated = Filter.Current.ExpandByLotSerialNbr == false;

            PXSelectBase <StoragePlaceStatus> byLocationSelect =
                new SelectFrom <StoragePlaceStatus>
                .Where <
                    StoragePlaceFilter.siteID.FromCurrent.NoDefault.IsEqual <StoragePlaceStatus.siteID>
                    .And <StoragePlaceStatus.qty.IsGreater <Zero> >
                    .And <
                        Not <FeatureInstalled <FeaturesSet.wMSCartTracking> >
                        .Or <StoragePlaceFilter.showLocations.FromCurrent.NoDefault.IsEqual <True> > .And <StoragePlaceStatus.isCart.IsEqual <False> >
                        .Or <StoragePlaceFilter.showCarts.FromCurrent.NoDefault.IsEqual <True> > .And <StoragePlaceStatus.isCart.IsEqual <True> > >
                    >
                .AggregateTo <
                    GroupBy <StoragePlaceStatus.siteCD>,
                    GroupBy <StoragePlaceStatus.storageCD>,
                    GroupBy <StoragePlaceStatus.isCart>,
                    GroupBy <StoragePlaceStatus.active>,
                    GroupBy <StoragePlaceStatus.inventoryCD>,
                    GroupBy <StoragePlaceStatus.subItemID>,
                    Sum <StoragePlaceStatus.qty> >
                .OrderBy <
                    StoragePlaceStatus.isCart.Asc,
                    StoragePlaceStatus.siteCD.Asc,
                    StoragePlaceStatus.storageCD.Desc,
                    StoragePlaceStatus.active.Desc,
                    StoragePlaceStatus.inventoryCD.Asc,
                    StoragePlaceStatus.subItemID.Asc,
                    StoragePlaceStatus.qty.Desc>
                .View(this);

            if (Filter.Current.StorageID != null)
            {
                byLocationSelect.WhereAnd <Where <StoragePlaceFilter.storageID.FromCurrent.IsEqual <StoragePlaceStatus.storageID> > >();
            }
            if (Filter.Current.InventoryID != null)
            {
                byLocationSelect.WhereAnd <Where <StoragePlaceFilter.inventoryID.FromCurrent.IsEqual <StoragePlaceStatus.inventoryID> > >();
            }
            if (Filter.Current.SubItemID != null)
            {
                byLocationSelect.WhereAnd <Where <StoragePlaceFilter.subItemID.FromCurrent.IsEqual <StoragePlaceStatus.subItemID> > >();
            }

            int startRow   = PXView.StartRow;
            int totalRows  = 0;
            var byLocation = Filter.Current.ExpandByLotSerialNbr == true
                                ? byLocationSelect.SelectMain()
                                : byLocationSelect.View.Select(PXView.Currents, PXView.Parameters, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows).RowCast <StoragePlaceStatus>().ToArray();

            if (byLocation.Length > 0 && Filter.Current.ExpandByLotSerialNbr == true)
            {
                PXSelectBase <StoragePlaceStatusExpanded> byLotSerialSelect =
                    new SelectFrom <StoragePlaceStatusExpanded>
                    .Where <
                        StoragePlaceFilter.siteID.FromCurrent.NoDefault.IsEqual <StoragePlaceStatusExpanded.siteID>
                        .And <StoragePlaceStatusExpanded.qty.IsGreater <Zero> >
                        >
                    .AggregateTo <
                        GroupBy <StoragePlaceStatusExpanded.siteCD>,
                        GroupBy <StoragePlaceStatusExpanded.storageCD>,
                        GroupBy <StoragePlaceStatusExpanded.active>,
                        GroupBy <StoragePlaceStatusExpanded.inventoryCD>,
                        GroupBy <StoragePlaceStatusExpanded.subItemID>,
                        GroupBy <StoragePlaceStatusExpanded.lotSerialNbr>,
                        Sum <StoragePlaceStatusExpanded.qty> >
                    .OrderBy <
                        StoragePlaceStatusExpanded.siteCD.Asc,
                        StoragePlaceStatusExpanded.storageCD.Desc,
                        StoragePlaceStatusExpanded.active.Desc,
                        StoragePlaceStatusExpanded.inventoryCD.Asc,
                        StoragePlaceStatusExpanded.subItemID.Asc,
                        StoragePlaceStatusExpanded.lotSerialNbr.Asc,
                        StoragePlaceStatusExpanded.qty.Desc>
                    .View(this);

                if (Filter.Current.StorageID != null)
                {
                    byLotSerialSelect.WhereAnd <Where <StoragePlaceFilter.storageID.FromCurrent.IsEqual <StoragePlaceStatusExpanded.storageID> > >();
                }
                if (Filter.Current.InventoryID != null)
                {
                    byLotSerialSelect.WhereAnd <Where <StoragePlaceFilter.inventoryID.FromCurrent.IsEqual <StoragePlaceStatusExpanded.inventoryID> > >();
                }
                if (Filter.Current.SubItemID != null)
                {
                    byLotSerialSelect.WhereAnd <Where <StoragePlaceFilter.subItemID.FromCurrent.IsEqual <StoragePlaceStatusExpanded.subItemID> > >();
                }
                if (Filter.Current.LotSerialNbr != null)
                {
                    byLotSerialSelect.WhereAnd <Where <StoragePlaceFilter.lotSerialNbr.FromCurrent.IsEqual <StoragePlaceStatusExpanded.lotSerialNbr> > >();
                }

                var byLotSerial =
                    byLotSerialSelect
                    .SelectMain()
                    .Select(
                        r => new StoragePlaceStatus
                {
                    SplittedIcon = r.SplittedIcon,
                    SiteID       = r.SiteID,
                    SiteCD       = r.SiteCD,
                    LocationID   = r.LocationID,
                    CartID       = null,
                    StorageID    = r.StorageID,
                    StorageCD    = r.StorageCD,
                    Descr        = r.Descr,
                    IsCart       = false,
                    Active       = r.Active,
                    InventoryID  = r.InventoryID,
                    InventoryCD  = r.InventoryCD,
                    SubItemID    = r.SubItemID,
                    LotSerialNbr = r.LotSerialNbr,
                    ExpireDate   = r.ExpireDate,
                    Qty          = r.Qty,
                    BaseUnit     = r.BaseUnit
                })
                    .ToArray();

                if (byLotSerial.Length > 0)
                {
                    int locationIdx            = 1;
                    int lotSerIdx              = 0;
                    StoragePlaceStatus current = byLocation[0];
                    result.Add(current);
                    while (locationIdx < byLocation.Length || lotSerIdx < byLotSerial.Length)
                    {
                        if (locationIdx >= byLocation.Length ||
                            lotSerIdx < byLotSerial.Length &&
                            current.SiteID == byLotSerial[lotSerIdx].SiteID &&
                            current.StorageID == byLotSerial[lotSerIdx].StorageID &&
                            current.InventoryID == byLotSerial[lotSerIdx].InventoryID &&
                            current.SubItemID == byLotSerial[lotSerIdx].SubItemID)
                        {
                            result.Add(byLotSerial[lotSerIdx]);
                            lotSerIdx++;
                        }
                        else
                        {
                            current = byLocation[locationIdx];
                            result.Add(current);
                            locationIdx++;
                        }
                    }
                }
                else
                {
                    result.AddRange(byLocation);
                }
            }
            else
            {
                result.AddRange(byLocation);
            }

            PXView.StartRow = 0;
            return(result);
        }