IHS0010MF.cpp 9.6 KB

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