VDSH0401F.cpp 9.9 KB

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