VDSH0201F.cpp 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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 "VDSH0201F.h"
  12. //---------------------------------------------------------------------------
  13. #pragma package(smart_init)
  14. #pragma link "cxButtons"
  15. #pragma link "cxCalc"
  16. #pragma link "cxCheckBox"
  17. #pragma link "cxClasses"
  18. #pragma link "cxContainer"
  19. #pragma link "cxControls"
  20. #pragma link "cxCustomData"
  21. #pragma link "cxData"
  22. #pragma link "cxDataStorage"
  23. #pragma link "cxEdit"
  24. #pragma link "cxFilter"
  25. #pragma link "cxGraphics"
  26. #pragma link "cxGrid"
  27. #pragma link "cxGridCustomTableView"
  28. #pragma link "cxGridCustomView"
  29. #pragma link "cxGridLevel"
  30. #pragma link "cxGridTableView"
  31. #pragma link "cxLabel"
  32. #pragma link "cxLookAndFeelPainters"
  33. #pragma link "cxLookAndFeels"
  34. #pragma link "cxStyles"
  35. #pragma link "cxTextEdit"
  36. #pragma link "dxSkinBlack"
  37. #pragma link "dxSkinBlue"
  38. #pragma link "dxSkinsCore"
  39. #pragma link "dxSkinscxPCPainter"
  40. #pragma link "dxSkinMcSkin"
  41. #pragma link "cxSpinEdit"
  42. #pragma resource "*.dfm"
  43. TVDSH0201 *VDSH0201 = NULL;
  44. //---------------------------------------------------------------------------
  45. __fastcall TVDSH0201::TVDSH0201(TComponent* Owner, HWND hHandle, String sFrom, String sTo, String sIdList)
  46. : TForm(Owner)
  47. {
  48. LangTrans->Translate(this, ITSDb_GetConnection());
  49. ITSSkin_Load(this);
  50. CMM_LoadForm(g_sFormsDir, this);
  51. FParent = hHandle;
  52. FStDateTime = sFrom;
  53. FEdDateTime = sTo;
  54. FIdList = sIdList;
  55. }
  56. //---------------------------------------------------------------------------
  57. __fastcall TVDSH0201::~TVDSH0201(void)
  58. {
  59. }
  60. //--------------------------------------------------------------------------
  61. void __fastcall TVDSH0201::FormInit()
  62. {
  63. ADOQry->Connection = ITSDb_GetConnection();
  64. m_pGDC = TvList->DataController;
  65. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<VDS-제어기 이벤트 이력 정보>";
  66. //TvList->ViewInfo->GroupByBoxViewInfo->Text = "그룹핑할 필드의 헤더를 이곳으로 드래그 하세요";
  67. LblSearch->Caption = FrmLang->lblQryCond->Caption + FStDateTime.SubString(1, 12) + " ~ " + FEdDateTime.SubString(1, 12);
  68. }
  69. //---------------------------------------------------------------------------
  70. void __fastcall TVDSH0201::FormShow(TObject *Sender)
  71. {
  72. FormInit();
  73. Refresh();
  74. TmrShow->Enabled = true;
  75. }
  76. //---------------------------------------------------------------------------
  77. void __fastcall TVDSH0201::CommClose()
  78. {
  79. CMM_SaveForm(g_sFormsDir, this);
  80. //VDSH0201 = NULL;
  81. }
  82. //---------------------------------------------------------------------------
  83. void __fastcall TVDSH0201::TmrShowTimer(TObject *Sender)
  84. {
  85. TmrShow->Enabled = false;
  86. Application->ProcessMessages();
  87. SelHistory();
  88. }
  89. //---------------------------------------------------------------------------
  90. void __fastcall TVDSH0201::ChkExpandClick(TObject *Sender)
  91. {
  92. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  93. }
  94. //---------------------------------------------------------------------------
  95. void __fastcall TVDSH0201::SelHistory()
  96. {
  97. TSqlCursor sqlCrs;
  98. String sQry;
  99. TADOQuery *pADO = ADOQry;
  100. sQry = "SELECT VDS_CTLR_NMBR, CRTN_DT, CMNC_STTS_CD AS CONN_STTS_CD, CBOX_DOOR_STTS_CD, \r\n"
  101. " FAN_STTS_CD, HETR_STTS_CD, VIDEO_INPUT, CBOX_TMPR \r\n"
  102. " FROM TB_VDS_CTLR_STTS_HS \r\n"
  103. " WHERE CRTN_DT BETWEEN :p01 AND :p02 \r\n"
  104. " AND VDS_CTLR_NMBR IN(" + FIdList + ") \r\n"
  105. " ORDER BY VDS_CTLR_NMBR, CRTN_DT \r\n";
  106. try
  107. {
  108. ITSDb_SQLText(pADO, sQry);
  109. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  110. ITSDb_SQLBind(pADO, "p02", FEdDateTime);
  111. ITSDb_SQLOpen(pADO);
  112. DspHistory();
  113. }
  114. catch(EDatabaseError &E)
  115. {
  116. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  117. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
  118. throw Exception(String(E.ClassName()) + E.Message);
  119. }
  120. catch(Exception &e)
  121. {
  122. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  123. DBERRORMSG(Caption, String(e.ClassName()), e.Message, sQry);
  124. throw Exception(String(e.ClassName()) + e.Message);
  125. }
  126. }
  127. //---------------------------------------------------------------------------
  128. void __fastcall TVDSH0201::DspHistory()
  129. {
  130. TADOQuery *pADO = ADOQry;
  131. try
  132. {
  133. TcxGridChartSeries *pChart = NULL;
  134. CMM_ClearGridTableView(TvList);
  135. int nRow = 0;
  136. int nDataCnt = 0;
  137. try {
  138. TvList->BeginUpdate();
  139. nDataCnt = pADO->RecordCount;
  140. m_pGDC->RecordCount = nDataCnt;
  141. for( ; !pADO->Eof; pADO->Next(), nRow++)
  142. {
  143. m_pGDC->Values[nRow][Column00->Index] = pADO->FieldByName("VDS_CTLR_NMBR")->AsString;
  144. String sDbDate = pADO->FieldByName("CRTN_DT")->AsString;
  145. m_pGDC->Values[nRow][Column01->Index] = APP_FormatStr(sDbDate, STR_DATETIME);
  146. String sCmnc = pADO->FieldByName("CONN_STTS_CD")->AsString;
  147. //String sPwer = pADO->FieldByName("PRNT_PWER_STTS_CD")->AsString;
  148. String sDoor = pADO->FieldByName("CBOX_DOOR_STTS_CD")->AsString;
  149. String sFan = pADO->FieldByName("FAN_STTS_CD")->AsString;
  150. String sHetr = pADO->FieldByName("HETR_STTS_CD")->AsString;
  151. m_pGDC->Values[nRow][Column02->Index] = sCmnc;
  152. //m_pGDC->Values[nRow][Column03->Index] = sPwer;
  153. m_pGDC->Values[nRow][Column04->Index] = sDoor;
  154. m_pGDC->Values[nRow][Column05->Index] = sFan;
  155. m_pGDC->Values[nRow][Column06->Index] = sHetr;
  156. m_pGDC->Values[nRow][Column10->Index] = pADO->FieldByName("CBOX_TMPR")->AsInteger;
  157. //m_pGDC->Values[nRow][Column07->Index] = pADO->FieldByName("PRNT_PWER_VAL")->AsString;
  158. m_pGDC->Values[nRow][Column08->Index] = pADO->FieldByName("VIDEO_INPUT")->AsString == "0" ? "정상" : "입력없음";
  159. }
  160. }
  161. __finally
  162. {
  163. if (pADO)
  164. {
  165. pADO->Close();
  166. }
  167. TvList->EndUpdate();
  168. //CxList->SetFocus();
  169. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + FrmLang->lblEA->Caption;//" 건";
  170. String sEnd = FrmLang->lblQrySel->Caption + " [" + LblRecords->Caption + "]";//"데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  171. Application->MessageBox(sEnd.c_str(),
  172. FrmLang->lblQryEnd->Caption.c_str(),//L"데이터 조회 완료",
  173. MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  174. }
  175. }
  176. catch(EDatabaseError &E)
  177. {
  178. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  179. DBERRORMSG(Caption, String(E.ClassName()), E.Message, pADO->SQL->Text);
  180. throw Exception(String(E.ClassName()) + E.Message);
  181. }
  182. catch(Exception &e)
  183. {
  184. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  185. DBERRORMSG(Caption, String(e.ClassName()), e.Message, pADO->SQL->Text);
  186. throw Exception(String(e.ClassName()) + e.Message);
  187. }
  188. }
  189. //---------------------------------------------------------------------------
  190. void __fastcall TVDSH0201::OnMessage(TMessage &Msg)
  191. {
  192. switch (Msg.Msg)
  193. {
  194. case WM_PARAM_DATABASE:
  195. if (WP_DB_SELECT_OK == Msg.WParam)
  196. {
  197. //ShowMessage("Select Ok");
  198. }
  199. break;
  200. }
  201. }
  202. //---------------------------------------------------------------------------
  203. void __fastcall TVDSH0201::BtnExlSaveClick(TObject *Sender)
  204. {
  205. TcxGrid *pGrid = CxList;
  206. TcxGridTableView *pView = TvList;
  207. String sTitle= Caption;//"VDS-제어기 이벤트이력";
  208. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  209. }
  210. //---------------------------------------------------------------------------
  211. void __fastcall TVDSH0201::FormClose(TObject *Sender, TCloseAction &Action)
  212. {
  213. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  214. CommClose();
  215. //VDSH0201 = NULL;
  216. }
  217. //---------------------------------------------------------------------------