VDSH0601F.cpp 8.3 KB

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