ITS0040MF.cpp 26 KB

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