using System; using System.Collections.Generic; using System.Text; namespace KySoft { public class cls转换金额 { public cls转换金额() { } public static string Get大写金额(double dblNumeric) { string N2S = ""; string strPlace_1 = ""; string strPlace_2 = ""; string strPlace_4 = ""; string strPlace_5 = ""; string strPlace_6 = ""; string strPlace_7 = ""; double intLen = 0; strPlace_1 = "零壹贰叁肆伍陆柒捌玖"; strPlace_2 = "仟佰拾万仟佰拾元角分"; strPlace_4 = (dblNumeric * 100).ToString().Trim(); if (strPlace_4.Length > 10 && dblNumeric > 0 && dblNumeric < 99999999.99) { intLen = Convert.ToInt32(dblNumeric * 100) / 100; if (dblNumeric - intLen >= 0.005) { intLen = intLen + 0.01; } strPlace_4 = (intLen * 100).ToString().Trim(); } if (strPlace_4.Length > 10 || dblNumeric < 0) N2S = "大于等于 99999999.99 的数值不能转换"; else { //strPlace_4 = GetFillString(10 - strPlace_4.Length," ") + strPlace_4; strPlace_4 = strPlace_4.PadLeft(10, ' '); N2S = ""; for (int i = 0; i < 10; i++) { strPlace_5 = Convert.ToString(strPlace_4[i]); if (strPlace_5 != " ") { strPlace_6 = Convert.ToString(strPlace_1[Convert.ToInt32(strPlace_5)]); strPlace_7 = Convert.ToString(strPlace_2[i]); if (strPlace_5 == "0" && i != 3 && i != 7) strPlace_7 = ""; if ((i == 8 && strPlace_4.Substring(i, 2) == "00") || (strPlace_5 == "0" && (i == 3 || i == 7 || i == 9))) strPlace_6 = ""; N2S = N2S + strPlace_6 + strPlace_7; if (Convert.ToString(strPlace_4[i]) == "0" && strPlace_4[i] != '0' && (i == 3 || i == 7)) N2S = N2S + "零"; } } if (strPlace_5 == "0" && N2S != "") N2S = N2S + "整"; } return N2S; } } }