IHS0070MF.cpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "AppGlobalF.h"
  6. #include "CDSItsCrossInfoF.h"
  7. #include "ITSLangTransF.h"
  8. #pragma hdrstop
  9. #include "IHS0070MF.h"
  10. #include "IHS00701F.h"
  11. //---------------------------------------------------------------------------
  12. #pragma package(smart_init)
  13. #pragma link "FRAME_ItsCrossF"
  14. #pragma link "cxButtons"
  15. #pragma link "cxCalendar"
  16. #pragma link "cxContainer"
  17. #pragma link "cxControls"
  18. #pragma link "cxDropDownEdit"
  19. #pragma link "cxEdit"
  20. #pragma link "cxGraphics"
  21. #pragma link "cxGroupBox"
  22. #pragma link "cxLabel"
  23. #pragma link "cxLookAndFeelPainters"
  24. #pragma link "cxLookAndFeels"
  25. #pragma link "cxMaskEdit"
  26. #pragma link "cxPC"
  27. #pragma link "cxPCdxBarPopupMenu"
  28. #pragma link "cxSpinEdit"
  29. #pragma link "cxSplitter"
  30. #pragma link "cxTextEdit"
  31. #pragma link "cxTimeEdit"
  32. #pragma link "dxSkinBlack"
  33. #pragma link "dxSkinBlue"
  34. #pragma link "dxSkinsCore"
  35. #pragma link "dxSkinscxPCPainter"
  36. #pragma link "cxCheckBox"
  37. #pragma link "cxClasses"
  38. #pragma link "cxCustomData"
  39. #pragma link "cxData"
  40. #pragma link "cxDataStorage"
  41. #pragma link "cxFilter"
  42. #pragma link "cxGrid"
  43. #pragma link "cxGridCustomTableView"
  44. #pragma link "cxGridCustomView"
  45. #pragma link "cxGridLevel"
  46. #pragma link "cxGridTableView"
  47. #pragma link "cxStyles"
  48. #pragma link "dxSkinMcSkin"
  49. #pragma resource "*.dfm"
  50. TIHS0070M *IHS0070M = NULL;
  51. //---------------------------------------------------------------------------
  52. __fastcall TIHS0070M::TIHS0070M(TComponent* Owner)
  53. : TForm(Owner)
  54. {
  55. LangTrans->Translate(this, ITSDb_GetConnection());
  56. FTitle = Caption;//"수집데이터 분석";
  57. ITSSkin_Load(this);
  58. CMM_LoadForm(g_sFormsDir, this);
  59. m_pFormList = new TList();
  60. TsList01->TabVisible = false;
  61. TabHour->TabVisible = false;
  62. TabHour->Visible = false;
  63. TabTime->TabVisible = false;
  64. TabTime->Visible = false;
  65. PgQry->ActivePage = TabTerm;
  66. PnlQry->Height = 190;
  67. if (!RCrossManager)
  68. {
  69. RCrossManager = new TRCrossManager();
  70. RCrossManager->LoadCrossRoad();
  71. RCrossManager->LoadCross();
  72. RCrossManager->LoadCrossDir();
  73. }
  74. }
  75. //---------------------------------------------------------------------------
  76. void __fastcall TIHS0070M::CommClose()
  77. {
  78. try
  79. {
  80. for (int idx = m_pFormList->Count-1; idx >= 0; idx--)
  81. {
  82. m_pFormList->Delete(idx);
  83. }
  84. delete m_pFormList;
  85. CMM_SaveForm(g_sFormsDir, this);
  86. }
  87. catch(...)
  88. {
  89. }
  90. }
  91. //---------------------------------------------------------------------------
  92. void __fastcall TIHS0070M::FormShow(TObject *Sender)
  93. {
  94. Refresh();
  95. FormInit();
  96. TmrShow->Enabled = true;
  97. }
  98. //---------------------------------------------------------------------------
  99. void __fastcall TIHS0070M::FormInit()
  100. {
  101. DtStDate->Date = Now() - 1;
  102. DtEdDate->Date = Now() - 1;
  103. //DtStTime->EditValue = Now().FormatString("hh");
  104. //DtEdTime->EditValue = Now().FormatString("hh");
  105. DtStTime->Time = StrToDateTime("00:00");
  106. DtEdTime->Time = StrToDateTime("23:59");
  107. }
  108. //---------------------------------------------------------------------------
  109. void __fastcall TIHS0070M::TmrShowTimer(TObject *Sender)
  110. {
  111. TmrShow->Enabled = false;
  112. FRAMEItsCross1->InitFilter(true);
  113. FRAMEItsCross1->InitItsCross();
  114. }
  115. //---------------------------------------------------------------------------
  116. void __fastcall TIHS0070M::RefreshData()
  117. {
  118. // 검색조건에 의한 링크 데이터 조회
  119. try
  120. {
  121. //SelListData();
  122. }
  123. __finally
  124. {
  125. }
  126. }
  127. //---------------------------------------------------------------------------
  128. void __fastcall TIHS0070M::BtnSearchClick(TObject *Sender)
  129. {
  130. Application->ProcessMessages();
  131. TSqlCursor sqlCrs((TControl*)BtnSearch);
  132. TcxGrid *pCxList = NULL;
  133. TcxGridTableView *pTvList = NULL;
  134. int nIdCol = -1;
  135. STCondition m_CrossCond;
  136. FRAMEItsCross1->GetCondition(m_CrossCond);
  137. String sWhere = m_CrossCond.ToSQLInString("(A.VDS_CTLR_NMBR, A.VDS_CMRA_NO)");
  138. FIdList = sWhere;
  139. String sTitle = FRAMEItsCross1->FSelNm;
  140. String sStTime, sEdTime, sTemp;
  141. switch(CbStatType->ItemIndex)
  142. {
  143. case 0: //수집교통량
  144. case 1: //5분교통량
  145. case 2: //15분 통계
  146. case 3: //시간 통계(1시간)
  147. sStTime = DtStDate->Date.FormatString("yyyyMMdd") + DtStTime->Time.FormatString("hh");
  148. sEdTime = DtEdDate->Date.FormatString("yyyyMMdd") + DtEdTime->Time.FormatString("hh");
  149. FStTime = sStTime + "0000";
  150. FEdTime = sEdTime + "5959";
  151. break;
  152. case 4: //일 통계(1일)
  153. sStTime = DtStDate->Date.FormatString("yyyyMMdd");
  154. sEdTime = DtEdDate->Date.FormatString("yyyyMMdd");
  155. FStTime = sStTime + "000000";
  156. FEdTime = sEdTime + "235959";
  157. break;
  158. case 5: //월 통계(1개월)
  159. sStTime = DtStDate->Date.FormatString("yyyyMM");
  160. sEdTime = DtEdDate->Date.FormatString("yyyyMM");
  161. sTemp.printf(L"%02d", ITSUtil_GetMonthLastDay(AnsiString(sEdTime).c_str()));
  162. //FStTime = sStTime + "01000000";
  163. FStTime = sStTime + "00000000";
  164. FEdTime = sEdTime + sTemp + "235959";
  165. break;
  166. case 6: //년 통계(1년)
  167. sStTime = DtStDate->Date.FormatString("yyyy");
  168. sEdTime = DtEdDate->Date.FormatString("yyyy");
  169. //FStTime = sStTime + "0101000000";
  170. FStTime = sStTime + "0000000000";
  171. FEdTime = sEdTime + "1231235959";
  172. break;
  173. default:
  174. return;
  175. }
  176. if (FStTime > FEdTime)
  177. {
  178. Application->MessageBox(FrmLang->lblQryDtErr->Caption.c_str(),//L"검색 시작시각이 검색 종료시각 보다 큽니다.",
  179. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  180. ActiveControl = DtStDate;
  181. return;
  182. }
  183. FStatType = CbStatType->ItemIndex;
  184. #if 0
  185. sTitle.printf(L"%s - %s(%s~%s) %s ", PgQry->Properties->ActivePage->Caption.c_str(),
  186. CbStatType->Text.c_str(),
  187. FStTime.c_str(),
  188. FEdTime.c_str(),
  189. FIdList.c_str());
  190. #else
  191. sTitle.printf(L"%s - %s(%s~%s) ", PgQry->Properties->ActivePage->Caption.c_str(),
  192. CbStatType->Text.c_str(),
  193. FStTime.c_str(),
  194. FEdTime.c_str());
  195. #endif
  196. try
  197. {
  198. Application->ProcessMessages();
  199. LockWindowUpdate(Handle);
  200. TcxTabSheet *pSheet = CMM_AddTabSheet(PgTab, sTitle);
  201. if (!pSheet) return;
  202. IHS00701 = new TIHS00701(this, Handle, FStTime, FEdTime, FIdList, CbStatType->ItemIndex);
  203. IHS00701->Parent = pSheet;
  204. IHS00701->Show();
  205. PgTab->ActivePage = pSheet;
  206. pSheet = PgTab->ActivePage;
  207. m_pFormList->Add(IHS00701);
  208. }
  209. __finally
  210. {
  211. LockWindowUpdate(0);
  212. }
  213. return;
  214. #if 0
  215. Application->ProcessMessages();
  216. TSqlCursor sqlCrs((TControl*)BtnSearch);
  217. #if 0
  218. FStDateTime = DtStDate->Date.FormatString("yyyymmdd") + DtStTime->Time.FormatString("hh");
  219. FEdDateTime = DtEdDate->Date.FormatString("yyyymmdd") + DtEdTime->Time.FormatString("hh");
  220. #else
  221. FStDateTime = DtStDate->Date.FormatString("yyyymmdd") + DtStTime->Time.FormatString("hhnn");
  222. FEdDateTime = DtEdDate->Date.FormatString("yyyymmdd") + DtEdTime->Time.FormatString("hhnn");
  223. #endif
  224. if (FStDateTime > FEdDateTime)
  225. {
  226. Application->MessageBox(FrmLang->lblQryDtErr->Caption.c_str(),//L"검색 시작시각이 검색 종료시각 보다 큽니다.",
  227. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  228. ActiveControl = DtStDate;
  229. return;
  230. }
  231. #if 0
  232. FStDateTime = FStDateTime + "0000";
  233. FEdDateTime = FEdDateTime + "5959";
  234. #else
  235. FStDateTime = FStDateTime + "00";
  236. FEdDateTime = FEdDateTime + "59";
  237. #endif
  238. FIdList = "";
  239. #if 0
  240. int nSelects = FRAMELinkList1->GetSelLinkIds(FIdList);
  241. if (0 == nSelects)
  242. {
  243. Application->MessageBox(FrmLang->lblSelLstErr->Caption.c_str(),//L"검색 목록을 선택하지 않았습니다.",
  244. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  245. FRAMELinkList1->CxList->SetFocus();
  246. return;
  247. }
  248. #endif
  249. STCodeCondition m_CrossCond;
  250. FRAMEItsCross1->GetCondition(m_CrossCond);
  251. String sWhere = m_CrossCond.ToSQLInString("A.LINK_ID");
  252. FIdList = sWhere;
  253. #if 0
  254. String sTitle = "[" + FStDateTime + "-" + FEdDateTime + "]";
  255. #else
  256. String sTitle = FRAMEItsCross1->FSelNm;
  257. #endif
  258. try
  259. {
  260. Application->ProcessMessages();
  261. LockWindowUpdate(Handle);
  262. TcxTabSheet *pSheet = CMM_AddTabSheet(PgTab, sTitle);
  263. if (!pSheet) return;
  264. IHS00701 = new TIHS00701(this, Handle, FStDateTime, FEdDateTime, FIdList);
  265. IHS00701->Parent = pSheet;
  266. IHS00701->Show();
  267. PgTab->ActivePage = pSheet;
  268. pSheet = PgTab->ActivePage;
  269. m_pFormList->Add(IHS00701);
  270. }
  271. __finally
  272. {
  273. LockWindowUpdate(0);
  274. }
  275. #endif
  276. }
  277. //---------------------------------------------------------------------------
  278. void __fastcall TIHS0070M::BtnCloseClick(TObject *Sender)
  279. {
  280. Close();
  281. }
  282. //---------------------------------------------------------------------------
  283. void __fastcall TIHS0070M::OnSubFormClose(TMessage Msg)
  284. {
  285. int nActiveIdx = PgTab->ActivePageIndex;
  286. if (nActiveIdx <= 0) return;
  287. LockWindowUpdate(Handle);
  288. TcxTabSheet *pSheet = PgTab->ActivePage;
  289. if (pSheet)
  290. {
  291. delete pSheet;
  292. }
  293. nActiveIdx--; // 첫번째 탭은 화면에 숨겨져 있다.
  294. m_pFormList->Delete(nActiveIdx);
  295. LockWindowUpdate(0);
  296. }
  297. //---------------------------------------------------------------------------
  298. void __fastcall TIHS0070M::PgTabDblClick(TObject *Sender)
  299. {
  300. TPoint APoint;
  301. APoint = PgTab->MouseDownPos;
  302. if (PgTab->IndexOfTabAt(APoint.x, APoint.y) != -1)
  303. POST_MSG(Handle, WM_SUBFORM_CLOSE, 0, 0);
  304. }
  305. //---------------------------------------------------------------------------
  306. void __fastcall TIHS0070M::FormClose(TObject *Sender, TCloseAction &Action)
  307. {
  308. CommClose();
  309. IHS0070M = NULL;
  310. Action = caFree;
  311. }
  312. //---------------------------------------------------------------------------
  313. void __fastcall TIHS0070M::btnFilterClick(TObject *Sender)
  314. {
  315. String sFilter = EdFilter->Text.Trim();
  316. FRAMEItsCross1->FilterItsCross(sFilter);
  317. //fnUpdateConditionHtmlState();
  318. }
  319. //---------------------------------------------------------------------------
  320. void __fastcall TIHS0070M::EdFilterKeyPress(TObject *Sender, wchar_t &Key)
  321. {
  322. if (VK_RETURN == Key)
  323. {
  324. btnFilterClick(NULL);
  325. }
  326. }
  327. //---------------------------------------------------------------------------
  328. void __fastcall TIHS0070M::PgTabCanCloseEx(TObject *Sender, int ATabIndex, bool &ACanClose)
  329. {
  330. int nActiveIdx = ATabIndex;
  331. if (nActiveIdx <= 0) return;
  332. nActiveIdx--; // 첫번째 탭은 화면에 숨겨져 있다.
  333. m_pFormList->Delete(nActiveIdx);
  334. }
  335. //---------------------------------------------------------------------------
  336. void __fastcall TIHS0070M::PgQryPageChanging(TObject *Sender, TcxTabSheet *NewPage, bool &AllowChange)
  337. {
  338. switch(NewPage->PageIndex)
  339. {
  340. case 0 :
  341. PnlQry->Height = 190;
  342. break;
  343. case 1 :
  344. PnlQry->Height = 220;
  345. break;
  346. case 2 :
  347. PnlQry->Height = 300;
  348. break;
  349. }
  350. }
  351. //---------------------------------------------------------------------------
  352. void __fastcall TIHS0070M::CbStatTypePropertiesChange(TObject *Sender)
  353. {
  354. switch(CbStatType->ItemIndex)
  355. {
  356. case 0: //수집교통량
  357. case 1: //5분교통량
  358. case 2: //15분 통계
  359. case 3: //시간 통계(1시간)
  360. DtStDate->Format = " yyyy년 MM월 dd일";
  361. DtEdDate->Format = " yyyy년 MM월 dd일";
  362. DtStTime->Visible = true;
  363. DtEdTime->Visible = true;
  364. break;
  365. case 4: //일 통계(1일)
  366. DtStDate->Format = " yyyy년 MM월 dd일";
  367. DtEdDate->Format = " yyyy년 MM월 dd일";
  368. DtStTime->Visible = false;
  369. DtEdTime->Visible = false;
  370. break;
  371. case 5: //월 통계(1개월)
  372. DtStDate->Format = " yyyy년 MM월";
  373. DtEdDate->Format = " yyyy년 MM월";
  374. DtStTime->Visible = false;
  375. DtEdTime->Visible = false;
  376. break;
  377. case 6: //년 통계(1년)
  378. DtStDate->Format = " yyyy년";
  379. DtEdDate->Format = " yyyy년";
  380. DtStTime->Visible = false;
  381. DtEdTime->Visible = false;
  382. break;
  383. }
  384. DtStDate->SetFocus();
  385. }
  386. //---------------------------------------------------------------------------