Asp tutorial. net up to millions of RMB in lowercase to uppercase
/// <Summary>
/// Convert the lower-case amount to the upper-case amount
/// </Summary>
/// <Param name = "number"> </param>
/// <Param name = "turntype"> </param>
/// <Returns> </returns>
Public static string converttochnmoney (decimal number, chnmoneytype turntype)
{
String s_chnnumstring = "";
// The correct maximum amount can reach 100,000 trillion yuan, with a score of million yuan or million
String result = string. empty;
If (number> 0)
{
String s_dxdw = "yuanqibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaiwanzhibaibaibaibaibaibai ";
Ulong je = (ulong) (number * 100 );
Ulong temnum = je;
Int index = 0;
For (int n = 0; temnum! = 0; n ++)
{
Index = (int) (temnum-temnum/10*10); // retrieve the last number
Temnum = temnum/10;
Result = s_chnnumstring.substring (index, 1) + s_dxdw.substring (n, 1) + result; // invoice format
}
If (turntype = chnmoneytype. checktype)
{
String temresult = string. empty;
String temmoney = string. empty;
String unit = string. empty;
String digitchar = string. empty;
String str1 = "Zero RMB ";
String str2 = "Zero yuan, trillion yuan ";
For (int n = result. length-2; n> = 0; n = n-2) // retrieves strings from each of the following two.
{
Temmoney = result. substring (n, 2 );
Unit = temmoney. substring (1, 1 );
Digitchar = temmoney. substring (0, 1 );
Switch (unit)
{
Case "points ":
If (digitchar = "0 ")
Temmoney = "whole ";
Break;
Case "RMB ":
Case "Ten Thousand ":
Case "":
String temdigitchar = temresult. substring (0, 1 );
If (digitchar = "0 ")
{
If (str1.indexof (temdigitchar) =-1)
Temmoney = unit + "zero ";
Else
{
If (temdigitchar = "Ten Thousand ")
Temresult = temresult. substring (1 );
Temmoney = unit;
}
}
Else if (temdigitchar = "")
Temresult = temresult. substring (1 );
Break;
Default:
If (digitchar = "0 ")
{
If (str2.indexof (temresult. substring (0, 1 ))! =-1)
Temmoney = "";
Else
Temmoney = "0 ";
}
Break;
}
Temresult = temmoney + temresult;
}
Result = temresult;
}
}
Return result;
}
}
/// <Summary>
/// Format of the large amount.
/// </Summary>
Public enum chnmoneytype
{
/// <Summary>
/// Check format
/// </Summary>
Checktype,
/// <Summary>
/// Invoice format
/// </Summary>
Invoicetype
}