Asp.net can convert tens of millions of RMB to uppercase in lowercase

Source: Internet
Author: User

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
}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.