IST0070MF.cpp 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "AppGlobalF.h"
  6. #include "CDSCodeF.h"
  7. #include "ITSLangTransF.h"
  8. #pragma hdrstop
  9. #include "IST0070MF.h"
  10. #include "IST00701F.h"
  11. #include "IST00702F.h"
  12. #include "IST00703F.h"
  13. #include "CDSRoadF.h"
  14. #include "CDSIfscF.h"
  15. #include "CDSLinkF.h"
  16. //---------------------------------------------------------------------------
  17. #pragma package(smart_init)
  18. #pragma link "FRAME_LinkListF"
  19. #pragma link "FRAME_RoadListF"
  20. #pragma link "cxButtons"
  21. #pragma link "cxCalendar"
  22. #pragma link "cxCheckBox"
  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 "cxPC"
  44. #pragma link "cxPCdxBarPopupMenu"
  45. #pragma link "cxSplitter"
  46. #pragma link "cxStyles"
  47. #pragma link "cxTextEdit"
  48. #pragma link "dxSkinBlack"
  49. #pragma link "dxSkinBlue"
  50. #pragma link "dxSkinsCore"
  51. #pragma link "dxSkinscxPCPainter"
  52. #pragma link "FRAME_IfscListF"
  53. #pragma resource "*.dfm"
  54. TIST0070M *IST0070M = NULL;
  55. //---------------------------------------------------------------------------
  56. __fastcall TIST0070M::TIST0070M(TComponent* Owner)
  57. : TForm(Owner)
  58. {
  59. LangTrans->Translate(this, ITSDb_GetConnection());
  60. ITSSkin_Load(this);
  61. CMM_LoadForm(g_sFormsDir, this);
  62. ColumnSel->Options->Filtering = false;
  63. FTitle = Caption;//"간선도로 소통정보 통계";
  64. m_pFormList = new TList();
  65. TsList01->TabVisible = false;
  66. MyItsAtrdManager = new TItsAtrdManager();
  67. MyItsAtrdManager->LoadFromDb();
  68. FRAMELinkList1->TvList->OptionsView->GroupByBox = false;
  69. FRAMELinkList1->PnlTop->Visible = false;
  70. FRAMELinkList1->PnlBottom->Visible = false;
  71. FRAMELinkList1->ColumnSeq->Visible = true;
  72. FRAMEIfscList1->TvList->OptionsView->GroupByBox = false;
  73. FRAMEIfscList1->PnlTop->Visible = false;
  74. FRAMEIfscList1->PnlBottom->Visible = false;
  75. FRAMEIfscList1->ColumnSeq->Visible = true;
  76. FRAMEIfscList1->Column02->Visible = false;
  77. FRAMEIfscList1->Column03->Visible = false;
  78. FRAMEIfscList1->Column09->Visible = false;
  79. FRAMEIfscList1->Column10->Visible = false;
  80. FRAMEIfscList1->Column08->Visible = false;
  81. FRAMEIfscList1->Column04->Visible = false;
  82. FRAMEIfscList1->Column05->Visible = false;
  83. FRAMERoadList1->TvList->OptionsView->GroupByBox = false;
  84. FRAMERoadList1->PnlTop->Visible = false;
  85. FRAMERoadList1->PnlBottom->Visible = false;
  86. FRAMERoadList1->ColumnSeq->Visible = true;
  87. FRAMERoadList1->Column02->Visible = false;
  88. FRAMERoadList1->Column03->Visible = false;
  89. PgLink->ActivePageIndex = 0;
  90. PgQry->ActivePageIndex = 0;
  91. PnlQry->Height = 190;
  92. FAtrdId = "";
  93. CbAtrd->Properties->Items->Clear();
  94. try
  95. {
  96. MyItsAtrdManager->FLists.Lock();
  97. FOR_STL(TItsAtrd*, pObj, MyItsAtrdManager->FLists)
  98. {
  99. if (pObj->DEL_YN == "Y") continue;
  100. String sDir = (pObj->DRCT_CD.Trim() == "0") ? FrmLang->lblUp->Caption : FrmLang->lblDown->Caption;//String("상행") : String("하행");
  101. String sAtr = pObj->ATRD_NM;
  102. CbAtrd->Properties->Items->AddObject(sAtr + " [" + sDir + "]", (TObject*)pObj);
  103. }
  104. }
  105. __finally
  106. {
  107. MyItsAtrdManager->FLists.UnLock();
  108. CbAtrd->ItemIndex = 0;
  109. }
  110. }
  111. //---------------------------------------------------------------------------
  112. void __fastcall TIST0070M::CommClose()
  113. {
  114. try
  115. {
  116. for (int idx = m_pFormList->Count-1; idx >= 0; idx--)
  117. {
  118. m_pFormList->Delete(idx);
  119. }
  120. delete m_pFormList;
  121. if (MyItsAtrdManager)
  122. {
  123. delete MyItsAtrdManager;
  124. MyItsAtrdManager = NULL;
  125. }
  126. CMM_SaveForm(g_sFormsDir, this);
  127. }
  128. catch(...)
  129. {
  130. }
  131. }
  132. //---------------------------------------------------------------------------
  133. void __fastcall TIST0070M::FormShow(TObject *Sender)
  134. {
  135. Refresh();
  136. FormInit();
  137. TmrShow->Enabled = true;
  138. }
  139. //---------------------------------------------------------------------------
  140. void __fastcall TIST0070M::FormInit()
  141. {
  142. CbStatType->ItemIndex = 0;
  143. TDateTime dtStart = Now()-1;
  144. TDateTime dtEnd = Now();
  145. DtStDate->Date = dtStart;
  146. DtEdDate->Date = dtEnd;
  147. DtStTime->Date = dtStart;
  148. DtEdTime->Date = dtEnd;
  149. //DtStTime->Time = StrToDateTime("00:00");
  150. //DtEdTime->Time = StrToDateTime("23:59");
  151. //시간대 검색
  152. CbStatType1->ItemIndex = 0;
  153. dtStrDate1->DateTime = Now()-1;
  154. dtEndDate1->DateTime = Now();//-1;
  155. CbStrTm1->ItemIndex = 7;
  156. CbEndTm1->ItemIndex = 7;
  157. //지정시각 검색
  158. CbStrTm2->ItemIndex = 7;
  159. CbEndTm2->ItemIndex = 7;
  160. InitQryList();
  161. }
  162. //---------------------------------------------------------------------------
  163. void __fastcall TIST0070M::InitQryList()
  164. {
  165. CMM_ClearGridTableView(TvList);
  166. int nRow = 0;
  167. try
  168. {
  169. TcxDataController *pGDC = TvList->DataController;;
  170. TvList->BeginUpdate();
  171. for (int ii = 0; ii < MAX_QRY_LIST; ii++)
  172. {
  173. nRow = pGDC->AppendRecord();
  174. pGDC->Values[nRow][ColumnSel->Index] = false; //선택
  175. pGDC->Values[nRow][Column00->Index] = "-"; //편집
  176. pGDC->Values[nRow][Column01->Index] = (Now() - (MAX_QRY_LIST-ii)).FormatString("yyyy-MM-dd");
  177. pGDC->Values[nRow][Column02->Index] = "07";
  178. pGDC->Values[nRow][Column03->Index] = "07";
  179. }
  180. }
  181. __finally
  182. {
  183. TvList->EndUpdate();
  184. }
  185. }
  186. //---------------------------------------------------------------------------
  187. void __fastcall TIST0070M::TmrShowTimer(TObject *Sender)
  188. {
  189. TmrShow->Enabled = false;
  190. }
  191. //---------------------------------------------------------------------------
  192. void __fastcall TIST0070M::RefreshData()
  193. {
  194. // 검색조건에 의한 링크 데이터 조회
  195. try
  196. {
  197. //SelListData();
  198. }
  199. __finally
  200. {
  201. }
  202. }
  203. //---------------------------------------------------------------------------
  204. void __fastcall TIST0070M::BtnCloseClick(TObject *Sender)
  205. {
  206. Close();
  207. }
  208. //---------------------------------------------------------------------------
  209. void __fastcall TIST0070M::OnSubFormClose(TMessage Msg)
  210. {
  211. int nActiveIdx = PgTab->ActivePageIndex;
  212. if (nActiveIdx <= 0) return;
  213. LockWindowUpdate(Handle);
  214. TcxTabSheet *pSheet = PgTab->ActivePage;
  215. if (pSheet)
  216. {
  217. delete pSheet;
  218. }
  219. nActiveIdx--; // 첫번째 탭은 화면에 숨겨져 있다.
  220. m_pFormList->Delete(nActiveIdx);
  221. LockWindowUpdate(0);
  222. }
  223. //---------------------------------------------------------------------------
  224. void __fastcall TIST0070M::PgTabDblClick(TObject *Sender)
  225. {
  226. TPoint APoint;
  227. APoint = PgTab->MouseDownPos;
  228. if (PgTab->IndexOfTabAt(APoint.x, APoint.y) != -1)
  229. POST_MSG(Handle, WM_SUBFORM_CLOSE, 0, 0);
  230. }
  231. //---------------------------------------------------------------------------
  232. void __fastcall TIST0070M::FormClose(TObject *Sender, TCloseAction &Action)
  233. {
  234. CommClose();
  235. IST0070M = NULL;
  236. Action = caFree;
  237. }
  238. //---------------------------------------------------------------------------
  239. void __fastcall TIST0070M::CbStatTypePropertiesChange(TObject *Sender)
  240. {
  241. switch(CbStatType->ItemIndex)
  242. {
  243. case 0: //15분 통계
  244. case 1: //시간 통계(1시간)
  245. DtStDate->Format = " yyyy년 MM월 dd일";
  246. DtEdDate->Format = " yyyy년 MM월 dd일";
  247. DtStTime->Visible = true;
  248. DtEdTime->Visible = true;
  249. break;
  250. case 2: //일 통계(1일)
  251. DtStDate->Format = " yyyy년 MM월 dd일";
  252. DtEdDate->Format = " yyyy년 MM월 dd일";
  253. DtStTime->Visible = false;
  254. DtEdTime->Visible = false;
  255. break;
  256. case 3: //월 통계(1개월)
  257. DtStDate->Format = " yyyy년 MM월";
  258. DtEdDate->Format = " yyyy년 MM월";
  259. DtStTime->Visible = false;
  260. DtEdTime->Visible = false;
  261. break;
  262. case 4: //년 통계(1년)
  263. DtStDate->Format = " yyyy년";
  264. DtEdDate->Format = " yyyy년";
  265. DtStTime->Visible = false;
  266. DtEdTime->Visible = false;
  267. break;
  268. }
  269. }
  270. //---------------------------------------------------------------------------
  271. void __fastcall TIST0070M::PgQryPageChanging(TObject *Sender, TcxTabSheet *NewPage,
  272. bool &AllowChange)
  273. {
  274. switch(NewPage->PageIndex)
  275. {
  276. case 0 :
  277. PnlQry->Height = 190;
  278. break;
  279. case 1 :
  280. PnlQry->Height = 220;
  281. break;
  282. case 2 :
  283. PnlQry->Height = 300;
  284. break;
  285. }
  286. }
  287. //---------------------------------------------------------------------------
  288. void __fastcall TIST0070M::SearchTermLink(bool ALink/*=false*/)
  289. {
  290. TcxGrid *pCxList = NULL;
  291. TcxGridTableView *pTvList = NULL;
  292. int nIdCol = -1;
  293. if (PgLink->Properties->ActivePage->PageIndex == 0)
  294. {
  295. pCxList = FRAMELinkList1->CxList;
  296. pTvList = FRAMELinkList1->TvList;
  297. nIdCol = FRAMELinkList1->Column01->Index;
  298. FLinkLevel = 0;
  299. }
  300. else
  301. if (PgLink->Properties->ActivePage->PageIndex == 1)
  302. {
  303. pCxList = FRAMEIfscList1->CxList;
  304. pTvList = FRAMEIfscList1->TvList;
  305. nIdCol = FRAMEIfscList1->Column01->Index;
  306. FLinkLevel = 1;
  307. }
  308. else
  309. if (PgLink->Properties->ActivePage->PageIndex == 2)
  310. {
  311. pCxList = FRAMERoadList1->CxList;
  312. pTvList = FRAMERoadList1->TvList;
  313. nIdCol = FRAMERoadList1->Column01->Index;
  314. FLinkLevel = 2;
  315. }
  316. if (!pTvList) return;
  317. if (ALink)
  318. {
  319. TcxDataController *pGDC = pTvList->DataController;
  320. int nIndex = pGDC->FocusedRecordIndex;
  321. if( nIndex < 0 )
  322. {
  323. Application->MessageBox(FrmLang->lblSelErr->Caption.c_str(),//L"링크를 먼저 선택 하세요.",
  324. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  325. ActiveControl = pCxList;
  326. return;
  327. }
  328. FLinkId = VarToStr(pGDC->Values[nIndex][nIdCol]);
  329. }
  330. else
  331. {
  332. if (FAtrdId == "")
  333. {
  334. Application->MessageBox(FrmLang->lblSelErr->Caption.c_str(),//L"간선도로를 먼저 선택 하세요.",
  335. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  336. ActiveControl = CbAtrd;
  337. return;
  338. }
  339. FLinkId = FAtrdId;
  340. }
  341. String sStTime, sEdTime, sTemp;
  342. switch(CbStatType->ItemIndex)
  343. {
  344. case 0: //15분 통계
  345. case 1: //시간 통계(1시간)
  346. sStTime = DtStDate->Date.FormatString("yyyyMMdd") + DtStTime->Time.FormatString("hh");
  347. sEdTime = DtEdDate->Date.FormatString("yyyyMMdd") + DtEdTime->Time.FormatString("hh");
  348. FStTime = sStTime + "0000";
  349. FEdTime = sEdTime + "5959";
  350. break;
  351. case 2: //일 통계(1일)
  352. sStTime = DtStDate->Date.FormatString("yyyyMMdd");
  353. sEdTime = DtEdDate->Date.FormatString("yyyyMMdd");
  354. FStTime = sStTime + "000000";
  355. FEdTime = sEdTime + "235959";
  356. break;
  357. case 3: //월 통계(1개월)
  358. sStTime = DtStDate->Date.FormatString("yyyyMM");
  359. sEdTime = DtEdDate->Date.FormatString("yyyyMM");
  360. sTemp.printf(L"%02d", ITSUtil_GetMonthLastDay(AnsiString(sEdTime).c_str()));
  361. FStTime = sStTime + "01000000";
  362. FEdTime = sEdTime + sTemp + "235959";
  363. break;
  364. case 4: //년 통계(1년)
  365. sStTime = DtStDate->Date.FormatString("yyyy");
  366. sEdTime = DtEdDate->Date.FormatString("yyyy");
  367. FStTime = sStTime + "0101000000";
  368. FEdTime = sEdTime + "1231235959";
  369. break;
  370. default:
  371. return;
  372. }
  373. if (sStTime > sEdTime)
  374. {
  375. Application->MessageBox(FrmLang->lblQryDtErr->Caption.c_str(),//L"검색 시작시각이 검색 종료시각 보다 큽니다.",
  376. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  377. ActiveControl = DtStDate;
  378. return;
  379. }
  380. FStatType = CbStatType->ItemIndex;
  381. String sTitle;
  382. #if 0
  383. sTitle.printf(L"%s - %s(%s~%s) %s ", PgLink->Properties->ActivePage->Caption.c_str(),
  384. CbStatType->Text.c_str(),
  385. sStTime.c_str(),
  386. sEdTime.c_str(),
  387. FLinkId.c_str());
  388. #endif
  389. if (ALink)
  390. {
  391. sTitle.printf(L"%s-(%s) %s ", PgLink->Properties->ActivePage->Caption.c_str(),
  392. CbStatType->Text.c_str(),
  393. FLinkId.c_str());
  394. }
  395. else
  396. {
  397. sTitle.printf(L"%s-(%s) %s ", PgLink->Properties->ActivePage->Caption.c_str(),
  398. CbStatType->Text.c_str(),
  399. FAtrdNm.c_str());
  400. }
  401. try
  402. {
  403. Application->ProcessMessages();
  404. LockWindowUpdate(Handle);
  405. TcxTabSheet *pSheet = CMM_AddTabSheet(PgTab, sTitle);
  406. if (!pSheet) return;
  407. IST00701 = new TIST00701(this, Handle, FLinkId, sStTime, sEdTime, FLinkLevel, FStatType, ALink);
  408. IST00701->Parent = pSheet;
  409. IST00701->Show();
  410. PgTab->ActivePage = pSheet;
  411. pSheet = PgTab->ActivePage;
  412. m_pFormList->Add(IST00701);
  413. }
  414. __finally
  415. {
  416. LockWindowUpdate(0);
  417. }
  418. }
  419. //---------------------------------------------------------------------------
  420. void __fastcall TIST0070M::SearchTimeLink(bool ALink/*=false*/)
  421. {
  422. TcxGrid *pCxList = NULL;
  423. TcxGridTableView *pTvList = NULL;
  424. int nIdCol = -1;
  425. if (PgLink->Properties->ActivePage->PageIndex == 0)
  426. {
  427. pCxList = FRAMELinkList1->CxList;
  428. pTvList = FRAMELinkList1->TvList;
  429. nIdCol = FRAMELinkList1->Column01->Index;
  430. FLinkLevel = 0;
  431. }
  432. else
  433. if (PgLink->Properties->ActivePage->PageIndex == 1)
  434. {
  435. pCxList = FRAMEIfscList1->CxList;
  436. pTvList = FRAMEIfscList1->TvList;
  437. nIdCol = FRAMEIfscList1->Column01->Index;
  438. FLinkLevel = 1;
  439. }
  440. else
  441. if (PgLink->Properties->ActivePage->PageIndex == 2)
  442. {
  443. pCxList = FRAMERoadList1->CxList;
  444. pTvList = FRAMERoadList1->TvList;
  445. nIdCol = FRAMERoadList1->Column01->Index;
  446. FLinkLevel = 2;
  447. }
  448. if (!pTvList) return;
  449. if (ALink)
  450. {
  451. TcxDataController *pGDC = pTvList->DataController;
  452. int nIndex = pGDC->FocusedRecordIndex;
  453. if( nIndex < 0 )
  454. {
  455. Application->MessageBox(FrmLang->lblSelErr->Caption.c_str(),//L"링크를 먼저 선택 하세요.",
  456. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  457. ActiveControl = pCxList;
  458. return;
  459. }
  460. FLinkId = VarToStr(pGDC->Values[nIndex][nIdCol]);
  461. }
  462. else
  463. {
  464. if (FAtrdId == "")
  465. {
  466. Application->MessageBox(FrmLang->lblSelErr->Caption.c_str(),//L"간선도로를 먼저 선택 하세요.",
  467. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  468. ActiveControl = CbAtrd;
  469. return;
  470. }
  471. FLinkId = FAtrdId;
  472. }
  473. String sStTime, sEdTime, sTemp;
  474. switch(CbStatType->ItemIndex)
  475. {
  476. case 0: //15분 통계
  477. case 1: //시간 통계(1시간)
  478. sStTime = dtStrDate1->DateTime.FormatString("yyyyMMdd");
  479. sEdTime = dtEndDate1->DateTime.FormatString("yyyyMMdd");
  480. FStTime = sStTime + "000000";
  481. FEdTime = sEdTime + "235959";
  482. break;
  483. default:
  484. return;
  485. }
  486. if (sStTime > sEdTime)
  487. {
  488. Application->MessageBox(FrmLang->lblQryDtErr->Caption.c_str(),//L"검색 시작일이 검색 종료일 보다 큽니다.",
  489. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  490. ActiveControl = dtStrDate1;
  491. return;
  492. }
  493. if (CbStrTm1->ItemIndex > CbEndTm1->ItemIndex)
  494. {
  495. Application->MessageBox(FrmLang->lblQryHourErr->Caption.c_str(),//L"시간대 시작시각이 시간대 종료시각 보다 큽니다.",
  496. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  497. ActiveControl = CbStrTm1;
  498. return;
  499. }
  500. FStTerm.printf(L"%02d0000", CbStrTm1->ItemIndex);
  501. FEdTerm.printf(L"%02d5959", CbEndTm1->ItemIndex);
  502. FStatType = CbStatType1->ItemIndex;
  503. String sTitle;
  504. #if 0
  505. sTitle.printf(L"%s - %s(%s~%s) %s ", PgLink->Properties->ActivePage->Caption.c_str(),
  506. CbStatType1->Text.c_str(),
  507. sStTime.c_str(),
  508. sEdTime.c_str(),
  509. FLinkId.c_str());
  510. #endif
  511. if (ALink)
  512. {
  513. sTitle.printf(L"%s-(%s) %s ", PgLink->Properties->ActivePage->Caption.c_str(),
  514. CbStatType->Text.c_str(),
  515. FLinkId.c_str());
  516. }
  517. else
  518. {
  519. sTitle.printf(L"%s-(%s) %s ", PgLink->Properties->ActivePage->Caption.c_str(),
  520. CbStatType->Text.c_str(),
  521. FAtrdNm.c_str());
  522. }
  523. try
  524. {
  525. Application->ProcessMessages();
  526. LockWindowUpdate(Handle);
  527. TcxTabSheet *pSheet = CMM_AddTabSheet(PgTab, sTitle);
  528. if (!pSheet) return;
  529. IST00702 = new TIST00702(this, Handle, FLinkId, FStTime, FEdTime, FLinkLevel, FStatType, FStTerm, FEdTerm, ALink);
  530. IST00702->Parent = pSheet;
  531. IST00702->Show();
  532. PgTab->ActivePage = pSheet;
  533. pSheet = PgTab->ActivePage;
  534. m_pFormList->Add(IST00702);
  535. }
  536. __finally
  537. {
  538. LockWindowUpdate(0);
  539. }
  540. }
  541. //---------------------------------------------------------------------------
  542. void __fastcall TIST0070M::SearchSpotLink(bool ALink/*=false*/)
  543. {
  544. TcxGrid *pCxList = NULL;
  545. TcxGridTableView *pTvList = NULL;
  546. int nIdCol = -1;
  547. if (PgLink->Properties->ActivePage->PageIndex == 0)
  548. {
  549. pCxList = FRAMELinkList1->CxList;
  550. pTvList = FRAMELinkList1->TvList;
  551. nIdCol = FRAMELinkList1->Column01->Index;
  552. FLinkLevel = 0;
  553. }
  554. else
  555. if (PgLink->Properties->ActivePage->PageIndex == 1)
  556. {
  557. pCxList = FRAMEIfscList1->CxList;
  558. pTvList = FRAMEIfscList1->TvList;
  559. nIdCol = FRAMEIfscList1->Column01->Index;
  560. FLinkLevel = 1;
  561. }
  562. else
  563. if (PgLink->Properties->ActivePage->PageIndex == 2)
  564. {
  565. pCxList = FRAMERoadList1->CxList;
  566. pTvList = FRAMERoadList1->TvList;
  567. nIdCol = FRAMERoadList1->Column01->Index;
  568. FLinkLevel = 2;
  569. }
  570. if (!pTvList) return;
  571. if (ALink)
  572. {
  573. TcxDataController *pGDC = pTvList->DataController;
  574. int nIndex = pGDC->FocusedRecordIndex;
  575. if( nIndex < 0 )
  576. {
  577. Application->MessageBox(FrmLang->lblSelErr->Caption.c_str(),//L"링크를 먼저 선택 하세요.",
  578. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  579. ActiveControl = pCxList;
  580. return;
  581. }
  582. FLinkId = VarToStr(pGDC->Values[nIndex][nIdCol]);
  583. }
  584. else
  585. {
  586. if (FAtrdId == "")
  587. {
  588. Application->MessageBox(FrmLang->lblSelErr->Caption.c_str(),//L"간선도로를 먼저 선택 하세요.",
  589. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  590. ActiveControl = CbAtrd;
  591. return;
  592. }
  593. FLinkId = FAtrdId;
  594. }
  595. int nSelects = CMM_GetCheckCount(TvList, ColumnSel->Index);
  596. if (0 == nSelects)
  597. {
  598. Application->MessageBox(FrmLang->lblSelNoDate->Caption.c_str(),//L"검색 지정일을 선택하지 않았습니다.",
  599. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  600. ActiveControl = CxList;
  601. return;
  602. }
  603. bool bDateCheck = true;
  604. int nRowCnt = TvList->ViewData->RecordCount;
  605. for (int ii = 0; ii < nRowCnt; ii++)
  606. {
  607. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  608. if (((bool)ARow->Values[ColumnSel->Index]))
  609. {
  610. try
  611. {
  612. if (VarIsNull(ARow->Values[Column01->Index]))
  613. {
  614. bDateCheck = false;
  615. break;
  616. }
  617. String sSelDay = ARow->Values[Column01->Index];
  618. sSelDay = StringReplace(sSelDay, DateSeparator, "", TReplaceFlags() << rfReplaceAll);
  619. if (sSelDay.Length() != 8)
  620. {
  621. bDateCheck = false;
  622. break;
  623. }
  624. }
  625. catch(Exception &e)
  626. {
  627. }
  628. }
  629. }
  630. if (!bDateCheck)
  631. {
  632. Application->MessageBox(FrmLang->lblSelDtErr->Caption.c_str(),//L"검색 지정일의 일자가 올바르지 않았습니다.",
  633. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  634. ActiveControl = CxList;
  635. return;
  636. }
  637. if (CbStrTm2->ItemIndex > CbEndTm2->ItemIndex)
  638. {
  639. Application->MessageBox(FrmLang->lblSelHourOver->Caption.c_str(),//L"시간대 시작시각이 시간대 종료시각 보다 큽니다.",
  640. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  641. ActiveControl = CbStrTm1;
  642. return;
  643. }
  644. FStTerm.printf(L"%02d0000", CbStrTm2->ItemIndex);
  645. FEdTerm.printf(L"%02d5959", CbEndTm2->ItemIndex);
  646. FStatType = CbStatType2->ItemIndex;
  647. String sTitle;
  648. #if 0
  649. sTitle.printf(L"%s - %s %s ", PgLink->Properties->ActivePage->Caption.c_str(),
  650. CbStatType2->Text.c_str(),
  651. FLinkId.c_str());
  652. #endif
  653. if (ALink)
  654. {
  655. sTitle.printf(L"%s-(%s) %s ", PgLink->Properties->ActivePage->Caption.c_str(),
  656. CbStatType->Text.c_str(),
  657. FLinkId.c_str());
  658. }
  659. else
  660. {
  661. sTitle.printf(L"%s-(%s) %s ", PgLink->Properties->ActivePage->Caption.c_str(),
  662. CbStatType->Text.c_str(),
  663. FAtrdNm.c_str());
  664. }
  665. try
  666. {
  667. Application->ProcessMessages();
  668. LockWindowUpdate(Handle);
  669. TcxTabSheet *pSheet = CMM_AddTabSheet(PgTab, sTitle);
  670. if (!pSheet) return;
  671. IST00703 = new TIST00703(this, Handle, FLinkId, FStTime, FEdTime, FLinkLevel, FStatType, FStTerm, FEdTerm, ALink);
  672. IST00703->FSelDayCnt = 0;
  673. int nRowCnt = TvList->ViewData->RecordCount;
  674. for (int ii = 0; ii < nRowCnt; ii++)
  675. {
  676. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  677. if (((bool)ARow->Values[ColumnSel->Index]))
  678. {
  679. try
  680. {
  681. TDateTime dt = VarToDateTime(ARow->Values[Column01->Index]);
  682. String sSelDay = dt.FormatString("yyyyMMdd");
  683. IST00703->FSelDay[IST00703->FSelDayCnt++] = sSelDay;
  684. }
  685. catch(Exception &e)
  686. {
  687. }
  688. }
  689. }
  690. IST00703->Parent = pSheet;
  691. IST00703->Show();
  692. PgTab->ActivePage = pSheet;
  693. pSheet = PgTab->ActivePage;
  694. m_pFormList->Add(IST00702);
  695. }
  696. __finally
  697. {
  698. LockWindowUpdate(0);
  699. }
  700. }
  701. //---------------------------------------------------------------------------
  702. void __fastcall TIST0070M::ClearAtrdList()
  703. {
  704. CMM_ClearGridTableView(FRAMELinkList1->TvList);
  705. CMM_ClearGridTableView(FRAMEIfscList1->TvList);
  706. CMM_ClearGridTableView(FRAMERoadList1->TvList);
  707. }
  708. //---------------------------------------------------------------------------
  709. void __fastcall TIST0070M::FillAtrdList(String AAtrdId)
  710. {
  711. TItsAtrd *pAtrd = MyItsAtrdManager->FLists.Find(AAtrdId);
  712. if (!pAtrd) return;
  713. FOR_STL(TItsAtrdRoad*, pAtrdRoad, pAtrd->FRoads)
  714. {
  715. TItsRoad *pRoad = ItsRoadManager->FLists.Find(pAtrdRoad->ROAD_ID);
  716. if (!pRoad) continue;
  717. FRAMERoadList1->AddRoad(pRoad->ROAD_ID);
  718. std::map<int, String>::iterator itPos;
  719. for(itPos = pRoad->FIfscs.begin(); itPos != pRoad->FIfscs.end(); ++itPos)
  720. {
  721. String sIfscId = itPos->second;
  722. TItsIfsc *pIfsc = ItsIfscManager->FLists.Find(sIfscId);
  723. if (!pIfsc) continue;
  724. FRAMEIfscList1->AddIfsc(pIfsc->IFSC_ID);
  725. std::map<int, String>::iterator itPos2;
  726. for(itPos2 = pIfsc->FLinks.begin(); itPos2 != pIfsc->FLinks.end(); ++itPos2)
  727. {
  728. String sLinkId = itPos2->second;
  729. TItsLink *pLink = ItsLinkManager->FLists.Find(sLinkId);
  730. if (!pLink) continue;
  731. FRAMELinkList1->AddLink(pLink->LINK_ID);
  732. }
  733. }
  734. }
  735. }
  736. //---------------------------------------------------------------------------
  737. void __fastcall TIST0070M::CbAtrdPropertiesChange(TObject *Sender)
  738. {
  739. ClearAtrdList();
  740. int nIdx = CbAtrd->ItemIndex;
  741. if (nIdx < 0 || nIdx >= CbAtrd->Properties->Items->Count)
  742. {
  743. return;
  744. }
  745. TItsAtrd *pObj = (TItsAtrd*)CbAtrd->Properties->Items->Objects[CbAtrd->ItemIndex];
  746. if (!pObj) return;
  747. FAtrdId = pObj->ATRD_ID;
  748. FAtrdNm = pObj->ATRD_NM;
  749. FillAtrdList(FAtrdId);
  750. }
  751. //---------------------------------------------------------------------------
  752. void __fastcall TIST0070M::BtnSearch5Click(TObject *Sender)
  753. {
  754. if (PgQry->Properties->ActivePage->PageIndex == 0)
  755. {
  756. SearchTermLink(true);
  757. }
  758. else
  759. if (PgQry->Properties->ActivePage->PageIndex == 1)
  760. {
  761. SearchTimeLink(true);
  762. }
  763. else
  764. if (PgQry->Properties->ActivePage->PageIndex == 2)
  765. {
  766. SearchSpotLink(true);
  767. }
  768. }
  769. //---------------------------------------------------------------------------
  770. void __fastcall TIST0070M::BtnSearchClick(TObject *Sender)
  771. {
  772. Application->ProcessMessages();
  773. TSqlCursor sqlCrs((TControl*)BtnSearch);
  774. SearchTermLink(false);
  775. }
  776. //---------------------------------------------------------------------------
  777. void __fastcall TIST0070M::BtnSearch1Click(TObject *Sender)
  778. {
  779. Application->ProcessMessages();
  780. TSqlCursor sqlCrs((TControl*)BtnSearch1);
  781. SearchTimeLink(false);
  782. }
  783. //---------------------------------------------------------------------------
  784. void __fastcall TIST0070M::BtnSearch2Click(TObject *Sender)
  785. {
  786. Application->ProcessMessages();
  787. TSqlCursor sqlCrs((TControl*)BtnSearch2);
  788. SearchSpotLink(false);
  789. }
  790. //---------------------------------------------------------------------------
  791. void __fastcall TIST0070M::PgTabCanCloseEx(TObject *Sender, int ATabIndex, bool &ACanClose)
  792. {
  793. int nActiveIdx = ATabIndex;
  794. if (nActiveIdx <= 0) return;
  795. nActiveIdx--; // 첫번째 탭은 화면에 숨겨져 있다.
  796. m_pFormList->Delete(nActiveIdx);
  797. }
  798. //---------------------------------------------------------------------------