VDSS010MF.cpp 9.9 KB

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