예제 #1
0
        private void _SetUnboundValue <T>(ItemPickerMapping im, string value) where T : class, IBqlField
        {
            IIProductLineFilter filter = PXSelect <IIProductLineFilter, Where <IIProductLineFilter.productLineID, Equal <Current <IIProductLine.productLineID> >, And <IIProductLineFilter.filterID, Equal <Current <T> > > >, OrderBy <Asc <IIProductLineFilter.sortOrder> > > .Select(this, im.ProductLineID).RowCast <IIProductLineFilter>()?.FirstOrDefault();

            switch (filter?.MappingColumnNbr)
            {
            case 1: im.Column1 = value; return;

            case 2: im.Column2 = value; return;

            case 3: im.Column3 = value; return;

            case 4: im.Column4 = value; return;

            case 5: im.Column5 = value; return;

            case 6: im.Column6 = value; return;

            case 7: im.Column7 = value; return;

            case 8: im.Column8 = value; return;

            case 9: im.Column9 = value; return;
            }
        }
예제 #2
0
        private string _GetUnboundValue <T>(ItemPickerMapping im) where T : class, IBqlField
        {
            IIProductLineFilter filter = PXSelect <IIProductLineFilter, Where <IIProductLineFilter.productLineID, Equal <Current <IIProductLine.productLineID> >, And <IIProductLineFilter.filterID, Equal <Current <T> > > >, OrderBy <Asc <IIProductLineFilter.sortOrder> > > .Select(this, im.ProductLineID).RowCast <IIProductLineFilter>()?.FirstOrDefault();

            switch (filter?.MappingColumnNbr)
            {
            case 1: return(im.Column1);

            case 2: return(im.Column2);

            case 3: return(im.Column3);

            case 4: return(im.Column4);

            case 5: return(im.Column5);

            case 6: return(im.Column6);

            case 7: return(im.Column7);

            case 8: return(im.Column8);

            case 9: return(im.Column9);
            }

            return("");
        }
예제 #3
0
        protected virtual void IIProductLineFilter_RowInserting(PXCache sender, PXRowInsertingEventArgs e)
        {
            IIProductLineFilter cf = (IIProductLineFilter)e.Row;

            if ((cf == null) || (cf.ProductLineID == null))
            {
                return;
            }

            if (IIFilters.Select().Count >= IIProductLines.Current?.FiltersCount)
            {
                throw new PXException("You cannot add more that '{0}' filters. If you want to add more, change value in the 'Filters' combo", IIProductLines.Current?.FiltersCount);
            }
        }
예제 #4
0
        public virtual void IIProductLineFilter_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            IIProductLineFilter cf = (IIProductLineFilter)e.Row;

            if ((cf == null) || (cf.ProductLineID == null))
            {
                return;
            }

            if ((e.Operation & PXDBOperation.Command) != PXDBOperation.Insert)
            {
                return;
            }

            PXResultset <IIProductLineFilter> rsFilters = PXSelect <IIProductLineFilter, Where <IIProductLineFilter.productLineID, Equal <Required <IIProductLineFilter.productLineID> >, And <IIProductLineFilter.filterID, NotEqual <Required <IIProductLineFilter.filterID> >, And <IIProductLineFilter.mappingColumnNbr, IsNotNull> > >, OrderBy <Asc <IIProductLineFilter.mappingColumnNbr> > > .Select(this, cf.ProductLineID, cf.FilterID);

            if ((rsFilters?.Count == null) || (rsFilters?.Count == 0))
            {
                cf.MappingColumnNbr = 1;
            }
            else if (rsFilters.RowCast <IIProductLineFilter>()?.ElementAt(rsFilters.Count - 1)?.MappingColumnNbr < 9)
            {
                cf.MappingColumnNbr = rsFilters.RowCast <IIProductLineFilter>()?.ElementAt(rsFilters.Count - 1)?.MappingColumnNbr + 1;
            }
            else if (rsFilters?.Count == 9)
            {
                throw new PXRowPersistingException("Mapping Column Nbr", cf.MappingColumnNbr, "There are already 9 filters. You cannot have more than 9 filters.");
            }
            else // find a hole
            {
                int curNum = 0;
                foreach (IIProductLineFilter f in rsFilters)
                {
                    if (f.MappingColumnNbr > (curNum + 1))
                    {
                        cf.MappingColumnNbr = curNum + 1;
                        break;
                    }
                    else
                    {
                        curNum++;
                    }
                }
            }
        }
예제 #5
0
        protected virtual void IIProductLineFilter_RowDeleting(PXCache sender, PXRowDeletingEventArgs e)
        {
            IIProductLineFilter cf = (IIProductLineFilter)e.Row;

            // Checking whether the deletion has been initiated from the UI
            if (!e.ExternalCall)
            {
                return;
            }
            if (sender.GetStatus(cf) == PXEntryStatus.InsertedDeleted)
            {
                return; // if inserted and then immediately deleted - the checks below are not needed
            }
            // Asking for confirmation on an attempt to delete a
            // shipment line other than the gift card line
            if (IIFilters.Ask("Confirm Delete", "Are you sure you want to delete the filter?", MessageButtons.YesNo) != WebDialogResult.Yes)
            {
                e.Cancel = true;
                return;
            }

            ItemPickerMappingEntry im_graph = PXGraph.CreateInstance <ItemPickerMappingEntry>();

            im_graph.ItemPickerMappings.Current = im_graph.ItemPickerMappings.Search <IIProductLine.productLineID>(cf.ProductLineID);
            PXResultset <ItemPickerMapping> rsMappings = PXSelect <ItemPickerMapping, Where <ItemPickerMapping.productLineID, Equal <Required <ItemPickerMapping.productLineID> > >, OrderBy <Asc <ItemPickerMapping.inventoryID> > > .Select(im_graph, cf.ProductLineID);

            foreach (ItemPickerMapping im in rsMappings)
            {
                bool bError = false;
                if (cf.FilterID == IIProductLines.Current.UnboundColumn1)
                {
                    bError = (im.UnboundValueColumn1 != null);
                }
                else if (cf.FilterID == IIProductLines.Current.UnboundColumn2)
                {
                    bError = (im.UnboundValueColumn2 != null);
                }
                else if (cf.FilterID == IIProductLines.Current.UnboundColumn3)
                {
                    bError = (im.UnboundValueColumn3 != null);
                }
                if (cf.FilterID == IIProductLines.Current.UnboundColumn4)
                {
                    bError = (im.UnboundValueColumn4 != null);
                }
                else if (cf.FilterID == IIProductLines.Current.UnboundColumn5)
                {
                    bError = (im.UnboundValueColumn5 != null);
                }
                else if (cf.FilterID == IIProductLines.Current.UnboundColumn6)
                {
                    bError = (im.UnboundValueColumn6 != null);
                }
                if (cf.FilterID == IIProductLines.Current.UnboundColumn7)
                {
                    bError = (im.UnboundValueColumn7 != null);
                }
                else if (cf.FilterID == IIProductLines.Current.UnboundColumn8)
                {
                    bError = (im.UnboundValueColumn8 != null);
                }
                else if (cf.FilterID == IIProductLines.Current.UnboundColumn9)
                {
                    bError = (im.UnboundValueColumn9 != null);
                }

                if (bError)
                {
                    throw new PXException("The filter '{0}' cannot be deleted while some values for it are in mappings. Clear values for the filter in the mappings, after that you'll be able to delete the filter", cf.FilterID);
                }
            }
        }