

static protected string IntToWord(string intStr)

{
string wordStr;
wordStr = intStr.Replace("0","零").Replace("1","壹").Replace("2","贰").Replace("3","叁").Replace("4","肆").Replace("5","伍").Replace("6","陆").Replace("7","柒").Replace("8","捌").Replace("9","玖");
return wordStr;
}

static public string IntToWordXiaoXie(string intStr)

{
string wordStr;
wordStr = intStr.Replace("0","零").Replace("1","一").Replace("2","二").Replace("3","三").Replace("4","四").Replace("5","五").Replace("6","六").Replace("7","七").Replace("8","八").Replace("9","九");
return wordStr;
}


static public string ArabToChina(double money)

{
string str1 = money.ToString();
string LeftStr;
string RightStr;
try

{
string[] arrStr = str1.Split('.');
LeftStr = arrStr[0].ToString();
RightStr = arrStr[1].ToString();
}
catch

{
LeftStr = str1;
RightStr = "";
}
if(LeftStr.Length <= 4)

{
LeftStr = NumToMoney(LeftStr).Trim('0') + "圆";
}
else if(LeftStr.Length > 4 && LeftStr.Length <=8)

{
string wanMoney = LeftStr.Substring(0,LeftStr.Length-4);
string qianMoney = Convert.ToDecimal(LeftStr.Substring(LeftStr.Length-4,4)).ToString();
wanMoney = NumToMoney(wanMoney).Trim('0') + "万";
qianMoney = NumToMoney(qianMoney).Trim('0') + "圆";
LeftStr = wanMoney + qianMoney;
}
else if(LeftStr.Length >8 && LeftStr.Length <=12)

{
string yiMoney = LeftStr.Substring(0,LeftStr.Length - 8);
string wanMoney = Convert.ToDecimal(LeftStr.Substring(LeftStr.Length -8 ,4)).ToString();
string qianMoney = Convert.ToDecimal(LeftStr.Substring(LeftStr.Length - 4,4)).ToString();
yiMoney = NumToMoney(yiMoney).Trim('0') + "亿";
wanMoney = NumToMoney(wanMoney).Trim('0') + "万";
qianMoney = NumToMoney(qianMoney).Trim('0') + "圆";
LeftStr = yiMoney + wanMoney + qianMoney;
}

//string RightStr = IntToWord(arrStr[1].ToString());
if(RightStr!="")

{
int iRight = RightStr.Length;
if(iRight==1)

{
RightStr = RightStr.Insert(1,"角");
}
if(iRight ==2)

{
if(RightStr[0].ToString()=="0")

{
RightStr = RightStr.Trim('0').Insert(0,"零").Insert(2,"分");
}
else

{
RightStr = RightStr.Insert(1,"角").Insert(3,"分");
}
}
}
if(LeftStr.Equals("圆") && RightStr!="")

{
return IntToWord(RightStr);
}
else

{
return IntToWord(LeftStr + RightStr);
}
}
static protected string NumToMoney(string money)

{
int i = money.Length;
if(i==2)

{
money = money.Insert(1,"拾");
}
else if(i==3)

{
money = money.Insert(1,"佰").Insert(3,"拾");
if(money[2].ToString()=="0")

{
money = money.Remove(3,1);
}
}
else if(i==4)

{
money = money.Insert(1,"仟").Insert(3,"佰").Insert(5,"拾");
if(money[2].ToString()=="0")

{
if(money[4].ToString()=="0")

{
money = money.Remove(3,3);
}
else

{
money = money.Remove(3,1);
}
}
else

{
if(money[4].ToString()=="0")

{
money = money.Remove(5,1);
}
}

}
return money;
}
posted on
2006-11-01 14:54
huazi4995
阅读(
431)
评论()
收藏
举报