CCAMH101F.cpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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 "CCAMH101F.h"
  12. //---------------------------------------------------------------------------
  13. #pragma package(smart_init)
  14. #pragma link "cxButtons"
  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 link "dxSkinMcSkin"
  40. #pragma resource "*.dfm"
  41. TCCAMH101 *CCAMH101 = NULL;
  42. //---------------------------------------------------------------------------
  43. __fastcall TCCAMH101::TCCAMH101(TComponent* Owner, HWND hHandle, String sFrom, String sTo, String sIdList)
  44. : TForm(Owner)
  45. {
  46. LangTrans->Translate(this, ITSDb_GetConnection());
  47. ITSSkin_Load(this);
  48. CMM_LoadForm(g_sFormsDir, this);
  49. FParent = hHandle;
  50. FStDateTime = sFrom;
  51. FEdDateTime = sTo;
  52. FIdList = sIdList;
  53. //Caption = "CCAM-제어기 상태 이력";
  54. }
  55. //---------------------------------------------------------------------------
  56. __fastcall TCCAMH101::~TCCAMH101(void)
  57. {
  58. }
  59. //--------------------------------------------------------------------------
  60. void __fastcall TCCAMH101::FormInit()
  61. {
  62. ADOQry->Connection = ITSDb_GetConnection();
  63. m_pGDC = TvList->DataController;
  64. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<CCAM-제어기 상태 이력 정보>";
  65. //TvList->ViewInfo->GroupByBoxViewInfo->Text = "그룹핑할 필드의 헤더를 이곳으로 드래그 하세요";
  66. LblSearch->Caption = FrmLang->lblQryCond->Caption + FStDateTime.SubString(1, 12) + " ~ " + FEdDateTime.SubString(1, 12);
  67. }
  68. //---------------------------------------------------------------------------
  69. void __fastcall TCCAMH101::FormShow(TObject *Sender)
  70. {
  71. FormInit();
  72. Refresh();
  73. TmrShow->Enabled = true;
  74. }
  75. //---------------------------------------------------------------------------
  76. void __fastcall TCCAMH101::CommClose()
  77. {
  78. CMM_SaveForm(g_sFormsDir, this);
  79. //CCAMH101 = NULL;
  80. }
  81. //---------------------------------------------------------------------------
  82. void __fastcall TCCAMH101::TmrShowTimer(TObject *Sender)
  83. {
  84. TmrShow->Enabled = false;
  85. Application->ProcessMessages();
  86. SelHistory();
  87. }
  88. //---------------------------------------------------------------------------
  89. void __fastcall TCCAMH101::ChkExpandClick(TObject *Sender)
  90. {
  91. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  92. }
  93. //---------------------------------------------------------------------------
  94. void __fastcall TCCAMH101::SelHistory()
  95. {
  96. TSqlCursor sqlCrs;
  97. String sQry;
  98. TADOQuery *pADO = ADOQry;
  99. #if 0
  100. sQry = "SELECT A.CCAM_CTLR_NMBR, B.CCAM_CTLR_ID, B.CCAM_CTLR_ID, B.CCAM_NM, A.VIDEO_INPUT, A.CBOX_TMPR, \r\n"
  101. " NVL(TO_CHAR(TO_DATE(A.CRTN_DT, 'YYYYMMDDHH24MISS'), 'YYYY-MM-DD HH24:MI:SS'), '정보없음') AS CRTN_DT, \r\n"
  102. " (SELECT CMMN_CD_KOR_NM FROM TB_CMMN_CD WHERE CMMN_CD = A.CMNC_STTS_CD AND CMMN_CLSF_CD = 'CMS') AS CONN_STTS_CD, \r\n"
  103. " (SELECT CMMN_CD_KOR_NM FROM TB_CMMN_CD WHERE CMMN_CD = A.CBOX_DOOR_STTS_CD AND CMMN_CLSF_CD = 'CDS') AS CBOX_DOOR_STTS_CD, \r\n"
  104. " (SELECT CMMN_CD_KOR_NM FROM TB_CMMN_CD WHERE CMMN_CD = A.FAN_STTS_CD AND CMMN_CLSF_CD = 'PAS') AS FAN_STTS_CD, \r\n"
  105. " (SELECT CMMN_CD_KOR_NM FROM TB_CMMN_CD WHERE CMMN_CD = A.HETR_STTS_CD AND CMMN_CLSF_CD = 'HTS') AS HETR_STTS_CD, \r\n"
  106. " (SELECT CMMN_CD_KOR_NM FROM TB_CMMN_CD WHERE CMMN_CD = A.VIDEO_INPUT AND CMMN_CLSF_CD = 'VDI') AS VIDEO_INPUT_CD \r\n"
  107. " FROM TB_CCAM_CTLR_STTS_HS A, TB_CCAM_CTLR B \r\n"
  108. " WHERE A.CRTN_DT BETWEEN :p01 AND :p02 \r\n"
  109. " AND B.CCAM_CTLR_NMBR IN(" + FIdList + ") \r\n"
  110. " AND A.CCAM_CTLR_NMBR = B.CCAM_CTLR_NMBR \r\n"
  111. " ORDER BY A.CCAM_CTLR_NMBR, A.CRTN_DT \r\n";
  112. #else
  113. sQry = "SELECT A.*, B.CCAM_CTLR_ID, B.CCAM_NM \r\n"
  114. " FROM TB_CCAM_CTLR_STTS_HS A, TB_CCAM_CTLR B \r\n"
  115. " WHERE A.CRTN_DT BETWEEN :p01 AND :p02 \r\n"
  116. " AND B.CCAM_CTLR_NMBR IN(" + FIdList + ") \r\n"
  117. " AND A.CCAM_CTLR_NMBR = B.CCAM_CTLR_NMBR \r\n"
  118. " ORDER BY A.CCAM_CTLR_NMBR, A.CRTN_DT \r\n";
  119. #endif
  120. try
  121. {
  122. ITSDb_SQLText(pADO, sQry);
  123. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  124. ITSDb_SQLBind(pADO, "p02", FEdDateTime);
  125. ITSDb_SQLOpen(pADO);
  126. DspHistory();
  127. }
  128. catch(EDatabaseError &E)
  129. {
  130. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  131. DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
  132. throw Exception(String(E.ClassName()) + E.Message);
  133. }
  134. catch(Exception &e)
  135. {
  136. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  137. DBERRORMSG(Caption, String(e.ClassName()), e.Message, sQry);
  138. throw Exception(String(e.ClassName()) + e.Message);
  139. }
  140. }
  141. //---------------------------------------------------------------------------
  142. void __fastcall TCCAMH101::DspHistory()
  143. {
  144. TADOQuery *pADO = ADOQry;
  145. try
  146. {
  147. TcxGridChartSeries *pChart = NULL;
  148. CMM_ClearGridTableView(TvList);
  149. int nRow = 0;
  150. int nDataCnt = 0;
  151. try {
  152. TvList->BeginUpdate();
  153. nDataCnt = pADO->RecordCount;
  154. m_pGDC->RecordCount = nDataCnt;
  155. for( ; !pADO->Eof; pADO->Next(), nRow++)
  156. {
  157. m_pGDC->Values[nRow][Column00->Index] = pADO->FieldByName("CCAM_CTLR_NMBR")->AsString;
  158. m_pGDC->Values[nRow][Column11->Index] = pADO->FieldByName("CCAM_CTLR_ID")->AsString;
  159. String sDbDate = pADO->FieldByName("CRTN_DT")->AsString;
  160. m_pGDC->Values[nRow][Column01->Index] = APP_FormatStr(sDbDate, STR_DATETIME);
  161. m_pGDC->Values[nRow][Column09->Index] = pADO->FieldByName("CCAM_NM")->AsString;
  162. String CMNC_STTS_CD = pADO->FieldByName("CMNC_STTS_CD")->AsString;
  163. if (CMNC_STTS_CD == "CMS0") m_pGDC->Values[nRow][Column02->Index] = FrmLang->lblComm0->Caption;
  164. else
  165. if (CMNC_STTS_CD == "CMS1") m_pGDC->Values[nRow][Column02->Index] = FrmLang->lblComm1->Caption;
  166. else m_pGDC->Values[nRow][Column02->Index] = FrmLang->lblUnknown->Caption;
  167. #if 0
  168. String sCmnc = pADO->FieldByName("CONN_STTS_CD")->AsString;
  169. //String sPwer = pADO->FieldByName("PRNT_PWER_STTS_CD")->AsString;
  170. String sDoor = pADO->FieldByName("CBOX_DOOR_STTS_CD")->AsString;
  171. String sFan = pADO->FieldByName("FAN_STTS_CD")->AsString;
  172. String sHetr = pADO->FieldByName("HETR_STTS_CD")->AsString;
  173. String sTmpr = pADO->FieldByName("CBOX_TMPR")->AsString;
  174. m_pGDC->Values[nRow][Column09->Index] = pADO->FieldByName("CCAM_NM")->AsString;
  175. m_pGDC->Values[nRow][Column02->Index] = sCmnc;
  176. //m_pGDC->Values[nRow][Column03->Index] = sPwer;
  177. m_pGDC->Values[nRow][Column04->Index] = sDoor;
  178. m_pGDC->Values[nRow][Column05->Index] = sFan;
  179. m_pGDC->Values[nRow][Column06->Index] = sHetr;
  180. m_pGDC->Values[nRow][Column10->Index] = sTmpr;
  181. m_pGDC->Values[nRow][Column07->Index] = pADO->FieldByName("VIDEO_INPUT_CD")->AsString;
  182. //m_pGDC->Values[nRow][Column08->Index] = pADO->FieldByName("VIDEO_INPUT")->AsString;
  183. #endif
  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) + FrmLang->lblEA->Caption;//" 건";
  195. String sEnd = FrmLang->lblQrySel->Caption + " [" + LblRecords->Caption + "]";//"데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
  196. Application->MessageBox(sEnd.c_str(),
  197. FrmLang->lblQryEnd->Caption.c_str(),//L"데이터 조회 완료",
  198. MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  199. }
  200. }
  201. catch(EDatabaseError &E)
  202. {
  203. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  204. DBERRORMSG(Caption, String(E.ClassName()), E.Message, pADO->SQL->Text);
  205. throw Exception(String(E.ClassName()) + E.Message);
  206. }
  207. catch(Exception &e)
  208. {
  209. ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
  210. DBERRORMSG(Caption, String(e.ClassName()), e.Message, pADO->SQL->Text);
  211. throw Exception(String(e.ClassName()) + e.Message);
  212. }
  213. }
  214. //---------------------------------------------------------------------------
  215. void __fastcall TCCAMH101::OnMessage(TMessage &Msg)
  216. {
  217. switch (Msg.Msg)
  218. {
  219. case WM_PARAM_DATABASE:
  220. if (WP_DB_SELECT_OK == Msg.WParam)
  221. {
  222. //ShowMessage("Select Ok");
  223. }
  224. break;
  225. }
  226. }
  227. //---------------------------------------------------------------------------
  228. void __fastcall TCCAMH101::BtnExlSaveClick(TObject *Sender)
  229. {
  230. TcxGrid *pGrid = CxList;
  231. TcxGridTableView *pView = TvList;
  232. String sTitle= Caption;//"CCAM-제어기 상태이력";
  233. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  234. }
  235. //---------------------------------------------------------------------------
  236. void __fastcall TCCAMH101::FormClose(TObject *Sender, TCloseAction &Action)
  237. {
  238. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  239. CommClose();
  240. //CCAMH101 = NULL;
  241. }
  242. //---------------------------------------------------------------------------
  243. void __fastcall TCCAMH101::Column02CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  244. bool &ADone)
  245. {
  246. TColor tColor = ACanvas->Brush->Color;
  247. TColor tFont = clBlack;
  248. try
  249. {
  250. if (!VarIsNull(AViewInfo->Value))
  251. {
  252. String sTmp = AViewInfo->Value;
  253. if (sTmp == FrmLang->lblComm0->Caption)
  254. {
  255. tColor = clLime;
  256. }
  257. else
  258. if (sTmp == FrmLang->lblComm1->Caption)
  259. {
  260. tColor = clRed;
  261. }
  262. else
  263. {
  264. tColor = clSilver;
  265. }
  266. }
  267. ACanvas->Font->Color = tFont;
  268. ACanvas->SetBrushColor(tColor);
  269. }
  270. catch(...)
  271. {
  272. }
  273. #if 0
  274. if( AViewInfo )
  275. {
  276. if(AViewInfo->Text == "정상")
  277. {
  278. ACanvas->Canvas->Font->Color = clTeal;
  279. }
  280. else if(AViewInfo->Text == "장애")
  281. {
  282. ACanvas->Canvas->Font->Color = clFuchsia;
  283. }
  284. else
  285. {
  286. ACanvas->Canvas->Font->Color = clGray;
  287. }
  288. }
  289. #endif
  290. }
  291. //---------------------------------------------------------------------------