FrmVmsLogSttsSubF.cpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  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_CTLR_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.CRTN_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("CRTN_DT")->AsString).FormatString(STR_DATETIME);
  171. String sComm = pADO->FieldByName("CMNC_STTS_CD")->AsString;
  172. if (sComm != "CMS0")
  173. {
  174. m_pGDC->Values[nRow][Col05->Index] = lblMOS1->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. #if 0
  188. //전원상태
  189. String sPwer = pADO->FieldByName("MODL_STTS_CD")->AsString;
  190. if (sPwer == "PWS0") m_pGDC->Values[nRow][Col12->Index] = lblPWS0->Caption;//"켜짐";
  191. else if (sPwer == "PWS1") m_pGDC->Values[nRow][Col12->Index] = lblPWS1->Caption;//"꺼짐";
  192. else m_pGDC->Values[nRow][Col12->Index] = "?";
  193. #endif
  194. //모듈전원상태
  195. String sModl = pADO->FieldByName("MODL_STTS_CD")->AsString;
  196. if (sModl == "MOS0") m_pGDC->Values[nRow][Col12->Index] = lblPWS0->Caption;//"켜짐";
  197. else if (sModl == "MOS1") m_pGDC->Values[nRow][Col12->Index] = lblPWS1->Caption;//"꺼짐";
  198. else m_pGDC->Values[nRow][Col12->Index] = "?";
  199. //도어
  200. String sDoor = pADO->FieldByName("CBOX_DOOR_STTS_CD")->AsString;
  201. if (sDoor == "CDS0") m_pGDC->Values[nRow][Col14->Index] = lblCDS0->Caption;//"닫힘";
  202. else if (sDoor == "CDS1") m_pGDC->Values[nRow][Col14->Index] = lblCDS1->Caption;//"열림";
  203. else m_pGDC->Values[nRow][Col14->Index] = "?";
  204. //팬상태
  205. String sFans = pADO->FieldByName("FAN_STTS_CD")->AsString;
  206. if (sFans == "PAS0") m_pGDC->Values[nRow][Col15->Index] = lblPAS0->Caption;//"동작";
  207. else if (sFans == "PAS1") m_pGDC->Values[nRow][Col15->Index] = lblPAS1->Caption;//"정지";
  208. else m_pGDC->Values[nRow][Col15->Index] = "?";
  209. //히터상태
  210. String sHets = pADO->FieldByName("HETR_STTS_CD")->AsString;
  211. if (sHets == "HTS0") m_pGDC->Values[nRow][Col16->Index] = lblHTS0->Caption;//"가동";
  212. else if (sHets == "HTS1") m_pGDC->Values[nRow][Col16->Index] = lblHTS1->Caption;//"중지";
  213. else m_pGDC->Values[nRow][Col16->Index] = "?";
  214. //온도
  215. m_pGDC->Values[nRow][Col17->Index] = pADO->FieldByName("CBOX_TMPR")->AsString;
  216. //화면휘도
  217. m_pGDC->Values[nRow][Col13->Index] = pADO->FieldByName("BRGH_VAL")->AsString;
  218. #if 0
  219. //모듈상태
  220. String sModl = pADO->FieldByName("MODL_STTS_CD")->AsString;
  221. if (sModl == "MOS0") m_pGDC->Values[nRow][Col11->Index] = lblMOS0->Caption;//"정상";
  222. else if (sModl == "MOS1") m_pGDC->Values[nRow][Col11->Index] = lblMOS0->Caption;//"장애";
  223. else m_pGDC->Values[nRow][Col11->Index] = "?";
  224. //모듈개별상태
  225. m_pGDC->Values[nRow][Col22->Index] = pADO->FieldByName("MODL_STTS")->AsString;
  226. //전원개별상태
  227. m_pGDC->Values[nRow][Col23->Index] = pADO->FieldByName("PWER_STTS")->AsString;
  228. #endif
  229. }
  230. }
  231. __finally
  232. {
  233. if (pADO)
  234. {
  235. pADO->Close();
  236. }
  237. TvList->EndUpdate();
  238. //CxList->SetFocus();
  239. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + lblCnt->Caption;//" 건";
  240. }
  241. }
  242. catch(EDatabaseError &E)
  243. {
  244. DBERRORMSG("History Results", String(E.ClassName()), E.Message, pADO->SQL->Text);
  245. throw Exception(String(E.ClassName()) + E.Message);
  246. }
  247. catch(Exception &e)
  248. {
  249. DBERRORMSG("History Results", String(e.ClassName()), e.Message, pADO->SQL->Text);
  250. throw Exception(String(e.ClassName()) + e.Message);
  251. }
  252. }
  253. //---------------------------------------------------------------------------
  254. void __fastcall TFrmVmsLogSttsSub::BtnExlSaveClick(TObject *Sender)
  255. {
  256. TcxGrid *pGrid = CxList;
  257. TcxGridTableView *pView = TvList;
  258. String sTitle= Caption;
  259. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  260. }
  261. //---------------------------------------------------------------------------
  262. void __fastcall TFrmVmsLogSttsSub::FormClose(TObject *Sender, TCloseAction &Action)
  263. {
  264. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  265. CommClose();
  266. }
  267. //---------------------------------------------------------------------------
  268. void __fastcall TFrmVmsLogSttsSub::FormDestroy(TObject *Sender)
  269. {
  270. //
  271. }
  272. //---------------------------------------------------------------------------
  273. void __fastcall TFrmVmsLogSttsSub::Col05CustomDrawCell(TcxCustomGridTableView *Sender,
  274. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  275. bool &ADone)
  276. {
  277. try
  278. {
  279. TColor tColor;
  280. String sStatus = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  281. tColor = ACanvas->Brush->Color;
  282. if (sStatus.Pos("-")) tColor = clGray;
  283. else if (sStatus.Pos(lblMOS1->Caption)) tColor = clRed;
  284. else if (sStatus.Pos(lblPWS0->Caption)) tColor = clYellow;
  285. else if (sStatus.Pos(lblCDS1->Caption)) tColor = clYellow;
  286. else if (sStatus.Pos(lblPAS0->Caption)) tColor = clYellow;
  287. else if (sStatus.Pos(lblHTS0->Caption)) tColor = clYellow;
  288. else if (sStatus.Pos("0")) tColor = clRed;
  289. else if (sStatus.Pos("?")) tColor = clGray;
  290. else tColor = clLime;
  291. ACanvas->SetBrushColor(tColor);
  292. ACanvas->Font->Color = clBlack;
  293. }
  294. catch(Exception &e)
  295. {
  296. }
  297. }
  298. //---------------------------------------------------------------------------
  299. void __fastcall TFrmVmsLogSttsSub::Col12CustomDrawCell(TcxCustomGridTableView *Sender,
  300. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  301. bool &ADone)
  302. {
  303. try
  304. {
  305. TColor tColor;
  306. String sStatus = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  307. tColor = ACanvas->Brush->Color;
  308. #if 1
  309. if (sStatus.Pos("-")) tColor = clGray;
  310. else if (sStatus.Pos(lblMOS1->Caption)) tColor = clRed;
  311. else if (sStatus.Pos(lblPWS1->Caption)) tColor = clRed;
  312. else if (sStatus.Pos("?")) tColor = clGray;
  313. else tColor = clLime;
  314. #else
  315. if (sStatus.Pos("-")) tColor = clGray;
  316. else if (sStatus.Pos("Error")) tColor = clRed;
  317. else if (sStatus.Pos("Off")) tColor = clRed;
  318. else if (sStatus.Pos("?")) tColor = clGray;
  319. else tColor = clLime;
  320. #endif
  321. ACanvas->SetBrushColor(tColor);
  322. ACanvas->Font->Color = clBlack;
  323. }
  324. catch(Exception &e)
  325. {
  326. }
  327. }
  328. //---------------------------------------------------------------------------