ÀÔ±Ý ¿¹Á¤ÀÏ + ÀԱݿ¹Á¤ ±Ý¾×ÀÌ Àִµ¥ ¹ÝÇØ
µé¾î¿Â ±Ý¾×Àº partial·Î ¾î´À°Ô ¾î´À°ÍÀÎÁö ¸ð¸£°Ô µé¾î ¿Â case°¡ ÀÖ½À´Ï´Ù.
1.ÀÏ´Ü µé¾î¿Â »ç¶÷µé ¸ñ·ÏÀ» ´ÙÀ½
2.µé¾î¿Â°Í ¸ñ·ÏÀ¸·Î ¸¸µì´Ï´Ù.
3.ÀÔ±Ý ¿¹Á¤ ¸ñ·ÏÀ» ¸¸µì´Ï´Ù.
1ÀÇ Á¶°ÇÀ¸·Î whileÀ» ¸¸µë !Eof
2ÀÇ Á¶°Ç°ªÀ» °¡Á®¿Í¼ while·Î ¸¸µë !Eof
3ÀÇ Á¶°Ç°ªÀ» °¡Á®¿Í¼Ò while·Î ¸¸µë .t.
2ÀÇ ±Ý¾×À» 3ÀÇ °ªÀ» »©°í ³²À¸¸é
3ÀÇ ´ÙÀ½À¸·Î ³Ñ°Å°¨
3ÀÇ °ªÀÌ ´õ ¸¹À¸¸é 2ÀÇ ³²Àº °ªÀ» ±â¾ïÇÏ°í
2ÀÇ ´ÙÀ½ °ªÀ¸·Î skip
2°ªÀ» 3°ú °è¼Ó ºñ±³
ÀÌ·±½ÄÀ¸·Î ÇÁ·Î±×·¥À» ¸¸µé¾î ÇØ°áÇß½À´Ï´Ù ¤Ð¤Ð
KMPAY->( dbGotop() )
oMeter := TDrMeta():New( "Converting...", "Wait...", KMPAY->( RecCount() ) )
WHILE !KMPAY->(Eof())
cQuery := "select * from m_pay where J_NO = " + ALLTRIM( KMPAY->J_NO ) + " and pay_code='001' order by pay_code2,pay_date"
::oPayDb:Query( cQuery,,,,,.f.)
oMeter:SetData( ++nCounter )
KMPAY2->(OrdScope( 0, KMPAY->J_NO ))
KMPAY2->(OrdScope( 1, KMPAY->J_NO ))
KMPAY2->(dbGotop())
WHILE !KMPAY2->(Eof())
nMoney := KMPAY2->J_MONEY
nInMoney := 0
WHILE .T.
//kmpay2->(dr_browse())
//::oPayDb:Browse()
IF nMoney - (::oPayDb:PAY_MONEY - nInMoney) >= 0
::oPayDb:PAY_IN_MONEY := ::oPayDb:PAY_MONEY
::oPayDb:PAY_IN_DATE := KMPAY2->J_DATE
nMoney := nMoney - (::oPayDb:PAY_MONEY - nInMoney)
nInMoney := 0
::oPayDb:update()
::oPayInDb:Blank()
::oPayInDb:CITY_CODE := "002"
::oPayInDb:J_NO := KMPAY->J_NO
::oPayInDb:PAY_CODE := ::oPayDb:PAY_CODE
::oPayInDb:PAY_CODE2 := ::oPayDb:PAY_CODE2
::oPayInDb:PAY_NAME := ::oPayDb:PAY_NAME
::oPayInDb:PAY_IN_DATE := KMPAY2->J_DATE
::oPayInDb:PAY_IN_MONEY := ::oPayDb:PAY_MONEY
::oPayInDb:PAY_BANK := KMPAY2->J_BANK
::oPayInDb:PAY_SENDER := KMPAY2->J_NAME
::oPayInDb:Insert()
::oPayDb:Skip()
ELSE
nInMoney += nMoney
KMPAY2->(dbSkip())
nMoney := KMPAY2->J_MONEY
ENDIF
IF nMoney == 0
EXIT
ENDIF
IF KMPAY2->(Eof())
EXIT
ENDIF
ENDDO
KMPAY2->( dbSkip() )
ENDDO
IF nInMoney > 0
KMPAY2->( dbSkip(-1) )
::oPayDb:PAY_IN_MONEY := nInMoney
::oPayDb:PAY_IN_DATE := KMPAY2->J_DATE
::oPayDb:update()
::oPayInDb:CITY_CODE := "002"
::oPayInDb:J_NO := KMPAY->J_NO
::oPayInDb:PAY_CODE := ::oPayDb:PAY_CODE
::oPayInDb:PAY_CODE2 := ::oPayDb:PAY_CODE2
::oPayInDb:PAY_NAME := ::oPayDb:PAY_NAME
::oPayInDb:PAY_IN_DATE := KMPAY2->J_DATE
::oPayInDb:PAY_IN_MONEY := nInMoney
::oPayInDb:PAY_BANK := KMPAY2->J_BANK
::oPayInDb:PAY_SENDER := KMPAY2->J_NAME
::oPayInDb:Insert()
ENDIF
KMPAY->( dbSkip() )
ENDDO
oMeter:End()