C#方法收藏:更新于2009-10-19 晴

Else , 2009/10/19 15:10 , 积累些,自己也写些 , Comments(0) , Reads(468) , Via Original
using System;
using System.Collections.Generic;
using System.Text;

namespace KuiDiPrint.tools.tableclass
{
    class mytool
    {

        public mytool()
        { }

        #region 四舍五入算法
        /// <summary>
        /// 四舍五入算法
        /// </summary>
        /// <param name="v">要进行处理的数据</param>
        /// <param name="x">保留的小数位数</param>
        /// <returns>四舍五入后的结果</returns>

        public double Round(double v, int x)
        {
            bool isNegative = false;
            //如果是负数
            if (v < 0)
            {
                isNegative = true;
                v = -v;
            }

            int IValue = 1;
            for (int i = 1; i <= x; i++)
            {
                IValue = IValue * 10;
            }
            double Int = Math.Floor(v * IValue + 0.5);
            v = Int / IValue;

            if (isNegative)
            {
                v = -v;
            }
            return v;
        }


        public string printConvertKDpay(string kdpay)
        {
            string abcd_str = "";
            switch (kdpay)
            {


                case "寄件人付現":
                    abcd_str = "A";
                    break;
                case "收件人付現":
                    abcd_str = "B";
                    break;
                case "寄件人月結":
                    abcd_str = "C";
                    break;
                case "收件人月結":
                    abcd_str = "C";
                    break;
                default:
                    abcd_str = "-";
                    break;

            }
            return abcd_str;

        }
        #endregion
    }
}
Add a comment

Nickname

Site URI

Email

Enable HTML Enable UBB Enable Emots Hidden Remember [Login] [Register]