VDSH0301F.cpp 8.3 KB

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