C#:小写金额转换为大写

        #region 小写金额转换为大写
        public static string CurrToChnNum(double Currnum)
        {
            string sResult = "";
            if (Math.Abs(Currnum) < 1e-20)
                return "零圆整";
            if (Currnum < 1e-20)
                sResult = "负";
            sResult = sResult + StringToChnNum(Math.Abs(Math.Round(Currnum, 2)).ToString());
            return sResult;
        }
        private static string FourNumToChnNum(string Str, string ChnNum, ref Boolean Pre)
        {
            string[] Digits = {"零", "壹", "贰", "叁", "肆",
                                     "伍", "陆", "柒", "捌", "玖"};
            int i, j, Len;
            string sResult = "";
            Len = Str.Length;
            for (i = 0; i < Len; i++)
            {
                j = Str[i] - 48;
                if (0 == j)
                    Pre = true;
                else
                {
                    if (Pre) sResult = sResult + "零";
                    sResult = sResult + Digits[j] + ChnNum.Substring(Len - i - 1, 1);
                    Pre = false;
                }
            }
            return sResult.Trim();
        }
        //将格式化好的小写串转换为大写串
        private static string StringToChnNum(string str)
        {
            const string ChnNum1 = "圆万亿兆";
            int i, Len, Len1, Level, Start;
            string s1; string s;
            Boolean Pre;
            string sResult = "";
            Len = str.IndexOf(‘.‘);
            Level = (Len + 3) / 4;
            Len1 = Len % 4;
            if (0 == Len1) Len1 = 4;
            Start = 0;
            for (i = 1; i <= Level; i++)
            {
                Pre = false;
                s = str.Substring(Start, Len1);
                s1 = FourNumToChnNum(s, " 拾佰仟", ref Pre);
                if (s1.Length > 0)
                    sResult = sResult + s1 + ChnNum1.Substring(Level - i, 1);
                Start = Start + Len1;
                Len1 = 4;
            }
            Pre = false;
            s1 = FourNumToChnNum(str.Substring(Len + 1, Math.Min(2, str.Length - Len - 1)), "分角", ref Pre);
            //s1 = "";
            if (s1.Length == 0)
                s1 = "整";
            sResult = sResult + s1;
            return sResult;
        }
        #endregion
时间: 2024-12-26 04:24:29

C#:小写金额转换为大写的相关文章

Oracle 小写金额转换为大写

在开发EBS的合同报表打印的时候需要将小写金额转换为大写. 如下是本人自己写的转换函数. 主要思路:先获取小数点位置,在区分整数与小数点处理,根据位数和数字组合读取金额. 最后再处理特殊显示部分. /******************************************************************* *  FUNCTION get_big_amount 数字金额转换为大写 *  p_amount 输入数据金额 *  返回大写金额,位数 :千亿----厘 ****

java将小写金额转换为大写的工具类

public class Tool {             private static final String UNIT = "万千佰拾亿千佰拾万千佰拾元角分";         private static final String DIGIT = "零壹贰叁肆伍陆柒捌玖";         private static final double MAX_VALUE = 9999999999999.99D;         public static St

人民币 小写金额转换为大写金额

### 人民币 小写金额转换为大写金额 标签(空格分隔): 人民币 小写金额转换为大写金额 --- jsp:```div class="form-group"><label class="col-sm-4 control-label">合计人民币金额(小写):</label><div class="col-sm-7"><input id="totalRmbLower" type=

小写金转换为大写

<body><input type="text" id="txt"/><br/><input type="button" id="ss" value="submit"/><br/><input type="text" id="result"/></body><script typ

汇编-小写字母转换为大写字母

一.实习题目:小写字母转换为大写字母 二.实习目的:  1.掌握分支程序设计方法 2.了解小写字母和大写字母在计算机中的表示方法并显示. 三.代码:   data segment A db 'a'; B db 'z'; C db 00h; bb db 0ah,0dh,'$' string db 0ah,0dh,'The input num is not a case letter','$'; data ends code segment assume DS:data,CS:code star

C# 把小写人民币转换为大写

/// <summary> /// 转换人民币大小金额 /// </summary> /// <param name="num">金额</param> /// <returns>返回大写形式</returns> public static string CmycurD(decimal num) { string str1 = "零壹贰叁肆伍陆柒捌玖"; //0-9所对应的汉字 string st

JS实现将数字金额转换为大写人民币汉字

function convertCurrency(money) { //汉字的数字 var cnNums = new Array('零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'); //基本单位 var cnIntRadice = new Array('', '拾', '佰', '仟'); //对应整数部分扩展单位 var cnIntUnits = new Array('', '万', '亿', '兆'); //对应小数部分单位 var cnDe

将小写字母转换为大写字母

var pinyin = (function () { var Pinyin = function (ops) { this.initialize(ops); }, options = { checkPolyphone: false, charcase: 'default' }; Pinyin.fn = Pinyin.prototype = { init: function (ops) { this.options = extend(options, ops); }, initialize: f

SQL标量值函数:小写金额转大写

我们日常开发业务系统中,作为统计报表中,特别是财务报表,显示中文金额经常遇到. 转换大小写的方法有很多,以下是从数据库函数方面解决这一问题. 效果如图: 调用:SELECT dbo.[Fn_ConvertRMB](192.4) 具体函数如下: -- ============================================= -- 调用:SELECT dbo.[Fn_ConvertRMB](192.4) -- Create date: 2015-01-06 -- Descripti