123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #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)
- {
- }
- }
- //---------------------------------------------------------------------------
|