AVIS020MF.cpp 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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 "AVIS020MF.h"
  9. #include "AVIS0201F.h"
  10. //---------------------------------------------------------------------------
  11. #pragma package(smart_init)
  12. #pragma link "cxButtons"
  13. #pragma link "cxContainer"
  14. #pragma link "cxControls"
  15. #pragma link "cxDropDownEdit"
  16. #pragma link "cxEdit"
  17. #pragma link "cxGraphics"
  18. #pragma link "cxGroupBox"
  19. #pragma link "cxLookAndFeelPainters"
  20. #pragma link "cxLookAndFeels"
  21. #pragma link "cxMaskEdit"
  22. #pragma link "cxPC"
  23. #pragma link "cxPCdxBarPopupMenu"
  24. #pragma link "cxSplitter"
  25. #pragma link "cxTextEdit"
  26. #pragma link "dxSkinBlack"
  27. #pragma link "dxSkinBlue"
  28. #pragma link "dxSkinsCore"
  29. #pragma link "dxSkinscxPCPainter"
  30. #pragma link "FRAME_AviDtctListF"
  31. #pragma resource "*.dfm"
  32. TAVIS020M *AVIS020M = NULL;
  33. //---------------------------------------------------------------------------
  34. __fastcall TAVIS020M::TAVIS020M(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. FRAMEAviDtctList1->PnlTop->Visible = false;
  43. FRAMEAviDtctList1->PnlBottom->Visible = false;
  44. FRAMEAviDtctList1->ColumnSel->Visible = false;
  45. }
  46. //---------------------------------------------------------------------------
  47. /*
  48. * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
  49. * Form과 DataModule class를 delete시킨다.
  50. * arguments
  51. *
  52. * return
  53. * void
  54. */
  55. void __fastcall TAVIS020M::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 TAVIS020M::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 TAVIS020M::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 TAVIS020M::TmrShowTimer(TObject *Sender)
  114. {
  115. TmrShow->Enabled = false;
  116. FRAMEAviDtctList1->UpdateList();
  117. }
  118. //---------------------------------------------------------------------------
  119. /*
  120. * Refresh Data Event Function
  121. * arguments
  122. *
  123. * return
  124. * void
  125. */
  126. void __fastcall TAVIS020M::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 TAVIS020M::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 = FRAMEAviDtctList1->CxList;
  153. pTvList = FRAMEAviDtctList1->TvList;
  154. nIdCol = FRAMEAviDtctList1->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: //15분 통계
  170. case 1: //시간 통계(1시간)
  171. sStTime = DtStDate->Date.FormatString("yyyyMMdd") + DtStTime->Time.FormatString("hh");
  172. sEdTime = DtEdDate->Date.FormatString("yyyyMMdd") + DtEdTime->Time.FormatString("hh");
  173. FStTime = sStTime + "0000";
  174. FEdTime = sEdTime + "5959";
  175. break;
  176. case 2: //시간 통계(1시간)
  177. sStTime = DtStDate->Date.FormatString("yyyyMMdd");
  178. sEdTime = DtEdDate->Date.FormatString("yyyyMMdd");
  179. FStTime = sStTime + "000000";
  180. FEdTime = sEdTime + "235959";
  181. break;
  182. case 3: //일 통계(1일)
  183. sStTime = DtStDate->Date.FormatString("yyyyMM");
  184. sEdTime = DtEdDate->Date.FormatString("yyyyMM");
  185. sTemp.printf(L"%02d", ITSUtil_GetMonthLastDay(AnsiString(sEdTime).c_str()));
  186. FStTime = sStTime + "01000000";
  187. FEdTime = sEdTime + sTemp + "235959";
  188. break;
  189. }
  190. if (sStTime > sEdTime)
  191. {
  192. Application->MessageBox(FrmLang->lblQryDtErr->Caption.c_str(),//L"검색 시작시각이 검색 종료시각 보다 큽니다.",
  193. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  194. ActiveControl = DtStDate;
  195. return;
  196. }
  197. FStatType = CbStatType->ItemIndex;
  198. String sTitle;
  199. sTitle.printf(L"%s(%s~%s) %s ", CbStatType->Text.c_str(),
  200. sStTime.c_str(),
  201. sEdTime.c_str(),
  202. FSelId.c_str());
  203. String sCaption;
  204. #if 0
  205. sCaption.printf(L"%s [%s] ", CbStatType->Text.c_str(), FSelId.c_str());
  206. #else
  207. sTitle = VarToStr(pGDC->Values[nIndex][FRAMEAviDtctList1->Column02->Index]);
  208. sCaption.printf(L"%s [%s] ", CbStatType->Text.c_str(), sTitle.c_str());
  209. #endif
  210. try
  211. {
  212. Application->ProcessMessages();
  213. LockWindowUpdate(Handle);
  214. TcxTabSheet *pSheet = CMM_AddTabSheet(PgTab, sCaption);
  215. if (!pSheet) return;
  216. AVIS0201 = new TAVIS0201(this, Handle, FSelId, sStTime, sEdTime, FStatType);
  217. AVIS0201->Parent = pSheet;
  218. AVIS0201->Show();
  219. PgTab->ActivePage = pSheet;
  220. pSheet = PgTab->ActivePage;
  221. m_pFormList->Add(AVIS0201);
  222. }
  223. __finally
  224. {
  225. LockWindowUpdate(0);
  226. }
  227. }
  228. //---------------------------------------------------------------------------
  229. /*
  230. * Close 버튼 클릭 이벤트 핸들러
  231. * arguments
  232. * Sender : event handler 객체
  233. * return
  234. * void
  235. */
  236. void __fastcall TAVIS020M::BtnCloseClick(TObject *Sender)
  237. {
  238. Close();
  239. }
  240. //---------------------------------------------------------------------------
  241. /*
  242. * 조회결과 폼이 닫힐때 메시지를 받아 처리한다.
  243. * arguments
  244. * Sender : event handler 객체
  245. * return
  246. * void
  247. */
  248. void __fastcall TAVIS020M::OnSubFormClose(TMessage Msg)
  249. {
  250. int nActiveIdx = PgTab->ActivePageIndex;
  251. if (nActiveIdx <= 0) return;
  252. LockWindowUpdate(Handle);
  253. TcxTabSheet *pSheet = PgTab->ActivePage;
  254. if (pSheet)
  255. {
  256. delete pSheet;
  257. }
  258. nActiveIdx--; // 첫번째 탭은 화면에 숨겨져 있다.
  259. m_pFormList->Delete(nActiveIdx);
  260. LockWindowUpdate(0);
  261. }
  262. //---------------------------------------------------------------------------
  263. /*
  264. * Tab Control의 Tab을 더블클릭하여 닫는다.
  265. * arguments
  266. * Sender : event handler 객체
  267. * return
  268. * void
  269. */
  270. void __fastcall TAVIS020M::PgTabDblClick(TObject *Sender)
  271. {
  272. TPoint APoint;
  273. APoint = PgTab->MouseDownPos;
  274. if (PgTab->IndexOfTabAt(APoint.x, APoint.y) != -1)
  275. POST_MSG(Handle, WM_SUBFORM_CLOSE, 0, 0);
  276. }
  277. //---------------------------------------------------------------------------
  278. void __fastcall TAVIS020M::FormClose(TObject *Sender, TCloseAction &Action)
  279. {
  280. CommClose();
  281. AVIS020M = NULL;
  282. Action = caFree;
  283. }
  284. //---------------------------------------------------------------------------
  285. void __fastcall TAVIS020M::CbStatTypePropertiesChange(TObject *Sender)
  286. {
  287. switch(CbStatType->ItemIndex)
  288. {
  289. case 0: //15분 통계
  290. case 1: //시간 통계(1시간)
  291. DtStDate->Format = " yyyy년 MM월 dd일";
  292. DtEdDate->Format = " yyyy년 MM월 dd일";
  293. DtStTime->Visible = true;
  294. DtEdTime->Visible = true;
  295. break;
  296. case 2: //일 통계(1일)
  297. DtStDate->Format = " yyyy년 MM월 dd일";
  298. DtEdDate->Format = " yyyy년 MM월 dd일";
  299. DtStTime->Visible = false;
  300. DtEdTime->Visible = false;
  301. break;
  302. case 3: //월 통계(1개월)
  303. DtStDate->Format = " yyyy년 MM월";
  304. DtEdDate->Format = " yyyy년 MM월";
  305. DtStTime->Visible = false;
  306. DtEdTime->Visible = false;
  307. break;
  308. }
  309. }
  310. //---------------------------------------------------------------------------
  311. void __fastcall TAVIS020M::PgTabCanCloseEx(TObject *Sender, int ATabIndex, bool &ACanClose)
  312. {
  313. int nActiveIdx = ATabIndex;
  314. if (nActiveIdx <= 0) return;
  315. nActiveIdx--; // 첫번째 탭은 화면에 숨겨져 있다.
  316. m_pFormList->Delete(nActiveIdx);
  317. }
  318. //---------------------------------------------------------------------------