IHS0010MF.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "ITSDbF.h"
  6. #include "AppGlobalF.h"
  7. #include "WindowMsgF.h"
  8. #include "ITSLangTransF.h"
  9. #pragma hdrstop
  10. #include "IHS0010MF.h"
  11. //---------------------------------------------------------------------------
  12. #pragma package(smart_init)
  13. #pragma link "cxButtons"
  14. #pragma link "cxCalendar"
  15. #pragma link "cxClasses"
  16. #pragma link "cxContainer"
  17. #pragma link "cxControls"
  18. #pragma link "cxCustomData"
  19. #pragma link "cxData"
  20. #pragma link "cxDataStorage"
  21. #pragma link "cxDropDownEdit"
  22. #pragma link "cxEdit"
  23. #pragma link "cxFilter"
  24. #pragma link "cxGraphics"
  25. #pragma link "cxGrid"
  26. #pragma link "cxGridCustomTableView"
  27. #pragma link "cxGridCustomView"
  28. #pragma link "cxGridLevel"
  29. #pragma link "cxGridTableView"
  30. #pragma link "cxLabel"
  31. #pragma link "cxLookAndFeelPainters"
  32. #pragma link "cxLookAndFeels"
  33. #pragma link "cxMaskEdit"
  34. #pragma link "cxPC"
  35. #pragma link "cxPCdxBarPopupMenu"
  36. #pragma link "cxSpinEdit"
  37. #pragma link "cxStyles"
  38. #pragma link "cxTextEdit"
  39. #pragma link "cxTimeEdit"
  40. #pragma link "dxSkinBlack"
  41. #pragma link "dxSkinBlue"
  42. #pragma link "dxSkinsCore"
  43. #pragma link "dxSkinscxPCPainter"
  44. #pragma resource "*.dfm"
  45. TIHS0010M *IHS0010M = NULL;
  46. //---------------------------------------------------------------------------
  47. __fastcall TIHS0010M::TIHS0010M(TComponent* Owner)
  48. : TForm(Owner)
  49. {
  50. LangTrans->Translate(this, ITSDb_GetConnection());
  51. ITSSkin_Load(this);
  52. CMM_LoadForm(g_sFormsDir, this);
  53. FTitle = Caption;//"운영자 접속 이력조회";
  54. }
  55. //---------------------------------------------------------------------------
  56. /*
  57. * form을 보여줄때 호출되는 event 메서드이다.
  58. * arguments
  59. * Sender : event handler 객체
  60. * return
  61. * void
  62. */
  63. void __fastcall TIHS0010M::FormShow(TObject *Sender)
  64. {
  65. PgList->ActivePageIndex = 0;
  66. // form 초기화
  67. FormInit();
  68. }
  69. //---------------------------------------------------------------------------
  70. /*
  71. * form 초기화
  72. * arguments
  73. *
  74. * return
  75. * void
  76. */
  77. void __fastcall TIHS0010M::FormInit()
  78. {
  79. ADOQry->Connection = ITSDb_GetConnection();
  80. m_pGDC = TvList->DataController;
  81. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<운영자 접속 이력 정보>";
  82. DtStDate->Date = Now() - 30;
  83. DtEdDate->Date = Now() - 1;
  84. //DtEdTime->EditValue = Now().FormatString("hh");
  85. DtStTime->Time = StrToDateTime("00:00");
  86. DtEdTime->Time = StrToDateTime("23:59");
  87. if (BtnSearch->Enabled)
  88. BtnSearch->SetFocus();
  89. }
  90. //---------------------------------------------------------------------------
  91. /*
  92. * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
  93. * Form과 DataModule class를 delete시킨다.
  94. * arguments
  95. *
  96. * return
  97. * void
  98. */
  99. void __fastcall TIHS0010M::CommClose()
  100. {
  101. try
  102. {
  103. CMM_SaveForm(g_sFormsDir, this);
  104. }
  105. catch(...)
  106. {
  107. }
  108. }
  109. //---------------------------------------------------------------------------
  110. /*
  111. * 화면이 로딩된 후 리스트 목록을 조회하도록 한다.
  112. * arguments
  113. *
  114. * return
  115. * void
  116. */
  117. void __fastcall TIHS0010M::TmrRefreshTimer(TObject *Sender)
  118. {
  119. TmrRefresh->Enabled = false;
  120. }
  121. //---------------------------------------------------------------------------
  122. /*
  123. * Excel Button Click Event Handler
  124. * arguments
  125. * Sender : event handler 객체
  126. * return
  127. * void
  128. */
  129. void __fastcall TIHS0010M::BtnExlSaveClick(TObject *Sender)
  130. {
  131. TcxGrid *pGrid = CxList;
  132. TcxGridTableView *pView = TvList;
  133. String sTitle= Caption;//"운영자 접속이력";
  134. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  135. }
  136. //---------------------------------------------------------------------------
  137. /*
  138. * Refresh Button Click Event Handler
  139. * arguments
  140. * Sender : event handler 객체
  141. * return
  142. * void
  143. */
  144. void __fastcall TIHS0010M::BtnSearchClick(TObject *Sender)
  145. {
  146. Application->ProcessMessages();
  147. TSqlCursor sqlCrs((TControl*)BtnSearch);
  148. RefreshData();
  149. }
  150. //---------------------------------------------------------------------------
  151. /*
  152. * Refresh Data Event Function
  153. * arguments
  154. *
  155. * return
  156. * void
  157. */
  158. void __fastcall TIHS0010M::RefreshData()
  159. {
  160. #if 0
  161. FStDateTime = DtStDate->Date.FormatString("yyyymmdd") + DtStTime->Time.FormatString("hh");
  162. FEdDateTime = DtEdDate->Date.FormatString("yyyymmdd") + DtEdTime->Time.FormatString("hh");
  163. #else
  164. FStDateTime = DtStDate->Date.FormatString("yyyymmdd") + DtStTime->Time.FormatString("hhnn");
  165. FEdDateTime = DtEdDate->Date.FormatString("yyyymmdd") + DtEdTime->Time.FormatString("hhnn");
  166. #endif
  167. if (wcscmp(FStDateTime.c_str(), FEdDateTime.c_str()) >= 0)
  168. {
  169. Application->MessageBox(FrmLang->lblQryDtErr->Caption.c_str(),//L"시작 시각이 종료 시각 보다 작거나 같습니다.",
  170. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  171. ActiveControl = DtStDate;
  172. return;
  173. }
  174. #if 0
  175. FStDateTime = FStDateTime + "0000";
  176. FEdDateTime = FEdDateTime + "5959";
  177. #else
  178. FStDateTime = FStDateTime + "00";
  179. FEdDateTime = FEdDateTime + "59";
  180. #endif
  181. SelHistory();
  182. }
  183. //---------------------------------------------------------------------------
  184. /*
  185. * 이력 데이터 조회/출력
  186. * arguments
  187. *
  188. * return
  189. * void
  190. */
  191. void __fastcall TIHS0010M::SelHistory()
  192. {
  193. String sQry;
  194. TADOQuery *pADO = ADOQry;
  195. sQry = "SELECT USER_ID, LOGIN_HMS, LOGOUT_HMS \r\n"
  196. " FROM TB_USERCNNC_HS \r\n"
  197. " WHERE LOGIN_HMS BETWEEN :p01 \r\n"
  198. " AND :p02 \r\n"
  199. " ORDER BY USER_ID, LOGIN_HMS \r\n";
  200. try
  201. {
  202. //pADO->Connection = ITSDb_GetConnection();
  203. ITSDb_SQLText(pADO, sQry);
  204. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  205. ITSDb_SQLBind(pADO, "p02", FEdDateTime);
  206. ITSDb_SQLOpen(pADO);
  207. DspHistory();
  208. }
  209. catch(EDatabaseError &E)
  210. {
  211. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  212. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
  213. throw Exception(String(E.ClassName()) + E.Message);
  214. }
  215. catch(Exception &exception)
  216. {
  217. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  218. DBERRORMSG(Caption, String(exception.ClassName()), exception.Message, sQry);
  219. throw Exception(String(exception.ClassName()) + exception.Message);
  220. }
  221. }
  222. //---------------------------------------------------------------------------
  223. void __fastcall TIHS0010M::DspHistory()
  224. {
  225. TADOQuery *pADO = ADOQry;
  226. try
  227. {
  228. CMM_ClearGridTableView(TvList);
  229. int nRow = 0;
  230. try {
  231. TvList->BeginUpdate();
  232. m_pGDC->RecordCount = pADO->RecordCount;
  233. for( ; !pADO->Eof; pADO->Next(), nRow++)
  234. {
  235. String sUsId = pADO->FieldByName("USER_ID")->AsString;
  236. String sInDt = pADO->FieldByName("LOGIN_HMS")->AsString;
  237. String sOuDt = pADO->FieldByName("LOGOUT_HMS")->AsString;
  238. m_pGDC->Values[nRow][Column01->Index] = sUsId;
  239. if (sInDt.IsEmpty())
  240. m_pGDC->Values[nRow][Column02->Index] = "-";
  241. else
  242. m_pGDC->Values[nRow][Column02->Index] = sInDt.SubString( 1, 4) + "-" +
  243. sInDt.SubString( 5, 2) + "-" +
  244. sInDt.SubString( 7, 2) + " " +
  245. sInDt.SubString( 9, 2) + ":" +
  246. sInDt.SubString(11, 2) + ":" +
  247. sInDt.SubString(13, 2);
  248. if (sOuDt.IsEmpty())
  249. m_pGDC->Values[nRow][Column03->Index] = "-";
  250. else
  251. m_pGDC->Values[nRow][Column03->Index] = sOuDt.SubString( 1, 4) + "-" +
  252. sOuDt.SubString( 5, 2) + "-" +
  253. sOuDt.SubString( 7, 2) + " " +
  254. sOuDt.SubString( 9, 2) + ":" +
  255. sOuDt.SubString(11, 2) + ":" +
  256. sOuDt.SubString(13, 2);
  257. }
  258. }
  259. __finally
  260. {
  261. if (pADO)
  262. {
  263. pADO->Close();
  264. }
  265. TvList->EndUpdate();
  266. CxList->SetFocus();
  267. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + FrmLang->lblEA->Caption;//" 건";
  268. String sEnd = FrmLang->lblQrySel->Caption + " [" + LblRecords->Caption + "]";//"데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  269. Application->MessageBox(sEnd.c_str(),
  270. FrmLang->lblQryEnd->Caption.c_str(),//L"데이터 조회 완료",
  271. MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  272. }
  273. }
  274. catch(EDatabaseError &E)
  275. {
  276. throw Exception(String(E.ClassName()) + E.Message);
  277. }
  278. catch(...)
  279. {
  280. throw Exception(FrmLang->lblDbErr->Caption);//"알수없는 오류가 발생하였습니다.");
  281. }
  282. }
  283. //---------------------------------------------------------------------------
  284. /*
  285. * Close 버튼 클릭 이벤트 핸들러
  286. * arguments
  287. * Sender : event handler 객체
  288. * return
  289. * void
  290. */
  291. void __fastcall TIHS0010M::BtnCloseClick(TObject *Sender)
  292. {
  293. Close();
  294. }
  295. //---------------------------------------------------------------------------
  296. void __fastcall TIHS0010M::FormClose(TObject *Sender, TCloseAction &Action)
  297. {
  298. CommClose();
  299. IHS0010M = NULL;
  300. Action = caFree;
  301. }
  302. //---------------------------------------------------------------------------
  303. void __fastcall TIHS0010M::OnMessage(TMessage &Msg)
  304. {
  305. switch (Msg.Msg)
  306. {
  307. case WM_PARAM_DATABASE:
  308. if (WP_DB_SELECT_OK == Msg.WParam)
  309. {
  310. //ShowMessage("Select Ok");
  311. }
  312. break;
  313. }
  314. }
  315. //---------------------------------------------------------------------------
  316. void __fastcall TIHS0010M::TvListDataControllerFilterChanged(TObject *Sender)
  317. {
  318. CMM_SetFilterLike(TvList);
  319. }
  320. //---------------------------------------------------------------------------