123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- //---------------------------------------------------------------------------
- #pragma hdrstop
- #include "CDSTrafficOprLinkF.h"
- #include "ITS_OPLibF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- TItsTrafficOprLink::TItsTrafficOprLink()
- {
- FGridIndex = -1; // ±×¸®µå À妽º
- }
- //---------------------------------------------------------------------------
- TItsTrafficOprLink::~TItsTrafficOprLink()
- {
- }
- //---------------------------------------------------------------------------
- //---------------------------------------------------------------------------
- TItsTrafficOprLinkManager *ItsTrafficOprLinkManager = NULL;
- //---------------------------------------------------------------------------
- /*
- * TrafficOprLink Manager
- */
- TItsTrafficOprLinkManager::TItsTrafficOprLinkManager()
- {
- }
- //---------------------------------------------------------------------------
- TItsTrafficOprLinkManager::~TItsTrafficOprLinkManager()
- {
- }
- //---------------------------------------------------------------------------
- bool TItsTrafficOprLinkManager::LoadFromDb(TADOConnection *ADbConn/*=NULL*/)
- {
- String sQry;
- TADOQuery *pADO = NULL;
- sQry = "SELECT LINK_ID, CRTN_DT, \r\n"
- " APLY_STRT_DT, APLY_END_DT, \r\n"
- " NVL(TFVL, 0) AS TFVL, \r\n"
- " NVL(SPED, 0) AS SPED, \r\n"
- " NVL(OCPY_RATE, 0) AS OCPY_RATE, \r\n"
- " NVL(TRVL_HH, 0) AS TRVL_HH \r\n"
- " FROM TB_LINK_SYOP_TRAF \r\n";
- // " ORDER BY 1, 2 \r\n";
- try
- {
- FDataSeq = 0;
- FLists.Lock();
- FLists.RemoveAll();
- try
- {
- pADO = new TADOQuery(NULL);
- pADO->Close();
- pADO->Connection = (NULL != ADbConn) ? ADbConn : ITSDb_GetConnection();
- pADO->SQL->Clear();
- pADO->SQL->Text = sQry;
- pADO->Prepared = true;
- pADO->Open();
- for( ; !pADO->Eof; pADO->Next())
- {
- TItsTrafficOprLink *pTrafficOprLink = new TItsTrafficOprLink();
- pTrafficOprLink->LINK_ID = pADO->FieldByName("LINK_ID")->AsString;
- pTrafficOprLink->CRTN_DT = pADO->FieldByName("CRTN_DT")->AsString;
- pTrafficOprLink->APLY_STRT_DT = pADO->FieldByName("APLY_STRT_DT")->AsString;
- pTrafficOprLink->APLY_END_DT = pADO->FieldByName("APLY_END_DT")->AsString;
- pTrafficOprLink->TFVL = pADO->FieldByName("TFVL")->AsString;
- pTrafficOprLink->SPED = pADO->FieldByName("SPED")->AsString;
- pTrafficOprLink->OCPY_RATE = pADO->FieldByName("OCPY_RATE")->AsString;
- pTrafficOprLink->TRVL_HH = pADO->FieldByName("TRVL_HH")->AsString;
- FLists.Push(String(FDataSeq++), pTrafficOprLink);
- pTrafficOprLink->Completed = true;
- }
- }
- catch(EDatabaseError &E)
- {
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- DBERRORMSG("TItsTrafficOprLinkManager::LoadFromDb", String(E.ClassName()), E.Message, sQry);
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(Exception &exception)
- {
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- DBERRORMSG("TItsTrafficOprLinkManager::LoadFromDb", String(exception.ClassName()), exception.Message, sQry);
- throw Exception(String(exception.ClassName()) + exception.Message);
- }
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- delete pADO;
- }
- FLists.UnLock();
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool TItsTrafficOprLinkManager::AllDelete(TADOConnection *ADbConn/*=NULL*/)
- {
- String sQry;
- TADOQuery *pADO = NULL;
- sQry = "DELETE FROM TB_LINK_SYOP_TRAF \r\n";
- try
- {
- FDataSeq = 0;
- FLists.Lock();
- FLists.RemoveAll();
- try
- {
- pADO = new TADOQuery(NULL);
- pADO->Close();
- pADO->Connection = (NULL != ADbConn) ? ADbConn : ITSDb_GetConnection();
- pADO->SQL->Clear();
- pADO->SQL->Text = sQry;
- pADO->ExecSQL();
- }
- catch(EDatabaseError &E)
- {
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- DBERRORMSG("TItsTrafficOprLinkManager::AllDelete", String(E.ClassName()), E.Message, sQry);
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(Exception &exception)
- {
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- DBERRORMSG("TItsTrafficOprLinkManager::AllDelete", String(exception.ClassName()), exception.Message, sQry);
- throw Exception(String(exception.ClassName()) + exception.Message);
- }
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- delete pADO;
- }
- FLists.UnLock();
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool TItsTrafficOprLinkManager::AllApply(int ALinkLevel, TADOConnection *ADbConn/*=NULL*/)
- {
- String sQry;
- TADOQuery *pADO = NULL;
- if (ALinkLevel == 1)
- {
- sQry = "INSERT INTO TB_LINK_SYOP_TRAF(LINK_ID, CRTN_DT, APLY_STRT_DT, APLY_END_DT, TFVL, SPED, OCPY_RATE, TRVL_HH) \r\n"
- "SELECT LINK_ID, \r\n"
- " TO_CHAR(SYSDATE, 'YYYYMMDDHH24MISS') AS CRTN_DT, \r\n"
- " TO_CHAR(SYSDATE, 'YYYYMMDDHH24MISS') AS APLY_STRT_DT, \r\n"
- " TO_CHAR(SYSDATE+1, 'YYYYMMDDHH24MISS') AS APLY_END_DT, \r\n"
- " 0, \r\n"
- " 100, \r\n"
- " 0, \r\n"
- " 0 \r\n"
- " FROM TB_LINK_TRAF \r\n"
- " WHERE SPED > 0 \r\n";
- }
- else if (ALinkLevel == 2)
- {
- sQry = "INSERT INTO TB_LINK_SYOP_TRAF(LINK_ID, CRTN_DT, APLY_STRT_DT, APLY_END_DT, TFVL, SPED, OCPY_RATE, TRVL_HH) \r\n"
- "SELECT IFSC_ID, \r\n"
- " TO_CHAR(SYSDATE, 'YYYYMMDDHH24MISS') AS CRTN_DT, \r\n"
- " TO_CHAR(SYSDATE, 'YYYYMMDDHH24MISS') AS APLY_STRT_DT, \r\n"
- " TO_CHAR(SYSDATE+1, 'YYYYMMDDHH24MISS') AS APLY_END_DT, \r\n"
- " 0, \r\n"
- " 100, \r\n"
- " 0, \r\n"
- " 0 \r\n"
- " FROM TB_IFSC_TRAF \r\n"
- " WHERE SPED > 0 \r\n";
- }
- else return true;
- try
- {
- String sSysDate = Now().FormatString("YYYYMMDDHHNNSS");
- FLists.Lock();
- try
- {
- pADO = new TADOQuery(NULL);
- pADO->Close();
- pADO->Connection = (NULL != ADbConn) ? ADbConn : ITSDb_GetConnection();
- pADO->SQL->Clear();
- pADO->SQL->Text = sQry;
- //pADO->Parameters->ParamByName("p01")->Value = sSysDate
- pADO->ExecSQL();
- }
- catch(EDatabaseError &E)
- {
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- DBERRORMSG("TItsTrafficOprLinkManager::AllApply", String(E.ClassName()), E.Message, sQry);
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(Exception &exception)
- {
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- DBERRORMSG("TItsTrafficOprLinkManager::AllApply", String(exception.ClassName()), exception.Message, sQry);
- throw Exception(String(exception.ClassName()) + exception.Message);
- }
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- delete pADO;
- }
- FLists.UnLock();
- }
- return true;
- }
- //---------------------------------------------------------------------------
|