金额小写变大写        /// 金额小写变大写
金额小写变大写        
/// </summary>
金额小写变大写        
/// <param name="smallnum"></param>
金额小写变大写        
/// <returns></returns>
金额小写变大写        public static string gMoney(decimal smallnum)                                                                                
{
金额小写变大写            
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++
{
金额小写变大写                
if (i==sint_len-1)
金额小写变大写                    
continue;
金额小写变大写
金额小写变大写                
金额小写变大写                cmon 
= cmoney.Substring(cbegin, 1);
金额小写变大写                cbegin 
= cbegin + 1;
金额小写变大写                sno 
=snum.Substring(i,1);
金额小写变大写                
if (sno=="-")
{
金额小写变大写                    cnum 
= cnum + "";
金额小写变大写                    
continue;
金额小写变大写                }

金额小写变大写                
else if(sno=="0")
{
金额小写变大写                    cnum_end 
= cnum.Substring(cnum.Length-2,1);
金额小写变大写                    
if(cbegin == 4 || (cbegin == 8 || cnum_end.IndexOf("亿")>=0|| cbegin == 12 ))
{
金额小写变大写                        cnum 
= cnum + cmon;
金额小写变大写                        
if (cnumber.IndexOf(cnum_end)>=0 )
金额小写变大写                            zflag 
= 1;
金额小写变大写                        
else
金额小写变大写                            zflag 
= 0;
金额小写变大写                    }

金额小写变大写                    
else
{
金额小写变大写                        zflag 
= 0;
金额小写变大写                    }

金额小写变大写                    
continue;
金额小写变大写                }

金额小写变大写                
else if( sno != "0" && zflag == 0)
{
金额小写变大写                    cnum 
= cnum + "";
金额小写变大写                    zflag 
= 1;
金额小写变大写                }

金额小写变大写                cno 
=cnumber.Substring(System.Convert.ToInt32(sno)-11);
金额小写变大写                cnum 
= cnum + cno + cmon;
金额小写变大写            }

金额小写变大写            
if (snum.Substring(snum.Length-2,1)=="0")
{
金额小写变大写                
return  cnum + "";
金额小写变大写            }

金额小写变大写            
else
金额小写变大写                
return cnum;
金额小写变大写        }


呵呵,CnBlogs上的高手太多了,被hbifts批评了,不敢在首页.Net区发了,发在这里吧,呵呵……

相关文章: