protected virtual void INSiteFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            INSiteFilter filter = (INSiteFilter)e.Row;

            INItemList.SetProcessDelegate <INIntegrityCheck>(delegate(INIntegrityCheck graph, INItemSiteSummary itemsite)
            {
                graph.Clear(PXClearOption.PreserveTimeStamp);
                graph.IntegrityCheckProc(itemsite, filter != null && filter.RebuildHistory == true ? filter.FinPeriodID : null, filter.ReplanBackorders == true);
            });
            PXUIFieldAttribute.SetEnabled <INSiteFilter.finPeriodID>(sender, null, filter.RebuildHistory == true);
        }
        protected virtual IEnumerable initemlist()
        {
            INSiteFilter filter = Filter.Current;

            if (filter == null)
            {
                yield break;
            }
            bool found = false;

            foreach (INUpdateStdCostRecord item in INItemList.Cache.Inserted)
            {
                found = true;
                yield return(item);
            }
            if (found)
            {
                yield break;
            }


            if (Filter.Current.SiteID == null)
            {
                //Non-Stock:

                PXSelectBase <InventoryItem> inventoryItems = new PXSelect <InventoryItem, Where <InventoryItem.stkItem, Equal <boolFalse>,
                                                                                                  And <InventoryItem.itemStatus, NotEqual <INItemStatus.inactive>, And <InventoryItem.itemStatus, NotEqual <INItemStatus.toDelete>,
                                                                                                                                                                        And <InventoryItem.pendingStdCostDate, LessEqual <Current <INSiteFilter.pendingStdCostDate> > > > > > >(this);

                foreach (InventoryItem item in inventoryItems.Select())
                {
                    INUpdateStdCostRecord record = new INUpdateStdCostRecord();
                    record.InventoryID        = item.InventoryID;
                    record.RecordID           = 1;
                    record.InvtAcctID         = item.InvtAcctID;
                    record.InvtSubID          = item.InvtSubID;
                    record.PendingStdCost     = item.PendingStdCost;
                    record.PendingStdCostDate = item.PendingStdCostDate;
                    record.StdCost            = item.StdCost;

                    yield return(INItemList.Insert(record));
                }

                PXSelectBase <INItemSite> itemSites = new PXSelectJoin <INItemSite,
                                                                        InnerJoin <InventoryItem, On <InventoryItem.inventoryID, Equal <INItemSite.inventoryID>,
                                                                                                      And <Match <InventoryItem, Current <AccessInfo.userName> > > > >,
                                                                        Where <INItemSite.valMethod, Equal <INValMethod.standard>,
                                                                               And <INItemSite.siteStatus, Equal <INItemStatus.active>,
                                                                                    And <InventoryItem.itemStatus, NotEqual <INItemStatus.inactive>, And <InventoryItem.itemStatus, NotEqual <INItemStatus.toDelete>,
                                                                                                                                                          And <INItemSite.pendingStdCostDate, LessEqual <Current <INSiteFilter.pendingStdCostDate> > >
                                                                                                                                                          > > > > >(this);

                foreach (INItemSite item in itemSites.Select())
                {
                    INUpdateStdCostRecord record = new INUpdateStdCostRecord();
                    record.InventoryID        = item.InventoryID;
                    record.SiteID             = item.SiteID;
                    record.RecordID           = item.SiteID;
                    record.InvtAcctID         = item.InvtAcctID;
                    record.InvtSubID          = item.InvtSubID;
                    record.PendingStdCost     = item.PendingStdCost;
                    record.PendingStdCostDate = item.PendingStdCostDate;
                    record.StdCost            = item.StdCost;
                    record.StdCostOverride    = item.StdCostOverride;

                    yield return(INItemList.Insert(record));
                }
            }
            else
            {
                //Stock

                PXSelectBase <INItemSite> s = new PXSelectJoin <INItemSite,
                                                                InnerJoin <InventoryItem, On <InventoryItem.inventoryID, Equal <INItemSite.inventoryID>,
                                                                                              And <Match <InventoryItem, Current <AccessInfo.userName> > > > >,
                                                                Where <INItemSite.valMethod, Equal <INValMethod.standard>,
                                                                       And <INItemSite.siteStatus, Equal <INItemStatus.active>,
                                                                            And <INItemSite.siteID, Equal <Current <INSiteFilter.siteID> >,
                                                                                 And <InventoryItem.itemStatus, NotEqual <INItemStatus.inactive>, And <InventoryItem.itemStatus, NotEqual <INItemStatus.toDelete>,
                                                                                                                                                       And <Where <INItemSite.pendingStdCostDate, LessEqual <Current <INSiteFilter.pendingStdCostDate> >, Or <Current <INSiteFilter.revalueInventory>, Equal <boolTrue> > >
                                                                                                                                                            > > > > > > >(this);

                foreach (INItemSite item in s.Select())
                {
                    INUpdateStdCostRecord record = new INUpdateStdCostRecord();
                    record.InventoryID        = item.InventoryID;
                    record.SiteID             = item.SiteID;
                    record.RecordID           = item.SiteID;
                    record.InvtAcctID         = item.InvtAcctID;
                    record.InvtSubID          = item.InvtSubID;
                    record.PendingStdCost     = item.PendingStdCost;
                    record.PendingStdCostDate = item.PendingStdCostDate;
                    record.StdCost            = item.StdCost;
                    record.StdCostOverride    = item.StdCostOverride;

                    yield return(INItemList.Insert(record));
                }
            }
        }