VDSH0601F.cpp 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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. /*
  58. * form 초기화
  59. *
  60. * arguments
  61. *
  62. * return
  63. * void
  64. */
  65. void __fastcall TVDSH0601::FormInit()
  66. {
  67. ADOQry->Connection = ITSDb_GetConnection();
  68. m_pGDC = TvList->DataController;
  69. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<VDS-검지기 보정 이력 정보>";
  70. //TvList->ViewInfo->GroupByBoxViewInfo->Text = "그룹핑할 필드의 헤더를 이곳으로 드래그 하세요";
  71. LblSearch->Caption = FrmLang->lblQryCond->Caption + FStDateTime.SubString(1, 12) + " ~ " + FEdDateTime.SubString(1, 12);
  72. }
  73. //---------------------------------------------------------------------------
  74. /*
  75. * form을 보여줄때 호출되는 event 메서드이다.
  76. * arguments
  77. * Sender : event handler 객체
  78. * return
  79. * void
  80. */
  81. void __fastcall TVDSH0601::FormShow(TObject *Sender)
  82. {
  83. FormInit();
  84. Refresh();
  85. TmrShow->Enabled = true;
  86. }
  87. //---------------------------------------------------------------------------
  88. /*
  89. * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
  90. * Form과 DataModule class를 delete시킨다.
  91. * arguments
  92. *
  93. * return
  94. * void
  95. */
  96. void __fastcall TVDSH0601::CommClose()
  97. {
  98. CMM_SaveForm(g_sFormsDir, this);
  99. //VDSH0601 = NULL;
  100. }
  101. //---------------------------------------------------------------------------
  102. /*
  103. * 최초 1회 수행되는 타이머 이벤트
  104. * arguments
  105. * Sender : event handler 객체
  106. * return
  107. * void
  108. */
  109. void __fastcall TVDSH0601::TmrShowTimer(TObject *Sender)
  110. {
  111. TmrShow->Enabled = false;
  112. Application->ProcessMessages();
  113. SelHistory();
  114. }
  115. //---------------------------------------------------------------------------
  116. void __fastcall TVDSH0601::ChkExpandClick(TObject *Sender)
  117. {
  118. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  119. }
  120. //---------------------------------------------------------------------------
  121. /*
  122. * Refresh Data Event Function
  123. * arguments
  124. *
  125. * return
  126. * void
  127. */
  128. void __fastcall TVDSH0601::SelHistory()
  129. {
  130. TSqlCursor sqlCrs;
  131. String sQry;
  132. TADOQuery *pADO = ADOQry;
  133. sQry = "SELECT A.DTCT_NMBR, B.ISTL_LANE, A.OCRR_DT, A.SYST_KIND_DVSN, \r\n"
  134. " A.TFVL, A.SPED, A.AVRG_OCPY_RATE, A.HDWY, A.AVRG_LNGT \r\n"
  135. " FROM TB_VDS_DTCT_ADJS A, TB_VDS_DTCT_MSTR B \r\n"
  136. " WHERE A.OCRR_DT BETWEEN :p01 AND :p02 \r\n"
  137. " AND B.DTCT_NMBR IN(" + FIdList + ") \r\n"
  138. " AND A.DTCT_NMBR = B.DTCT_NMBR \r\n"
  139. " ORDER BY A.DTCT_NMBR, A.OCRR_DT \r\n";
  140. try
  141. {
  142. ITSDb_SQLText(pADO, sQry);
  143. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  144. ITSDb_SQLBind(pADO, "p02", FEdDateTime);
  145. ITSDb_SQLOpen(pADO);
  146. DspHistory();
  147. }
  148. catch(EDatabaseError &E)
  149. {
  150. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  151. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
  152. throw Exception(String(E.ClassName()) + E.Message);
  153. }
  154. catch(Exception &exception)
  155. {
  156. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  157. DBERRORMSG(Caption, String(exception.ClassName()), exception.Message, sQry);
  158. throw Exception(String(exception.ClassName()) + exception.Message);
  159. }
  160. }
  161. //---------------------------------------------------------------------------
  162. void __fastcall TVDSH0601::DspHistory()
  163. {
  164. TADOQuery *pADO = ADOQry;
  165. try
  166. {
  167. TcxGridChartSeries *pChart = NULL;
  168. CMM_ClearGridTableView(TvList);
  169. int nRow = 0;
  170. int nDataCnt = 0;
  171. try {
  172. TvList->BeginUpdate();
  173. nDataCnt = pADO->RecordCount;
  174. m_pGDC->RecordCount = nDataCnt;
  175. for( ; !pADO->Eof; pADO->Next(), nRow++)
  176. {
  177. m_pGDC->Values[nRow][Column00->Index] = pADO->FieldByName("DTCT_NMBR")->AsString;
  178. m_pGDC->Values[nRow][Column01->Index] = pADO->FieldByName("ISTL_LANE")->AsString;
  179. String sDbDate = pADO->FieldByName("OCRR_DT")->AsString;
  180. m_pGDC->Values[nRow][Column02->Index] = ITSUtil_FormatStr(sDbDate, STR_DATETIME);
  181. m_pGDC->Values[nRow][Column03->Index] = pADO->FieldByName("SYST_KIND_DVSN")->AsString;
  182. m_pGDC->Values[nRow][Column04->Index] = FormatFloat("##,##0", pADO->FieldByName("TFVL")->AsInteger);
  183. m_pGDC->Values[nRow][Column05->Index] = FormatFloat("##,##0", pADO->FieldByName("SPED")->AsInteger);
  184. m_pGDC->Values[nRow][Column06->Index] = FormatFloat("##0.#0", pADO->FieldByName("AVRG_OCPY_RATE")->AsFloat);
  185. m_pGDC->Values[nRow][Column07->Index] = FormatFloat("##,##0", pADO->FieldByName("HDWY")->AsInteger);
  186. m_pGDC->Values[nRow][Column08->Index] = FormatFloat("##0.0", pADO->FieldByName("AVRG_LNGT")->AsFloat);
  187. }
  188. }
  189. __finally
  190. {
  191. if (pADO)
  192. {
  193. pADO->Close();
  194. }
  195. TvList->EndUpdate();
  196. //CxList->SetFocus();
  197. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + FrmLang->lblEA->Caption;//" 건";
  198. String sEnd = FrmLang->lblQrySel->Caption + " [" + LblRecords->Caption + "]";//"데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  199. Application->MessageBox(sEnd.c_str(),
  200. FrmLang->lblQryEnd->Caption.c_str(),//L"데이터 조회 완료",
  201. MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  202. }
  203. }
  204. catch(EDatabaseError &E)
  205. {
  206. throw Exception(String(E.ClassName()) + E.Message);
  207. }
  208. catch(...)
  209. {
  210. throw Exception(FrmLang->lblDbErr->Caption);//"알수없는 오류가 발생하였습니다.");
  211. }
  212. }
  213. //---------------------------------------------------------------------------
  214. void __fastcall TVDSH0601::OnMessage(TMessage &Msg)
  215. {
  216. switch (Msg.Msg)
  217. {
  218. case WM_PARAM_DATABASE:
  219. if (WP_DB_SELECT_OK == Msg.WParam)
  220. {
  221. //ShowMessage("Select Ok");
  222. }
  223. break;
  224. }
  225. }
  226. //---------------------------------------------------------------------------
  227. void __fastcall TVDSH0601::BtnExlSaveClick(TObject *Sender)
  228. {
  229. TcxGrid *pGrid = CxList;
  230. TcxGridTableView *pView = TvList;
  231. String sTitle= Caption;//"VDS-검지기 보정이력";
  232. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  233. }
  234. //---------------------------------------------------------------------------
  235. void __fastcall TVDSH0601::FormClose(TObject *Sender, TCloseAction &Action)
  236. {
  237. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  238. CommClose();
  239. //VDSH0601 = NULL;
  240. }
  241. //---------------------------------------------------------------------------