金额小写变大写



ExpandedBlockStart.gif ContractedBlock.gif             /**/ /// <summary>
InBlock.gif        
/// 金额小写变大写
InBlock.gif        
/// </summary>
InBlock.gif        
/// <param name="smallnum"></param>
ExpandedBlockEnd.gif        
/// <returns></returns>

None.gif          public   static   string  gMoney( decimal  smallnum)                                                                                
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif {
InBlock.gif            
string cmoney , cnumber, cnum, cnum_end,cmon ,cno,snum ,sno;
InBlock.gif            
int snum_len , sint_len, cbegin, zflag , i;
InBlock.gif            
if(smallnum > 1000000000000 || smallnum < -99999999999 || smallnum == 0)
InBlock.gif                
return "";
InBlock.gif            cmoney 
= "仟佰拾亿仟佰拾万仟佰拾元角分" ;// 大写人民币单位字符串
InBlock.gif
            cnumber = "壹贰叁肆伍陆柒捌玖"          ;// 大写数字字符串
InBlock.gif
            cnum = ""                               ;// 转换后的大写数字字符串
InBlock.gif
            cnum_end = ""                           ;// 转换后的大写数字字符串的最后一位
InBlock.gif
            cmon = ""                               ;// 取大写人民币单位字符串中的某一位
InBlock.gif
            cno = ""                                ;// 取大写数字字符串中的某一位
InBlock.gif

InBlock.gif
InBlock.gif            
InBlock.gif            snum 
= Round(smallnum,2).ToString("############.00");  ;// 小写数字字符串
InBlock.gif
            snum_len = snum.Length                  ;// 小写数字字符串的长度
InBlock.gif
            sint_len = snum_len - 2                 ;// 小写数字整数部份字符串的长度
InBlock.gif
            sno = ""                                ;// 小写数字字符串中的某个数字字符
InBlock.gif
            cbegin = 15 - snum_len                  ;// 大写人民币单位中的汉字位置
InBlock.gif
            zflag = 1                               ;// 小写数字字符是否为0(0=0)的判断标志
InBlock.gif
            i = 0                                   ;// 小写数字字符串中数字字符的位置
InBlock.gif

InBlock.gif            
if(snum_len > 15)
InBlock.gif                
return "";
InBlock.gif            
for(i=0;i<snum_len;i++
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
if (i==sint_len-1)
InBlock.gif                    
continue;
InBlock.gif
InBlock.gif                
InBlock.gif                cmon 
= cmoney.Substring(cbegin, 1);
InBlock.gif                cbegin 
= cbegin + 1;
InBlock.gif                sno 
=snum.Substring(i,1);
InBlock.gif                
if (sno=="-")
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    cnum 
= cnum + "";
InBlock.gif                    
continue;
ExpandedSubBlockEnd.gif                }

InBlock.gif                
else if(sno=="0")
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    cnum_end 
= cnum.Substring(cnum.Length-2,1);
InBlock.gif                    
if(cbegin == 4 || (cbegin == 8 || cnum_end.IndexOf("亿")>=0|| cbegin == 12 ))
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        cnum 
= cnum + cmon;
InBlock.gif                        
if (cnumber.IndexOf(cnum_end)>=0 )
InBlock.gif                            zflag 
= 1;
InBlock.gif                        
else
InBlock.gif                            zflag 
= 0;
ExpandedSubBlockEnd.gif                    }

InBlock.gif                    
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        zflag 
= 0;
ExpandedSubBlockEnd.gif                    }

InBlock.gif                    
continue;
ExpandedSubBlockEnd.gif                }

InBlock.gif                
else if( sno != "0" && zflag == 0)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    cnum 
= cnum + "";
InBlock.gif                    zflag 
= 1;
ExpandedSubBlockEnd.gif                }

InBlock.gif                cno 
=cnumber.Substring(System.Convert.ToInt32(sno)-11);
InBlock.gif                cnum 
= cnum + cno + cmon;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
if (snum.Substring(snum.Length-2,1)=="0")
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return  cnum + "";
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
InBlock.gif                
return cnum;
ExpandedBlockEnd.gif        }


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值