using System.Text; // using GreatFriends.ThaiBahtText; namespace BMA.EHR.Recruit.Service.Extensions { public static class IntegerExtension { // public static string ToThaiBahtText(this int value, bool appendBahtOnly) // { // var decValue = (decimal)value; // return decValue.ThaiBahtText(appendBahtOnly: appendBahtOnly); // } public static string ToThaiMonth(this int value) { switch (value) { case 1: return "มกราคม"; case 2: return "กุมภาพันธ์"; case 3: return "มีนาคม"; case 4: return "เมษายน"; case 5: return "พฤษภาคม"; case 6: return "มิถุนายน"; case 7: return "กรกฎาคม"; case 8: return "สิงหาคม"; case 9: return "กันยายน"; case 10: return "ตุลาคม"; case 11: return "พฤศจิกายน"; case 12: return "ธันวาคม"; default: return ""; } } public static int ToThaiYear(this int value) { if (value < 2400) return value + 543; else return value; } public static int ToCeYear(this int value) { if (value >= 2400) return value - 543; else return value; } public static string ToNumericText(this int number) { return number.ToString("#,##0"); } public static string ToThaiNumber(this string value) { string arabicNumbers = "0123456789"; string thaiNumbers = "๐๑๒๓๔๕๖๗๘๙"; StringBuilder result = new StringBuilder(); foreach (char digit in value) { int index = arabicNumbers.IndexOf(digit); if (index >= 0) { result.Append(thaiNumbers[index]); } else { result.Append(digit); } } return result.ToString(); } } }