ITS0040MF.cpp 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "ITSDbF.h"
  6. #include "AppGlobalF.h"
  7. #include "CDSCodeF.h"
  8. #include "CDSNodeF.h"
  9. #include "CDSLinkF.h"
  10. #include "CDSIfscF.h"
  11. #include "CDSRoadF.h"
  12. #include "ITSLangTransF.h"
  13. #pragma hdrstop
  14. #include "ITS0040MF.h"
  15. #include "ITSSEL2MF.h"
  16. #include "ITSSELAMF.h"
  17. //---------------------------------------------------------------------------
  18. #pragma package(smart_init)
  19. #pragma link "cxButtonEdit"
  20. #pragma link "cxButtons"
  21. #pragma link "cxCalc"
  22. #pragma link "cxClasses"
  23. #pragma link "cxContainer"
  24. #pragma link "cxControls"
  25. #pragma link "cxCustomData"
  26. #pragma link "cxData"
  27. #pragma link "cxDataStorage"
  28. #pragma link "cxDropDownEdit"
  29. #pragma link "cxEdit"
  30. #pragma link "cxFilter"
  31. #pragma link "cxGraphics"
  32. #pragma link "cxGrid"
  33. #pragma link "cxGridCustomTableView"
  34. #pragma link "cxGridCustomView"
  35. #pragma link "cxGridLevel"
  36. #pragma link "cxGridTableView"
  37. #pragma link "cxGroupBox"
  38. #pragma link "cxLabel"
  39. #pragma link "cxLookAndFeelPainters"
  40. #pragma link "cxLookAndFeels"
  41. #pragma link "cxMaskEdit"
  42. #pragma link "cxSpinEdit"
  43. #pragma link "cxSplitter"
  44. #pragma link "cxStyles"
  45. #pragma link "cxTextEdit"
  46. #pragma link "dxSkinBlack"
  47. #pragma link "dxSkinBlue"
  48. #pragma link "dxSkinsCore"
  49. #pragma link "dxSkinscxPCPainter"
  50. #pragma resource "*.dfm"
  51. TITS0040M *ITS0040M = NULL;
  52. //---------------------------------------------------------------------------
  53. __fastcall TITS0040M::TITS0040M(TComponent* Owner)
  54. : TForm(Owner)
  55. {
  56. LangTrans->Translate(this, ITSDb_GetConnection());
  57. ITSSkin_Load(this);
  58. CMM_LoadForm(g_sFormsDir, this);
  59. FTitle = Caption;//"반복정체구간 관리";
  60. }
  61. //---------------------------------------------------------------------------
  62. /*
  63. * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
  64. * Form과 DataModule class를 delete시킨다.
  65. * arguments
  66. *
  67. * return
  68. * void
  69. */
  70. void __fastcall TITS0040M::CommClose()
  71. {
  72. try
  73. {
  74. CMM_SaveForm(g_sFormsDir, this);
  75. }
  76. catch(...)
  77. {
  78. }
  79. }
  80. //---------------------------------------------------------------------------
  81. /*
  82. * form 초기화
  83. *
  84. * arguments
  85. *
  86. * return
  87. * void
  88. */
  89. void __fastcall TITS0040M::FormInit()
  90. {
  91. //SendMessage(DateTimePicker1->Handle, DTM_SETFORMAT, 0, Longint("HH:mm:ss"));
  92. //DateTimePicker1->Time = FormatDateTime("HH:mm:ss", Time());
  93. m_pGDC1 = TvList1->DataController;
  94. m_pGDC2 = TvList2->DataController;
  95. TvList1->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<예상 반복정체구간 정보가 없습니다>";
  96. TvList2->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<확정 반복정체구간 정보가 없습니다>";
  97. FCodeRCS = ItsCodeManager->FLists.Find("RCS"); //반복정체구간 출처 유형
  98. FCodeDTW = ItsCodeManager->FLists.Find("DTW"); //요일유형
  99. FCodeLTC = ItsCodeManager->FLists.Find("LTC"); //소통등급
  100. FCodeIFD = ItsCodeManager->FLists.Find("IFD"); //정보제공구간 방향코드
  101. if (FCodeDTW)
  102. {
  103. CbDayType->Properties->Items->Clear();
  104. FOR_STL(TItsSubCode *, pSubCode, FCodeDTW->FSubLists)
  105. {
  106. CbDayType->Properties->Items->Add("[" + pSubCode->CMMN_CD + "] " + pSubCode->CMMN_CD_KOR_NM);
  107. }
  108. CbDayType->ItemIndex = 0;
  109. }
  110. }
  111. //---------------------------------------------------------------------------
  112. /*
  113. * Form을 보여줄때 호출되는 event 메서드이다.
  114. * arguments
  115. * Sender : event handler 객체
  116. * return
  117. * void
  118. */
  119. void __fastcall TITS0040M::FormShow(TObject *Sender)
  120. {
  121. Refresh();
  122. FormInit();
  123. TmrShow->Enabled = true;
  124. }
  125. //---------------------------------------------------------------------------
  126. /*
  127. * Form이 Show되고 난 후 최초 1회 수행되는 타이머 이벤트
  128. * arguments
  129. * Sender : event handler 객체
  130. * return
  131. * void
  132. */
  133. void __fastcall TITS0040M::TmrShowTimer(TObject *Sender)
  134. {
  135. TmrShow->Enabled = false;
  136. BtnSearchClick((TObject*)BtnSearch);
  137. }
  138. //---------------------------------------------------------------------------
  139. /*
  140. * Search 버튼 클릭 이벤트 핸들러
  141. * arguments
  142. * Sender : event handler 객체
  143. * return
  144. * void
  145. */
  146. void __fastcall TITS0040M::BtnSearchClick(TObject *Sender)
  147. {
  148. Application->ProcessMessages();
  149. TSqlCursor sqlCrs((TControl*)BtnSearch);
  150. RefreshData();
  151. }
  152. //---------------------------------------------------------------------------
  153. /*
  154. * Refresh Data Event Function
  155. * arguments
  156. *
  157. * return
  158. * void
  159. */
  160. void __fastcall TITS0040M::RefreshData()
  161. {
  162. ItsRepeatCongestManager->LoadFromDb();
  163. SelConfirmList();
  164. SelUnConfirmList();
  165. }
  166. //---------------------------------------------------------------------------
  167. void __fastcall TITS0040M::SelConfirmList()
  168. {
  169. TItsIfsc *pSvcLink;
  170. TItsSubCode *pSubCode;
  171. CMM_ClearGridTableView(TvList2);
  172. int nRow2 = 0;
  173. try
  174. {
  175. TvList2->BeginUpdate();
  176. try
  177. {
  178. ItsRepeatCongestManager->FListsCnfm.Lock();
  179. FOR_STL(TItsRepeatCongest*, pRpLink, ItsRepeatCongestManager->FListsCnfm)
  180. {
  181. //링크기본정보
  182. pSvcLink = ItsIfscManager->FLists.Find(pRpLink->IFSC_ID);
  183. if (!pSvcLink) continue; //기본정보가 없는 것은 보여줄 필요가 없다.
  184. String sStatTm = pRpLink->STAT_YM;
  185. if (sStatTm != "") sStatTm.Insert("-", 5);
  186. String sDTW = "[" + pRpLink->DAY_TYPE_CD + "] "; //요일 유형 코드
  187. if (FCodeDTW)
  188. {
  189. pSubCode = FCodeDTW->FSubLists.Find(pRpLink->DAY_TYPE_CD);
  190. if (pSubCode) sDTW = sDTW + pSubCode->CMMN_CD_KOR_NM;
  191. }
  192. String sStTm = pRpLink->CNFS_STRT_HM;
  193. sStTm.Insert(":", 3);
  194. String sEdTm = pRpLink->CNFS_END_HM;
  195. sEdTm.Insert(":", 3);
  196. #if 0
  197. String sCrtDt = pRpLink->CRTN_YMD;
  198. if (sCrtDt.Length() > 7)
  199. {
  200. sCrtDt.Insert("-", 7);
  201. }
  202. sCrtDt.Insert("-", 5);
  203. #endif
  204. String sRCS = "[" + pRpLink->REPT_CNGS_SECT_ORGN_CD + "] "; //반복 정체 구간 원본 코드
  205. if (FCodeRCS)
  206. {
  207. pSubCode = FCodeRCS->FSubLists.Find(pRpLink->REPT_CNGS_SECT_ORGN_CD);
  208. if (pSubCode) sRCS = sRCS + pSubCode->CMMN_CD_KOR_NM;
  209. }
  210. if (pRpLink->REPT_CNGS_SECT_ORGN_CD == "") sRCS = "";
  211. String sIFD = "[" + pSvcLink->DRCT_CD + "] ";
  212. if (FCodeIFD)
  213. {
  214. pSubCode = FCodeIFD->FSubLists.Find(pSvcLink->DRCT_CD); // 방향코드
  215. if (pSubCode) sIFD = sIFD + pSubCode->CMMN_CD_KOR_NM;
  216. }
  217. // if (pRpLink->DCSN_YN != "Y")
  218. nRow2 = m_pGDC2->AppendRecord();
  219. m_pGDC2->Values[nRow2][BColumn01->Index] = pSvcLink->IFSC_ID; //ID
  220. m_pGDC2->Values[nRow2][BColumn02->Index] = ITSUtil_FormatStr(pRpLink->STAT_YM, STR_MM); //통계년월
  221. m_pGDC2->Values[nRow2][BColumn03->Index] = sDTW; //요일
  222. m_pGDC2->Values[nRow2][BColumn04->Index] = sStTm; //혼잡시작시분
  223. m_pGDC2->Values[nRow2][BColumn05->Index] = sEdTm; //혼잡종료시분
  224. m_pGDC2->Values[nRow2][BColumn06->Index] = pRpLink->AVRG_SPED; //평균속도
  225. m_pGDC2->Values[nRow2][BColumn07->Index] = pRpLink->AVRG_TRVL_HH;//평균통행시간
  226. m_pGDC2->Values[nRow2][BColumn08->Index] = pRpLink->DCSN_YN; //확정여부
  227. //m_pGDC2->Values[nRow2][BColumn09->Index] = sCrtDt; //생성일자
  228. m_pGDC2->Values[nRow2][BColumn09->Index] = ITSUtil_FormatStr(pRpLink->CRTN_YMD, STR_DATE); //생성일자
  229. m_pGDC2->Values[nRow2][BColumn10->Index] = sRCS; //생성자
  230. m_pGDC2->Values[nRow2][BColumn11->Index] = pSvcLink->IFSC_NM; //명칭
  231. m_pGDC2->Values[nRow2][BColumn12->Index] = sIFD; //방향
  232. m_pGDC2->Values[nRow2][BColumn13->Index] = pSvcLink->STRT_NM; //시점명
  233. m_pGDC2->Values[nRow2][BColumn14->Index] = pSvcLink->END_NM; //종점명
  234. m_pGDC2->Values[nRow2][BColumn99->Index] = (int)pRpLink;
  235. }
  236. }
  237. __finally
  238. {
  239. ItsRepeatCongestManager->FListsCnfm.UnLock();
  240. }
  241. }
  242. __finally
  243. {
  244. TvList2->EndUpdate();
  245. TvList2->DataController->GotoFirst();
  246. TvList2->DataController->FocusedRecordIndex = 0;
  247. }
  248. }
  249. //---------------------------------------------------------------------------
  250. void __fastcall TITS0040M::SelUnConfirmList()
  251. {
  252. TItsIfsc *pSvcLink;
  253. TItsSubCode *pSubCode;
  254. CMM_ClearGridTableView(TvList1);
  255. int nRow1 = 0;
  256. try
  257. {
  258. TvList1->BeginUpdate();
  259. try
  260. {
  261. ItsRepeatCongestManager->FLists.Lock();
  262. FOR_STL(TItsRepeatCongest*, pRpLink, ItsRepeatCongestManager->FLists)
  263. {
  264. //링크기본정보
  265. pSvcLink = ItsIfscManager->FLists.Find(pRpLink->IFSC_ID);
  266. if (!pSvcLink) continue; //기본정보가 없는 것은 보여줄 필요가 없다.
  267. String sStatTm = pRpLink->STAT_YM;
  268. if (sStatTm != "") sStatTm.Insert("-", 5);
  269. String sDTW = "[" + pRpLink->DAY_TYPE_CD + "] "; //요일 유형 코드
  270. if (FCodeDTW)
  271. {
  272. pSubCode = FCodeDTW->FSubLists.Find(pRpLink->DAY_TYPE_CD);
  273. if (pSubCode) sDTW = sDTW + pSubCode->CMMN_CD_KOR_NM;
  274. }
  275. String sStTm = pRpLink->CNFS_STRT_HM;
  276. sStTm.Insert(":", 3);
  277. String sEdTm = pRpLink->CNFS_END_HM;
  278. sEdTm.Insert(":", 3);
  279. #if 0
  280. String sCrtDt = pRpLink->CRTN_YMD;
  281. if (sCrtDt.Length() > 7)
  282. {
  283. sCrtDt.Insert("-", 7);
  284. }
  285. sCrtDt.Insert("-", 5);
  286. #endif
  287. String sRCS = "[" + pRpLink->REPT_CNGS_SECT_ORGN_CD + "] "; //반복 정체 구간 원본 코드
  288. if (FCodeRCS)
  289. {
  290. pSubCode = FCodeRCS->FSubLists.Find(pRpLink->REPT_CNGS_SECT_ORGN_CD);
  291. if (pSubCode) sRCS = sRCS + pSubCode->CMMN_CD_KOR_NM;
  292. }
  293. if (pRpLink->REPT_CNGS_SECT_ORGN_CD == "") sRCS = "";
  294. String sIFD = "[" + pSvcLink->DRCT_CD + "] ";
  295. if (FCodeIFD)
  296. {
  297. pSubCode = FCodeIFD->FSubLists.Find(pSvcLink->DRCT_CD); // 방향코드
  298. if (pSubCode) sIFD = sIFD + pSubCode->CMMN_CD_KOR_NM;
  299. }
  300. // if (pRpLink->DCSN_YN != "Y")
  301. nRow1 = m_pGDC1->AppendRecord();
  302. m_pGDC1->Values[nRow1][AColumn01->Index] = pSvcLink->IFSC_ID; //ID
  303. m_pGDC1->Values[nRow1][AColumn02->Index] = ITSUtil_FormatStr(pRpLink->STAT_YM, STR_MM); //통계년월
  304. m_pGDC1->Values[nRow1][AColumn03->Index] = sDTW; //요일
  305. m_pGDC1->Values[nRow1][AColumn04->Index] = sStTm; //혼잡시작시분
  306. m_pGDC1->Values[nRow1][AColumn05->Index] = sEdTm; //혼잡종료시분
  307. m_pGDC1->Values[nRow1][AColumn06->Index] = pRpLink->AVRG_SPED; //평균속도
  308. m_pGDC1->Values[nRow1][AColumn07->Index] = pRpLink->AVRG_TRVL_HH;//평균통행시간
  309. m_pGDC1->Values[nRow1][AColumn08->Index] = pRpLink->DCSN_YN; //확정여부
  310. //m_pGDC1->Values[nRow1][AColumn09->Index] = sCrtDt; //생성일자
  311. m_pGDC1->Values[nRow1][AColumn09->Index] = ITSUtil_FormatStr(pRpLink->CRTN_YMD, STR_DATE); //생성일자
  312. m_pGDC1->Values[nRow1][AColumn10->Index] = sRCS; //생성자
  313. m_pGDC1->Values[nRow1][AColumn11->Index] = pSvcLink->IFSC_NM; //명칭
  314. m_pGDC1->Values[nRow1][AColumn12->Index] = sIFD; //방향
  315. m_pGDC1->Values[nRow1][AColumn13->Index] = pSvcLink->STRT_NM; //시점명
  316. m_pGDC1->Values[nRow1][AColumn14->Index] = pSvcLink->END_NM; //종점명
  317. m_pGDC1->Values[nRow1][AColumn99->Index] = (int)pRpLink;
  318. }
  319. }
  320. __finally
  321. {
  322. ItsRepeatCongestManager->FLists.UnLock();
  323. }
  324. }
  325. __finally
  326. {
  327. TvList1->EndUpdate();
  328. TvList1->DataController->GotoFirst();
  329. TvList1->DataController->FocusedRecordIndex = 0;
  330. }
  331. }
  332. //---------------------------------------------------------------------------
  333. /*
  334. * Close 버튼 클릭 이벤트 핸들러
  335. * arguments
  336. * Sender : event handler 객체
  337. * return
  338. * void
  339. */
  340. void __fastcall TITS0040M::BtnCloseClick(TObject *Sender)
  341. {
  342. Close();
  343. }
  344. //---------------------------------------------------------------------------
  345. void __fastcall TITS0040M::FormClose(TObject *Sender, TCloseAction &Action)
  346. {
  347. CommClose();
  348. ITS0040M = NULL;
  349. Action = caFree;
  350. }
  351. //---------------------------------------------------------------------------
  352. void __fastcall TITS0040M::BtnOperatorInputClick(TObject *Sender)
  353. {
  354. GrpOperatroInput->Visible = !GrpOperatroInput->Visible;
  355. }
  356. //---------------------------------------------------------------------------
  357. void __fastcall TITS0040M::EdLinkIdPropertiesButtonClick(TObject *Sender, int AButtonIndex)
  358. {
  359. PopupAddLink->Popup(EdLinkId->ClientOrigin.x, EdLinkId->ClientOrigin.y + EdLinkId->Height);
  360. }
  361. //---------------------------------------------------------------------------
  362. void __fastcall TITS0040M::MnuListListClick(TObject *Sender)
  363. {
  364. try {
  365. TITSSEL2M *pSelForm = new TITSSEL2M(this);
  366. pSelForm->m_bSelected = false;
  367. pSelForm->ShowModal();
  368. if (pSelForm->m_bSelected)
  369. {
  370. EdLinkId->Text = pSelForm->m_sSelLinkId;
  371. }
  372. delete pSelForm;
  373. } catch(...) { }
  374. }
  375. //---------------------------------------------------------------------------
  376. void __fastcall TITS0040M::MnuGisAddClick(TObject *Sender)
  377. {
  378. try {
  379. TITSSELAM *pSelForm = new TITSSELAM(this);
  380. pSelForm->MultiSelect = false;
  381. pSelForm->LinkLevel = 2;
  382. pSelForm->ShowModal();
  383. Application->ProcessMessages();
  384. if (pSelForm->Selected)
  385. {
  386. String sLinkId = pSelForm->TvList->DataController->Values[0][pSelForm->Column01->Index];
  387. TItsIfsc *pIfsc = ItsIfscManager->FLists.Find(sLinkId);
  388. if (!pIfsc)
  389. {
  390. Application->MessageBox(lblSelErr->Caption.c_str(),//L"정보가 없는 구간을 선택하였습니다. 다른 구간을 선택하세요.",
  391. FTitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
  392. return;
  393. }
  394. EdLinkId->Text = sLinkId;
  395. }
  396. delete pSelForm;
  397. } catch(...) { }
  398. }
  399. //---------------------------------------------------------------------------
  400. void __fastcall TITS0040M::BtnCnfmCancelClick(TObject *Sender)
  401. {
  402. UnconfirmData(true);
  403. }
  404. //---------------------------------------------------------------------------
  405. void __fastcall TITS0040M::BtnAppCancelClick(TObject *Sender)
  406. {
  407. UnconfirmData(false);
  408. }
  409. //---------------------------------------------------------------------------
  410. void __fastcall TITS0040M::UnconfirmData(bool AConfirm)
  411. {
  412. TcxGridTableView *TvList = TvList1;
  413. TcxDataController *pGDC = m_pGDC1;
  414. int nIdx = AColumn99->Index;
  415. String sTitle = lblGss1->Caption + " " + lblCancel->Caption;//"예상 반복정체구간 취소";
  416. if (AConfirm)
  417. {
  418. TvList = TvList2;
  419. pGDC = m_pGDC2;
  420. nIdx = BColumn99->Index;
  421. sTitle = lblGss2->Caption + " " + lblCancel->Caption;//"확정 반복정체구간 취소";
  422. }
  423. int nSelRows = TvList->Controller->SelectedRowCount;
  424. if (nSelRows <= 0)
  425. {
  426. Application->MessageBox(lblSelErr2->Caption.c_str(),//L"작업 할 정체구간을 선택하세요.",
  427. sTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  428. return;
  429. }
  430. if (Application->MessageBox(lblCancel2->Caption.c_str(),//L"선택한 정체구간을 취소 하시겠습니까?",
  431. sTitle.c_str(), MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return;
  432. TADOQuery *pADO = NULL;
  433. String sQry;
  434. try
  435. {
  436. TItsRepeatCongest *pRpLink;
  437. int nSelIdx, nMemPtr;
  438. TvList->BeginUpdate();
  439. sQry = "DELETE TB_REPT_CNGS_SECT \r\n"
  440. " WHERE IFSC_ID = :p01 \r\n"
  441. " AND STAT_YM = :p02 \r\n"
  442. " AND DAY_TYPE_CD = :p03 \r\n"
  443. " AND CNFS_STRT_HM = :p04 \r\n";
  444. try
  445. {
  446. pADO = new TADOQuery(NULL);
  447. pADO->Close();
  448. pADO->Connection = ITSDb_GetConnection();
  449. ITSDb_SQLText(pADO, sQry);
  450. ITSDb_GetConnection()->BeginTrans();
  451. for (int ii = 0; ii < nSelRows; ii++)
  452. {
  453. nSelIdx = TvList->Controller->SelectedRows[ii]->RecordIndex;
  454. nMemPtr = pGDC->Values[nSelIdx][nIdx];
  455. pRpLink = (TItsRepeatCongest *)nMemPtr;
  456. ITSDb_SQLBind(pADO, "p01", pRpLink->IFSC_ID);
  457. ITSDb_SQLBind(pADO, "p02", pRpLink->STAT_YM);
  458. ITSDb_SQLBind(pADO, "p03", pRpLink->DAY_TYPE_CD);
  459. ITSDb_SQLBind(pADO, "p04", pRpLink->CNFS_STRT_HM);
  460. ITSDb_SQLExec(pADO);
  461. }
  462. ITSDb_GetConnection()->CommitTrans();
  463. Application->MessageBox(lblCancel3->Caption.c_str(),//L"반복정체구간 취소 작업을 완료하였습니다.",
  464. sTitle.c_str(), MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  465. }
  466. catch(EDatabaseError &E)
  467. {
  468. ITSDb_GetConnection()->RollbackTrans();
  469. ShowMessage(String(E.ClassName()) + E.Message);
  470. }
  471. catch(Exception &exception)
  472. {
  473. ITSDb_GetConnection()->RollbackTrans();
  474. ShowMessage(String(exception.ClassName()) + exception.Message);
  475. }
  476. catch(...)
  477. {
  478. ITSDb_GetConnection()->RollbackTrans();
  479. ShowMessage(FrmLang->lblDbDelErr->Caption);//"데이터 삭제 중에 알수없는 DB 오류가 발생하였습니다.");
  480. }
  481. }
  482. __finally
  483. {
  484. if (pADO)
  485. {
  486. pADO->Close();
  487. delete pADO;
  488. }
  489. TvList->EndUpdate();
  490. RefreshData();
  491. }
  492. }
  493. //---------------------------------------------------------------------------
  494. void __fastcall TITS0040M::BtnApplyClick(TObject *Sender)
  495. {
  496. int nSelRows = TvList1->Controller->SelectedRowCount;
  497. if (nSelRows <= 0)
  498. {
  499. Application->MessageBox(lblQry1->Caption.c_str(),//L"반복정체구간으로 확정할 구간을 선택하세요.",
  500. lblCnfm->Caption.c_str(),//L"반복정체구간 확정",
  501. MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  502. return;
  503. }
  504. if (Application->MessageBox(lblQry2->Caption.c_str(),//L"선택한 구간을 반복정체구간으로 확정 하시겠습니까?",
  505. lblCnfm->Caption.c_str(),//L"반복정체구간 확정",
  506. MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return;
  507. TADOQuery *pADO = NULL;
  508. String sQry;
  509. try
  510. {
  511. TItsRepeatCongest *pRpLink;
  512. int nSelIdx, nMemPtr;
  513. TvList1->BeginUpdate();
  514. sQry = "UPDATE TB_REPT_CNGS_SECT \r\n"
  515. " SET DCSN_YN = 'Y' \r\n"
  516. " WHERE IFSC_ID = :p01 \r\n"
  517. " AND STAT_YM = :p02 \r\n"
  518. " AND DAY_TYPE_CD = :p03 \r\n"
  519. " AND CNFS_STRT_HM = :p04 \r\n";
  520. try
  521. {
  522. pADO = new TADOQuery(NULL);
  523. pADO->Close();
  524. pADO->Connection = ITSDb_GetConnection();
  525. ITSDb_SQLText(pADO, sQry);
  526. ITSDb_GetConnection()->BeginTrans();
  527. for (int ii = 0; ii < nSelRows; ii++)
  528. {
  529. nSelIdx = TvList1->Controller->SelectedRows[ii]->RecordIndex;
  530. nMemPtr = m_pGDC1->Values[nSelIdx][AColumn99->Index];
  531. pRpLink = (TItsRepeatCongest *)nMemPtr;
  532. ITSDb_SQLBind(pADO, "p01", pRpLink->IFSC_ID);
  533. ITSDb_SQLBind(pADO, "p02", pRpLink->STAT_YM);
  534. ITSDb_SQLBind(pADO, "p03", pRpLink->DAY_TYPE_CD);
  535. ITSDb_SQLBind(pADO, "p04", pRpLink->CNFS_STRT_HM);
  536. ITSDb_SQLExec(pADO);
  537. }
  538. ITSDb_GetConnection()->CommitTrans();
  539. Application->MessageBox(FrmLang->lblDbSave->Caption.c_str(),//L"예상 반복정체구간을 확정 반복정체구간으로 저장 하였습니다.",
  540. lblCnfm->Caption.c_str(),//L"반복정체구간 확정",
  541. MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  542. }
  543. catch(EDatabaseError &E)
  544. {
  545. ITSDb_GetConnection()->RollbackTrans();
  546. ShowMessage(String(E.ClassName()) + E.Message);
  547. }
  548. catch(Exception &exception)
  549. {
  550. ITSDb_GetConnection()->RollbackTrans();
  551. ShowMessage(String(exception.ClassName()) + exception.Message);
  552. }
  553. catch(...)
  554. {
  555. ITSDb_GetConnection()->RollbackTrans();
  556. ShowMessage(FrmLang->lblDbDelErr->Caption);//"데이터 삭제 중에 알수없는 DB 오류가 발생하였습니다.");
  557. }
  558. }
  559. __finally
  560. {
  561. if (pADO)
  562. {
  563. pADO->Close();
  564. delete pADO;
  565. }
  566. TvList1->EndUpdate();
  567. RefreshData();
  568. }
  569. }
  570. //---------------------------------------------------------------------------
  571. void __fastcall TITS0040M::BtnSaveClick(TObject *Sender)
  572. {
  573. String sSvcId = EdLinkId->Text.Trim();
  574. TItsIfsc *pIfsc;
  575. pIfsc = ItsIfscManager->FLists.Find(sSvcId);
  576. if (!pIfsc)
  577. {
  578. Application->MessageBox(lblQry3->Caption.c_str(),//L"등록되어 있지 않은 서비스 구간이거나 서비스 구간을 선택하지 않으셨습니다.\r\n서비스 구간을 확인 후 작업하세요.",
  579. lblOpr->Caption.c_str(),//L"반복정체구간 운영자등록",
  580. MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  581. ActiveControl = EdLinkId;
  582. return;
  583. }
  584. String sStTime = DtStTime->Time.FormatString("hhnn");
  585. String sEdTime = DtEdTime->Time.FormatString("hhnn");
  586. if (sStTime > sEdTime)
  587. {
  588. Application->MessageBox(lblQry4->Caption.c_str(),//L"혼잡 시작시분 과 혼잡 종료시분이 정확히 입력되지 않았습니다.\r\n혼잡 시작/종료 시각을 확인 후 작업하세요.",
  589. lblOpr->Caption.c_str(),//L"반복정체구간 운영자등록",
  590. MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  591. ActiveControl = DtStTime;
  592. return;
  593. }
  594. String sDayType = ITSUtil_GetCode(CbDayType->Text);
  595. TADOQuery *pADO = NULL;
  596. String sQry;
  597. try
  598. {
  599. TItsRepeatCongest *pRpLink;
  600. int nSelIdx;
  601. TvList1->BeginUpdate();
  602. sQry = "INSERT INTO TB_REPT_CNGS_SECT ( \r\n"
  603. " IFSC_ID , \r\n"
  604. " STAT_YM , \r\n"
  605. " DAY_TYPE_CD , \r\n"
  606. " CNFS_STRT_HM , \r\n"
  607. " CNFS_END_HM , \r\n"
  608. " AVRG_SPED , \r\n"
  609. " AVRG_TRVL_HH , \r\n"
  610. " DCSN_YN , \r\n"
  611. " CRTN_YMD , \r\n"
  612. " REPT_CNGS_SECT_ORGN_CD ) \r\n"
  613. " VALUES ( \r\n"
  614. " :p01, \r\n"
  615. " TO_CHAR(SYSDATE, 'YYYYMM'), \r\n"
  616. " :p02, \r\n"
  617. " :p03, \r\n"
  618. " :p04, \r\n"
  619. " :p05, \r\n"
  620. " :p06, \r\n"
  621. " 'Y', \r\n"
  622. " TO_CHAR(SYSDATE, 'YYYYMM'), \r\n"
  623. " 'RCS2' ) \r\n";
  624. try
  625. {
  626. pADO = new TADOQuery(NULL);
  627. pADO->Close();
  628. pADO->Connection = ITSDb_GetConnection();
  629. ITSDb_SQLText(pADO, sQry);
  630. ITSDb_GetConnection()->BeginTrans();
  631. ITSDb_SQLBind(pADO, "p01", sSvcId);
  632. ITSDb_SQLBind(pADO, "p02", sDayType);
  633. ITSDb_SQLBind(pADO, "p03", sStTime);
  634. ITSDb_SQLBind(pADO, "p04", sEdTime);
  635. ITSDb_SQLBind(pADO, "p05", SpSpeed->Value);
  636. ITSDb_SQLBind(pADO, "p06", SpAvgTm->Value);
  637. ITSDb_SQLExec(pADO);
  638. ITSDb_GetConnection()->CommitTrans();
  639. Application->MessageBox(FrmLang->lblDbSave->Caption.c_str(),//L"운영자 등록 반복정체구간 정보를 저장 하였습니다.",
  640. lblOpr->Caption.c_str(),//L"반복정체구간 운영자등록",
  641. MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  642. EdLinkId->Text = "";
  643. BtnOperatorInputClick(NULL);
  644. }
  645. catch(EDatabaseError &E)
  646. {
  647. ITSDb_GetConnection()->RollbackTrans();
  648. ShowMessage(String(E.ClassName()) + E.Message);
  649. }
  650. catch(Exception &exception)
  651. {
  652. ITSDb_GetConnection()->RollbackTrans();
  653. ShowMessage(String(exception.ClassName()) + exception.Message);
  654. }
  655. catch(...)
  656. {
  657. ITSDb_GetConnection()->RollbackTrans();
  658. ShowMessage(FrmLang->lblDbDelErr->Caption);//"데이터 삭제 중에 알수없는 DB 오류가 발생하였습니다.");
  659. }
  660. }
  661. __finally
  662. {
  663. if (pADO)
  664. {
  665. pADO->Close();
  666. delete pADO;
  667. }
  668. TvList1->EndUpdate();
  669. RefreshData();
  670. }
  671. }
  672. //---------------------------------------------------------------------------
  673. void __fastcall TITS0040M::TvList1DataControllerFilterChanged(TObject *Sender)
  674. {
  675. CMM_SetFilterLike(TvList1);
  676. }
  677. //---------------------------------------------------------------------------