Ejemplo n.º 1
0
 public void DeleteCarryMode(CarryMode carrymode)
 {
     if (carrymode == null)
     {
         throw new ArgumentNullException("carrymode");
     }
     _carrymoderepository.Delete(carrymode);
 }
Ejemplo n.º 2
0
 public void InsertCarryMode(CarryMode carrymode)
 {
     if (carrymode == null)
     {
         throw new ArgumentNullException("carrymode");
     }
     _carrymoderepository.Insert(carrymode);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 格式化输出字符串
        /// </summary>
        /// <param name="mode"></param>
        /// <param name="length"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public static string FormatLong(CarryMode mode, int length, object value)
        {
            string result = string.Empty;
            double tempValue = 0, power = 1;

            if (IsDouble(value) == false)
            {
                result = string.Empty;
            }
            else
            {
                if (Double.TryParse(Convert.ToString(value), out tempValue) == false)
                {
                    tempValue = 0;
                }
                if (length < 0)
                {
                    length = 0;
                }
                if (length > 15)
                {
                    length = 15;
                }
                switch (mode)
                {
                case CarryMode.Lower:
                    power     = Math.Pow(10, length);
                    tempValue = Math.Round(Math.Floor(tempValue * power) / power, length);
                    break;

                case CarryMode.Upper:
                    power     = Math.Pow(10, length);
                    tempValue = Math.Round(Math.Ceiling(tempValue * power) / power, length);
                    break;

                default:
                    tempValue = Math.Round(tempValue, length);
                    break;
                }
                string format = "f" + length.ToString();
                if (length > 0)
                {
                    result = tempValue.ToString(format);
                }
                else
                {
                    result = tempValue.ToString();
                }
            }
            return(result);
        }