DSRH070MF.cpp 9.3 KB

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