Esempio n. 1
0
        public static string Format(object value, int decimalDigits, int decimalScale, bool displayThousandSeperator, bool displayEmptyForZero)
        {
            string result;

            if (value == null)
            {
                result = string.Empty;
            }
            else if (value.GetType() == typeof(string))
            {
                result = (string)value;
            }
            else
            {
                decimal num = System.Convert.ToDecimal(value);
                if (num != 0m)
                {
                    if (decimalDigits > 0)
                    {
                        result = NumberUtils.Format(NumberUtils.Round(num, decimalDigits), "n" + decimalDigits, displayThousandSeperator);
                    }
                    else if (decimalScale > 0)
                    {
                        num    = NumberUtils.Round(num, decimalScale);
                        result = (displayThousandSeperator ? NumberUtils.FormatWithThousandSeperator(num, decimalScale) : NumberUtils.Format(num));
                    }
                    else if (displayThousandSeperator)
                    {
                        result = NumberUtils.FormatWithThousandSeperator(num, 8);
                    }
                    else
                    {
                        result = NumberUtils.Format(num);
                    }
                }
                else
                {
                    result = (displayEmptyForZero ? string.Empty : NumberUtils.Format(num));
                }
            }
            return(result);
        }
Esempio n. 2
0
 public static string Format(object value, int decimalDigits, int decimalScale)
 {
     return(NumberUtils.Format(value, decimalDigits, decimalScale, false, false));
 }
Esempio n. 3
0
 public static string Format(object value)
 {
     return(NumberUtils.Format(value, 0, 8));
 }