DSRH0401F.cpp 8.3 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. #pragma hdrstop
  9. #include "DSRH0401F.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. TDSRH0401 *DSRH0401 = NULL;
  40. //---------------------------------------------------------------------------
  41. __fastcall TDSRH0401::TDSRH0401(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 TDSRH0401::~TDSRH0401(void)
  54. {
  55. }
  56. //--------------------------------------------------------------------------
  57. /*
  58. * form 초기화
  59. *
  60. * arguments
  61. *
  62. * return
  63. * void
  64. */
  65. void __fastcall TDSRH0401::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 TDSRH0401::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 TDSRH0401::CommClose()
  97. {
  98. CMM_SaveForm(g_sFormsDir, this);
  99. //DSRH0401 = NULL;
  100. }
  101. //---------------------------------------------------------------------------
  102. /*
  103. * 최초 1회 수행되는 타이머 이벤트
  104. * arguments
  105. * Sender : event handler 객체
  106. * return
  107. * void
  108. */
  109. void __fastcall TDSRH0401::TmrShowTimer(TObject *Sender)
  110. {
  111. TmrShow->Enabled = false;
  112. Application->ProcessMessages();
  113. SelHistory();
  114. }
  115. //---------------------------------------------------------------------------
  116. void __fastcall TDSRH0401::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 TDSRH0401::SelHistory()
  129. {
  130. TSqlCursor sqlCrs;
  131. String sQry;
  132. TADOQuery *pADO = ADOQry;
  133. sQry = "SELECT A.RSE_SECT_ID, A.CRTN_DT, A.TFVL, A.TRVL_SPED, A.TRVL_HH, \r\n"
  134. " B.STRT_SPOT_NM, B.END_SPOT_NM, B.STRT_ID, B.END_ID \r\n"
  135. " FROM TB_RSE_SECT_TRAF A, \r\n"
  136. " TB_RSE_SECT_MSTR B \r\n"
  137. " WHERE A.RSE_SECT_ID = B.RSE_SECT_ID \r\n"
  138. " AND A.CRTN_DT BETWEEN :p01 AND :p02 \r\n"
  139. " AND A.RSE_SECT_ID IN(" + FIdList + ") \r\n"
  140. " ORDER BY A.RSE_SECT_ID, A.CRTN_DT \r\n";
  141. //" ORDER BY TO_NUMBER(A.RSE_SECT_ID), A.CRTN_DT \r\n";
  142. try
  143. {
  144. ITSDb_SQLText(pADO, sQry);
  145. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  146. ITSDb_SQLBind(pADO, "p02", FEdDateTime);
  147. ITSDb_SQLOpen(pADO);
  148. DspHistory();
  149. }
  150. catch(EDatabaseError &E)
  151. {
  152. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  153. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
  154. throw Exception(String(E.ClassName()) + E.Message);
  155. }
  156. catch(Exception &exception)
  157. {
  158. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  159. DBERRORMSG(Caption, String(exception.ClassName()), exception.Message, sQry);
  160. throw Exception(String(exception.ClassName()) + exception.Message);
  161. }
  162. }
  163. //---------------------------------------------------------------------------
  164. void __fastcall TDSRH0401::DspHistory()
  165. {
  166. TADOQuery *pADO = ADOQry;
  167. try
  168. {
  169. TcxGridChartSeries *pChart = NULL;
  170. CMM_ClearGridTableView(TvList);
  171. int nRow = 0;
  172. int nDataCnt = 0;
  173. try {
  174. TvList->BeginUpdate();
  175. nDataCnt = pADO->RecordCount;
  176. m_pGDC->RecordCount = nDataCnt;
  177. //for( ; !pADO->Eof; pADO->Next(), nRow++)
  178. for( ; !pADO->Eof; pADO->Next())
  179. {
  180. m_pGDC->Values[nRow][Column00->Index] = pADO->FieldByName("RSE_SECT_ID")->AsString;
  181. String sDbDate = pADO->FieldByName("CRTN_DT")->AsString;
  182. m_pGDC->Values[nRow][Column01->Index] = ITSUtil_FormatStr(sDbDate, STR_DATETIME);
  183. m_pGDC->Values[nRow][Column02->Index] = pADO->FieldByName("TFVL")->AsString;
  184. m_pGDC->Values[nRow][Column03->Index] = pADO->FieldByName("TRVL_SPED")->AsString;
  185. m_pGDC->Values[nRow][Column04->Index] = pADO->FieldByName("TRVL_HH")->AsString;
  186. m_pGDC->Values[nRow][Column05->Index] = pADO->FieldByName("STRT_SPOT_NM")->AsString;
  187. m_pGDC->Values[nRow][Column06->Index] = pADO->FieldByName("STRT_ID")->AsString;
  188. m_pGDC->Values[nRow][Column07->Index] = pADO->FieldByName("END_SPOT_NM")->AsString;
  189. m_pGDC->Values[nRow][Column08->Index] = pADO->FieldByName("END_ID")->AsString;
  190. nRow++;
  191. }
  192. }
  193. __finally
  194. {
  195. if (pADO)
  196. {
  197. pADO->Close();
  198. }
  199. TvList->EndUpdate();
  200. //CxList->SetFocus();
  201. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + " 건";
  202. String sEnd = "데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  203. Application->MessageBox(sEnd.c_str(), L"데이터 조회 완료", MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  204. }
  205. }
  206. catch(EDatabaseError &E)
  207. {
  208. throw Exception(String(E.ClassName()) + E.Message);
  209. }
  210. catch(...)
  211. {
  212. throw Exception(FrmLang->lblDbErr->Caption);//"알수없는 오류가 발생하였습니다.");
  213. }
  214. }
  215. //---------------------------------------------------------------------------
  216. void __fastcall TDSRH0401::OnMessage(TMessage &Msg)
  217. {
  218. switch (Msg.Msg)
  219. {
  220. case WM_PARAM_DATABASE:
  221. if (WP_DB_SELECT_OK == Msg.WParam)
  222. {
  223. //ShowMessage("Select Ok");
  224. }
  225. break;
  226. }
  227. }
  228. //---------------------------------------------------------------------------
  229. void __fastcall TDSRH0401::BtnExlSaveClick(TObject *Sender)
  230. {
  231. TcxGrid *pGrid = CxList;
  232. TcxGridTableView *pView = TvList;
  233. String sTitle = "DSRC-RSE 가공정보이력";
  234. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  235. }
  236. //---------------------------------------------------------------------------
  237. void __fastcall TDSRH0401::FormClose(TObject *Sender, TCloseAction &Action)
  238. {
  239. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  240. CommClose();
  241. //DSRH0401 = NULL;
  242. }
  243. //---------------------------------------------------------------------------