export payment
This commit is contained in:
parent
b7b2ea40d0
commit
9a71ab6b87
3 changed files with 105 additions and 0 deletions
|
|
@ -70,5 +70,46 @@ namespace BMA.EHR.Recurit.Exam.Service.Extensions
|
|||
}
|
||||
return result.ToString();
|
||||
}
|
||||
|
||||
public static string NumberToThaiText(this float number)
|
||||
{
|
||||
int baht = (int)number; // แยกส่วนบาท
|
||||
int satang = (int)Math.Round((number - baht) * 100); // คำนวณสตางค์ (ปัดเป็นจำนวนเต็ม)
|
||||
|
||||
string bahtText = ConvertIntToThai(baht) + "บาท";
|
||||
string satangText = satang > 0 ? ConvertIntToThai(satang) + "สตางค์" : "ถ้วน";
|
||||
|
||||
return bahtText + satangText;
|
||||
}
|
||||
|
||||
public static string ConvertIntToThai(int number)
|
||||
{
|
||||
string[] unit = { "", "สิบ", "ร้อย", "พัน", "หมื่น", "แสน", "ล้าน" };
|
||||
string[] digit = { "ศูนย์", "หนึ่ง", "สอง", "สาม", "สี่", "ห้า", "หก", "เจ็ด", "แปด", "เก้า" };
|
||||
|
||||
string result = "";
|
||||
string numStr = number.ToString();
|
||||
int len = numStr.Length;
|
||||
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
int num = numStr[i] - '0';
|
||||
int pos = len - i - 1;
|
||||
|
||||
if (num != 0)
|
||||
{
|
||||
if (pos == 1 && num == 1)
|
||||
result += "สิบ";
|
||||
else if (pos == 1 && num == 2)
|
||||
result += "ยี่สิบ";
|
||||
else if (pos == 0 && num == 1 && len > 1)
|
||||
result += "เอ็ด";
|
||||
else
|
||||
result += digit[num] + unit[pos];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue