IHS0010MF.cpp 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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. #include "ITS_OPLibF.h"
  10. #pragma hdrstop
  11. #include "IHS0010MF.h"
  12. //---------------------------------------------------------------------------
  13. #pragma package(smart_init)
  14. #pragma link "cxButtons"
  15. #pragma link "cxCalendar"
  16. #pragma link "cxClasses"
  17. #pragma link "cxContainer"
  18. #pragma link "cxControls"
  19. #pragma link "cxCustomData"
  20. #pragma link "cxData"
  21. #pragma link "cxDataStorage"
  22. #pragma link "cxDropDownEdit"
  23. #pragma link "cxEdit"
  24. #pragma link "cxFilter"
  25. #pragma link "cxGraphics"
  26. #pragma link "cxGrid"
  27. #pragma link "cxGridCustomTableView"
  28. #pragma link "cxGridCustomView"
  29. #pragma link "cxGridLevel"
  30. #pragma link "cxGridTableView"
  31. #pragma link "cxLabel"
  32. #pragma link "cxLookAndFeelPainters"
  33. #pragma link "cxLookAndFeels"
  34. #pragma link "cxMaskEdit"
  35. #pragma link "cxPC"
  36. #pragma link "cxPCdxBarPopupMenu"
  37. #pragma link "cxSpinEdit"
  38. #pragma link "cxStyles"
  39. #pragma link "cxTextEdit"
  40. #pragma link "cxTimeEdit"
  41. #pragma link "dxSkinBlack"
  42. #pragma link "dxSkinBlue"
  43. #pragma link "dxSkinsCore"
  44. #pragma link "dxSkinscxPCPainter"
  45. #pragma link "dxSkinMcSkin"
  46. #pragma resource "*.dfm"
  47. TIHS0010M *IHS0010M = NULL;
  48. //---------------------------------------------------------------------------
  49. __fastcall TIHS0010M::TIHS0010M(TComponent* Owner)
  50. : TForm(Owner)
  51. {
  52. LangTrans->Translate(this, ITSDb_GetConnection());
  53. ITSSkin_Load(this);
  54. CMM_LoadForm(g_sFormsDir, this);
  55. FTitle = Caption;//"운영자 접속 이력조회";
  56. }
  57. //---------------------------------------------------------------------------
  58. void __fastcall TIHS0010M::FormShow(TObject *Sender)
  59. {
  60. PgList->ActivePageIndex = 0;
  61. // form 초기화
  62. FormInit();
  63. }
  64. //---------------------------------------------------------------------------
  65. void __fastcall TIHS0010M::FormInit()
  66. {
  67. ADOQry->Connection = ITSDb_GetConnection();
  68. m_pGDC = TvList->DataController;
  69. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<운영자 접속 이력 정보>";
  70. DtStDate->Date = Now() - 30;
  71. DtEdDate->Date = Now() - 1;
  72. //DtEdTime->EditValue = Now().FormatString("hh");
  73. DtStTime->Time = StrToDateTime("00:00");
  74. DtEdTime->Time = StrToDateTime("23:59");
  75. if (BtnSearch->Enabled)
  76. BtnSearch->SetFocus();
  77. }
  78. //---------------------------------------------------------------------------
  79. void __fastcall TIHS0010M::CommClose()
  80. {
  81. try
  82. {
  83. CMM_SaveForm(g_sFormsDir, this);
  84. }
  85. catch(...)
  86. {
  87. }
  88. }
  89. //---------------------------------------------------------------------------
  90. void __fastcall TIHS0010M::TmrRefreshTimer(TObject *Sender)
  91. {
  92. TmrRefresh->Enabled = false;
  93. }
  94. //---------------------------------------------------------------------------
  95. void __fastcall TIHS0010M::BtnExlSaveClick(TObject *Sender)
  96. {
  97. TcxGrid *pGrid = CxList;
  98. TcxGridTableView *pView = TvList;
  99. String sTitle= Caption;//"운영자 접속이력";
  100. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  101. }
  102. //---------------------------------------------------------------------------
  103. void __fastcall TIHS0010M::BtnSearchClick(TObject *Sender)
  104. {
  105. Application->ProcessMessages();
  106. TSqlCursor sqlCrs((TControl*)BtnSearch);
  107. RefreshData();
  108. }
  109. //---------------------------------------------------------------------------
  110. void __fastcall TIHS0010M::RefreshData()
  111. {
  112. #if 0
  113. FStDateTime = DtStDate->Date.FormatString("yyyymmdd") + DtStTime->Time.FormatString("hh");
  114. FEdDateTime = DtEdDate->Date.FormatString("yyyymmdd") + DtEdTime->Time.FormatString("hh");
  115. #else
  116. FStDateTime = DtStDate->Date.FormatString("yyyymmdd") + DtStTime->Time.FormatString("hhnn");
  117. FEdDateTime = DtEdDate->Date.FormatString("yyyymmdd") + DtEdTime->Time.FormatString("hhnn");
  118. #endif
  119. if (wcscmp(FStDateTime.c_str(), FEdDateTime.c_str()) >= 0)
  120. {
  121. Application->MessageBox(FrmLang->lblQryDtErr->Caption.c_str(),//L"시작 시각이 종료 시각 보다 작거나 같습니다.",
  122. FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
  123. ActiveControl = DtStDate;
  124. return;
  125. }
  126. #if 0
  127. FStDateTime = FStDateTime + "0000";
  128. FEdDateTime = FEdDateTime + "5959";
  129. #else
  130. FStDateTime = FStDateTime + "00";
  131. FEdDateTime = FEdDateTime + "59";
  132. #endif
  133. SelHistory();
  134. }
  135. //---------------------------------------------------------------------------
  136. void __fastcall TIHS0010M::SelHistory()
  137. {
  138. String sQry;
  139. TADOQuery *pADO = ADOQry;
  140. sQry = "SELECT USER_ID, LOGIN_HMS, LOGOUT_HMS \r\n"
  141. " FROM TB_USER_CNNC_HS \r\n"
  142. " WHERE LOGIN_HMS BETWEEN :p01 \r\n"
  143. " AND :p02 \r\n"
  144. " ORDER BY USER_ID, LOGIN_HMS \r\n";
  145. try
  146. {
  147. //pADO->Connection = ITSDb_GetConnection();
  148. ITSDb_SQLText(pADO, sQry);
  149. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  150. ITSDb_SQLBind(pADO, "p02", FEdDateTime);
  151. ITSDb_SQLOpen(pADO);
  152. DspHistory();
  153. }
  154. catch(EDatabaseError &E)
  155. {
  156. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  157. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
  158. throw Exception(String(E.ClassName()) + E.Message);
  159. }
  160. catch(Exception &e)
  161. {
  162. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  163. DBERRORMSG(Caption, String(e.ClassName()), e.Message, sQry);
  164. throw Exception(String(e.ClassName()) + e.Message);
  165. }
  166. }
  167. //---------------------------------------------------------------------------
  168. void __fastcall TIHS0010M::DspHistory()
  169. {
  170. TADOQuery *pADO = ADOQry;
  171. try
  172. {
  173. CMM_ClearGridTableView(TvList);
  174. int nRow = 0;
  175. try {
  176. TvList->BeginUpdate();
  177. m_pGDC->RecordCount = pADO->RecordCount;
  178. for( ; !pADO->Eof; pADO->Next(), nRow++)
  179. {
  180. String sUsId = pADO->FieldByName("USER_ID")->AsString;
  181. String sInDt = pADO->FieldByName("LOGIN_HMS")->AsString;
  182. String sOuDt = pADO->FieldByName("LOGOUT_HMS")->AsString;
  183. m_pGDC->Values[nRow][Column01->Index] = sUsId;
  184. if (sInDt.IsEmpty())
  185. m_pGDC->Values[nRow][Column02->Index] = "-";
  186. else
  187. m_pGDC->Values[nRow][Column02->Index] = sInDt.SubString( 1, 4) + "-" +
  188. sInDt.SubString( 5, 2) + "-" +
  189. sInDt.SubString( 7, 2) + " " +
  190. sInDt.SubString( 9, 2) + ":" +
  191. sInDt.SubString(11, 2) + ":" +
  192. sInDt.SubString(13, 2);
  193. if (sOuDt.IsEmpty())
  194. m_pGDC->Values[nRow][Column03->Index] = "-";
  195. else
  196. m_pGDC->Values[nRow][Column03->Index] = sOuDt.SubString( 1, 4) + "-" +
  197. sOuDt.SubString( 5, 2) + "-" +
  198. sOuDt.SubString( 7, 2) + " " +
  199. sOuDt.SubString( 9, 2) + ":" +
  200. sOuDt.SubString(11, 2) + ":" +
  201. sOuDt.SubString(13, 2);
  202. }
  203. }
  204. __finally
  205. {
  206. if (pADO)
  207. {
  208. pADO->Close();
  209. }
  210. TvList->EndUpdate();
  211. CxList->SetFocus();
  212. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + FrmLang->lblEA->Caption;//" 건";
  213. String sEnd = FrmLang->lblQrySel->Caption + " [" + LblRecords->Caption + "]";//"데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  214. Application->MessageBox(sEnd.c_str(),
  215. FrmLang->lblQryEnd->Caption.c_str(),//L"데이터 조회 완료",
  216. MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  217. }
  218. }
  219. catch(EDatabaseError &E)
  220. {
  221. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  222. DBERRORMSG(Caption, String(E.ClassName()), E.Message, pADO->SQL->Text);
  223. throw Exception(String(E.ClassName()) + E.Message);
  224. }
  225. catch(Exception &e)
  226. {
  227. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  228. DBERRORMSG(Caption, String(e.ClassName()), e.Message, pADO->SQL->Text);
  229. throw Exception(String(e.ClassName()) + e.Message);
  230. }
  231. }
  232. //---------------------------------------------------------------------------
  233. void __fastcall TIHS0010M::BtnCloseClick(TObject *Sender)
  234. {
  235. Close();
  236. }
  237. //---------------------------------------------------------------------------
  238. void __fastcall TIHS0010M::FormClose(TObject *Sender, TCloseAction &Action)
  239. {
  240. CommClose();
  241. IHS0010M = NULL;
  242. Action = caFree;
  243. }
  244. //---------------------------------------------------------------------------
  245. void __fastcall TIHS0010M::OnMessage(TMessage &Msg)
  246. {
  247. switch (Msg.Msg)
  248. {
  249. case WM_PARAM_DATABASE:
  250. if (WP_DB_SELECT_OK == Msg.WParam)
  251. {
  252. //ShowMessage("Select Ok");
  253. }
  254. break;
  255. }
  256. }
  257. //---------------------------------------------------------------------------
  258. void __fastcall TIHS0010M::TvListDataControllerFilterChanged(TObject *Sender)
  259. {
  260. CMM_SetFilterLike(TvList);
  261. }
  262. //---------------------------------------------------------------------------