VDSH0301F.cpp 8.4 KB

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