WBH00101F.cpp 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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 "ITS_OPLibF.h"
  9. #pragma hdrstop
  10. #include "WBH00101F.h"
  11. //---------------------------------------------------------------------------
  12. #pragma package(smart_init)
  13. #pragma link "cxButtons"
  14. #pragma link "cxCheckBox"
  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 "cxEdit"
  22. #pragma link "cxFilter"
  23. #pragma link "cxGraphics"
  24. #pragma link "cxGrid"
  25. #pragma link "cxGridCustomTableView"
  26. #pragma link "cxGridCustomView"
  27. #pragma link "cxGridLevel"
  28. #pragma link "cxGridTableView"
  29. #pragma link "cxLabel"
  30. #pragma link "cxLookAndFeelPainters"
  31. #pragma link "cxLookAndFeels"
  32. #pragma link "cxStyles"
  33. #pragma link "dxSkinBlack"
  34. #pragma link "dxSkinBlue"
  35. #pragma link "dxSkinsCore"
  36. #pragma link "dxSkinscxPCPainter"
  37. #pragma link "dxSkinMcSkin"
  38. #pragma resource "*.dfm"
  39. TWBH00101 *WBH00101 = NULL;
  40. //---------------------------------------------------------------------------
  41. __fastcall TWBH00101::TWBH00101(TComponent* Owner, HWND hHandle, String sFrom, String sTo, String sIdList)
  42. : TForm(Owner)
  43. {
  44. ITSSkin_Load(this);
  45. CMM_LoadForm(g_sFormsDir, this);
  46. FParent = hHandle;
  47. FStDateTime = sFrom;
  48. FEdDateTime = sTo;
  49. FIdList = sIdList;
  50. Caption = "홈페이지 관리자 이력조회";
  51. }
  52. //---------------------------------------------------------------------------
  53. __fastcall TWBH00101::~TWBH00101(void)
  54. {
  55. }
  56. //--------------------------------------------------------------------------
  57. void __fastcall TWBH00101::FormInit()
  58. {
  59. ADOQry->Connection = ITSDb_GetConnection();
  60. m_pGDC = TvList->DataController;
  61. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<홈페이지 관리자 이력 정보>";
  62. //TvList->ViewInfo->GroupByBoxViewInfo->Text = "그룹핑할 필드의 헤더를 이곳으로 드래그 하세요";
  63. LblSearch->Caption = "검색조건: [" + FIdList + "] " + FStDateTime.SubString(1, 12) + " ~ " + FEdDateTime.SubString(1, 12);
  64. }
  65. //---------------------------------------------------------------------------
  66. void __fastcall TWBH00101::FormShow(TObject *Sender)
  67. {
  68. FormInit();
  69. Refresh();
  70. TmrShow->Enabled = true;
  71. }
  72. //---------------------------------------------------------------------------
  73. void __fastcall TWBH00101::CommClose()
  74. {
  75. CMM_SaveForm(g_sFormsDir, this);
  76. //WBH00101 = NULL;
  77. }
  78. //---------------------------------------------------------------------------
  79. void __fastcall TWBH00101::TmrShowTimer(TObject *Sender)
  80. {
  81. TmrShow->Enabled = false;
  82. Application->ProcessMessages();
  83. SelHistory();
  84. }
  85. //---------------------------------------------------------------------------
  86. void __fastcall TWBH00101::ChkExpandClick(TObject *Sender)
  87. {
  88. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  89. }
  90. //---------------------------------------------------------------------------
  91. void __fastcall TWBH00101::SelHistory()
  92. {
  93. TSqlCursor sqlCrs;
  94. String sQry;
  95. TADOQuery *pADO = ADOQry;
  96. sQry = "SELECT B.EMAIL, B.NAME AS USERNAME, \r\n"
  97. " NVL(C.PAGE_NAME, A.PAGE_ID) AS PAGENAME, \r\n"
  98. " TO_CHAR(A.RGST_DT, 'YYYYMMDDHH24MISS') AS RGST_DT, \r\n"
  99. " A.IP_ADDR AS IP_ADDRESS, A.EXECUTE_ID, A.EXECUTE_RES, \r\n"
  100. " A.REMARKS \r\n"
  101. " FROM TB_WEB_USER_HS A, \r\n"
  102. " TB_WEB_USER_INFR B, \r\n"
  103. " TB_WEB_PAGE C \r\n"
  104. " WHERE A.RGST_DT BETWEEN TO_DATE(:p01, 'YYYYMMDDHH24MISS') \r\n"
  105. " AND TO_DATE(:p02, 'YYYYMMDDHH24MISS') \r\n"
  106. " AND A.USER_ID IN (" + FIdList + ") \r\n"
  107. " AND A.USER_ID = B.USER_ID \r\n"
  108. " AND A.PAGE_ID = C.PAGE_ID(+) \r\n"
  109. " ORDER BY B.EMAIL, PAGENAME \r\n";
  110. try
  111. {
  112. ITSDb_SQLText(pADO, sQry);
  113. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  114. ITSDb_SQLBind(pADO, "p02", FEdDateTime);
  115. ITSDb_SQLOpen(pADO);
  116. DspHistory();
  117. }
  118. catch(EDatabaseError &E)
  119. {
  120. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  121. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
  122. throw Exception(String(E.ClassName()) + E.Message);
  123. }
  124. catch(Exception &exception)
  125. {
  126. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  127. DBERRORMSG(Caption, String(exception.ClassName()), exception.Message, sQry);
  128. throw Exception(String(exception.ClassName()) + exception.Message);
  129. }
  130. }
  131. //---------------------------------------------------------------------------
  132. void __fastcall TWBH00101::DspHistory()
  133. {
  134. TADOQuery *pADO = ADOQry;
  135. try
  136. {
  137. CMM_ClearGridTableView(TvList);
  138. int nRow = 0;
  139. int nDataCnt = 0;
  140. try
  141. {
  142. TvList->BeginUpdate();
  143. nDataCnt = pADO->RecordCount;
  144. m_pGDC->RecordCount = nDataCnt;
  145. for( ; !pADO->Eof; pADO->Next(), nRow++)
  146. {
  147. m_pGDC->Values[nRow][Column01->Index] = pADO->FieldByName("EMAIL")->AsString;
  148. m_pGDC->Values[nRow][Column02->Index] = pADO->FieldByName("USERNAME")->AsString;
  149. String sDbDate = pADO->FieldByName("RGST_DT")->AsString;
  150. m_pGDC->Values[nRow][Column03->Index] = APP_FormatStr(sDbDate, STR_DATETIME);
  151. m_pGDC->Values[nRow][Column04->Index] = pADO->FieldByName("IP_ADDRESS")->AsString;
  152. m_pGDC->Values[nRow][Column05->Index] = pADO->FieldByName("PAGENAME")->AsString;
  153. String sJobType = pADO->FieldByName("EXECUTE_ID")->AsString;
  154. if (sJobType == "I") sJobType = "로그인";
  155. else if (sJobType == "O") sJobType = "로그아웃";
  156. else if (sJobType == "C") sJobType = "등록";
  157. else if (sJobType == "R") sJobType = "조회";
  158. else if (sJobType == "U") sJobType = FrmLang->lblModify->Caption;//"수정";
  159. else if (sJobType == "D") sJobType = FrmLang->lblDelete->Caption;//"삭제";
  160. m_pGDC->Values[nRow][Column06->Index] = sJobType;
  161. String sJobRes = pADO->FieldByName("EXECUTE_RES")->AsString;
  162. if (sJobRes == "0") sJobRes = "성공";
  163. else if (sJobRes == "1") sJobRes = "실패";
  164. m_pGDC->Values[nRow][Column07->Index] = sJobRes;
  165. m_pGDC->Values[nRow][Column08->Index] = pADO->FieldByName("REMARKS")->AsString;
  166. }
  167. }
  168. __finally
  169. {
  170. if (pADO)
  171. {
  172. pADO->Close();
  173. }
  174. TvList->EndUpdate();
  175. //CxList->SetFocus();
  176. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + " 건";
  177. String sEnd = "데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  178. Application->MessageBox(sEnd.c_str(), L"데이터 조회 완료", MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  179. }
  180. }
  181. catch(EDatabaseError &E)
  182. {
  183. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  184. DBERRORMSG(Caption, String(E.ClassName()), E.Message, pADO->SQL->Text);
  185. throw Exception(String(E.ClassName()) + E.Message);
  186. }
  187. catch(Exception &e)
  188. {
  189. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  190. DBERRORMSG(Caption, String(e.ClassName()), e.Message, pADO->SQL->Text);
  191. throw Exception(String(e.ClassName()) + e.Message);
  192. }
  193. }
  194. //---------------------------------------------------------------------------
  195. void __fastcall TWBH00101::OnMessage(TMessage &Msg)
  196. {
  197. switch (Msg.Msg)
  198. {
  199. case WM_PARAM_DATABASE:
  200. if (WP_DB_SELECT_OK == Msg.WParam)
  201. {
  202. //ShowMessage("Select Ok");
  203. }
  204. break;
  205. }
  206. }
  207. //---------------------------------------------------------------------------
  208. void __fastcall TWBH00101::BtnExlSaveClick(TObject *Sender)
  209. {
  210. TcxGrid *pGrid = CxList;
  211. TcxGridTableView *pView = TvList;
  212. String sTitle = "홈페이지관리자이력조회";
  213. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  214. }
  215. //---------------------------------------------------------------------------
  216. void __fastcall TWBH00101::FormClose(TObject *Sender, TCloseAction &Action)
  217. {
  218. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  219. CommClose();
  220. //WBH00101 = NULL;
  221. }
  222. //---------------------------------------------------------------------------
  223. void __fastcall TWBH00101::FormDestroy(TObject *Sender)
  224. {
  225. CommClose();
  226. }
  227. //---------------------------------------------------------------------------
  228. void __fastcall TWBH00101::Column07CustomDrawCell(TcxCustomGridTableView *Sender,
  229. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  230. bool &ADone)
  231. {
  232. if (AViewInfo->Value == "실패")
  233. {
  234. ACanvas->Canvas->Brush->Color = clRed;
  235. ACanvas->Canvas->Font->Color = clWhite;
  236. }
  237. }
  238. //---------------------------------------------------------------------------