数字金额转成大写中文金额

数字金额转成大写中文金额

#region "数字金额转成大写中文金额"
//传入数字字符 如:12121212.232323
public string MoneyToChinese(string StrLowerMoney)
{
string ReturnStr;
string LowerMoney;
ReturnStr="";
StrLowerMoney=StrLowerMoney.Replace("-","");
LowerMoney=System.String.Format(StrLowerMoney.ToString(),".00");
LowerMoney=StrLowerMoney.Replace(",","");
string strLower="";
string strUPart="";
string strUpper="";
int iTemp;
try
{
strLower=LowerMoney.ToString();
iTemp=1;
while (iTemp<=strLower.Length)
{
switch(strLower.Substring(strLower.Length -iTemp,1))
{
case ".":
strUPart = "元";
break;
case "0":
strUPart = "零";
break;
case "1":
strUPart = "壹";
break;
case "2":
strUPart = "贰";
break;
case "3":
strUPart = "叁";
break;
case "4":
strUPart = "肆";
break;
case "5":
strUPart = "伍";
break;
case "6":
strUPart = "陆";
break;
case "7":
strUPart = "柒";
break;
case "8":
strUPart = "捌";
break;
case "9":
strUPart = "玖";
break;
}
switch(iTemp)
{
case 1:
strUPart = strUPart + "分";
break;
case 2:
strUPart = strUPart + "角";
break;
case 3:
strUPart = strUPart + "";
break;
case 4:
strUPart = strUPart + "";
break;
case 5:
strUPart = strUPart + "拾";
break;
case 6:
strUPart = strUPart + "佰";
break;
case 7:
strUPart = strUPart + "仟";
break;
case 8:
strUPart = strUPart + "万";
break;
case 9:
strUPart = strUPart + "拾";
break;
case 10:
strUPart = strUPart + "佰";
break;
case 11:
strUPart = strUPart + "仟";
break;
case 12:
strUPart = strUPart + "亿";
break;
case 13:
strUPart = strUPart + "拾";
break;
case 14:
strUPart = strUPart + "佰";
break;
case 15:
strUPart = strUPart + "仟";
break;
case 16:
strUPart = strUPart + "万";
break;
default:
strUPart = strUPart + "";
break;
}
strUpper = strUPart + strUpper;
iTemp = iTemp + 1;
}
strUpper = strUpper.Replace("零拾", "零");
strUpper = strUpper.Replace("零佰", "零");
strUpper = strUpper.Replace("零仟", "零");
strUpper = strUpper.Replace("零零零", "零");
strUpper = strUpper.Replace("零零", "零");
strUpper = strUpper.Replace("零角零分", "整");
strUpper = strUpper.Replace("零分", "整");
strUpper = strUpper.Replace("零角", "零");
strUpper = strUpper.Replace("零亿零万零元", "亿元");
strUpper = strUpper.Replace("亿零万零元", "亿元");
strUpper = strUpper.Replace("零亿零万", "亿");
strUpper = strUpper.Replace("零万零元", "万元");
strUpper = strUpper.Replace("万零元", "万元");
strUpper = strUpper.Replace("零亿", "亿");
strUpper = strUpper.Replace("零万", "万");
strUpper = strUpper.Replace("零元", "元");
strUpper = strUpper.Replace("零零", "零");
//对壹元以下的金额的处理
if (strUpper.Substring(1, 1)== "元")
{
strUpper = strUpper.Substring( 2, strUpper.Length - 1);
}
if (strUpper.Substring(1,1)=="零")
{
strUpper=strUpper.Substring(2,strUpper.Length-1);
}
if (strUpper.Substring(1,1)=="角")
{
strUpper=strUpper.Substring(2,strUpper.Length-1);
}
if (strUpper.Substring(1,1)=="分")
{
strUpper=strUpper.Substring(2,strUpper.Length-1);
}
if (strUpper.Substring(1,1)=="整")
{
strUpper="零元整";
}
if (strUpper.Substring(1,1)=="零")
{
strUpper=strUpper.Substring(2,strUpper.Length-1);
}
}
catch{}
ReturnStr=strUpper;
return ReturnStr;
}
# endregion
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值