VDSH0301F.cpp 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. void __fastcall TVDSH0301::FormInit()
  59. {
  60. ADOQry->Connection = ITSDb_GetConnection();
  61. m_pGDC = TvList->DataController;
  62. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<VDS-검지기 과거수집 이력 정보>";
  63. //TvList->ViewInfo->GroupByBoxViewInfo->Text = "그룹핑할 필드의 헤더를 이곳으로 드래그 하세요";
  64. LblSearch->Caption = FrmLang->lblQryCond->Caption + FStDateTime.SubString(1, 12) + " ~ " + FEdDateTime.SubString(1, 12);
  65. }
  66. //---------------------------------------------------------------------------
  67. void __fastcall TVDSH0301::FormShow(TObject *Sender)
  68. {
  69. FormInit();
  70. Refresh();
  71. TmrShow->Enabled = true;
  72. }
  73. //---------------------------------------------------------------------------
  74. void __fastcall TVDSH0301::CommClose()
  75. {
  76. CMM_SaveForm(g_sFormsDir, this);
  77. //VDSH0301 = NULL;
  78. }
  79. //---------------------------------------------------------------------------
  80. void __fastcall TVDSH0301::TmrShowTimer(TObject *Sender)
  81. {
  82. TmrShow->Enabled = false;
  83. Application->ProcessMessages();
  84. SelHistory();
  85. }
  86. //---------------------------------------------------------------------------
  87. void __fastcall TVDSH0301::ChkExpandClick(TObject *Sender)
  88. {
  89. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  90. }
  91. //---------------------------------------------------------------------------
  92. void __fastcall TVDSH0301::SelHistory()
  93. {
  94. TSqlCursor sqlCrs;
  95. String sQry;
  96. TADOQuery *pADO = ADOQry;
  97. sQry = "SELECT A.VDS_DTCT_NMBR, B.ISTL_LANE, A.OCRR_DT, A.SYST_KIND_DVSN, \r\n"
  98. " A.TFVL, A.SPED, A.AVRG_OCPY_RATE, A.HDWY, A.AVRG_LNGT \r\n"
  99. " FROM TB_VDS_DTCT_PAST_CLCT A, TB_VDS_DTCT B \r\n"
  100. " WHERE A.OCRR_DT BETWEEN :p01 AND :p02 \r\n"
  101. " AND B.VDS_DTCT_NMBR IN(" + FIdList + ") \r\n"
  102. " AND A.VDS_DTCT_NMBR = B.VDS_DTCT_NMBR \r\n"
  103. " ORDER BY A.VDS_DTCT_NMBR, A.OCRR_DT \r\n";
  104. try
  105. {
  106. ITSDb_SQLText(pADO, sQry);
  107. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  108. ITSDb_SQLBind(pADO, "p02", FEdDateTime);
  109. ITSDb_SQLOpen(pADO);
  110. DspHistory();
  111. }
  112. catch(EDatabaseError &E)
  113. {
  114. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  115. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
  116. throw Exception(String(E.ClassName()) + E.Message);
  117. }
  118. catch(Exception &e)
  119. {
  120. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  121. DBERRORMSG(Caption, String(e.ClassName()), e.Message, sQry);
  122. throw Exception(String(e.ClassName()) + e.Message);
  123. }
  124. }
  125. //---------------------------------------------------------------------------
  126. void __fastcall TVDSH0301::DspHistory()
  127. {
  128. TADOQuery *pADO = ADOQry;
  129. try
  130. {
  131. TcxGridChartSeries *pChart = NULL;
  132. CMM_ClearGridTableView(TvList);
  133. int nRow = 0;
  134. int nDataCnt = 0;
  135. try {
  136. TvList->BeginUpdate();
  137. nDataCnt = pADO->RecordCount;
  138. m_pGDC->RecordCount = nDataCnt;
  139. for( ; !pADO->Eof; pADO->Next(), nRow++)
  140. {
  141. m_pGDC->Values[nRow][Column00->Index] = pADO->FieldByName("VDS_DTCT_NMBR")->AsString;
  142. m_pGDC->Values[nRow][Column01->Index] = pADO->FieldByName("ISTL_LANE")->AsString;
  143. String sDbDate = pADO->FieldByName("OCRR_DT")->AsString;
  144. m_pGDC->Values[nRow][Column02->Index] = ITSUtil_FormatStr(sDbDate, STR_DATETIME);
  145. m_pGDC->Values[nRow][Column03->Index] = pADO->FieldByName("SYST_KIND_DVSN")->AsString;
  146. m_pGDC->Values[nRow][Column04->Index] = FormatFloat("##,##0", pADO->FieldByName("TFVL")->AsInteger);
  147. m_pGDC->Values[nRow][Column05->Index] = FormatFloat("##,##0", pADO->FieldByName("SPED")->AsInteger);
  148. m_pGDC->Values[nRow][Column06->Index] = FormatFloat("##0.#0", pADO->FieldByName("AVRG_OCPY_RATE")->AsFloat);
  149. m_pGDC->Values[nRow][Column07->Index] = FormatFloat("##,##0", pADO->FieldByName("HDWY")->AsInteger);
  150. m_pGDC->Values[nRow][Column08->Index] = FormatFloat("##0.#0", pADO->FieldByName("AVRG_LNGT")->AsFloat);
  151. }
  152. }
  153. __finally
  154. {
  155. if (pADO)
  156. {
  157. pADO->Close();
  158. }
  159. TvList->EndUpdate();
  160. //CxList->SetFocus();
  161. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + FrmLang->lblEA->Caption;//" 건";
  162. String sEnd = FrmLang->lblQrySel->Caption + " [" + LblRecords->Caption + "]";//"데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  163. Application->MessageBox(sEnd.c_str(),
  164. FrmLang->lblQryEnd->Caption.c_str(),//L"데이터 조회 완료",
  165. MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  166. }
  167. }
  168. catch(EDatabaseError &E)
  169. {
  170. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  171. DBERRORMSG(Caption, String(E.ClassName()), E.Message, pADO->SQL->Text);
  172. throw Exception(String(E.ClassName()) + E.Message);
  173. }
  174. catch(Exception &e)
  175. {
  176. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  177. DBERRORMSG(Caption, String(e.ClassName()), e.Message, pADO->SQL->Text);
  178. throw Exception(String(e.ClassName()) + e.Message);
  179. }
  180. }
  181. //---------------------------------------------------------------------------
  182. void __fastcall TVDSH0301::OnMessage(TMessage &Msg)
  183. {
  184. switch (Msg.Msg)
  185. {
  186. case WM_PARAM_DATABASE:
  187. if (WP_DB_SELECT_OK == Msg.WParam)
  188. {
  189. //ShowMessage("Select Ok");
  190. }
  191. break;
  192. }
  193. }
  194. //---------------------------------------------------------------------------
  195. void __fastcall TVDSH0301::BtnExlSaveClick(TObject *Sender)
  196. {
  197. TcxGrid *pGrid = CxList;
  198. TcxGridTableView *pView = TvList;
  199. String sTitle= Caption;//"VDS-검지기 과거수집이력";
  200. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  201. }
  202. //---------------------------------------------------------------------------
  203. void __fastcall TVDSH0301::FormClose(TObject *Sender, TCloseAction &Action)
  204. {
  205. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  206. CommClose();
  207. //VDSH0301 = NULL;
  208. }
  209. //---------------------------------------------------------------------------