DSRH0401F.cpp 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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 "DSRH0401F.h"
  11. //---------------------------------------------------------------------------
  12. #pragma package(smart_init)
  13. #pragma link "cxButtons"
  14. #pragma link "cxCalc"
  15. #pragma link "cxCheckBox"
  16. #pragma link "cxClasses"
  17. #pragma link "cxContainer"
  18. #pragma link "cxControls"
  19. #pragma link "cxCustomData"
  20. #pragma link "cxData"
  21. #pragma link "cxDataStorage"
  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 "cxStyles"
  34. #pragma link "cxTextEdit"
  35. #pragma link "dxSkinBlack"
  36. #pragma link "dxSkinBlue"
  37. #pragma link "dxSkinsCore"
  38. #pragma link "dxSkinscxPCPainter"
  39. #pragma link "dxSkinMcSkin"
  40. #pragma resource "*.dfm"
  41. TDSRH0401 *DSRH0401 = NULL;
  42. //---------------------------------------------------------------------------
  43. __fastcall TDSRH0401::TDSRH0401(TComponent* Owner, HWND hHandle, String sFrom, String sTo, String sIdList)
  44. : TForm(Owner)
  45. {
  46. LangTrans->Translate(this, ITSDb_GetConnection());
  47. ITSSkin_Load(this);
  48. CMM_LoadForm(g_sFormsDir, this);
  49. FParent = hHandle;
  50. FStDateTime = sFrom;
  51. FEdDateTime = sTo;
  52. FIdList = sIdList;
  53. //Caption = "DSRC 가공정보 이력";
  54. }
  55. //---------------------------------------------------------------------------
  56. __fastcall TDSRH0401::~TDSRH0401(void)
  57. {
  58. }
  59. //--------------------------------------------------------------------------
  60. void __fastcall TDSRH0401::FormInit()
  61. {
  62. ADOQry->Connection = ITSDb_GetConnection();
  63. m_pGDC = TvList->DataController;
  64. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<DSRC 가공정보 이력 정보>";
  65. //TvList->ViewInfo->GroupByBoxViewInfo->Text = "그룹핑할 필드의 헤더를 이곳으로 드래그 하세요";
  66. LblSearch->Caption = "검색조건: " + FStDateTime.SubString(1, 12) + " ~ " + FEdDateTime.SubString(1, 12);
  67. }
  68. //---------------------------------------------------------------------------
  69. void __fastcall TDSRH0401::FormShow(TObject *Sender)
  70. {
  71. FormInit();
  72. Refresh();
  73. TmrShow->Enabled = true;
  74. }
  75. //---------------------------------------------------------------------------
  76. void __fastcall TDSRH0401::CommClose()
  77. {
  78. CMM_SaveForm(g_sFormsDir, this);
  79. //DSRH0401 = NULL;
  80. }
  81. //---------------------------------------------------------------------------
  82. void __fastcall TDSRH0401::TmrShowTimer(TObject *Sender)
  83. {
  84. TmrShow->Enabled = false;
  85. Application->ProcessMessages();
  86. SelHistory();
  87. }
  88. //---------------------------------------------------------------------------
  89. void __fastcall TDSRH0401::ChkExpandClick(TObject *Sender)
  90. {
  91. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  92. }
  93. //---------------------------------------------------------------------------
  94. void __fastcall TDSRH0401::SelHistory()
  95. {
  96. TSqlCursor sqlCrs;
  97. String sQry;
  98. TADOQuery *pADO = ADOQry;
  99. sQry = "SELECT A.RSE_SECT_ID, A.CRTN_DT, A.TFVL, A.TRVL_SPED, A.TRVL_HH, \r\n"
  100. " B.STRT_SPOT_NM, B.END_SPOT_NM, B.STRT_ID, B.END_ID \r\n"
  101. " FROM TB_RSE_SECT_TRAF A, \r\n"
  102. " TB_RSE_SECT_MSTR B \r\n"
  103. " WHERE A.RSE_SECT_ID = B.RSE_SECT_ID \r\n"
  104. " AND A.CRTN_DT BETWEEN :p01 AND :p02 \r\n"
  105. " AND A.RSE_SECT_ID IN(" + FIdList + ") \r\n"
  106. " ORDER BY A.RSE_SECT_ID, A.CRTN_DT \r\n";
  107. //" ORDER BY TO_NUMBER(A.RSE_SECT_ID), A.CRTN_DT \r\n";
  108. try
  109. {
  110. ITSDb_SQLText(pADO, sQry);
  111. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  112. ITSDb_SQLBind(pADO, "p02", FEdDateTime);
  113. ITSDb_SQLOpen(pADO);
  114. DspHistory();
  115. }
  116. catch(EDatabaseError &E)
  117. {
  118. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  119. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
  120. throw Exception(String(E.ClassName()) + E.Message);
  121. }
  122. catch(Exception &exception)
  123. {
  124. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  125. DBERRORMSG(Caption, String(exception.ClassName()), exception.Message, sQry);
  126. throw Exception(String(exception.ClassName()) + exception.Message);
  127. }
  128. }
  129. //---------------------------------------------------------------------------
  130. void __fastcall TDSRH0401::DspHistory()
  131. {
  132. TADOQuery *pADO = ADOQry;
  133. try
  134. {
  135. TcxGridChartSeries *pChart = NULL;
  136. CMM_ClearGridTableView(TvList);
  137. int nRow = 0;
  138. int nDataCnt = 0;
  139. try {
  140. TvList->BeginUpdate();
  141. nDataCnt = pADO->RecordCount;
  142. m_pGDC->RecordCount = nDataCnt;
  143. //for( ; !pADO->Eof; pADO->Next(), nRow++)
  144. for( ; !pADO->Eof; pADO->Next())
  145. {
  146. m_pGDC->Values[nRow][Column00->Index] = pADO->FieldByName("RSE_SECT_ID")->AsString;
  147. String sDbDate = pADO->FieldByName("CRTN_DT")->AsString;
  148. //m_pGDC->Values[nRow][Column01->Index] = ITSUtil_FormatStr(sDbDate, STR_DATETIME);
  149. m_pGDC->Values[nRow][Column01->Index] = ITSUtil_StrToDateTime(sDbDate).FormatString(STR_DATETIME);
  150. m_pGDC->Values[nRow][Column02->Index] = pADO->FieldByName("TFVL")->AsString;
  151. m_pGDC->Values[nRow][Column03->Index] = pADO->FieldByName("TRVL_SPED")->AsString;
  152. m_pGDC->Values[nRow][Column04->Index] = pADO->FieldByName("TRVL_HH")->AsString;
  153. m_pGDC->Values[nRow][Column05->Index] = pADO->FieldByName("STRT_SPOT_NM")->AsString;
  154. m_pGDC->Values[nRow][Column06->Index] = pADO->FieldByName("STRT_ID")->AsString;
  155. m_pGDC->Values[nRow][Column07->Index] = pADO->FieldByName("END_SPOT_NM")->AsString;
  156. m_pGDC->Values[nRow][Column08->Index] = pADO->FieldByName("END_ID")->AsString;
  157. nRow++;
  158. }
  159. }
  160. __finally
  161. {
  162. if (pADO)
  163. {
  164. pADO->Close();
  165. }
  166. TvList->EndUpdate();
  167. //CxList->SetFocus();
  168. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + " 건";
  169. String sEnd = "데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  170. Application->MessageBox(sEnd.c_str(), L"데이터 조회 완료", MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  171. }
  172. }
  173. catch(EDatabaseError &E)
  174. {
  175. throw Exception(String(E.ClassName()) + E.Message);
  176. }
  177. catch(...)
  178. {
  179. throw Exception(FrmLang->lblDbErr->Caption);//"알수없는 오류가 발생하였습니다.");
  180. }
  181. }
  182. //---------------------------------------------------------------------------
  183. void __fastcall TDSRH0401::OnMessage(TMessage &Msg)
  184. {
  185. switch (Msg.Msg)
  186. {
  187. case WM_PARAM_DATABASE:
  188. if (WP_DB_SELECT_OK == Msg.WParam)
  189. {
  190. //ShowMessage("Select Ok");
  191. }
  192. break;
  193. }
  194. }
  195. //---------------------------------------------------------------------------
  196. void __fastcall TDSRH0401::BtnExlSaveClick(TObject *Sender)
  197. {
  198. TcxGrid *pGrid = CxList;
  199. TcxGridTableView *pView = TvList;
  200. String sTitle = "DSRC 가공정보이력";
  201. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  202. }
  203. //---------------------------------------------------------------------------
  204. void __fastcall TDSRH0401::FormClose(TObject *Sender, TCloseAction &Action)
  205. {
  206. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  207. CommClose();
  208. //DSRH0401 = NULL;
  209. }
  210. //---------------------------------------------------------------------------