WBH00101F.cpp 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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. #pragma hdrstop
  9. #include "WBH00101F.h"
  10. //---------------------------------------------------------------------------
  11. #pragma package(smart_init)
  12. #pragma link "cxButtons"
  13. #pragma link "cxCheckBox"
  14. #pragma link "cxClasses"
  15. #pragma link "cxContainer"
  16. #pragma link "cxControls"
  17. #pragma link "cxCustomData"
  18. #pragma link "cxData"
  19. #pragma link "cxDataStorage"
  20. #pragma link "cxEdit"
  21. #pragma link "cxFilter"
  22. #pragma link "cxGraphics"
  23. #pragma link "cxGrid"
  24. #pragma link "cxGridCustomTableView"
  25. #pragma link "cxGridCustomView"
  26. #pragma link "cxGridLevel"
  27. #pragma link "cxGridTableView"
  28. #pragma link "cxLabel"
  29. #pragma link "cxLookAndFeelPainters"
  30. #pragma link "cxLookAndFeels"
  31. #pragma link "cxStyles"
  32. #pragma link "dxSkinBlack"
  33. #pragma link "dxSkinBlue"
  34. #pragma link "dxSkinsCore"
  35. #pragma link "dxSkinscxPCPainter"
  36. #pragma resource "*.dfm"
  37. TWBH00101 *WBH00101 = NULL;
  38. //---------------------------------------------------------------------------
  39. __fastcall TWBH00101::TWBH00101(TComponent* Owner, HWND hHandle, String sFrom, String sTo, String sIdList)
  40. : TForm(Owner)
  41. {
  42. ITSSkin_Load(this);
  43. CMM_LoadForm(g_sFormsDir, this);
  44. FParent = hHandle;
  45. FStDateTime = sFrom;
  46. FEdDateTime = sTo;
  47. FIdList = sIdList;
  48. Caption = "홈페이지 관리자 이력조회";
  49. }
  50. //---------------------------------------------------------------------------
  51. __fastcall TWBH00101::~TWBH00101(void)
  52. {
  53. }
  54. //--------------------------------------------------------------------------
  55. /*
  56. * form 초기화
  57. *
  58. * arguments
  59. *
  60. * return
  61. * void
  62. */
  63. void __fastcall TWBH00101::FormInit()
  64. {
  65. ADOQry->Connection = ITSDb_GetConnection();
  66. m_pGDC = TvList->DataController;
  67. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<홈페이지 관리자 이력 정보>";
  68. //TvList->ViewInfo->GroupByBoxViewInfo->Text = "그룹핑할 필드의 헤더를 이곳으로 드래그 하세요";
  69. LblSearch->Caption = "검색조건: [" + FIdList + "] " + FStDateTime.SubString(1, 12) + " ~ " + FEdDateTime.SubString(1, 12);
  70. }
  71. //---------------------------------------------------------------------------
  72. /*
  73. * form을 보여줄때 호출되는 event 메서드이다.
  74. * arguments
  75. * Sender : event handler 객체
  76. * return
  77. * void
  78. */
  79. void __fastcall TWBH00101::FormShow(TObject *Sender)
  80. {
  81. FormInit();
  82. Refresh();
  83. TmrShow->Enabled = true;
  84. }
  85. //---------------------------------------------------------------------------
  86. /*
  87. * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
  88. * Form과 DataModule class를 delete시킨다.
  89. * arguments
  90. *
  91. * return
  92. * void
  93. */
  94. void __fastcall TWBH00101::CommClose()
  95. {
  96. CMM_SaveForm(g_sFormsDir, this);
  97. //WBH00101 = NULL;
  98. }
  99. //---------------------------------------------------------------------------
  100. /*
  101. * 최초 1회 수행되는 타이머 이벤트
  102. * arguments
  103. * Sender : event handler 객체
  104. * return
  105. * void
  106. */
  107. void __fastcall TWBH00101::TmrShowTimer(TObject *Sender)
  108. {
  109. TmrShow->Enabled = false;
  110. Application->ProcessMessages();
  111. SelHistory();
  112. }
  113. //---------------------------------------------------------------------------
  114. void __fastcall TWBH00101::ChkExpandClick(TObject *Sender)
  115. {
  116. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  117. }
  118. //---------------------------------------------------------------------------
  119. /*
  120. * Refresh Data Event Function
  121. * arguments
  122. *
  123. * return
  124. * void
  125. */
  126. void __fastcall TWBH00101::SelHistory()
  127. {
  128. TSqlCursor sqlCrs;
  129. String sQry;
  130. TADOQuery *pADO = ADOQry;
  131. sQry = "SELECT B.EMAIL, B.USERNAME, \r\n"
  132. " NVL(C.PAGENAME, A.PAGEID) AS PAGENAME, \r\n"
  133. " TO_CHAR(A.RGST_DT, 'YYYYMMDDHH24MISS') AS RGST_DT, \r\n"
  134. " A.IP_ADDRESS, A.EXECUTE_ID, A.EXECUTE_RES, A.REMARKS \r\n"
  135. " FROM TB_MS_WEB_MEMBER_HS A, \r\n"
  136. " TB_MS_WEB_MEMBER B, \r\n"
  137. " TB_MS_WEB_PAGE C \r\n"
  138. " WHERE A.RGST_DT BETWEEN TO_DATE(:p01, 'YYYYMMDDHH24MISS') \r\n"
  139. " AND TO_DATE(:p02, 'YYYYMMDDHH24MISS') \r\n"
  140. " AND A.EMAIL IN (" + FIdList + ") \r\n"
  141. " AND A.EMAIL = B.EMAIL \r\n"
  142. " AND A.PAGEID = C.PAGEID(+) \r\n"
  143. " ORDER BY B.EMAIL, PAGENAME \r\n";
  144. try
  145. {
  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 &exception)
  159. {
  160. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  161. DBERRORMSG(Caption, String(exception.ClassName()), exception.Message, sQry);
  162. throw Exception(String(exception.ClassName()) + exception.Message);
  163. }
  164. }
  165. //---------------------------------------------------------------------------
  166. void __fastcall TWBH00101::DspHistory()
  167. {
  168. TADOQuery *pADO = ADOQry;
  169. try
  170. {
  171. CMM_ClearGridTableView(TvList);
  172. int nRow = 0;
  173. int nDataCnt = 0;
  174. try
  175. {
  176. TvList->BeginUpdate();
  177. nDataCnt = pADO->RecordCount;
  178. m_pGDC->RecordCount = nDataCnt;
  179. for( ; !pADO->Eof; pADO->Next(), nRow++)
  180. {
  181. m_pGDC->Values[nRow][Column01->Index] = pADO->FieldByName("EMAIL")->AsString;
  182. m_pGDC->Values[nRow][Column02->Index] = pADO->FieldByName("USERNAME")->AsString;
  183. String sDbDate = pADO->FieldByName("RGST_DT")->AsString;
  184. m_pGDC->Values[nRow][Column03->Index] = ITSUtil_FormatStr(sDbDate, STR_DATETIME);
  185. m_pGDC->Values[nRow][Column04->Index] = pADO->FieldByName("IP_ADDRESS")->AsString;
  186. m_pGDC->Values[nRow][Column05->Index] = pADO->FieldByName("PAGENAME")->AsString;
  187. String sJobType = pADO->FieldByName("EXECUTE_ID")->AsString;
  188. if (sJobType == "I") sJobType = "로그인";
  189. else if (sJobType == "O") sJobType = "로그아웃";
  190. else if (sJobType == "C") sJobType = "등록";
  191. else if (sJobType == "R") sJobType = "조회";
  192. else if (sJobType == "U") sJobType = FrmLang->lblModify->Caption;//"수정";
  193. else if (sJobType == "D") sJobType = FrmLang->lblDelete->Caption;//"삭제";
  194. m_pGDC->Values[nRow][Column06->Index] = sJobType;
  195. String sJobRes = pADO->FieldByName("EXECUTE_RES")->AsString;
  196. if (sJobRes == "0") sJobRes = "성공";
  197. else if (sJobRes == "1") sJobRes = "실패";
  198. m_pGDC->Values[nRow][Column07->Index] = sJobRes;
  199. m_pGDC->Values[nRow][Column08->Index] = pADO->FieldByName("REMARKS")->AsString;
  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) + " 건";
  211. String sEnd = "데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  212. Application->MessageBox(sEnd.c_str(), L"데이터 조회 완료", MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  213. }
  214. }
  215. catch(EDatabaseError &E)
  216. {
  217. throw Exception(String(E.ClassName()) + E.Message);
  218. }
  219. catch(...)
  220. {
  221. throw Exception(FrmLang->lblDbErr->Caption);//"알수없는 오류가 발생하였습니다.");
  222. }
  223. }
  224. //---------------------------------------------------------------------------
  225. void __fastcall TWBH00101::OnMessage(TMessage &Msg)
  226. {
  227. switch (Msg.Msg)
  228. {
  229. case WM_PARAM_DATABASE:
  230. if (WP_DB_SELECT_OK == Msg.WParam)
  231. {
  232. //ShowMessage("Select Ok");
  233. }
  234. break;
  235. }
  236. }
  237. //---------------------------------------------------------------------------
  238. void __fastcall TWBH00101::BtnExlSaveClick(TObject *Sender)
  239. {
  240. TcxGrid *pGrid = CxList;
  241. TcxGridTableView *pView = TvList;
  242. String sTitle = "홈페이지관리자이력조회";
  243. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  244. }
  245. //---------------------------------------------------------------------------
  246. void __fastcall TWBH00101::FormClose(TObject *Sender, TCloseAction &Action)
  247. {
  248. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  249. CommClose();
  250. //WBH00101 = NULL;
  251. }
  252. //---------------------------------------------------------------------------
  253. void __fastcall TWBH00101::FormDestroy(TObject *Sender)
  254. {
  255. CommClose();
  256. }
  257. //---------------------------------------------------------------------------
  258. void __fastcall TWBH00101::Column07CustomDrawCell(TcxCustomGridTableView *Sender,
  259. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  260. bool &ADone)
  261. {
  262. if (AViewInfo->Value == "실패")
  263. {
  264. ACanvas->Canvas->Brush->Color = clRed;
  265. ACanvas->Canvas->Font->Color = clWhite;
  266. }
  267. }
  268. //---------------------------------------------------------------------------