AVIH0801F.cpp 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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. #pragma hdrstop
  9. #include "AVIH0801F.h"
  10. //---------------------------------------------------------------------------
  11. #pragma package(smart_init)
  12. #pragma link "cxButtons"
  13. #pragma link "cxCheckBox"
  14. #pragma link "cxClasses"
  15. #pragma link "cxContainer"
  16. #pragma link "cxControls"
  17. #pragma link "cxCustomData"
  18. #pragma link "cxData"
  19. #pragma link "cxDataStorage"
  20. #pragma link "cxEdit"
  21. #pragma link "cxFilter"
  22. #pragma link "cxGraphics"
  23. #pragma link "cxGrid"
  24. #pragma link "cxGridCustomTableView"
  25. #pragma link "cxGridCustomView"
  26. #pragma link "cxGridLevel"
  27. #pragma link "cxGridTableView"
  28. #pragma link "cxLabel"
  29. #pragma link "cxLookAndFeelPainters"
  30. #pragma link "cxLookAndFeels"
  31. #pragma link "cxStyles"
  32. #pragma link "dxSkinBlack"
  33. #pragma link "dxSkinBlue"
  34. #pragma link "dxSkinsCore"
  35. #pragma link "dxSkinscxPCPainter"
  36. #pragma resource "*.dfm"
  37. TAVIH0801 *AVIH0801 = NULL;
  38. //---------------------------------------------------------------------------
  39. __fastcall TAVIH0801::TAVIH0801(TComponent* Owner, HWND hHandle, String sFrom, String sTo, String sIdList)
  40. : TForm(Owner)
  41. {
  42. ITSSkin_Load(this);
  43. CMM_LoadForm(g_sFormsDir, this);
  44. FParent = hHandle;
  45. FStDateTime = sFrom;
  46. FEdDateTime = sTo;
  47. FIdList = sIdList;
  48. Caption = "AVI-지점 수집 이력";
  49. }
  50. //---------------------------------------------------------------------------
  51. __fastcall TAVIH0801::~TAVIH0801(void)
  52. {
  53. }
  54. //--------------------------------------------------------------------------
  55. /*
  56. * form 초기화
  57. *
  58. * arguments
  59. *
  60. * return
  61. * void
  62. */
  63. void __fastcall TAVIH0801::FormInit()
  64. {
  65. ADOQry->Connection = ITSDb_GetConnection();
  66. m_pGDC = TvList->DataController;
  67. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<AVI-지점 수집 이력>";
  68. //TvList->ViewInfo->GroupByBoxViewInfo->Text = "그룹핑할 필드의 헤더를 이곳으로 드래그 하세요";
  69. LblSearch->Caption = "검색조건: " + FStDateTime.SubString(1, 12) + " ~ " + FEdDateTime.SubString(1, 12);
  70. }
  71. //---------------------------------------------------------------------------
  72. /*
  73. * form을 보여줄때 호출되는 event 메서드이다.
  74. * arguments
  75. * Sender : event handler 객체
  76. * return
  77. * void
  78. */
  79. void __fastcall TAVIH0801::FormShow(TObject *Sender)
  80. {
  81. FormInit();
  82. Refresh();
  83. TmrShow->Enabled = true;
  84. }
  85. //---------------------------------------------------------------------------
  86. /*
  87. * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
  88. * Form과 DataModule class를 delete시킨다.
  89. * arguments
  90. *
  91. * return
  92. * void
  93. */
  94. void __fastcall TAVIH0801::CommClose()
  95. {
  96. CMM_SaveForm(g_sFormsDir, this);
  97. //AVIH0801 = NULL;
  98. }
  99. //---------------------------------------------------------------------------
  100. /*
  101. * 최초 1회 수행되는 타이머 이벤트
  102. * arguments
  103. * Sender : event handler 객체
  104. * return
  105. * void
  106. */
  107. void __fastcall TAVIH0801::TmrShowTimer(TObject *Sender)
  108. {
  109. TmrShow->Enabled = false;
  110. Application->ProcessMessages();
  111. SelHistory();
  112. }
  113. //---------------------------------------------------------------------------
  114. void __fastcall TAVIH0801::ChkExpandClick(TObject *Sender)
  115. {
  116. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  117. }
  118. //---------------------------------------------------------------------------
  119. /*
  120. * Refresh Data Event Function
  121. * arguments
  122. *
  123. * return
  124. * void
  125. */
  126. void __fastcall TAVIH0801::SelHistory()
  127. {
  128. TSqlCursor sqlCrs;
  129. String sQry;
  130. TADOQuery *pADO = ADOQry;
  131. sQry = "SELECT DT.AVI_CTLR_MNGM_NMBR, AVI.AVI_LCTN_NM, DT.AVI_DTCT_NMBR, DT.ISTL_LANE, \r\n"
  132. " R.OCRR_DT, R.TFVL, R.AVRG_OCPY_RATE, R.SPED \r\n"
  133. " FROM TB_AVI_DTCT_RAW_CLCT R, TB_AVI_DTCT_MSTR DT, TB_AVI_CTLR AVI \r\n"
  134. " WHERE R.OCRR_DT BETWEEN :p01 AND :p02 \r\n"
  135. " AND AVI.AVI_CTLR_MNGM_NMBR = DT.AVI_CTLR_MNGM_NMBR \r\n"
  136. " AND DT.AVI_DTCT_NMBR IN(" + FIdList + ") \r\n"
  137. " AND DT.AVI_DTCT_NMBR = R.AVI_DTCT_NMBR \r\n"
  138. " ORDER BY DT.AVI_CTLR_MNGM_NMBR ASC, R.OCRR_DT, DT.ISTL_LANE \r\n";
  139. try
  140. {
  141. ITSDb_SQLText(pADO, sQry);
  142. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  143. ITSDb_SQLBind(pADO, "p02", FEdDateTime);
  144. ITSDb_SQLOpen(pADO);
  145. DspHistory();
  146. }
  147. catch(EDatabaseError &E)
  148. {
  149. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  150. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
  151. throw Exception(String(E.ClassName()) + E.Message);
  152. }
  153. catch(Exception &exception)
  154. {
  155. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  156. DBERRORMSG(Caption, String(exception.ClassName()), exception.Message, sQry);
  157. throw Exception(String(exception.ClassName()) + exception.Message);
  158. }
  159. }
  160. //---------------------------------------------------------------------------
  161. void __fastcall TAVIH0801::DspHistory()
  162. {
  163. TADOQuery *pADO = ADOQry;
  164. try
  165. {
  166. CMM_ClearGridTableView(TvList);
  167. int nRow = 0;
  168. int nDataCnt = 0;
  169. try {
  170. TvList->BeginUpdate();
  171. nDataCnt = pADO->RecordCount;
  172. m_pGDC->RecordCount = nDataCnt;
  173. for( ; !pADO->Eof; pADO->Next(), nRow++)
  174. {
  175. m_pGDC->Values[nRow][Column00->Index] = pADO->FieldByName("AVI_CTLR_MNGM_NMBR")->AsString;
  176. m_pGDC->Values[nRow][Column09->Index] = pADO->FieldByName("AVI_LCTN_NM")->AsString;
  177. m_pGDC->Values[nRow][Column01->Index] = pADO->FieldByName("AVI_DTCT_NMBR")->AsString;
  178. m_pGDC->Values[nRow][Column02->Index] = pADO->FieldByName("ISTL_LANE")->AsString;
  179. String sDbDate = pADO->FieldByName("OCRR_DT")->AsString;
  180. m_pGDC->Values[nRow][Column03->Index] = ITSUtil_FormatStr(sDbDate, STR_DATETIME);
  181. m_pGDC->Values[nRow][Column04->Index] = pADO->FieldByName("TFVL")->AsString;
  182. //m_pGDC->Values[nRow][Column05->Index] = pADO->FieldByName("AVRG_OCPY_RATE")->AsString;
  183. m_pGDC->Values[nRow][Column06->Index] = pADO->FieldByName("SPED")->AsString;
  184. }
  185. }
  186. __finally
  187. {
  188. if (pADO)
  189. {
  190. pADO->Close();
  191. }
  192. TvList->EndUpdate();
  193. //CxList->SetFocus();
  194. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + " 건";
  195. String sEnd = "데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  196. Application->MessageBox(sEnd.c_str(), L"데이터 조회 완료", MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  197. }
  198. }
  199. catch(EDatabaseError &E)
  200. {
  201. throw Exception(String(E.ClassName()) + E.Message);
  202. }
  203. catch(...)
  204. {
  205. throw Exception(FrmLang->lblDbErr->Caption);//"알수없는 오류가 발생하였습니다.");
  206. }
  207. }
  208. //---------------------------------------------------------------------------
  209. void __fastcall TAVIH0801::OnMessage(TMessage &Msg)
  210. {
  211. switch (Msg.Msg)
  212. {
  213. case WM_PARAM_DATABASE:
  214. if (WP_DB_SELECT_OK == Msg.WParam)
  215. {
  216. //ShowMessage("Select Ok");
  217. }
  218. break;
  219. }
  220. }
  221. //---------------------------------------------------------------------------
  222. void __fastcall TAVIH0801::BtnExlSaveClick(TObject *Sender)
  223. {
  224. TcxGrid *pGrid = CxList;
  225. TcxGridTableView *pView = TvList;
  226. String sTitle = "AVI-지점 수집 이력";
  227. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  228. }
  229. //---------------------------------------------------------------------------
  230. void __fastcall TAVIH0801::FormClose(TObject *Sender, TCloseAction &Action)
  231. {
  232. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  233. CommClose();
  234. //AVIH0801 = NULL;
  235. }
  236. //---------------------------------------------------------------------------
  237. void __fastcall TAVIH0801::FormDestroy(TObject *Sender)
  238. {
  239. CommClose();
  240. }
  241. //---------------------------------------------------------------------------