#region 大寫國字轉換
private string ChangeText(int _value)
{
string _text = " 零 角整";
int _length = Convert.ToString(_value).Length;
#region 個位數
try
{
_text = " " + ChangeTextCT(Convert.ToInt32(Convert.ToString(_value).Substring(_length - 1).Substring(0, 1))) + " 元" + _text;
}
catch (Exception)
{
_text = " 零 元" + _text;
}
#endregion
#region 拾位數
try
{
_text = " " + ChangeTextCT(Convert.ToInt32(Convert.ToString(_value).Substring(_length - 2).Substring(0, 1))) + " 拾" + _text;
}
catch (Exception)
{
_text = " 零 拾" + _text;
}
#endregion
#region 佰位數
try
{
_text = " " + ChangeTextCT(Convert.ToInt32(Convert.ToString(_value).Substring(_length - 3).Substring(0, 1))) + " 佰" + _text;
}
catch (Exception)
{
_text = " 零 佰" + _text;
}
#endregion
#region 仟位數
try
{
_text = " " + ChangeTextCT(Convert.ToInt32(Convert.ToString(_value).Substring(_length - 4).Substring(0, 1))) + " 仟" + _text;
}
catch (Exception)
{
_text = " 零 仟" + _text;
}
#endregion
#region 萬位數
try
{
_text = " " + ChangeTextCT(Convert.ToInt32(Convert.ToString(_value).Substring(_length - 5).Substring(0, 1))) + " 萬" + _text;
}
catch (Exception)
{
_text = " 零 萬" + _text;
}
#endregion
#region 拾萬位數
try
{
_text = " " + ChangeTextCT(Convert.ToInt32(Convert.ToString(_value).Substring(_length - 6).Substring(0, 1))) + " 拾萬" + _text;
}
catch (Exception)
{
_text = " 零 拾萬" + _text;
}
#endregion
return _text;
}
private string ChangeTextCT(int _value)
{
string _text = "";
switch (_value)
{
case 0:
_text = "零";
break;
case 1:
_text = "壹";
break;
case 2:
_text = "貳";
break;
case 3:
_text = "參";
break;
case 4:
_text = "肆";
break;
case 5:
_text = "伍";
break;
case 6:
_text = "陸";
break;
case 7:
_text = "柒";
break;
case 8:
_text = "捌";
break;
case 9:
_text = "玖";
break;
default:
_text = "零";
break;
}
return _text;
}
#endregion
C#将数字转化为 大写金额类型
最新推荐文章于 2024-06-07 16:44:26 发布