示例#1
0
        /// <summary><see cref="INUnit"/> Inserted</summary>
        protected virtual void INUnit_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
        {
            INUnit unit = e.Row as INUnit;

            if (unit != null && unit.FromUnit != null && Item.Current != null)
            {
                unit.UnitRate = GetUnitRate(sender, unit, Item.Current.ItemClassID);
            }

            foreach (var row in itemxrefrecords.Select())
            {
                VerifyXRefUOMExists(itemxrefrecords.Cache, row);
            }
        }
示例#2
0
        public virtual decimal?GetUnitRate(PXCache sender, INUnit unit, int?itemClassID)
        {
            decimal?unitRate     = unit != null ? unit.UnitRate ?? 1m : 1m;
            INUnit  existingUnit = PXSelect <INUnit,
                                             Where <INUnit.unitType, NotEqual <INUnitType.inventoryItem>,
                                                    And <INUnit.fromUnit, Equal <Current <INUnit.fromUnit> >,
                                                         And <INUnit.toUnit, Equal <Current <INUnit.toUnit> >,
                                                              And <INUnit.unitMultDiv, Equal <Current <INUnit.unitMultDiv> >,
                                                                   And <Where <INUnit.itemClassID, Equal <Required <INUnit.itemClassID> >, Or <INUnit.unitType, Equal <INUnitType.global> > > > > > > >,
                                             OrderBy <Asc <INUnit.unitType> > > .SelectSingleBound(sender.Graph, new object[] { unit }, itemClassID);

            if (existingUnit != null)
            {
                unitRate = existingUnit.UnitRate;
            }

            return(unitRate);
        }
示例#3
0
        protected virtual void INUnit_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            INUnit       row   = (INUnit)e.Row;
            PXFieldState state = (PXFieldState)sender.GetStateExt <INUnit.fromUnit>(row);
            uint         msgNbr;
            String       msqPrefix;

            if (Item.Current != null && row.ToUnit == Item.Current.BaseUnit && (state.Error == null || state.Error == PXMessages.Localize(Messages.BaseUnitNotSmallest, out msgNbr, out msqPrefix) || state.ErrorLevel == PXErrorLevel.RowInfo))
            {
                if (row.UnitMultDiv == MultDiv.Multiply && row.UnitRate < 1 || row.UnitMultDiv == MultDiv.Divide && row.UnitRate > 1)
                {
                    sender.RaiseExceptionHandling <INUnit.fromUnit>(row, row.FromUnit, new PXSetPropertyException(Messages.BaseUnitNotSmallest, PXErrorLevel.RowWarning));
                }
                else
                {
                    sender.RaiseExceptionHandling <INUnit.fromUnit>(row, row.FromUnit, null);
                }
            }
        }