private static void PopulateCalculatedDataPercent(Control textBox, ItemValueRange itemValueRange) { if (itemValueRange != null && !itemValueRange.IsZero()) { textBox.Text = (100 * itemValueRange.Min).ToString("N2"); } }
private static void PopulateCalculatedData(Control textBox, ItemValueRange itemValueRange) { if (itemValueRange != null && !itemValueRange.IsZero()) { var round = Math.Round(itemValueRange.Min); if (Math.Abs(itemValueRange.Min - round) < 0.0001) { textBox.Text = itemValueRange.Min.ToString("N0"); } else { textBox.Text = itemValueRange.Min.ToString("N2"); } } }
/// <summary> /// Returns <c>null</c> if <paramref name="value"/> is 0-0 of the value if different. /// </summary> /// <param name="value"></param> /// <returns></returns> public static ItemValueRange NullIfZero(this ItemValueRange value) { return(value.IsZero() ? null : value); }