//--------------------------------------------------------------------------- #include #include "AppGlobalF.h" #include "ITSSkinF.h" #include "ITSUtilF.h" #include "ITSDbF.h" #include "ITSLogF.h" #include "ITSLangTransF.h" #pragma hdrstop #include "FrmCctvLogCtrlSubF.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 resource "*.dfm" //TFrmCctvLogCtlSub *FrmCctvLogCtlSub = NULL; //--------------------------------------------------------------------------- __fastcall TFrmCctvLogCtrlSub::TFrmCctvLogCtrlSub(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 TFrmCctvLogCtrlSub::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 TFrmCctvLogCtrlSub::FormShow(TObject *Sender) { FormInit(); Refresh(); TmrShow->Enabled = true; } //--------------------------------------------------------------------------- void __fastcall TFrmCctvLogCtrlSub::CommClose() { //CMM_SaveForm(g_sFormsDir, this); //FrmVmsLogSub = NULL; } //--------------------------------------------------------------------------- void __fastcall TFrmCctvLogCtrlSub::TmrShowTimer(TObject *Sender) { TmrShow->Enabled = false; SelHistory(); } //--------------------------------------------------------------------------- void __fastcall TFrmCctvLogCtrlSub::ChkExpandClick(TObject *Sender) { CMM_ExpandCollapseChk(TvList, ChkExpand->Checked); } //--------------------------------------------------------------------------- void __fastcall TFrmCctvLogCtrlSub::SelHistory() { TSqlCursor sqlCrs; String sQry; TADOQuery *pADO = ADOQry; sQry = "SELECT A.*, B.CCTV_CTLR_ID, B.ISTL_LCTN_NM \r\n" " FROM TB_CCTV_CTRL_HS A, \r\n" " TB_CCTV_CTLR B \r\n" " WHERE B.CCTV_CTLR_NMBR IN(" + FIdList + ") \r\n" " AND A.CTRL_DT BETWEEN :p01 AND :p02 \r\n" " AND A.CCTV_CTLR_NMBR = B.CCTV_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 TFrmCctvLogCtrlSub::DspHistory() { TADOQuery *pADO = ADOQry; try { 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][Col00->Index] = pADO->FieldByName("CCTV_CTLR_NMBR")->AsString; m_pGDC->Values[nRow][Col01->Index] = pADO->FieldByName("CCTV_CTLR_ID")->AsString; m_pGDC->Values[nRow][Col02->Index] = pADO->FieldByName("ISTL_LCTN_NM")->AsString; String sCtlType = pADO->FieldByName("CTL_TYPE")->AsString; //Á¦¾îÀ¯Çü(V01:Àü±¤ÆÇON,V02:Àü±¤ÆÇOFF,V03:Á¦¾î±â¸®¼Â,V04:ÇÔüȯ°æ¼³Á¤,V05:Àü±¤ÆÇON/OFF½Ã°¢¼³Á¤) if (sCtlType == "V01") sCtlType = lblV01->Caption;//"Àü±¤ÆÇON"; else if (sCtlType == "V02") sCtlType = lblV02->Caption;//"Àü±¤ÆÇOFF"; else if (sCtlType == "V03") sCtlType = lblV03->Caption;//"Á¦¾î±â¸®¼Â"; else if (sCtlType == "V04") sCtlType = lblV04->Caption;//"ÇÔüȯ°æ¼³Á¤"; else if (sCtlType == "V05") sCtlType = lblV05->Caption;//"Àü±¤ÆÇON/OFF½Ã°¢¼³Á¤"; else if (sCtlType == "V06") sCtlType = lblV06->Caption;//"¿î¿µ¸ðµåº¯°æ"; else if (sCtlType == "V07") sCtlType = lblV07->Caption;//"ÈÖµµÁ¦¾î"; else if (sCtlType == "V08") sCtlType = lblV08->Caption;//"±âº»¸Þ½ÃÁö´Ù¿î·Îµå"; else if (sCtlType == "V09") sCtlType = lblV09->Caption;//"Æû Ç¥ÃâÁÖ±â"; else if (sCtlType == "V10") sCtlType = lblV10->Caption;//"Æû Áï½Ã ´Ù¿î·Îµå"; #if 0 if (sCtlType == "V01") sCtlType = "Board On"; else if (sCtlType == "V02") sCtlType = "Board Off"; else if (sCtlType == "V03") sCtlType = "Reset"; else if (sCtlType == "V04") sCtlType = "Parameter Set"; else if (sCtlType == "V05") sCtlType = "Board ON/OFF Time Set"; else if (sCtlType == "V06") sCtlType = "Operating Mode Change"; else if (sCtlType == "V07") sCtlType = "Luminance contorol"; else if (sCtlType == "V08") sCtlType = "Default Message Download"; else if (sCtlType == "V09") sCtlType = "Form Display Cycle Time"; else if (sCtlType == "V10") sCtlType = "Form Immediately Download"; #endif m_pGDC->Values[nRow][Col03->Index] = sCtlType; m_pGDC->Values[nRow][Col04->Index] = ITSUtil_StrToDateTime(pADO->FieldByName("CTRL_DT")->AsString).FormatString(STR_DATETIME); m_pGDC->Values[nRow][Col05->Index] = pADO->FieldByName("CTRL_VAL")->AsString; m_pGDC->Values[nRow][Col06->Index] = pADO->FieldByName("CTRL_RESULT")->AsInteger == 1 ? lblSucc->Caption : lblFai->Caption;//"¼º°ø" : "½ÇÆÐ"; m_pGDC->Values[nRow][Col07->Index] = pADO->FieldByName("USER_ID")->AsString; } } __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 TFrmCctvLogCtrlSub::BtnExlSaveClick(TObject *Sender) { TcxGrid *pGrid = CxList; TcxGridTableView *pView = TvList; String sTitle= Caption; CMM_ExportToExcelFile(sTitle, pGrid, pView, this); } //--------------------------------------------------------------------------- void __fastcall TFrmCctvLogCtrlSub::FormClose(TObject *Sender, TCloseAction &Action) { POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0); CommClose(); } //--------------------------------------------------------------------------- void __fastcall TFrmCctvLogCtrlSub::FormDestroy(TObject *Sender) { // } //--------------------------------------------------------------------------- void __fastcall TFrmCctvLogCtrlSub::Col06CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo, bool &ADone) { try { TColor tColor; String sResult = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index]; tColor = ACanvas->Brush->Color; if (sResult == lblFai->Caption)//"½ÇÆÐ") tColor = clRed; //else tColor = clLime; ACanvas->SetBrushColor(tColor); } catch(Exception &e) { } } //---------------------------------------------------------------------------