CCAMH101F.cpp 12 KB

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