ITS0040MF.cpp 26 KB

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