VDSH0401F.cpp 10.0 KB

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