![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**//// <summary>
/// 金额小写变大写
/// </summary>
/// <param name="smallnum"></param>
/// <returns></returns>
public static string gMoney(decimal smallnum)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
string cmoney , cnumber, cnum, cnum_end,cmon ,cno,snum ,sno;
int snum_len , sint_len, cbegin, zflag , i;
if(smallnum > 1000000000000 || smallnum < -99999999999 || smallnum == 0)
return "";
cmoney = "仟佰拾亿仟佰拾万仟佰拾元角分" ;// 大写人民币单位字符串
cnumber = "壹贰叁肆伍陆柒捌玖" ;// 大写数字字符串
cnum = "" ;// 转换后的大写数字字符串
cnum_end = "" ;// 转换后的大写数字字符串的最后一位
cmon = "" ;// 取大写人民币单位字符串中的某一位
cno = "" ;// 取大写数字字符串中的某一位
snum = Round(smallnum,2).ToString("############.00"); ;// 小写数字字符串
snum_len = snum.Length ;// 小写数字字符串的长度
sint_len = snum_len - 2 ;// 小写数字整数部份字符串的长度
sno = "" ;// 小写数字字符串中的某个数字字符
cbegin = 15 - snum_len ;// 大写人民币单位中的汉字位置
zflag = 1 ;// 小写数字字符是否为0(0=0)的判断标志
i = 0 ;// 小写数字字符串中数字字符的位置
if(snum_len > 15)
return "";
for(i=0;i<snum_len;i++)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if (i==sint_len-1)
continue;
cmon = cmoney.Substring(cbegin, 1);
cbegin = cbegin + 1;
sno =snum.Substring(i,1);
if (sno=="-")
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
cnum = cnum + "负";
continue;
}
else if(sno=="0")
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
cnum_end = cnum.Substring(cnum.Length-2,1);
if(cbegin == 4 || (cbegin == 8 || cnum_end.IndexOf("亿")>=0|| cbegin == 12 ))
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
cnum = cnum + cmon;
if (cnumber.IndexOf(cnum_end)>=0 )
zflag = 1;
else
zflag = 0;
}
else
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
zflag = 0;
}
continue;
}
else if( sno != "0" && zflag == 0)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
cnum = cnum + "零";
zflag = 1;
}
cno =cnumber.Substring(System.Convert.ToInt32(sno)-1, 1);
cnum = cnum + cno + cmon;
}
if (snum.Substring(snum.Length-2,1)=="0")
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return cnum + "整";
}
else
return cnum;
}
呵呵,CnBlogs上的高手太多了,被批评了,不敢在首页.Net区发了,发在这里吧,呵呵……