VDSH0201F.cpp 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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 "VDSH0201F.h"
  11. //---------------------------------------------------------------------------
  12. #pragma package(smart_init)
  13. #pragma link "cxButtons"
  14. #pragma link "cxCalc"
  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 resource "*.dfm"
  40. TVDSH0201 *VDSH0201 = NULL;
  41. //---------------------------------------------------------------------------
  42. __fastcall TVDSH0201::TVDSH0201(TComponent* Owner, HWND hHandle, String sFrom, String sTo, String sIdList)
  43. : TForm(Owner)
  44. {
  45. LangTrans->Translate(this, ITSDb_GetConnection());
  46. ITSSkin_Load(this);
  47. CMM_LoadForm(g_sFormsDir, this);
  48. FParent = hHandle;
  49. FStDateTime = sFrom;
  50. FEdDateTime = sTo;
  51. FIdList = sIdList;
  52. }
  53. //---------------------------------------------------------------------------
  54. __fastcall TVDSH0201::~TVDSH0201(void)
  55. {
  56. }
  57. //--------------------------------------------------------------------------
  58. /*
  59. * form 초기화
  60. *
  61. * arguments
  62. *
  63. * return
  64. * void
  65. */
  66. void __fastcall TVDSH0201::FormInit()
  67. {
  68. ADOQry->Connection = ITSDb_GetConnection();
  69. m_pGDC = TvList->DataController;
  70. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<VDS-제어기 이벤트 이력 정보>";
  71. //TvList->ViewInfo->GroupByBoxViewInfo->Text = "그룹핑할 필드의 헤더를 이곳으로 드래그 하세요";
  72. LblSearch->Caption = FrmLang->lblQryCond->Caption + FStDateTime.SubString(1, 12) + " ~ " + FEdDateTime.SubString(1, 12);
  73. }
  74. //---------------------------------------------------------------------------
  75. /*
  76. * form을 보여줄때 호출되는 event 메서드이다.
  77. * arguments
  78. * Sender : event handler 객체
  79. * return
  80. * void
  81. */
  82. void __fastcall TVDSH0201::FormShow(TObject *Sender)
  83. {
  84. FormInit();
  85. Refresh();
  86. TmrShow->Enabled = true;
  87. }
  88. //---------------------------------------------------------------------------
  89. /*
  90. * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
  91. * Form과 DataModule class를 delete시킨다.
  92. * arguments
  93. *
  94. * return
  95. * void
  96. */
  97. void __fastcall TVDSH0201::CommClose()
  98. {
  99. CMM_SaveForm(g_sFormsDir, this);
  100. //VDSH0201 = NULL;
  101. }
  102. //---------------------------------------------------------------------------
  103. /*
  104. * 최초 1회 수행되는 타이머 이벤트
  105. * arguments
  106. * Sender : event handler 객체
  107. * return
  108. * void
  109. */
  110. void __fastcall TVDSH0201::TmrShowTimer(TObject *Sender)
  111. {
  112. TmrShow->Enabled = false;
  113. Application->ProcessMessages();
  114. SelHistory();
  115. }
  116. //---------------------------------------------------------------------------
  117. void __fastcall TVDSH0201::ChkExpandClick(TObject *Sender)
  118. {
  119. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  120. }
  121. //---------------------------------------------------------------------------
  122. /*
  123. * Refresh Data Event Function
  124. * arguments
  125. *
  126. * return
  127. * void
  128. */
  129. void __fastcall TVDSH0201::SelHistory()
  130. {
  131. TSqlCursor sqlCrs;
  132. String sQry;
  133. TADOQuery *pADO = ADOQry;
  134. sQry = "SELECT CTLR_MNGM_NMBR, OCRR_DT, CMNC_STTS_CD, PRNT_PWER_STTS_CD, CBOX_DOOR_STTS_CD, \r\n"
  135. " FAN_STTS_CD, HETR_STTS_CD, PRNT_PWER_VAL, SUB_CTLR_VAL \r\n"
  136. " FROM TB_VDS_CTLR_STTS_RAW \r\n"
  137. " WHERE OCRR_DT BETWEEN :p01 AND :p02 \r\n"
  138. " AND CTLR_MNGM_NMBR IN(" + FIdList + ") \r\n"
  139. " ORDER BY CTLR_MNGM_NMBR, 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 TVDSH0201::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("CTLR_MNGM_NMBR")->AsString;
  178. String sDbDate = pADO->FieldByName("OCRR_DT")->AsString;
  179. m_pGDC->Values[nRow][Column01->Index] = ITSUtil_FormatStr(sDbDate, STR_DATETIME);
  180. String sCmnc = pADO->FieldByName("CMNC_STTS_CD")->AsString;
  181. String sPwer = pADO->FieldByName("PRNT_PWER_STTS_CD")->AsString;
  182. String sDoor = pADO->FieldByName("CBOX_DOOR_STTS_CD")->AsString;
  183. String sFan = pADO->FieldByName("FAN_STTS_CD")->AsString;
  184. String sHetr = pADO->FieldByName("HETR_STTS_CD")->AsString;
  185. m_pGDC->Values[nRow][Column02->Index] = sCmnc;
  186. m_pGDC->Values[nRow][Column03->Index] = sPwer;
  187. m_pGDC->Values[nRow][Column04->Index] = sPwer;
  188. m_pGDC->Values[nRow][Column05->Index] = sFan;
  189. m_pGDC->Values[nRow][Column06->Index] = sHetr;
  190. m_pGDC->Values[nRow][Column07->Index] = pADO->FieldByName("PRNT_PWER_VAL")->AsString;
  191. m_pGDC->Values[nRow][Column08->Index] = pADO->FieldByName("SUB_CTLR_VAL")->AsString;
  192. }
  193. }
  194. __finally
  195. {
  196. if (pADO)
  197. {
  198. pADO->Close();
  199. }
  200. TvList->EndUpdate();
  201. //CxList->SetFocus();
  202. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + FrmLang->lblEA->Caption;//" 건";
  203. String sEnd = FrmLang->lblQrySel->Caption + " [" + LblRecords->Caption + "]";//"데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  204. Application->MessageBox(sEnd.c_str(),
  205. FrmLang->lblQryEnd->Caption.c_str(),//L"데이터 조회 완료",
  206. MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  207. }
  208. }
  209. catch(EDatabaseError &E)
  210. {
  211. throw Exception(String(E.ClassName()) + E.Message);
  212. }
  213. catch(...)
  214. {
  215. throw Exception(FrmLang->lblDbErr->Caption);//"알수없는 오류가 발생하였습니다.");
  216. }
  217. }
  218. //---------------------------------------------------------------------------
  219. void __fastcall TVDSH0201::OnMessage(TMessage &Msg)
  220. {
  221. switch (Msg.Msg)
  222. {
  223. case WM_PARAM_DATABASE:
  224. if (WP_DB_SELECT_OK == Msg.WParam)
  225. {
  226. //ShowMessage("Select Ok");
  227. }
  228. break;
  229. }
  230. }
  231. //---------------------------------------------------------------------------
  232. void __fastcall TVDSH0201::BtnExlSaveClick(TObject *Sender)
  233. {
  234. TcxGrid *pGrid = CxList;
  235. TcxGridTableView *pView = TvList;
  236. String sTitle= Caption;//"VDS-제어기 이벤트이력";
  237. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  238. }
  239. //---------------------------------------------------------------------------
  240. void __fastcall TVDSH0201::FormClose(TObject *Sender, TCloseAction &Action)
  241. {
  242. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  243. CommClose();
  244. //VDSH0201 = NULL;
  245. }
  246. //---------------------------------------------------------------------------