전체소스코드
static str convert_RealToKOR_WithOutDec(real _Amount_real)
{
str _Amount_str = "";
container _Amount_container_Each = conNull();
container _Amount_container = conNull();
int _Amount_Unit = 0;
int _Amount_int = 0;
container _containerSort = conNull();
int _i = 0;
str _ToKOR_Each = "";
str _ToKOR = "";
str _Unit1 = "";
str _Unit2 = "";
str _Unit3 = "";
str _Unit4 = "";
_Amount_str = strReplace(strFmt("%1",decRound(_Amount_real,0)),",","");
_Amount_str = subStr(_Amount_str,1,strScan(_Amount_str,".",1,strLen(_Amount_str))-1);
for(_i=1;_i<=strLen(_Amount_str);_i++)
{
_Amount_container_Each = [_i,str2int(subStr(_Amount_str,_i,1))];
_Amount_container += [_Amount_container_Each];
}
_containerSort = PBU_DataType_Helper::sort_Container(_Amount_container,"DESC");
_i = 0;
for (_i=1;_i<=conLen(_containerSort);_i++)
{
_Amount_int = conPeek(conPeek(_containerSort,_i),2);
if(_Amount_int !=0)
{
_ToKOR_Each = PBU_DataType_Helper::convert_IntToSTRForRealToKOR(_Amount_int,_i);
//만(萬) 10000
if(_Unit1 =="" && _ToKOR_Each != "" && (_i >=5 && _i <=8))
{
_Unit1 = "만";
_ToKOR = strFmt("%1%2%3",_ToKOR_Each,_Unit1,_ToKOR);
}
//억(億) 10의 8제곱 (1만의 1만배)
else if(_Unit2 =="" && _ToKOR_Each != "" && (_i >=9 && _i <=12))
{
_Unit2 = "억";
_ToKOR = strFmt("%1%2%3",_ToKOR_Each,_Unit2,_ToKOR);
}
//조(兆) 10의 12제곱 (1억의 1만배)
else if(_Unit3 =="" && _ToKOR_Each != "" && (_i >=13 && _i <=16))
{
_Unit3 = "조";
_ToKOR = strFmt("%1%2%3",_ToKOR_Each,_Unit3,_ToKOR);
}
//경(京) 10의 16제곱 (1조의 1만배)
else if(_Unit4 =="" && _ToKOR_Each != "" && (_i ==17))
{
_Unit4 = "경";
_ToKOR = strFmt("%1%2%3",_ToKOR_Each,_Unit4,_ToKOR);
}
else if(_i > 17)
{
_ToKOR = strFmt("%1","#################");
}
else
{
_ToKOR = strFmt("%1%2",_ToKOR_Each,_ToKOR);
}
}
_Amount_int = 0;
}
return _ToKOR;
}
static container sort_Container(container _container, str _sort = "DESC")
{
container _containerSort = _container;
container _TempContainer1;
container _TempContainer2;
int _i;
int _j;
for (_i = 1; _i <= conlen(_containerSort); _i++)
{
for (_j = _i + 1; _j <= conlen(_containerSort); _j++)
{
_TempContainer1 = conpeek(_containerSort, _i);
_TempContainer2 = conpeek(_containerSort, _j);
switch (_sort)
{
case "DESC":
if (conpeek(_TempContainer1,1) < conpeek(_TempContainer2,1))
{
_containerSort = condel(_containerSort, _j, 1);
_containerSort = conins(_containerSort, _j, _TempContainer1);
_containerSort = condel(_containerSort, _i, 1);
_containerSort = conins(_containerSort, _i, _TempContainer2);
}
break;
case "ASC":
if (conpeek(_TempContainer1,1) > conpeek(_TempContainer2,1))
{
_containerSort = condel(_containerSort, _j, 1);
_containerSort = conins(_containerSort, _j, _TempContainer1);
_containerSort = condel(_containerSort, _i, 1);
_containerSort = conins(_containerSort, _i, _TempContainer2);
}
break;
}
}
}
return _containerSort;
}
static str 10 convert_IntToSTRForRealToKOR(int _Amount_int,
int _Amount_Unit)
{
str 10 _AmountKORWord="";
switch (_Amount_int)
{
case 1:
_AmountKORWord = "일";
break;
case 2:
_AmountKORWord = "이";
break;
case 3:
_AmountKORWord = "삼";
break;
case 4:
_AmountKORWord = "사";
break;
case 5:
_AmountKORWord = "오";
break;
case 6:
_AmountKORWord = "육";
break;
case 7:
_AmountKORWord = "칠";
break;
case 8:
_AmountKORWord = "팔";
break;
case 9:
_AmountKORWord = "구";
break;
case 10:
_AmountKORWord = "십";
break;
}
switch (_Amount_Unit)
{
case 1:
_AmountKORWord = _AmountKORWord +"";
break;
case 2:
_AmountKORWord = _AmountKORWord +"십";
break;
case 3:
_AmountKORWord = _AmountKORWord +"백";
break;
case 4:
_AmountKORWord = _AmountKORWord +"천";
break;
case 5:
_AmountKORWord = _AmountKORWord +"";
break;
case 6:
_AmountKORWord = _AmountKORWord +"십";
break;
case 7:
_AmountKORWord = _AmountKORWord +"백";
break;
case 8:
_AmountKORWord = _AmountKORWord +"천";
break;
case 9:
_AmountKORWord = _AmountKORWord +"";
break;
case 10:
_AmountKORWord = _AmountKORWord +"십";
break;
case 11:
_AmountKORWord = _AmountKORWord +"백";
break;
case 12:
_AmountKORWord = _AmountKORWord +"천";
break;
case 13:
_AmountKORWord = _AmountKORWord +"";
break;
case 14:
_AmountKORWord = _AmountKORWord +"십";
break;
case 15:
_AmountKORWord = _AmountKORWord +"백";
break;
case 16:
_AmountKORWord = _AmountKORWord +"천";
break;
}
return _AmountKORWord;
}
No comments:
Post a Comment