123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372 |
- /****************************************************************************
- * @source :
- * @description :
- ****************************************************************************
- * DATE AUTHOR DESCRIPTION
- * --------------------------------------------------------------------------
- * 2011/12/24 정승호 최초작성
- *
- ****************************************************************************/
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include "AppGlobalF.h"
- #include "ITSSkinF.h"
- #include "ITSUtilF.h"
- #include "ITSDbF.h"
- #include "ITSLogF.h"
- #include "ITSLangTransF.h"
- #pragma hdrstop
- #include "FrmVmsLogSttsSubF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "cxButtons"
- #pragma link "cxCalc"
- #pragma link "cxCheckBox"
- #pragma link "cxClasses"
- #pragma link "cxContainer"
- #pragma link "cxControls"
- #pragma link "cxCustomData"
- #pragma link "cxData"
- #pragma link "cxDataStorage"
- #pragma link "cxEdit"
- #pragma link "cxFilter"
- #pragma link "cxGraphics"
- #pragma link "cxGrid"
- #pragma link "cxGridCustomTableView"
- #pragma link "cxGridCustomView"
- #pragma link "cxGridLevel"
- #pragma link "cxGridTableView"
- #pragma link "cxLookAndFeelPainters"
- #pragma link "cxLookAndFeels"
- #pragma link "cxSplitter"
- #pragma link "cxStyles"
- #pragma link "cxTextEdit"
- #pragma link "dxSkinBlack"
- #pragma link "dxSkinBlue"
- #pragma link "dxSkinCaramel"
- #pragma link "dxSkinCoffee"
- #pragma link "dxSkinDarkRoom"
- #pragma link "dxSkinDarkSide"
- #pragma link "dxSkinFoggy"
- #pragma link "dxSkinGlassOceans"
- #pragma link "dxSkiniMaginary"
- #pragma link "dxSkinLilian"
- #pragma link "dxSkinLiquidSky"
- #pragma link "dxSkinLondonLiquidSky"
- #pragma link "dxSkinMcSkin"
- #pragma link "dxSkinMoneyTwins"
- #pragma link "dxSkinOffice2007Black"
- #pragma link "dxSkinOffice2007Blue"
- #pragma link "dxSkinOffice2007Green"
- #pragma link "dxSkinOffice2007Pink"
- #pragma link "dxSkinOffice2007Silver"
- #pragma link "dxSkinOffice2010Black"
- #pragma link "dxSkinOffice2010Blue"
- #pragma link "dxSkinOffice2010Silver"
- #pragma link "dxSkinsCore"
- #pragma link "dxSkinscxPCPainter"
- #pragma link "dxSkinSeven"
- #pragma link "dxSkinSharp"
- #pragma link "dxSkinSilver"
- #pragma link "dxSkinStardust"
- #pragma link "cxLabel"
- #pragma link "cxGridBandedTableView"
- #pragma resource "*.dfm"
- //TFrmVmsLogSttsSub *FrmVmsLogSttsSub = NULL;
- //---------------------------------------------------------------------------
- __fastcall TFrmVmsLogSttsSub::TFrmVmsLogSttsSub(TComponent* Owner, HWND hHandle, String sFrom, String sTo, String sIdList)
- : TForm(Owner)
- {
- LangTrans->Translate(this, ITSDb_GetConnection());
- ITSSkin_Load(this);
- //CMM_LoadForm(g_sFormsDir, this);
- FParent = hHandle;
- FStDateTime = sFrom;
- FEdDateTime = sTo;
- FIdList = sIdList;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsLogSttsSub::FormInit()
- {
- ADOQry->Connection = ITSDb_GetConnection();
- m_pGDC = TvList->DataController;
- TvList->OptionsView->NoDataToDisplayInfoText = Caption + ": " + lblText1->Caption;//조회결과가 없습니다.";
- LblSearch->Caption = lblText2->Caption + FStDateTime.SubString(1, 10) + " ~ " + FEdDateTime.SubString(1, 10);
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsLogSttsSub::FormShow(TObject *Sender)
- {
- FormInit();
- Refresh();
- TmrShow->Enabled = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsLogSttsSub::CommClose()
- {
- //CMM_SaveForm(g_sFormsDir, this);
- //FrmVmsLogSub = NULL;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsLogSttsSub::TmrShowTimer(TObject *Sender)
- {
- TmrShow->Enabled = false;
- SelHistory();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsLogSttsSub::ChkExpandClick(TObject *Sender)
- {
- CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsLogSttsSub::SelHistory()
- {
- TSqlCursor sqlCrs;
- String sQry;
- TADOQuery *pADO = ADOQry;
- sQry = "SELECT A.*, B.VMS_CTLR_ID, B.VMS_NM \r\n"
- " FROM TB_VMS_CTLR_STTS_HS A, \r\n"
- " TB_VMS_CTLR B \r\n"
- " WHERE B.VMS_CTLR_NMBR IN(" + FIdList + ") \r\n"
- " AND A.CRTN_DT BETWEEN :p01 AND :p02 \r\n"
- " AND A.VMS_CTLR_NMBR = B.VMS_CTLR_NMBR \r\n";
- try
- {
- ITSDb_SQLText(pADO, sQry);
- ITSDb_SQLBind(pADO, "p01", FStDateTime);
- ITSDb_SQLBind(pADO, "p02", FEdDateTime);
- ITSDb_SQLOpen(pADO);
- }
- catch(EDatabaseError &E)
- {
- DBERRORMSG("History Qeury", String(E.ClassName()), E.Message, sQry);
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(Exception &e)
- {
- DBERRORMSG("History Qeury", String(e.ClassName()), e.Message, sQry);
- throw Exception(String(e.ClassName()) + e.Message);
- }
- DspHistory();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsLogSttsSub::DspHistory()
- {
- TADOQuery *pADO = ADOQry;
- try
- {
- TcxGridChartSeries *pChart = NULL;
- CMM_ClearGridTableView(TvList);
- int nRow = 0;
- int nDataCnt = 0;
- try {
- TvList->BeginUpdate(lsimImmediate);
- nDataCnt = pADO->RecordCount;
- m_pGDC->RecordCount = nDataCnt;
- for( ; !pADO->Eof; pADO->Next(), nRow++)
- {
- m_pGDC->Values[nRow][Col01->Index] = pADO->FieldByName("VMS_CTLR_NMBR")->AsString;
- m_pGDC->Values[nRow][Col02->Index] = pADO->FieldByName("VMS_CTLR_ID")->AsString;
- m_pGDC->Values[nRow][Col03->Index] = pADO->FieldByName("VMS_NM")->AsString;
- m_pGDC->Values[nRow][Col04->Index] = ITSUtil_StrToDateTime(pADO->FieldByName("CRTN_DT")->AsString).FormatString(STR_DATETIME);
- String sComm = pADO->FieldByName("CMNC_STTS_CD")->AsString;
- if (sComm != "CMS0")
- {
- m_pGDC->Values[nRow][Col05->Index] = lblMOS1->Caption;//"장애";
- m_pGDC->Values[nRow][Col11->Index] = "-";
- m_pGDC->Values[nRow][Col12->Index] = "-";
- m_pGDC->Values[nRow][Col13->Index] = "-";
- m_pGDC->Values[nRow][Col14->Index] = "-";
- m_pGDC->Values[nRow][Col15->Index] = "-";
- m_pGDC->Values[nRow][Col16->Index] = "-";
- m_pGDC->Values[nRow][Col17->Index] = "-";
- m_pGDC->Values[nRow][Col22->Index] = "-";
- m_pGDC->Values[nRow][Col23->Index] = "-";
- continue;
- }
- m_pGDC->Values[nRow][Col05->Index] = lblMOS0->Caption;//"정상";
- #if 0
- //전원상태
- String sPwer = pADO->FieldByName("MODL_STTS_CD")->AsString;
- if (sPwer == "PWS0") m_pGDC->Values[nRow][Col12->Index] = lblPWS0->Caption;//"켜짐";
- else if (sPwer == "PWS1") m_pGDC->Values[nRow][Col12->Index] = lblPWS1->Caption;//"꺼짐";
- else m_pGDC->Values[nRow][Col12->Index] = "?";
- #endif
- //모듈전원상태
- String sModl = pADO->FieldByName("MODL_STTS_CD")->AsString;
- if (sModl == "MOS0") m_pGDC->Values[nRow][Col12->Index] = lblPWS0->Caption;//"켜짐";
- else if (sModl == "MOS1") m_pGDC->Values[nRow][Col12->Index] = lblPWS1->Caption;//"꺼짐";
- else m_pGDC->Values[nRow][Col12->Index] = "?";
- //도어
- String sDoor = pADO->FieldByName("CBOX_DOOR_STTS_CD")->AsString;
- if (sDoor == "CDS0") m_pGDC->Values[nRow][Col14->Index] = lblCDS0->Caption;//"닫힘";
- else if (sDoor == "CDS1") m_pGDC->Values[nRow][Col14->Index] = lblCDS1->Caption;//"열림";
- else m_pGDC->Values[nRow][Col14->Index] = "?";
- //팬상태
- String sFans = pADO->FieldByName("FAN_STTS_CD")->AsString;
- if (sFans == "PAS0") m_pGDC->Values[nRow][Col15->Index] = lblPAS0->Caption;//"동작";
- else if (sFans == "PAS1") m_pGDC->Values[nRow][Col15->Index] = lblPAS1->Caption;//"정지";
- else m_pGDC->Values[nRow][Col15->Index] = "?";
- //히터상태
- String sHets = pADO->FieldByName("HETR_STTS_CD")->AsString;
- if (sHets == "HTS0") m_pGDC->Values[nRow][Col16->Index] = lblHTS0->Caption;//"가동";
- else if (sHets == "HTS1") m_pGDC->Values[nRow][Col16->Index] = lblHTS1->Caption;//"중지";
- else m_pGDC->Values[nRow][Col16->Index] = "?";
- //온도
- m_pGDC->Values[nRow][Col17->Index] = pADO->FieldByName("CBOX_TMPR")->AsString;
- //화면휘도
- m_pGDC->Values[nRow][Col13->Index] = pADO->FieldByName("BRGH_VAL")->AsString;
- #if 0
- //모듈상태
- String sModl = pADO->FieldByName("MODL_STTS_CD")->AsString;
- if (sModl == "MOS0") m_pGDC->Values[nRow][Col11->Index] = lblMOS0->Caption;//"정상";
- else if (sModl == "MOS1") m_pGDC->Values[nRow][Col11->Index] = lblMOS0->Caption;//"장애";
- else m_pGDC->Values[nRow][Col11->Index] = "?";
- //모듈개별상태
- m_pGDC->Values[nRow][Col22->Index] = pADO->FieldByName("MODL_STTS")->AsString;
- //전원개별상태
- m_pGDC->Values[nRow][Col23->Index] = pADO->FieldByName("PWER_STTS")->AsString;
- #endif
- }
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- }
- TvList->EndUpdate();
- //CxList->SetFocus();
- LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + lblCnt->Caption;//" 건";
- }
- }
- catch(EDatabaseError &E)
- {
- DBERRORMSG("History Results", String(E.ClassName()), E.Message, pADO->SQL->Text);
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(Exception &e)
- {
- DBERRORMSG("History Results", String(e.ClassName()), e.Message, pADO->SQL->Text);
- throw Exception(String(e.ClassName()) + e.Message);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsLogSttsSub::BtnExlSaveClick(TObject *Sender)
- {
- TcxGrid *pGrid = CxList;
- TcxGridTableView *pView = TvList;
- String sTitle= Caption;
- CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsLogSttsSub::FormClose(TObject *Sender, TCloseAction &Action)
- {
- POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
- CommClose();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsLogSttsSub::FormDestroy(TObject *Sender)
- {
- //
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsLogSttsSub::Col05CustomDrawCell(TcxCustomGridTableView *Sender,
- TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
- bool &ADone)
- {
- try
- {
- TColor tColor;
- String sStatus = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
- tColor = ACanvas->Brush->Color;
- if (sStatus.Pos("-")) tColor = clGray;
- else if (sStatus.Pos(lblMOS1->Caption)) tColor = clRed;
- else if (sStatus.Pos(lblPWS0->Caption)) tColor = clYellow;
- else if (sStatus.Pos(lblCDS1->Caption)) tColor = clYellow;
- else if (sStatus.Pos(lblPAS0->Caption)) tColor = clYellow;
- else if (sStatus.Pos(lblHTS0->Caption)) tColor = clYellow;
- else if (sStatus.Pos("0")) tColor = clRed;
- else if (sStatus.Pos("?")) tColor = clGray;
- else tColor = clLime;
- ACanvas->SetBrushColor(tColor);
- ACanvas->Font->Color = clBlack;
- }
- catch(Exception &e)
- {
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsLogSttsSub::Col12CustomDrawCell(TcxCustomGridTableView *Sender,
- TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
- bool &ADone)
- {
- try
- {
- TColor tColor;
- String sStatus = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
- tColor = ACanvas->Brush->Color;
- #if 1
- if (sStatus.Pos("-")) tColor = clGray;
- else if (sStatus.Pos(lblMOS1->Caption)) tColor = clRed;
- else if (sStatus.Pos(lblPWS1->Caption)) tColor = clRed;
- else if (sStatus.Pos("?")) tColor = clGray;
- else tColor = clLime;
- #else
- if (sStatus.Pos("-")) tColor = clGray;
- else if (sStatus.Pos("Error")) tColor = clRed;
- else if (sStatus.Pos("Off")) tColor = clRed;
- else if (sStatus.Pos("?")) tColor = clGray;
- else tColor = clLime;
- #endif
- ACanvas->SetBrushColor(tColor);
- ACanvas->Font->Color = clBlack;
- }
- catch(Exception &e)
- {
- }
- }
- //---------------------------------------------------------------------------
|