金额大写
//inId?º?ð?îÊäÈë?ò ID
//outId?º?óÐ?Êä?ö?ò ID
//txtId?º???æ?óÐ?µÄÎÄ???ò ID
//max?º×î?ó??Î?Êý????º?Ð?Êý??
//Ê?ÓÃ?????ºthis.Txt_Amount.Attributes["onkeyup"]="TypeAmount('Txt
_Amount','L_Amount','Txt_AmountLab',10)"
function TypeAmount(inId,outId,txtId,max)
{
var obj = document.getElementById(inId);
document.getElementById(outId).innerHTML = MoneyFormat(obj.value,max);
document.getElementById(txtId).value =
document.getElementById(outId).innerHTML; }
function
MoneyFormat(aiMoney,aiMaxOut){ //?óÐ?ÈËÃñ?Òת??(ÒÔ?ÖΪµ?Î?)
if (!aiMaxOut){aiMaxOut = 7;}
aiMoney = aiMoney.replace(/,/g,'') ;
lcMoney = parseFloat(aiMoney)+"";
if (lcMoney=='NaN'){lcMoney='0.00'}
if (lcMoney.indexOf('.')==-1){
lcMoney=lcMoney+".00"
}else{
lcMoney=lcMoney.substring(0,lcMoney.indexOf('.')+3)
if
(((lcMoney.substring(lcMoney.indexOf('.'))).length)==2){lcMoney=lc
Money+'0'}
}
lcMoneyNs = lcMoney;
lcMoney = lcMoney.replace('.','')
lcMoney = lcMoney.replace('-','')
var liLength=lcMoney.length , lcFormat="";
for (i=1; i<=(aiMaxOut-liLength); i++){
lcMoney = '0' + lcMoney;
}
if (liLength>aiMaxOut){lcFormat = '?ð?îÖµ???ö??Î?!';aiMaxOut=0;}
liLength=aiMaxOut;
var AlterlcMoney= new
Array("Áã","Ò?","??","Èþ","ËÁ","Îé","Â?","Æâ","?Æ","?Á");
for (i=1; i<=liLength; i++){
var liTempMoney = parseFloat(lcMoney.substring(liLength-i));
lcMoney = lcMoney.substring(0,liLength-i);
if (i==1){lcFormat =" ?Ö " + lcFormat;}
if (i==2){lcFormat =" ?Ç " + lcFormat;}
if (i==3){lcFormat =" Ôª " + lcFormat;}
if (i==4){lcFormat =" Ê? " + lcFormat;}
if (i==5){lcFormat =" ?Û " + lcFormat;}
if (i==6){lcFormat =" Ǫ " + lcFormat;}
if (i==7){lcFormat =" Íò " + lcFormat;}
if (i==8){lcFormat =" Ê? " + lcFormat;}
if (i==9){lcFormat =" ?Û " + lcFormat;}
if (i==10){lcFormat =" Ǫ "+ lcFormat;}
if (i==11){lcFormat =" ÒÚ " + lcFormat;}
if (i==12){lcFormat =" Ê? " + lcFormat;}
if (i==13){lcFormat =" ?Û " + lcFormat;}
if (i==14){lcFormat =" Ǫ " + lcFormat;}
if (i==15){lcFormat =" Íò " + lcFormat;}
lcFormat = "
"+AlterlcMoney[liTempMoney]+"" + lcFormat;
}
lcMoney = lcFormat;
return lcMoney +" Õû";
}
/********************* ÒÔÏÂÊÇ C# ???? *********************/
///
/// ?ñÊ???Êý×ÖÊä?ö??Ð?Ð??ä?É?ÆÎñ?óÐ?
///
///
Êý×Ö
///
ÐèÒªµÄ???È
public static string FormatNumberLab(string num, int len) {
if (len > 15) { return "?ð?î???ö??Î?"; }
string rtn = "";
string[] lc = { "Áã", "Ò?", "??", "Èþ", "ËÁ", "Îé", "Â?", "Æâ", "?Æ", "?Á" };
string[] lc2 = { "?Ö", "?Ç", "Ôª", "Ê?", "?Û", "Ǫ", "Íò", "Ê?", "?Û", "Ǫ", "ÒÚ", "Ê?", "?Û", "Ǫ", "Íò" };
//ÏÈת?É2Î?ÊýµÄÊý×Ö
num = ValidateNumber(num) ? num : "0.00";
num = (decimal.Parse(num) * 100).ToString("0");//ÒÆ?ýÐ?Êýµã
string lcFormat = "";
num = FormatNumberAhead(num, len+1, "0");//ÏòÇ???Æë 0 ???ÓÉÏÐ?ÊýµãÁ?Î?Êý
for (int i = 0; i <= len; i++)
{
rtn = lcFormat + rtn;
lcFormat = "
" + lc[int.Parse(num[num.Length - i -1].ToString())] + "";
lcFormat += " " + lc2[i] + " ";
}
rtn += " Õû";
return rtn;
}
///
/// ?ñÊ???Êý×ÖÊä?ö??ÏòÇ???ÆëÖ???×Ö?û
///
///
Êý×Ö
///
ÐèÒªµÄ???È ///
Ö???×Ö?û
public static string FormatNumberAhead(string num, int len, string s)
{
string rtn = "";
if (num.Length >= len) { return num; }
ArrayList arr = ArrayList.Repeat(s, len - num.Length);
rtn = string.Join("", arr.ToArray(typeof(string)) as string[]) +
num;
return rtn;
}
///
/// ?ìÑéÎÄ??ÊÇ?ñΪÊý×Ö
///
///
public static bool ValidateNumber(string str) {
System.Text.RegularExpressions.Regex rex = new System.Text.RegularExpressions.Regex(@"^(\d+)?(\.(\d+))?$");
return rex.IsMatch(str);
}