VDSH0801F.cpp 9.8 KB

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