Public class MoneyConvertChinese
{
/// <Summary>
/// Convert the amount to uppercase
/// </Summary>
/// <Param name = "LowerMoney"> amount to be converted </param>
/// <Returns> capital amount </returns>
Public string MoneyToChinese (string LowerMoney)
{
String functionReturnValue = null;
Bool IsNegative = false; // whether it is a negative number
If (LowerMoney. Trim (). Substring (0, 1) = "-")
{
LowerMoney = LowerMoney. Trim (). Remove (0, 1 );
IsNegative = true;
}
Try
{
String strLower = null;
String strUPart = null;
String strUpper = null;
Int iTemp = 0;
LowerMoney = Math. Round (double. Parse (LowerMoney), 2). ToString ();
// Keep it to two decimal places
If (LowerMoney. IndexOf (".")> 0)
{
If (LowerMoney. IndexOf (".") = LowerMoney. Length-2)
{
LowerMoney = LowerMoney + "0 ";
}
}
Else
{
LowerMoney = LowerMoney + ". 00 ";
}
StrLower = LowerMoney;
ITemp = 1;
StrUpper = "";
While (iTemp <= strLower. Length)
{
Switch (strLower. Substring (strLower. Length-iTemp, 1 ))
{
Case ".":
StrUPart = "circle ";
Break;
Case "0 ":
StrUPart = "zero ";
Break;
Case "1 ":
StrUPart = "1 ";
Break;
Case "2 ":
StrUPart = "II ";
Break;
Case "3 ":
StrUPart = "";
Break;
Case "4 ":
StrUPart = "Si ";
Break;
Case "5 ":
StrUPart = "Wu ";
Break;
Case "6 ":
StrUPart = "";
Break;
Case "7 ":
StrUPart = "parts ";
Break;
Case "8 ":
StrUPart = "parts ";
Break;
Case "9 ":
StrUPart = "parts ";
Break;
}
Switch (iTemp)
{
Case 1:
StrUPart = strUPart + "points ";
Break;
Case 2:
StrUPart = strUPart + "";
Break;
Case 3:
StrUPart = strUPart + "";
Break;
Case 4:
StrUPart = strUPart + "";
Break;
Case 5:
StrUPart = strUPart + "pick up ";
Break;
Case 6:
StrUPart = strUPart + "parts ";
Break;
Case 7:
StrUPart = strUPart + "parts ";
Break;
Case 8:
StrUPart = strUPart + "Ten Thousand ";
Break;
Case 9:
StrUPart = strUPart + "pick up ";
Break;
Case 10:
StrUPart = strUPart + "parts ";
Break;
Case 11:
StrUPart = strUPart + "parts ";
Break;
Case 12:
StrUPart = strUPart + "";
Break;
Case 13:
StrUPart = strUPart + "pick up ";
Break;
Case 14:
StrUPart = strUPart + "parts ";
Break;
Case 15:
StrUPart = strUPart + "parts ";
Break;
Case 16:
StrUPart = strUPart + "Ten Thousand ";
Break;
Default:
StrUPart = strUPart + "";
Break;
}
StrUpper = strUPart + strUpper;
ITemp = iTemp + 1;
}
StrUpper = strUpper. Replace ("Zero pick", "zero ");
StrUpper = strUpper. Replace ("zero percent", "zero ");
StrUpper = strUpper. Replace ("zero percent", "zero ");
StrUpper = strUpper. Replace ("zero", "zero ");
StrUpper = strUpper. Replace ("zero", "zero ");
StrUpper = strUpper. Replace ("zero-angle zero-point", "whole ");
StrUpper = strUpper. Replace ("0 points", "whole ");
StrUpper = strUpper. Replace ("", "");
StrUpper = strUpper. Replace ("0 billion 0 thousand ");
StrUpper = strUpper. Replace ("0 thousand ");
StrUpper = strUpper. Replace ("0 billion 0 thousand", "");
StrUpper = strUpper. Replace ("0 thousand ");
StrUpper = strUpper. Replace ("", "");
StrUpper = strUpper. Replace ("0 billion ");
StrUpper = strUpper. Replace ("0 thousand ");
StrUpper = strUpper. Replace ("0 circle", "circle ");
StrUpper = strUpper. Replace ("zero", "zero ");
// Processing the amount below the yundun
If (strUpper. Substring (0, 1) = "circle ")
{
StrUpper = strUpper. Substring (1, strUpper. Length-1 );
}
If (strUpper. Substring (0, 1) = "0 ")
{
StrUpper = strUpper. Substring (1, strUpper. Length-1 );
}
If (strUpper. Substring (0, 1) = "")
{
StrUpper = strUpper. Substring (1, strUpper. Length-1 );
}
If (strUpper. Substring (0, 1) = "points ")
{
StrUpper = strUpper. Substring (1, strUpper. Length-1 );
}
If (strUpper. Substring (0, 1) = "integer ")
{
StrUpper = "Zero circle ";
}
FunctionReturnValue = strUpper;
}
Catch
{
FunctionReturnValue = "Zero circle ";
}
If (IsNegative = true)
{
Return "negative" + functionReturnValue;
}
Else
{
Return functionReturnValue;
}
}
}