FrmVmsLogSttsSubF.cpp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. /****************************************************************************
  2. * @source :
  3. * @description :
  4. ****************************************************************************
  5. * DATE AUTHOR DESCRIPTION
  6. * --------------------------------------------------------------------------
  7. * 2011/12/24 정승호 최초작성
  8. *
  9. ****************************************************************************/
  10. //---------------------------------------------------------------------------
  11. #include <vcl.h>
  12. #include "AppGlobalF.h"
  13. #include "ITSSkinF.h"
  14. #include "ITSUtilF.h"
  15. #include "ITSDbF.h"
  16. #include "ITSLogF.h"
  17. #include "ITSLangTransF.h"
  18. #pragma hdrstop
  19. #include "FrmVmsLogSttsSubF.h"
  20. //---------------------------------------------------------------------------
  21. #pragma package(smart_init)
  22. #pragma link "cxButtons"
  23. #pragma link "cxCalc"
  24. #pragma link "cxCheckBox"
  25. #pragma link "cxClasses"
  26. #pragma link "cxContainer"
  27. #pragma link "cxControls"
  28. #pragma link "cxCustomData"
  29. #pragma link "cxData"
  30. #pragma link "cxDataStorage"
  31. #pragma link "cxEdit"
  32. #pragma link "cxFilter"
  33. #pragma link "cxGraphics"
  34. #pragma link "cxGrid"
  35. #pragma link "cxGridCustomTableView"
  36. #pragma link "cxGridCustomView"
  37. #pragma link "cxGridLevel"
  38. #pragma link "cxGridTableView"
  39. #pragma link "cxLookAndFeelPainters"
  40. #pragma link "cxLookAndFeels"
  41. #pragma link "cxSplitter"
  42. #pragma link "cxStyles"
  43. #pragma link "cxTextEdit"
  44. #pragma link "dxSkinBlack"
  45. #pragma link "dxSkinBlue"
  46. #pragma link "dxSkinCaramel"
  47. #pragma link "dxSkinCoffee"
  48. #pragma link "dxSkinDarkRoom"
  49. #pragma link "dxSkinDarkSide"
  50. #pragma link "dxSkinFoggy"
  51. #pragma link "dxSkinGlassOceans"
  52. #pragma link "dxSkiniMaginary"
  53. #pragma link "dxSkinLilian"
  54. #pragma link "dxSkinLiquidSky"
  55. #pragma link "dxSkinLondonLiquidSky"
  56. #pragma link "dxSkinMcSkin"
  57. #pragma link "dxSkinMoneyTwins"
  58. #pragma link "dxSkinOffice2007Black"
  59. #pragma link "dxSkinOffice2007Blue"
  60. #pragma link "dxSkinOffice2007Green"
  61. #pragma link "dxSkinOffice2007Pink"
  62. #pragma link "dxSkinOffice2007Silver"
  63. #pragma link "dxSkinOffice2010Black"
  64. #pragma link "dxSkinOffice2010Blue"
  65. #pragma link "dxSkinOffice2010Silver"
  66. #pragma link "dxSkinsCore"
  67. #pragma link "dxSkinscxPCPainter"
  68. #pragma link "dxSkinSeven"
  69. #pragma link "dxSkinSharp"
  70. #pragma link "dxSkinSilver"
  71. #pragma link "dxSkinStardust"
  72. #pragma link "cxLabel"
  73. #pragma link "cxGridBandedTableView"
  74. #pragma resource "*.dfm"
  75. //TFrmVmsLogSttsSub *FrmVmsLogSttsSub = NULL;
  76. //---------------------------------------------------------------------------
  77. __fastcall TFrmVmsLogSttsSub::TFrmVmsLogSttsSub(TComponent* Owner, HWND hHandle, String sFrom, String sTo, String sIdList)
  78. : TForm(Owner)
  79. {
  80. LangTrans->Translate(this, ITSDb_GetConnection());
  81. ITSSkin_Load(this);
  82. //CMM_LoadForm(g_sFormsDir, this);
  83. FParent = hHandle;
  84. FStDateTime = sFrom;
  85. FEdDateTime = sTo;
  86. FIdList = sIdList;
  87. }
  88. //---------------------------------------------------------------------------
  89. void __fastcall TFrmVmsLogSttsSub::FormInit()
  90. {
  91. ADOQry->Connection = ITSDb_GetConnection();
  92. m_pGDC = TvList->DataController;
  93. TvList->OptionsView->NoDataToDisplayInfoText = Caption + ": " + lblText1->Caption;//조회결과가 없습니다.";
  94. LblSearch->Caption = lblText2->Caption + FStDateTime.SubString(1, 10) + " ~ " + FEdDateTime.SubString(1, 10);
  95. }
  96. //---------------------------------------------------------------------------
  97. void __fastcall TFrmVmsLogSttsSub::FormShow(TObject *Sender)
  98. {
  99. FormInit();
  100. Refresh();
  101. TmrShow->Enabled = true;
  102. }
  103. //---------------------------------------------------------------------------
  104. void __fastcall TFrmVmsLogSttsSub::CommClose()
  105. {
  106. //CMM_SaveForm(g_sFormsDir, this);
  107. //FrmVmsLogSub = NULL;
  108. }
  109. //---------------------------------------------------------------------------
  110. void __fastcall TFrmVmsLogSttsSub::TmrShowTimer(TObject *Sender)
  111. {
  112. TmrShow->Enabled = false;
  113. SelHistory();
  114. }
  115. //---------------------------------------------------------------------------
  116. void __fastcall TFrmVmsLogSttsSub::ChkExpandClick(TObject *Sender)
  117. {
  118. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  119. }
  120. //---------------------------------------------------------------------------
  121. void __fastcall TFrmVmsLogSttsSub::SelHistory()
  122. {
  123. TSqlCursor sqlCrs;
  124. String sQry;
  125. TADOQuery *pADO = ADOQry;
  126. sQry = "SELECT A.*, B.VMS_CTLR_ID, B.VMS_NM \r\n"
  127. " FROM TB_VMS_STTS_HS A, \r\n"
  128. " TB_VMS_CTLR B \r\n"
  129. " WHERE B.VMS_CTLR_NMBR IN(" + FIdList + ") \r\n"
  130. " AND A.RGST_DT BETWEEN :p01 AND :p02 \r\n"
  131. " AND A.VMS_CTLR_NMBR = B.VMS_CTLR_NMBR \r\n";
  132. try
  133. {
  134. ITSDb_SQLText(pADO, sQry);
  135. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  136. ITSDb_SQLBind(pADO, "p02", FEdDateTime);
  137. ITSDb_SQLOpen(pADO);
  138. }
  139. catch(EDatabaseError &E)
  140. {
  141. DBERRORMSG("History Qeury", String(E.ClassName()), E.Message, sQry);
  142. throw Exception(String(E.ClassName()) + E.Message);
  143. }
  144. catch(Exception &e)
  145. {
  146. DBERRORMSG("History Qeury", String(e.ClassName()), e.Message, sQry);
  147. throw Exception(String(e.ClassName()) + e.Message);
  148. }
  149. DspHistory();
  150. }
  151. //---------------------------------------------------------------------------
  152. void __fastcall TFrmVmsLogSttsSub::DspHistory()
  153. {
  154. TADOQuery *pADO = ADOQry;
  155. try
  156. {
  157. TcxGridChartSeries *pChart = NULL;
  158. CMM_ClearGridTableView(TvList);
  159. int nRow = 0;
  160. int nDataCnt = 0;
  161. try {
  162. TvList->BeginUpdate(lsimImmediate);
  163. nDataCnt = pADO->RecordCount;
  164. m_pGDC->RecordCount = nDataCnt;
  165. for( ; !pADO->Eof; pADO->Next(), nRow++)
  166. {
  167. m_pGDC->Values[nRow][Col01->Index] = pADO->FieldByName("VMS_CTLR_NMBR")->AsString;
  168. m_pGDC->Values[nRow][Col02->Index] = pADO->FieldByName("VMS_CTLR_ID")->AsString;
  169. m_pGDC->Values[nRow][Col03->Index] = pADO->FieldByName("VMS_NM")->AsString;
  170. m_pGDC->Values[nRow][Col04->Index] = ITSUtil_StrToDateTime(pADO->FieldByName("RGST_DT")->AsString).FormatString(STR_DATETIME);
  171. String sComm = pADO->FieldByName("CONN_STTS_CD")->AsString;
  172. if (sComm != "CMS0")
  173. {
  174. m_pGDC->Values[nRow][Col05->Index] = lblMOS0->Caption;//"장애";
  175. m_pGDC->Values[nRow][Col11->Index] = "-";
  176. m_pGDC->Values[nRow][Col12->Index] = "-";
  177. m_pGDC->Values[nRow][Col13->Index] = "-";
  178. m_pGDC->Values[nRow][Col14->Index] = "-";
  179. m_pGDC->Values[nRow][Col15->Index] = "-";
  180. m_pGDC->Values[nRow][Col16->Index] = "-";
  181. m_pGDC->Values[nRow][Col17->Index] = "-";
  182. m_pGDC->Values[nRow][Col22->Index] = "-";
  183. m_pGDC->Values[nRow][Col23->Index] = "-";
  184. continue;
  185. }
  186. m_pGDC->Values[nRow][Col05->Index] = lblMOS0->Caption;//"정상";
  187. //모듈상태
  188. String sModl = pADO->FieldByName("CBOXFAN_STTS_CD")->AsString;
  189. if (sModl == "MOS0") m_pGDC->Values[nRow][Col11->Index] = lblMOS0->Caption;//"정상";
  190. else m_pGDC->Values[nRow][Col11->Index] = lblMOS0->Caption;//"장애";
  191. //전원상태
  192. String sPwer = pADO->FieldByName("PWER_STTS_CD")->AsString;
  193. if (sPwer == "PWS0") m_pGDC->Values[nRow][Col12->Index] = lblPWS0->Caption;//"켜짐";
  194. else m_pGDC->Values[nRow][Col12->Index] = lblPWS1->Caption;//"꺼짐";
  195. //화면휘도
  196. m_pGDC->Values[nRow][Col13->Index] = pADO->FieldByName("CBOX_HMDT")->AsString;
  197. //도어
  198. String sDoor = pADO->FieldByName("CBOXDOOR_OPEN_STTS_CD")->AsString;
  199. if (sDoor == "CDS0") m_pGDC->Values[nRow][Col14->Index] = lblCDS0->Caption;//"닫힘";
  200. else m_pGDC->Values[nRow][Col14->Index] = lblCDS1->Caption;//"열림";
  201. //팬상태
  202. String sFans = pADO->FieldByName("FAN_STTS_CD")->AsString;
  203. if (sFans == "PAS0") m_pGDC->Values[nRow][Col15->Index] = lblPAS0->Caption;//"동작";
  204. else m_pGDC->Values[nRow][Col15->Index] = lblPAS1->Caption;//"정지";
  205. //히터상태
  206. String sHets = pADO->FieldByName("HETR_STTS_CD")->AsString;
  207. if (sHets == "HTS0") m_pGDC->Values[nRow][Col16->Index] = lblHTS0->Caption;//"가동";
  208. else m_pGDC->Values[nRow][Col16->Index] = lblHTS1->Caption;//"중지";
  209. //온도
  210. m_pGDC->Values[nRow][Col17->Index] = pADO->FieldByName("CBOX_TMPR")->AsString;
  211. #if 0
  212. //모듈개별상태
  213. m_pGDC->Values[nRow][Col22->Index] = pADO->FieldByName("MODL_STTS")->AsString;
  214. //전원개별상태
  215. m_pGDC->Values[nRow][Col23->Index] = pADO->FieldByName("PWER_STTS")->AsString;
  216. #endif
  217. }
  218. }
  219. __finally
  220. {
  221. if (pADO)
  222. {
  223. pADO->Close();
  224. }
  225. TvList->EndUpdate();
  226. //CxList->SetFocus();
  227. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + lblCnt->Caption;//" 건";
  228. }
  229. }
  230. catch(EDatabaseError &E)
  231. {
  232. DBERRORMSG("History Results", String(E.ClassName()), E.Message, pADO->SQL->Text);
  233. throw Exception(String(E.ClassName()) + E.Message);
  234. }
  235. catch(Exception &e)
  236. {
  237. DBERRORMSG("History Results", String(e.ClassName()), e.Message, pADO->SQL->Text);
  238. throw Exception(String(e.ClassName()) + e.Message);
  239. }
  240. }
  241. //---------------------------------------------------------------------------
  242. void __fastcall TFrmVmsLogSttsSub::BtnExlSaveClick(TObject *Sender)
  243. {
  244. TcxGrid *pGrid = CxList;
  245. TcxGridTableView *pView = TvList;
  246. String sTitle= Caption;
  247. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  248. }
  249. //---------------------------------------------------------------------------
  250. void __fastcall TFrmVmsLogSttsSub::FormClose(TObject *Sender, TCloseAction &Action)
  251. {
  252. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  253. CommClose();
  254. }
  255. //---------------------------------------------------------------------------
  256. void __fastcall TFrmVmsLogSttsSub::FormDestroy(TObject *Sender)
  257. {
  258. //
  259. }
  260. //---------------------------------------------------------------------------
  261. void __fastcall TFrmVmsLogSttsSub::Col05CustomDrawCell(TcxCustomGridTableView *Sender,
  262. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  263. bool &ADone)
  264. {
  265. try
  266. {
  267. TColor tColor;
  268. String sStatus = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  269. tColor = ACanvas->Brush->Color;
  270. #if 1
  271. if (sStatus.Pos("-")) tColor = clGray;
  272. else if (sStatus.Pos(lblMOS1->Caption)) tColor = clRed;
  273. else if (sStatus.Pos(lblPWS0->Caption)) tColor = clYellow;
  274. else if (sStatus.Pos(lblCDS1->Caption)) tColor = clYellow;
  275. else if (sStatus.Pos(lblPAS0->Caption)) tColor = clYellow;
  276. else if (sStatus.Pos(lblHTS0->Caption)) tColor = clYellow;
  277. else if (sStatus.Pos("0")) tColor = clRed;
  278. else tColor = clLime;
  279. #else
  280. if (sStatus.Pos("-")) tColor = clGray;
  281. else if (sStatus.Pos("장애")) tColor = clRed;
  282. else if (sStatus.Pos("켜짐")) tColor = clYellow;
  283. else if (sStatus.Pos("열림")) tColor = clYellow;
  284. else if (sStatus.Pos("동작")) tColor = clYellow;
  285. else if (sStatus.Pos("가동")) tColor = clYellow;
  286. else if (sStatus.Pos("0")) tColor = clRed;
  287. else tColor = clLime;
  288. #endif
  289. ACanvas->SetBrushColor(tColor);
  290. ACanvas->Font->Color = clBlack;
  291. }
  292. catch(Exception &e)
  293. {
  294. }
  295. }
  296. //---------------------------------------------------------------------------
  297. void __fastcall TFrmVmsLogSttsSub::Col12CustomDrawCell(TcxCustomGridTableView *Sender,
  298. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  299. bool &ADone)
  300. {
  301. try
  302. {
  303. TColor tColor;
  304. String sStatus = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  305. tColor = ACanvas->Brush->Color;
  306. #if 1
  307. if (sStatus.Pos("-")) tColor = clGray;
  308. else if (sStatus.Pos(lblMOS1->Caption)) tColor = clRed;
  309. else if (sStatus.Pos(lblPWS1->Caption)) tColor = clRed;
  310. else tColor = clLime;
  311. #else
  312. if (sStatus.Pos("-")) tColor = clGray;
  313. else if (sStatus.Pos("Error")) tColor = clRed;
  314. else if (sStatus.Pos("Off")) tColor = clRed;
  315. else tColor = clLime;
  316. #endif
  317. ACanvas->SetBrushColor(tColor);
  318. ACanvas->Font->Color = clBlack;
  319. }
  320. catch(Exception &e)
  321. {
  322. }
  323. }
  324. //---------------------------------------------------------------------------