protected void CreateStockItemParams_InventoryCD_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
    {
        e.IsAltered = true;
        object ret = e.ReturnValue;
        PXDimensionAttribute restoreCombo = null;

        foreach (PXEventSubscriberAttribute attr in sender.Graph.Caches[typeof(InventoryItem)]
                 .GetAttributesReadonly <InventoryItem.inventoryCD>())
        {
            if (attr is PXDimensionAttribute)
            {
                if (((PXDimensionAttribute)attr).ValidComboRequired)
                {
                    ((PXDimensionAttribute)attr).ValidComboRequired = false;
                    restoreCombo = (PXDimensionAttribute)attr;
                    break;
                }
            }
        }
        sender.Graph.Caches[typeof(InventoryItem)].
        RaiseFieldSelecting <InventoryItem.inventoryCD>(null, ref ret, true);
        if (restoreCombo != null)
        {
            restoreCombo.ValidComboRequired = true;
        }
        e.ReturnState = ret;
    }
        public override void Persist()
        {
            if (Header.Cache.IsDirty && Detail.Select().Count == 0 && Header.Current != null)
            {
                throw new PXException(Messages.DimensionIsEmpty);
            }

            var dimension = Header.Current;

            if (dimension == null)
            {
                base.Persist();
            }
            else
            {
                try
                {
                    using (PXTransactionScope tscope = new PXTransactionScope())
                    {
                        if (Header.Cache.GetStatus(dimension) != PXEntryStatus.Deleted)
                        {
                            InsertNumberingValue(Header.Current);
                            CorrectChildDimensions();
                        }

                        var oldLength = (short?)Header.Cache.GetValueOriginal <Dimension.length>(dimension);

                        if (dimension.Length < oldLength)
                        {
                            if (dimension.DimensionID == "SUBACCOUNT")
                            {
                                CheckLongerSubKeysDoNotExist(dimension.Length);

                                PXUpdate <Set <Sub.subCD, Substring <Sub.subCD, int1, CurrentValue <Dimension.length> > >,
                                          Sub>
                                .Update(this);
                            }

                            ValidateDimensionForKeyDuplication(dimension);
                        }

                        PXDimensionAttribute.Clear();
                        base.Persist();
                        Header.Current = dimension;
                        PXDimensionAttribute.Clear();

                        tscope.Complete();
                    }
                }
                catch (PXDatabaseException e)
                {
                    if (e.ErrorCode == PXDbExceptions.DeleteForeignKeyConstraintViolation)
                    {
                        throw new PXException(Messages.SegmentHasValues, e.Keys[1]);
                    }
                    throw;
                }
            }
            PXPageCacheUtils.InvalidateCachedPages();
        }
Beispiel #3
0
 public override void Persist()
 {
     populateNeighbours <PX.SM.Users>(Users);
     populateNeighbours <INSite>(Site);
     populateNeighbours <PX.SM.Users>(Users);
     base.Persist();
     PXSelectorAttribute.ClearGlobalCache <PX.SM.Users>();
     PXSelectorAttribute.ClearGlobalCache <PX.Objects.IN.INSite>();
     PXDimensionAttribute.Clear();
 }
 public override void Persist()
 {
     populateNeighbours <PX.SM.Users>(Users);
     populateNeighbours <PMProject>(Project);
     populateNeighbours <PX.SM.Users>(Users);
     base.Persist();
     PXSelectorAttribute.ClearGlobalCache <PX.SM.Users>();
     PXSelectorAttribute.ClearGlobalCache <PMProject>();
     PXDimensionAttribute.Clear();
 }
        protected virtual void Dimension_RowUpdating(PXCache cache, PXRowUpdatingEventArgs e)
        {
            Dimension newRow    = (Dimension)e.NewRow;
            Dimension currow    = (Dimension)Header.Current;
            int       maxLength = PXDimensionAttribute.GetMaxLength(currow.DimensionID);

            if (newRow.Length > maxLength)
            {
                cache.RaiseExceptionHandling <Dimension.length>(e.Row, newRow.Length,
                                                                new PXSetPropertyException <Dimension.length>(Messages.DimensionLengthOutOfRange));
            }
        }
            public InventoryCDAttribute()
                : base()
            {
                PXDimensionAttribute attr = new PXDimensionAttribute(InventoryAttribute.DimensionName);

                attr.ValidComboRequired = true;
                _Attributes.Add(attr);

                PXSelectorAttribute selectorattr = new PXSelectorAttribute(typeof(Search <InventoryItem.inventoryCD, Where <Match <Current <AccessInfo.userName> > > >));

                _Attributes.Add(selectorattr);
            }
Beispiel #7
0
 public override void Persist()
 {
     populateNeighbours <PX.SM.Users>(Users);
     populateNeighbours <InventoryItem>(Item);
     populateNeighbours <INItemClass>(Class);
     populateNeighbours <InventoryItem>(Item);
     populateNeighbours <PX.SM.Users>(Users);
     base.Persist();
     PXSelectorAttribute.ClearGlobalCache <PX.SM.Users>();
     PXSelectorAttribute.ClearGlobalCache <PX.Objects.IN.INItemClass>();
     PXSelectorAttribute.ClearGlobalCache <PX.Objects.IN.InventoryItem>();
     PXDimensionAttribute.Clear();
 }
 public static string CreateSubCDWildcard(string aSub, string dimensionID)
 {
     if (IsSubCDEmpty(aSub))
     {
         return(PXDatabase.Provider.SqlDialect.WildcardAnything);
     }
     if (aSub[aSub.Length - 1] != '?' &&
         aSub[aSub.Length - 1] != ' ' &&
         aSub.Length == PXDimensionAttribute.GetLength(dimensionID))
     {
         aSub = aSub + "?";
     }
     return(Regex.Replace(Regex.Replace(aSub, "[ \\?]+$", PXDatabase.Provider.SqlDialect.WildcardAnything), "[ \\?]", PXDatabase.Provider.SqlDialect.WildcardAnySingle));
 }
Beispiel #9
0
        protected virtual void INItemXRef_AlternateID_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            var row = e.Row as INItemXRef;

            if (row == null || Item.Current == null || row.AlternateID == null)
            {
                return;
            }

            if (!PXDimensionAttribute.MatchMask <InventoryItem.inventoryCD>(Item.Cache, row.AlternateID))
            {
                sender.RaiseExceptionHandling <INItemXRef.alternateID>(row, row.AlternateID, new PXSetPropertyException(Messages.AlternateIDDoesNotCorrelateWithCurrentSegmentRules, PXErrorLevel.Warning));
            }
        }
Beispiel #10
0
 public override void Persist()
 {
     try
     {
         PXDimensionAttribute.Clear();
         base.Persist();
         PXDimensionAttribute.Clear();
     }
     catch (PXDatabaseException e)
     {
         if (e.ErrorCode == PXDbExceptions.DeleteForeignKeyConstraintViolation)
         {
             throw new PXException(Messages.SegmentHasValues, e.Keys[1]);
         }
         throw;
     }
 }
Beispiel #11
0
        public override void Persist()
        {
            if (Header.Cache.IsDirty && Detail.Select().Count == 0 && Header.Current != null)
            {
                throw new PXException(Messages.DimensionIsEmpty);
            }

            var current = Header.Current;

            if (current == null)
            {
                base.Persist();
            }
            else
            {
                try
                {
                    if (Header.Cache.GetStatus(current) != PXEntryStatus.Deleted)
                    {
                        InsertNumberingValue(Header.Current);
                        CorrectChildDimensions();
                    }

                    if (Header.Current.DimensionID == IN.SubItemAttribute.DimensionName)
                    {
                        ValidateSubItems();
                    }


                    PXDimensionAttribute.Clear();
                    base.Persist();
                    Header.Current = current;
                    PXDimensionAttribute.Clear();
                }
                catch (PXDatabaseException e)
                {
                    if (e.ErrorCode == PXDbExceptions.DeleteForeignKeyConstraintViolation)
                    {
                        throw new PXException(Messages.SegmentHasValues, e.Keys[1]);
                    }
                    throw;
                }
            }
            PXPageCacheUtils.InvalidateCachedPages();
        }
        public PXEmployeeSingleSelectorAttribute()
        {
            PXDimensionAttribute attr = new PXDimensionAttribute("BIZACCT");

            attr.ValidComboRequired = true;
            _Attributes.Add(attr);

            PXSelectorAttribute selattr = new PXSelectorAttribute(GetCommand(),
                                                                  typeof(EPEmployee.acctCD),
                                                                  typeof(EPEmployee.bAccountID), typeof(EPEmployee.acctName),
                                                                  typeof(EPEmployee.classID), typeof(EPEmployeePosition.positionID), typeof(EPEmployee.departmentID),
                                                                  typeof(EPEmployee.defLocationID), typeof(Users.username), typeof(Users.displayName));

            selattr.SubstituteKey    = typeof(EPEmployee.acctCD);
            selattr.DescriptionField = typeof(EPEmployee.acctName);

            _Attributes.Add(selattr);
            _Attributes.Add(new PXRestrictorAttribute(typeof(Where <EPEmployee.status, NotEqual <BAccount.status.inactive> >), Objects.EP.Messages.InactiveEpmloyee, typeof(EPEmployee.acctCD), typeof(EPEmployee.status)));
        }
        protected virtual void Dimension_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            Dimension dim = (Dimension)e.Row;

            dim.MaxLength = PXDimensionAttribute.GetMaxLength(dim.DimensionID);

            PXUIFieldAttribute.SetEnabled <Dimension.length>(cache, dim, false);
            PXUIFieldAttribute.SetVisible <Dimension.maxLength>(cache, dim, HasMaxLength(dim));
            PXUIFieldAttribute.SetEnabled <Dimension.segments>(cache, dim, false);

            bool numberingIDEnabled = true;
            bool specificModule     = true;
            bool validateEnabled    = false;

            Detail.Cache.AllowInsert = true;
            Detail.Cache.AllowUpdate = true;
            Detail.Cache.AllowDelete = true;

            switch (dim.DimensionID)
            {
            case SubItemAttribute.DimensionName:
                validateEnabled = true;
                PXUIFieldAttribute.SetEnabled <Segment.autoNumber>(Detail.Cache, null, false);
                break;

            case SubAccountAttribute.DimensionName:
                validateEnabled = true;
                break;

            case AccountAttribute.DimensionName:
                break;

            case AR.CustomerAttribute.DimensionName:
            case AR.SalesPersonAttribute.DimensionName:
            case IN.InventoryAttribute.DimensionName:
            case IN.SiteAttribute.DimensionName:
            case IN.LocationAttribute.DimensionName:
            case AP.VendorAttribute.DimensionName:
            case AR.CustomerRawAttribute.DimensionName:
            case EP.EmployeeRawAttribute.DimensionName:
            case CR.LeadRawAttribute.DimensionName:
                validateEnabled = dim.Validate == false;
                PXUIFieldAttribute.SetEnabled <Segment.autoNumber>(Detail.Cache, null, true);
                PXUIFieldAttribute.SetVisible <Segment.isCosted>(Detail.Cache, null, false);
                break;

            default:
                validateEnabled = true;
                break;
            }

            cache.AllowDelete = dim.Internal != true;

            PXUIFieldAttribute.SetVisible <Segment.consolOrder>(Detail.Cache, null, dim.DimensionID == SubAccountAttribute.DimensionName);
            PXUIFieldAttribute.SetVisible <Segment.consolNumChar>(Detail.Cache, null, dim.DimensionID == SubAccountAttribute.DimensionName);

            PXUIFieldAttribute.SetVisible <Segment.isCosted>(Detail.Cache, null, dim.DimensionID == SubItemAttribute.DimensionName);

            bool hasParent = dim.ParentDimensionID != null;

            Detail.Cache.AllowInsert &= !hasParent;
            PXUIFieldAttribute.SetVisible <Segment.inherited>(Detail.Cache, null, hasParent);
            PXUIFieldAttribute.SetVisible <Segment.isOverrideForUI>(Detail.Cache, null, hasParent);

            PXUIFieldAttribute.SetEnabled <Dimension.numberingID>(cache, e.Row, numberingIDEnabled);
            PXUIFieldAttribute.SetEnabled <Dimension.specificModule>(cache, e.Row, specificModule);
            PXUIFieldAttribute.SetEnabled <Dimension.validate>(cache, e.Row, validateEnabled);
        }
        protected virtual void ValidateDimensionForKeyDuplication(Dimension dimension)
        {
            if (string.IsNullOrEmpty(dimension.ParentDimensionID))
            {
                Dictionary <string, KeyValuePair <Type, string> > dictTables = PXDimensionAttribute.GetTables(dimension.DimensionID);
                if (dictTables != null)
                {
                    foreach (string table in dictTables.Keys)
                    {
                        KeyValuePair <Type, string> pair = dictTables[table];
                        Type        typeTable            = pair.Key;
                        PXCache     cach      = Caches[typeTable];
                        Type        typeField = cach.GetBqlField(pair.Value);
                        List <Type> keys      = cach.BqlKeys;

                        if (!keys.Contains(typeField))
                        {
                            continue;
                        }

                        int    line  = 0;
                        int    count = (keys.Count - 1) * 2 + 1;
                        Type[] group = new Type[count];

                        foreach (Type key in keys)
                        {
                            if (key != typeField)
                            {
                                group[line]     = typeof(GroupBy <,>);
                                group[line + 1] = key;
                                line           += 2;
                            }
                        }

                        group[count - 1] = typeof(Count);
                        Type groupby = BqlCommand.Compose(group);

                        BqlCommand select = BqlCommand.CreateInstance
                                                (typeof(Select4 <,>),
                                                typeTable,
                                                typeof(Aggregate <>),
                                                typeof(GroupBy <,>),
                                                typeof(Left <,>),
                                                typeField,
                                                typeof(CurrentValue <>),
                                                typeof(Dimension.length),
                                                groupby
                                                );

                        PXView        view = new PXView(this, false, select);
                        List <object> rows = view.SelectMulti(null);

                        foreach (PXResult row in rows)
                        {
                            if (row.RowCount > 1)
                            {
                                throw new PXRowPersistingException
                                          (typeof(Dimension.length).Name,
                                          dimension.Length,
                                          PXMessages.LocalizeFormatNoPrefixNLA(Messages.DimensionDuplicate, BqlCommand.GetTableName(typeTable))
                                          );
                            }
                        }
                    }
                }
            }
        }