VDSH0201F.cpp 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. void __fastcall TVDSH0201::FormInit()
  59. {
  60. ADOQry->Connection = ITSDb_GetConnection();
  61. m_pGDC = TvList->DataController;
  62. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<VDS-제어기 이벤트 이력 정보>";
  63. //TvList->ViewInfo->GroupByBoxViewInfo->Text = "그룹핑할 필드의 헤더를 이곳으로 드래그 하세요";
  64. LblSearch->Caption = FrmLang->lblQryCond->Caption + FStDateTime.SubString(1, 12) + " ~ " + FEdDateTime.SubString(1, 12);
  65. }
  66. //---------------------------------------------------------------------------
  67. void __fastcall TVDSH0201::FormShow(TObject *Sender)
  68. {
  69. FormInit();
  70. Refresh();
  71. TmrShow->Enabled = true;
  72. }
  73. //---------------------------------------------------------------------------
  74. void __fastcall TVDSH0201::CommClose()
  75. {
  76. CMM_SaveForm(g_sFormsDir, this);
  77. //VDSH0201 = NULL;
  78. }
  79. //---------------------------------------------------------------------------
  80. void __fastcall TVDSH0201::TmrShowTimer(TObject *Sender)
  81. {
  82. TmrShow->Enabled = false;
  83. Application->ProcessMessages();
  84. SelHistory();
  85. }
  86. //---------------------------------------------------------------------------
  87. void __fastcall TVDSH0201::ChkExpandClick(TObject *Sender)
  88. {
  89. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  90. }
  91. //---------------------------------------------------------------------------
  92. void __fastcall TVDSH0201::SelHistory()
  93. {
  94. TSqlCursor sqlCrs;
  95. String sQry;
  96. TADOQuery *pADO = ADOQry;
  97. sQry = "SELECT VDS_CTLR_NMBR, CRTN_DT, CMNC_STTS_CD AS CONN_STTS_CD, CBOX_DOOR_STTS_CD, \r\n"
  98. " FAN_STTS_CD, HETR_STTS_CD, VIDEO_INPUT \r\n"
  99. " FROM TB_VDS_CTLR_STTS_HS \r\n"
  100. " WHERE CRTN_DT BETWEEN :p01 AND :p02 \r\n"
  101. " AND VDS_CTLR_NMBR IN(" + FIdList + ") \r\n"
  102. " ORDER BY VDS_CTLR_NMBR, CRTN_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 TVDSH0201::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_CTLR_NMBR")->AsString;
  141. String sDbDate = pADO->FieldByName("CRTN_DT")->AsString;
  142. m_pGDC->Values[nRow][Column01->Index] = ITSUtil_FormatStr(sDbDate, STR_DATETIME);
  143. String sCmnc = pADO->FieldByName("CONN_STTS_CD")->AsString;
  144. //String sPwer = pADO->FieldByName("PRNT_PWER_STTS_CD")->AsString;
  145. String sDoor = pADO->FieldByName("CBOX_DOOR_STTS_CD")->AsString;
  146. String sFan = pADO->FieldByName("FAN_STTS_CD")->AsString;
  147. String sHetr = pADO->FieldByName("HETR_STTS_CD")->AsString;
  148. m_pGDC->Values[nRow][Column02->Index] = sCmnc;
  149. //m_pGDC->Values[nRow][Column03->Index] = sPwer;
  150. m_pGDC->Values[nRow][Column04->Index] = sDoor;
  151. m_pGDC->Values[nRow][Column05->Index] = sFan;
  152. m_pGDC->Values[nRow][Column06->Index] = sHetr;
  153. //m_pGDC->Values[nRow][Column07->Index] = pADO->FieldByName("PRNT_PWER_VAL")->AsString;
  154. m_pGDC->Values[nRow][Column08->Index] = pADO->FieldByName("VIDEO_INPUT")->AsString == "0" ? "정상" : "입력없음";
  155. }
  156. }
  157. __finally
  158. {
  159. if (pADO)
  160. {
  161. pADO->Close();
  162. }
  163. TvList->EndUpdate();
  164. //CxList->SetFocus();
  165. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + FrmLang->lblEA->Caption;//" 건";
  166. String sEnd = FrmLang->lblQrySel->Caption + " [" + LblRecords->Caption + "]";//"데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  167. Application->MessageBox(sEnd.c_str(),
  168. FrmLang->lblQryEnd->Caption.c_str(),//L"데이터 조회 완료",
  169. MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  170. }
  171. }
  172. catch(EDatabaseError &E)
  173. {
  174. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  175. DBERRORMSG(Caption, String(E.ClassName()), E.Message, pADO->SQL->Text);
  176. throw Exception(String(E.ClassName()) + E.Message);
  177. }
  178. catch(Exception &e)
  179. {
  180. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  181. DBERRORMSG(Caption, String(e.ClassName()), e.Message, pADO->SQL->Text);
  182. throw Exception(String(e.ClassName()) + e.Message);
  183. }
  184. }
  185. //---------------------------------------------------------------------------
  186. void __fastcall TVDSH0201::OnMessage(TMessage &Msg)
  187. {
  188. switch (Msg.Msg)
  189. {
  190. case WM_PARAM_DATABASE:
  191. if (WP_DB_SELECT_OK == Msg.WParam)
  192. {
  193. //ShowMessage("Select Ok");
  194. }
  195. break;
  196. }
  197. }
  198. //---------------------------------------------------------------------------
  199. void __fastcall TVDSH0201::BtnExlSaveClick(TObject *Sender)
  200. {
  201. TcxGrid *pGrid = CxList;
  202. TcxGridTableView *pView = TvList;
  203. String sTitle= Caption;//"VDS-제어기 이벤트이력";
  204. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  205. }
  206. //---------------------------------------------------------------------------
  207. void __fastcall TVDSH0201::FormClose(TObject *Sender, TCloseAction &Action)
  208. {
  209. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  210. CommClose();
  211. //VDSH0201 = NULL;
  212. }
  213. //---------------------------------------------------------------------------