IHS0070MF.cpp 12 KB

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