protected virtual IEnumerable addLocation(PXAdapter e)
        {
            if (this.LocationFilter.AskExt((graph, viewName) => graph.Views[viewName].Cache.Clear(), true) == WebDialogResult.OK)
            {
                var source =
                    this.LocationFilter.Current.EndLocationID == null
                                                ? PXSelect <INLocation,
                                                            Where <INLocation.siteID, Equal <Current <INPIClass.siteID> >,
                                                                   And <INLocation.locationCD, GreaterEqual <Required <INLocation.locationCD> > > > >
                    .Select(this,
                            this.LocationFilter.Cache.GetValueExt <INPILocationFilter.startLocationID>(
                                this.LocationFilter.Current).ToString())
                                                : PXSelect
                    <INLocation,
                     Where <INLocation.siteID, Equal <Current <INPIClass.siteID> >,
                            And <INLocation.locationCD, Between <Required <INLocation.locationCD>, Required <INLocation.locationCD> > > > >
                    .Select(this,
                            this.LocationFilter.Cache.GetValueExt <INPILocationFilter.startLocationID>(this.LocationFilter.Current).ToString(),
                            this.LocationFilter.Cache.GetValueExt <INPILocationFilter.endLocationID>(this.LocationFilter.Current).ToString());

                foreach (INLocation l in source)
                {
                    INPIClassLocation item = (INPIClassLocation)Locations.Cache.CreateInstance();
                    item.LocationID = l.LocationID;
                    Locations.Insert(item);
                }
            }
            return(e.Get());
        }
示例#2
0
        protected virtual IEnumerable addLocation(PXAdapter e)
        {
            if (this.LocationFilter.AskExt((graph, viewName) => graph.Views[viewName].Cache.Clear(), true) == WebDialogResult.OK)
            {
                var source =
                    this.LocationFilter.Current.EndLocationID == null
                                                ? PXSelectReadonly <INLocation,
                                                                    Where <INLocation.siteID, Equal <Current <INPIClass.siteID> >,
                                                                           And <INLocation.locationCD, GreaterEqual <Required <INLocation.locationCD> > > > >
                    .Select(this,
                            this.LocationFilter.Cache.GetValueExt <INPILocationFilter.startLocationID>(
                                this.LocationFilter.Current).ToString())
                                                : PXSelectReadonly
                    <INLocation,
                     Where <INLocation.siteID, Equal <Current <INPIClass.siteID> >,
                            And <INLocation.locationCD, Between <Required <INLocation.locationCD>, Required <INLocation.locationCD> > > > >
                    .Select(this,
                            this.LocationFilter.Cache.GetValueExt <INPILocationFilter.startLocationID>(this.LocationFilter.Current).ToString(),
                            this.LocationFilter.Cache.GetValueExt <INPILocationFilter.endLocationID>(this.LocationFilter.Current).ToString());

                HashSet <int?> existingLocations = PXSelect <INPIClassLocation,
                                                             Where <INPIClassLocation.pIClassID, Equal <Current <INPIClass.pIClassID> > > > .Select(this)
                                                   .Select(l => ((INPIClassLocation)l).LocationID)
                                                   .Where(l => l.HasValue)
                                                   .ToHashSet();

                foreach (INLocation l in source.RowCast <INLocation>().Where(s => !existingLocations.Contains(s.LocationID)))
                {
                    INPIClassLocation item = (INPIClassLocation)Locations.Cache.CreateInstance();
                    item.LocationID = l.LocationID;
                    Locations.Insert(item);
                }
            }
            return(e.Get());
        }
示例#3
0
        protected virtual void INLocation_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            INLocation row = e.Row as INLocation;

            if (row == null)
            {
                return;
            }

            if ((e.Operation & PXDBOperation.Command) != PXDBOperation.Delete && row.ProjectID != null && row.TaskID == null && row.Active == true)
            {
                INLocation anotherWildcardLocation = PXSelect <INLocation, Where <INLocation.locationID, NotEqual <Required <INLocation.locationID> >,
                                                                                  And <INLocation.projectID, Equal <Required <INLocation.projectID> >, And <INLocation.taskID, IsNull, And <INLocation.active, Equal <True> > > > > > .Select(this, row.LocationID, row.ProjectID);

                if (anotherWildcardLocation != null)
                {
                    PMProject project = PXSelect <PMProject, Where <PMProject.contractID, Equal <Required <PMProject.contractID> > > > .Select(this, row.ProjectID);

                    INSite warehouse = PXSelect <INSite, Where <INSite.siteID, Equal <Required <INSite.siteID> > > > .Select(this, anotherWildcardLocation.SiteID);

                    if (sender.RaiseExceptionHandling <INLocation.projectID>(e.Row, project.ContractCD, new PXSetPropertyException(Messages.ProjectWildcardLocationIsUsedIn, PXErrorLevel.Error, warehouse.SiteCD, anotherWildcardLocation.LocationCD)))
                    {
                        throw new PXRowPersistingException(PXDataUtils.FieldName <INLocation.projectID>(), row.ProjectID, Messages.ProjectWildcardLocationIsUsedIn, warehouse.SiteCD, anotherWildcardLocation.LocationCD);
                    }
                }
            }
            if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Delete)
            {
                INItemSite itemSite = PXSelect <INItemSite, Where <INItemSite.siteID, Equal <Current <INSite.siteID> >,
                                                                   And <Where <INItemSite.dfltReceiptLocationID, Equal <Required <INItemSite.dfltReceiptLocationID> >,
                                                                               Or <INItemSite.dfltShipLocationID, Equal <Required <INItemSite.dfltShipLocationID> > > > > > > .Select(this, row.LocationID, row.LocationID);

                if (itemSite != null)
                {
                    InventoryItem initem = PXSelect <InventoryItem, Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .Select(this, itemSite.InventoryID) ?? new InventoryItem();

                    if (sender.RaiseExceptionHandling <INLocation.locationID>(e.Row, row.LocationCD, new PXSetPropertyException(Messages.LocationInUseInItemWarehouseDetails, PXErrorLevel.Error, row.LocationCD.TrimEnd(), initem.InventoryCD.TrimEnd())))
                    {
                        throw new PXRowPersistingException(PXDataUtils.FieldName <INLocation.locationID>(), row.LocationID, Messages.LocationInUseInItemWarehouseDetails, row.LocationCD.TrimEnd(), initem.InventoryCD.TrimEnd());
                    }
                }

                INPIClassLocation piLocation = PXSelectJoin <INPIClassLocation, InnerJoin <INPIClass, On <INPIClass.pIClassID, Equal <INPIClassLocation.pIClassID> > >, Where <INPIClass.siteID, Equal <Current <INSite.siteID> >,
                                                                                                                                                                               And <INPIClassLocation.locationID, Equal <Required <INPIClassLocation.locationID> > > > > .Select(this, row.LocationID);

                if (piLocation != null)
                {
                    if (sender.RaiseExceptionHandling <INLocation.locationID>(e.Row, row.LocationCD, new PXSetPropertyException(Messages.LocationInUseInPIType, PXErrorLevel.Error, row.LocationCD.TrimEnd(), piLocation.PIClassID.TrimEnd())))
                    {
                        throw new PXRowPersistingException(PXDataUtils.FieldName <INLocation.locationID>(), row.LocationID, Messages.LocationInUseInPIType, row.LocationCD.TrimEnd(), piLocation.PIClassID.TrimEnd());
                    }
                }
            }
        }