コード例 #1
0
        protected virtual decimal ConvertValue(decimal value, string from, string to)
        {
            if (from == to)
            {
                return(value);
            }

            bool   reverse = false;
            INUnit unit    = INUnit.UK.ByGlobal.Find(Base, from, to);

            if (unit == null)
            {
                unit    = INUnit.UK.ByGlobal.Find(Base, to, from);
                reverse = true;
            }

            if (unit == null)
            {
                throw new PXException(IN.Messages.ConversionNotFound, from, to);
            }

            decimal result = INUnitAttribute.ConvertValue(value, unit, INPrecision.NOROUND, reverse);

            return(decimal.Round(result, 6, MidpointRounding.AwayFromZero));
        }