//--------------------------------------------------------------------------- #include #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] = "-"; m_pGDC->Values[nRow][Col24->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 sModlOnOff = pADO->FieldByName("PWER_STTS_CD")->AsString; if (sModlOnOff == "MOS0") m_pGDC->Values[nRow][Col24->Index] = lblPWS0->Caption;//"ÄÑÁü"; else if (sModlOnOff == "MOS1") m_pGDC->Values[nRow][Col24->Index] = lblPWS1->Caption;//"²¨Áü"; else m_pGDC->Values[nRow][Col24->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) { } } //--------------------------------------------------------------------------- void __fastcall TFrmVmsLogSttsSub::Col17CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo, bool &ADone) { try { TColor tBrush = ACanvas->Brush->Color; TColor tFont = ACanvas->Font->Color; String sValue = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index]; if (sValue != "-" && sValue.ToIntDef(0) > g_AppCfg.Temp.AlarmValue) { tBrush = clFuchsia; tFont = clWhite; } ACanvas->SetBrushColor(tBrush); ACanvas->Font->Color = tFont; } catch(Exception &e) { } } //---------------------------------------------------------------------------