AVIS010MF.cpp 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "AppGlobalF.h"
  6. #include "CDSCodeF.h"
  7. #pragma hdrstop
  8. #include "AVIS010MF.h"
  9. #include "AVIS0101F.h"
  10. //---------------------------------------------------------------------------
  11. #pragma package(smart_init)
  12. #pragma link "FRAME_AviSectListF"
  13. #pragma link "cxButtons"
  14. #pragma link "cxContainer"
  15. #pragma link "cxControls"
  16. #pragma link "cxDropDownEdit"
  17. #pragma link "cxEdit"
  18. #pragma link "cxGraphics"
  19. #pragma link "cxGroupBox"
  20. #pragma link "cxLookAndFeelPainters"
  21. #pragma link "cxLookAndFeels"
  22. #pragma link "cxMaskEdit"
  23. #pragma link "cxPC"
  24. #pragma link "cxPCdxBarPopupMenu"
  25. #pragma link "cxSplitter"
  26. #pragma link "cxTextEdit"
  27. #pragma link "dxSkinBlack"
  28. #pragma link "dxSkinBlue"
  29. #pragma link "dxSkinsCore"
  30. #pragma link "dxSkinscxPCPainter"
  31. #pragma resource "*.dfm"
  32. TAVIS010M *AVIS010M = NULL;
  33. //---------------------------------------------------------------------------
  34. __fastcall TAVIS010M::TAVIS010M(TComponent* Owner)
  35. : TForm(Owner)
  36. {
  37. ITSSkin_Load(this);
  38. CMM_LoadForm(g_sFormsDir, this);
  39. FTitle = "AVI-구간 소통상황 통계";
  40. m_pFormList = new TList();
  41. TsList01->TabVisible = false;
  42. FRAMEAviSectList1->PnlBottom->Visible = false;
  43. FRAMEAviSectList1->PnlTop->Visible = false;
  44. FRAMEAviSectList1->ColumnSel->Visible = false;
  45. }
  46. //---------------------------------------------------------------------------
  47. /*
  48. * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
  49. * Form과 DataModule class를 delete시킨다.
  50. * arguments
  51. *
  52. * return
  53. * void
  54. */
  55. void __fastcall TAVIS010M::CommClose()
  56. {
  57. try
  58. {
  59. for (int idx = m_pFormList->Count-1; idx >= 0; idx--)
  60. {
  61. m_pFormList->Delete(idx);
  62. }
  63. delete m_pFormList;
  64. CMM_SaveForm(g_sFormsDir, this);
  65. }
  66. catch(...)
  67. {
  68. }
  69. }
  70. //---------------------------------------------------------------------------
  71. /*
  72. * Form을 보여줄때 호출되는 event 메서드이다.
  73. * arguments
  74. * Sender : event handler 객체
  75. * return
  76. * void
  77. */
  78. void __fastcall TAVIS010M::FormShow(TObject *Sender)
  79. {
  80. Refresh();
  81. FormInit();
  82. TmrShow->Enabled = true;
  83. }
  84. //---------------------------------------------------------------------------
  85. /*
  86. * form 초기화
  87. *
  88. * arguments
  89. *
  90. * return
  91. * void
  92. */
  93. void __fastcall TAVIS010M::FormInit()
  94. {
  95. CbStatType->ItemIndex = 0;
  96. TDateTime dtStart = Now()-1;
  97. TDateTime dtEnd = Now();
  98. DtStDate->Date = dtStart;
  99. DtEdDate->Date = dtEnd;
  100. DtStTime->Date = dtStart;
  101. DtEdTime->Date = dtEnd;
  102. //DtStTime->Time = StrToDateTime("00:00");
  103. //DtEdTime->Time = StrToDateTime("23:59");
  104. }
  105. //---------------------------------------------------------------------------
  106. /*
  107. * Form이 Show되고 난 후 최초 1회 수행되는 타이머 이벤트
  108. * arguments
  109. * Sender : event handler 객체
  110. * return
  111. * void
  112. */
  113. void __fastcall TAVIS010M::TmrShowTimer(TObject *Sender)
  114. {
  115. TmrShow->Enabled = false;
  116. FRAMEAviSectList1->UpdateList();
  117. }
  118. //---------------------------------------------------------------------------
  119. /*
  120. * Refresh Data Event Function
  121. * arguments
  122. *
  123. * return
  124. * void
  125. */
  126. void __fastcall TAVIS010M::RefreshData()
  127. {
  128. // 검색조건에 의한 링크 데이터 조회
  129. try
  130. {
  131. //SelListData();
  132. }
  133. __finally
  134. {
  135. }
  136. }
  137. //---------------------------------------------------------------------------
  138. /*
  139. * Search 버튼 클릭 이벤트 핸들러
  140. * arguments
  141. * Sender : event handler 객체
  142. * return
  143. * void
  144. */
  145. void __fastcall TAVIS010M::BtnSearchClick(TObject *Sender)
  146. {
  147. Application->ProcessMessages();
  148. TSqlCursor sqlCrs((TControl*)BtnSearch);
  149. TcxGrid *pCxList;
  150. TcxGridTableView *pTvList = NULL;
  151. int nIdCol = -1;
  152. pCxList = FRAMEAviSectList1->CxList;
  153. pTvList = FRAMEAviSectList1->TvList;
  154. nIdCol = FRAMEAviSectList1->Column02->Index;
  155. if (!pTvList) return;
  156. TcxDataController *pGDC = pTvList->DataController;
  157. int nIndex = pGDC->FocusedRecordIndex;
  158. if( nIndex < 0 )
  159. {
  160. Application->MessageBox(FrmLang->lblSelErr->Caption.c_str(),//L"AVI 구간을 먼저 선택 하세요.",
  161. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  162. ActiveControl = pCxList;
  163. return;
  164. }
  165. FSelId = VarToStr(pGDC->Values[nIndex][nIdCol]);
  166. String sStTime, sEdTime, sTemp;
  167. switch(CbStatType->ItemIndex)
  168. {
  169. case 0: //5분 통계
  170. case 1: //15분 통계
  171. case 2: //시간 통계(1시간)
  172. sStTime = DtStDate->Date.FormatString("yyyyMMdd") + DtStTime->Time.FormatString("hh");
  173. sEdTime = DtEdDate->Date.FormatString("yyyyMMdd") + DtEdTime->Time.FormatString("hh");
  174. FStTime = sStTime + "0000";
  175. FEdTime = sEdTime + "5959";
  176. break;
  177. case 3: //일 통계(1일)
  178. sStTime = DtStDate->Date.FormatString("yyyyMMdd");
  179. sEdTime = DtEdDate->Date.FormatString("yyyyMMdd");
  180. FStTime = sStTime + "000000";
  181. FEdTime = sEdTime + "235959";
  182. break;
  183. case 4: //월 통계(1개월)
  184. sStTime = DtStDate->Date.FormatString("yyyyMM");
  185. sEdTime = DtEdDate->Date.FormatString("yyyyMM");
  186. sTemp.printf(L"%02d", ITSUtil_GetMonthLastDay(AnsiString(sEdTime).c_str()));
  187. FStTime = sStTime + "01000000";
  188. FEdTime = sEdTime + sTemp + "235959";
  189. break;
  190. }
  191. if (sStTime > sEdTime)
  192. {
  193. Application->MessageBox(FrmLang->lblQryDtErr->Caption.c_str(),//L"검색 시작시각이 검색 종료시각 보다 큽니다.",
  194. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  195. ActiveControl = DtStDate;
  196. return;
  197. }
  198. FStatType = CbStatType->ItemIndex;
  199. String sTitle;
  200. sTitle.printf(L"%s(%s~%s) %s ", CbStatType->Text.c_str(),
  201. sStTime.c_str(),
  202. sEdTime.c_str(),
  203. FSelId.c_str());
  204. String sCaption;
  205. #if 0
  206. sCaption.printf(L"%s [%s] ", CbStatType->Text.c_str(), FSelId.c_str());
  207. #else
  208. sTitle = VarToStr(pGDC->Values[nIndex][FRAMEAviSectList1->Column03->Index]);
  209. sCaption.printf(L"%s [%s] ", CbStatType->Text.c_str(), sTitle.c_str());
  210. #endif
  211. try
  212. {
  213. Application->ProcessMessages();
  214. LockWindowUpdate(Handle);
  215. TcxTabSheet *pSheet = CMM_AddTabSheet(PgTab, sCaption);
  216. if (!pSheet) return;
  217. AVIS0101 = new TAVIS0101(this, Handle, FSelId, sStTime, sEdTime, FStatType);
  218. AVIS0101->Parent = pSheet;
  219. AVIS0101->Show();
  220. PgTab->ActivePage = pSheet;
  221. pSheet = PgTab->ActivePage;
  222. m_pFormList->Add(AVIS0101);
  223. }
  224. __finally
  225. {
  226. LockWindowUpdate(0);
  227. }
  228. }
  229. //---------------------------------------------------------------------------
  230. /*
  231. * Close 버튼 클릭 이벤트 핸들러
  232. * arguments
  233. * Sender : event handler 객체
  234. * return
  235. * void
  236. */
  237. void __fastcall TAVIS010M::BtnCloseClick(TObject *Sender)
  238. {
  239. Close();
  240. }
  241. //---------------------------------------------------------------------------
  242. /*
  243. * 조회결과 폼이 닫힐때 메시지를 받아 처리한다.
  244. * arguments
  245. * Sender : event handler 객체
  246. * return
  247. * void
  248. */
  249. void __fastcall TAVIS010M::OnSubFormClose(TMessage Msg)
  250. {
  251. int nActiveIdx = PgTab->ActivePageIndex;
  252. if (nActiveIdx <= 0) return;
  253. LockWindowUpdate(Handle);
  254. TcxTabSheet *pSheet = PgTab->ActivePage;
  255. if (pSheet)
  256. {
  257. delete pSheet;
  258. }
  259. nActiveIdx--; // 첫번째 탭은 화면에 숨겨져 있다.
  260. m_pFormList->Delete(nActiveIdx);
  261. LockWindowUpdate(0);
  262. }
  263. //---------------------------------------------------------------------------
  264. /*
  265. * Tab Control의 Tab을 더블클릭하여 닫는다.
  266. * arguments
  267. * Sender : event handler 객체
  268. * return
  269. * void
  270. */
  271. void __fastcall TAVIS010M::PgTabDblClick(TObject *Sender)
  272. {
  273. TPoint APoint;
  274. APoint = PgTab->MouseDownPos;
  275. if (PgTab->IndexOfTabAt(APoint.x, APoint.y) != -1)
  276. POST_MSG(Handle, WM_SUBFORM_CLOSE, 0, 0);
  277. }
  278. //---------------------------------------------------------------------------
  279. void __fastcall TAVIS010M::FormClose(TObject *Sender, TCloseAction &Action)
  280. {
  281. CommClose();
  282. AVIS010M = NULL;
  283. Action = caFree;
  284. }
  285. //---------------------------------------------------------------------------
  286. void __fastcall TAVIS010M::CbStatTypePropertiesChange(TObject *Sender)
  287. {
  288. switch(CbStatType->ItemIndex)
  289. {
  290. case 0: //15분 통계
  291. case 1: //15분 통계
  292. case 2: //시간 통계(1시간)
  293. DtStDate->Format = " yyyy년 MM월 dd일";
  294. DtEdDate->Format = " yyyy년 MM월 dd일";
  295. DtStTime->Visible = true;
  296. DtEdTime->Visible = true;
  297. break;
  298. case 3: //일 통계(1일)
  299. DtStDate->Format = " yyyy년 MM월 dd일";
  300. DtEdDate->Format = " yyyy년 MM월 dd일";
  301. DtStTime->Visible = false;
  302. DtEdTime->Visible = false;
  303. break;
  304. case 4: //월 통계(1개월)
  305. DtStDate->Format = " yyyy년 MM월";
  306. DtEdDate->Format = " yyyy년 MM월";
  307. DtStTime->Visible = false;
  308. DtEdTime->Visible = false;
  309. break;
  310. }
  311. }
  312. //---------------------------------------------------------------------------
  313. void __fastcall TAVIS010M::PgTabCanCloseEx(TObject *Sender, int ATabIndex, bool &ACanClose)
  314. {
  315. int nActiveIdx = ATabIndex;
  316. if (nActiveIdx <= 0) return;
  317. nActiveIdx--; // 첫번째 탭은 화면에 숨겨져 있다.
  318. m_pFormList->Delete(nActiveIdx);
  319. }
  320. //---------------------------------------------------------------------------