VDSH0801F.cpp 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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 "VDSH0801F.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. TVDSH0801 *VDSH0801 = NULL;
  42. //---------------------------------------------------------------------------
  43. __fastcall TVDSH0801::TVDSH0801(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 TVDSH0801::~TVDSH0801(void)
  57. {
  58. }
  59. //--------------------------------------------------------------------------
  60. void __fastcall TVDSH0801::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 TVDSH0801::FormShow(TObject *Sender)
  70. {
  71. FormInit();
  72. Refresh();
  73. TmrShow->Enabled = true;
  74. }
  75. //---------------------------------------------------------------------------
  76. void __fastcall TVDSH0801::CommClose()
  77. {
  78. CMM_SaveForm(g_sFormsDir, this);
  79. //VDSH0801 = NULL;
  80. }
  81. //---------------------------------------------------------------------------
  82. void __fastcall TVDSH0801::TmrShowTimer(TObject *Sender)
  83. {
  84. TmrShow->Enabled = false;
  85. Application->ProcessMessages();
  86. SelHistory();
  87. }
  88. //---------------------------------------------------------------------------
  89. void __fastcall TVDSH0801::ChkExpandClick(TObject *Sender)
  90. {
  91. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  92. }
  93. //---------------------------------------------------------------------------
  94. void __fastcall TVDSH0801::SelHistory()
  95. {
  96. TSqlCursor sqlCrs;
  97. String sQry;
  98. TADOQuery *pADO = ADOQry;
  99. sQry = "SELECT A.*, \r\n"
  100. " B.VDS_DTCT_ID, B.VDS_DTCT_NM, B.ISTL_LANE, \r\n"
  101. " B.DTCT_TYPE, \r\n"
  102. " (SELECT CMMN_CD_KOR_NM \r\n"
  103. " FROM TB_CMMN_CD \r\n"
  104. " WHERE CMMN_CLSF_CD = 'DTT' \r\n"
  105. " AND CMMN_CD = B.DTCT_TYPE) AS DTCT_TYPE_NM, \r\n"
  106. " B.DTCT_DIR, \r\n"
  107. " (SELECT CMMN_CD_KOR_NM \r\n"
  108. " FROM TB_CMMN_CD \r\n"
  109. " WHERE CMMN_CLSF_CD = 'VCD' \r\n"
  110. " AND CMMN_CD = B.DTCT_DIR) AS DTCT_DIR_NM \r\n"
  111. " FROM TB_VDS_DTCT_VEH_CLCT A, \r\n"
  112. " TB_VDS_DTCT B \r\n"
  113. " WHERE A.CLCT_DT BETWEEN :p01 AND :p02 \r\n"
  114. " AND B.VDS_DTCT_NMBR IN(" + FIdList + ") \r\n"
  115. " AND A.VDS_DTCT_NMBR = B.VDS_DTCT_NMBR \r\n"
  116. " ORDER BY A.VDS_DTCT_NMBR, A.CLCT_DT, A.CLCT_SEQ \r\n";
  117. try
  118. {
  119. ITSDb_SQLText(pADO, sQry);
  120. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  121. ITSDb_SQLBind(pADO, "p02", FEdDateTime);
  122. ITSDb_SQLOpen(pADO);
  123. DspHistory();
  124. }
  125. catch(EDatabaseError &E)
  126. {
  127. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  128. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
  129. throw Exception(String(E.ClassName()) + E.Message);
  130. }
  131. catch(Exception &e)
  132. {
  133. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  134. DBERRORMSG(Caption, String(e.ClassName()), e.Message, sQry);
  135. throw Exception(String(e.ClassName()) + e.Message);
  136. }
  137. }
  138. //---------------------------------------------------------------------------
  139. void __fastcall TVDSH0801::DspHistory()
  140. {
  141. TADOQuery *pADO = ADOQry;
  142. try
  143. {
  144. TcxGridChartSeries *pChart = NULL;
  145. CMM_ClearGridTableView(TvList);
  146. int nRow = 0;
  147. int nDataCnt = 0;
  148. try {
  149. TvList->BeginUpdate();
  150. nDataCnt = pADO->RecordCount;
  151. m_pGDC->RecordCount = nDataCnt;
  152. for( ; !pADO->Eof; pADO->Next(), nRow++)
  153. {
  154. m_pGDC->Values[nRow][Column00->Index] = pADO->FieldByName("VDS_DTCT_NMBR")->AsString;
  155. m_pGDC->Values[nRow][Column01->Index] = pADO->FieldByName("VDS_DTCT_ID")->AsString;
  156. m_pGDC->Values[nRow][Column02->Index] = pADO->FieldByName("ISTL_LANE")->AsString;
  157. m_pGDC->Values[nRow][Column03->Index] = pADO->FieldByName("DTCT_DIR_NM")->AsString;
  158. m_pGDC->Values[nRow][Column04->Index] = pADO->FieldByName("VDS_DTCT_NM")->AsString;
  159. String sDbDate = pADO->FieldByName("VEH_CLCT_DT")->AsString;
  160. m_pGDC->Values[nRow][Column05->Index] = APP_FormatStr(sDbDate, STR_DATETIME);
  161. m_pGDC->Values[nRow][Column06->Index] = pADO->FieldByName("SPED")->AsString;
  162. m_pGDC->Values[nRow][Column07->Index] = pADO->FieldByName("OCPY_TIME")->AsString;
  163. //차종 (1-소형, 2-중형, 3-대형)
  164. String sCarType = pADO->FieldByName("VEH_TYPE")->AsString;
  165. if (sCarType == "1")
  166. m_pGDC->Values[nRow][Column08->Index] = "소형";
  167. else if (sCarType == "2")
  168. m_pGDC->Values[nRow][Column08->Index] = "중형";
  169. else if (sCarType == "3")
  170. m_pGDC->Values[nRow][Column08->Index] = "대형";
  171. else
  172. m_pGDC->Values[nRow][Column08->Index] = "기타: " + sCarType;
  173. m_pGDC->Values[nRow][Column09->Index] = pADO->FieldByName("HDWY_VEH_TIME")->AsString;
  174. //m_pGDC->Values[nRow][Column10->Index] = pADO->FieldByName("DETECT_LANE")->AsString;
  175. //m_pGDC->Values[nRow][Column11->Index] = pADO->FieldByName("CLCT_SEQ")->AsString;
  176. m_pGDC->Values[nRow][Column12->Index] = pADO->FieldByName("DTCT_TYPE_NM")->AsString;
  177. }
  178. }
  179. __finally
  180. {
  181. if (pADO)
  182. {
  183. pADO->Close();
  184. }
  185. TvList->EndUpdate();
  186. //CxList->SetFocus();
  187. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + FrmLang->lblEA->Caption;//" 건";
  188. String sEnd = FrmLang->lblQrySel->Caption + " [" + LblRecords->Caption + "]";//"데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  189. Application->MessageBox(sEnd.c_str(),
  190. FrmLang->lblQryEnd->Caption.c_str(),//L"데이터 조회 완료",
  191. MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  192. }
  193. }
  194. catch(EDatabaseError &E)
  195. {
  196. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  197. DBERRORMSG(Caption, String(E.ClassName()), E.Message, pADO->SQL->Text);
  198. throw Exception(String(E.ClassName()) + E.Message);
  199. }
  200. catch(Exception &e)
  201. {
  202. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  203. DBERRORMSG(Caption, String(e.ClassName()), e.Message, pADO->SQL->Text);
  204. throw Exception(String(e.ClassName()) + e.Message);
  205. }
  206. }
  207. //---------------------------------------------------------------------------
  208. void __fastcall TVDSH0801::OnMessage(TMessage &Msg)
  209. {
  210. switch (Msg.Msg)
  211. {
  212. case WM_PARAM_DATABASE:
  213. if (WP_DB_SELECT_OK == Msg.WParam)
  214. {
  215. //ShowMessage("Select Ok");
  216. }
  217. break;
  218. }
  219. }
  220. //---------------------------------------------------------------------------
  221. void __fastcall TVDSH0801::BtnExlSaveClick(TObject *Sender)
  222. {
  223. TcxGrid *pGrid = CxList;
  224. TcxGridTableView *pView = TvList;
  225. String sTitle= Caption;//"VDS-검지기 과거수집이력";
  226. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  227. }
  228. //---------------------------------------------------------------------------
  229. void __fastcall TVDSH0801::FormClose(TObject *Sender, TCloseAction &Action)
  230. {
  231. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  232. CommClose();
  233. //VDSH0801 = NULL;
  234. }
  235. //---------------------------------------------------------------------------