DSRH0501F.cpp 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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 "DSRH0501F.h"
  10. //---------------------------------------------------------------------------
  11. #pragma package(smart_init)
  12. #pragma link "cxButtons"
  13. #pragma link "cxCalc"
  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 "cxTextEdit"
  34. #pragma link "dxSkinBlack"
  35. #pragma link "dxSkinBlue"
  36. #pragma link "dxSkinsCore"
  37. #pragma link "dxSkinscxPCPainter"
  38. #pragma resource "*.dfm"
  39. TDSRH0501 *DSRH0501 = NULL;
  40. //---------------------------------------------------------------------------
  41. __fastcall TDSRH0501::TDSRH0501(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 = "DSRC-RSE 제공정보 이력";
  51. }
  52. //---------------------------------------------------------------------------
  53. __fastcall TDSRH0501::~TDSRH0501(void)
  54. {
  55. }
  56. //--------------------------------------------------------------------------
  57. /*
  58. * form 초기화
  59. *
  60. * arguments
  61. *
  62. * return
  63. * void
  64. */
  65. void __fastcall TDSRH0501::FormInit()
  66. {
  67. ADOQry->Connection = ITSDb_GetConnection();
  68. m_pGDC = TvList->DataController;
  69. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<DSRC-RSE 제공정보 이력 정보>";
  70. //TvList->ViewInfo->GroupByBoxViewInfo->Text = "그룹핑할 필드의 헤더를 이곳으로 드래그 하세요";
  71. LblSearch->Caption = "검색조건: " + FStDateTime.SubString(1, 12) + " ~ " + FEdDateTime.SubString(1, 12);
  72. }
  73. //---------------------------------------------------------------------------
  74. /*
  75. * form을 보여줄때 호출되는 event 메서드이다.
  76. * arguments
  77. * Sender : event handler 객체
  78. * return
  79. * void
  80. */
  81. void __fastcall TDSRH0501::FormShow(TObject *Sender)
  82. {
  83. FormInit();
  84. Refresh();
  85. TmrShow->Enabled = true;
  86. }
  87. //---------------------------------------------------------------------------
  88. /*
  89. * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
  90. * Form과 DataModule class를 delete시킨다.
  91. * arguments
  92. *
  93. * return
  94. * void
  95. */
  96. void __fastcall TDSRH0501::CommClose()
  97. {
  98. CMM_SaveForm(g_sFormsDir, this);
  99. //DSRH0501 = NULL;
  100. }
  101. //---------------------------------------------------------------------------
  102. /*
  103. * 최초 1회 수행되는 타이머 이벤트
  104. * arguments
  105. * Sender : event handler 객체
  106. * return
  107. * void
  108. */
  109. void __fastcall TDSRH0501::TmrShowTimer(TObject *Sender)
  110. {
  111. TmrShow->Enabled = false;
  112. Application->ProcessMessages();
  113. SelHistory();
  114. }
  115. //---------------------------------------------------------------------------
  116. void __fastcall TDSRH0501::ChkExpandClick(TObject *Sender)
  117. {
  118. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  119. }
  120. //---------------------------------------------------------------------------
  121. /*
  122. * Refresh Data Event Function
  123. * arguments
  124. *
  125. * return
  126. * void
  127. */
  128. void __fastcall TDSRH0501::SelHistory()
  129. {
  130. TSqlCursor sqlCrs;
  131. String sQry;
  132. TADOQuery *pADO = ADOQry;
  133. sQry = "SELECT A.OFFR_SECT_ID, A.OFFR_DT, A.OFFR_CONT \r\n"
  134. " FROM TB_RSE_OFFR_INFR_HS A \r\n"
  135. " WHERE A.OFFR_DT BETWEEN :p01 AND :p02 \r\n"
  136. " AND A.OFFR_SECT_ID IN(" + FIdList + ") \r\n"
  137. " ORDER BY A.OFFR_SECT_ID, A.OFFR_DT \r\n";
  138. //" ORDER BY TO_NUMBER(A.OFFR_SECT_ID), A.OFFR_DT \r\n";
  139. try
  140. {
  141. ITSDb_SQLText(pADO, sQry);
  142. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  143. ITSDb_SQLBind(pADO, "p02", FEdDateTime);
  144. ITSDb_SQLOpen(pADO);
  145. DspHistory();
  146. }
  147. catch(EDatabaseError &E)
  148. {
  149. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  150. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
  151. throw Exception(String(E.ClassName()) + E.Message);
  152. }
  153. catch(Exception &exception)
  154. {
  155. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  156. DBERRORMSG(Caption, String(exception.ClassName()), exception.Message, sQry);
  157. throw Exception(String(exception.ClassName()) + exception.Message);
  158. }
  159. }
  160. //---------------------------------------------------------------------------
  161. void __fastcall TDSRH0501::DspHistory()
  162. {
  163. TADOQuery *pADO = ADOQry;
  164. try
  165. {
  166. TcxGridChartSeries *pChart = NULL;
  167. CMM_ClearGridTableView(TvList);
  168. int nRow = 0;
  169. int nDataCnt = 0;
  170. try {
  171. TvList->BeginUpdate();
  172. nDataCnt = pADO->RecordCount;
  173. m_pGDC->RecordCount = nDataCnt;
  174. //for( ; !pADO->Eof; pADO->Next(), nRow++)
  175. for( ; !pADO->Eof; pADO->Next())
  176. {
  177. m_pGDC->Values[nRow][Column00->Index] = pADO->FieldByName("OFFR_SECT_ID")->AsString;
  178. String sDbDate = pADO->FieldByName("OFFR_DT")->AsString;
  179. m_pGDC->Values[nRow][Column01->Index] = ITSUtil_FormatStr(sDbDate, STR_DATETIME);
  180. m_pGDC->Values[nRow][Column02->Index] = pADO->FieldByName("OFFR_CONT")->AsString;
  181. nRow++;
  182. }
  183. }
  184. __finally
  185. {
  186. if (pADO)
  187. {
  188. pADO->Close();
  189. }
  190. TvList->EndUpdate();
  191. //CxList->SetFocus();
  192. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + " 건";
  193. String sEnd = "데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  194. Application->MessageBox(sEnd.c_str(), L"데이터 조회 완료", MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  195. }
  196. }
  197. catch(EDatabaseError &E)
  198. {
  199. throw Exception(String(E.ClassName()) + E.Message);
  200. }
  201. catch(...)
  202. {
  203. throw Exception(FrmLang->lblDbErr->Caption);//"알수없는 오류가 발생하였습니다.");
  204. }
  205. }
  206. //---------------------------------------------------------------------------
  207. void __fastcall TDSRH0501::OnMessage(TMessage &Msg)
  208. {
  209. switch (Msg.Msg)
  210. {
  211. case WM_PARAM_DATABASE:
  212. if (WP_DB_SELECT_OK == Msg.WParam)
  213. {
  214. //ShowMessage("Select Ok");
  215. }
  216. break;
  217. }
  218. }
  219. //---------------------------------------------------------------------------
  220. void __fastcall TDSRH0501::BtnExlSaveClick(TObject *Sender)
  221. {
  222. TcxGrid *pGrid = CxList;
  223. TcxGridTableView *pView = TvList;
  224. String sTitle = "DSRC-RSE 제공정보이력";
  225. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  226. }
  227. //---------------------------------------------------------------------------
  228. void __fastcall TDSRH0501::FormClose(TObject *Sender, TCloseAction &Action)
  229. {
  230. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  231. CommClose();
  232. //DSRH0501 = NULL;
  233. }
  234. //---------------------------------------------------------------------------