123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include "ITSSkinF.h"
- #include "ITSUtilF.h"
- #include "ITSDbF.h"
- #include "AppGlobalF.h"
- #include "WindowMsgF.h"
- #include "CDSFacilityF.h"
- #include "ITSLangTransF.h"
- #pragma hdrstop
- #include "CRSM000MF.h"
- #include "FrmMainF.h"
- #include "ITS_OPLibF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "cxButtons"
- #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 "cxGridBandedTableView"
- #pragma link "cxGridCustomTableView"
- #pragma link "cxGridCustomView"
- #pragma link "cxGridLevel"
- #pragma link "cxGridTableView"
- #pragma link "cxGroupBox"
- #pragma link "cxLabel"
- #pragma link "cxLookAndFeelPainters"
- #pragma link "cxLookAndFeels"
- #pragma link "cxStyles"
- #pragma link "cxTextEdit"
- #pragma link "dxSkinBlue"
- #pragma link "dxSkinsCore"
- #pragma link "dxSkinscxPCPainter"
- #pragma link "dxSkinBlack"
- #pragma link "dxSkinMcSkin"
- #pragma resource "*.dfm"
- TCRSM000M *CRSM000M = NULL;
- //---------------------------------------------------------------------------
- __fastcall TCRSM000M::TCRSM000M(TComponent* Owner)
- : TForm(Owner)
- {
- LangTrans->Translate(this, ITSDb_GetConnection());
- ITSSkin_Load(this);
- CMM_LoadForm(g_sFormsDir, this);
- FTitle = Caption;
- FFacilityType = "";
- }
- //---------------------------------------------------------------------------
- void __fastcall TCRSM000M::CommClose()
- {
- try
- {
- CMM_SaveForm(g_sFormsDir, this);
- }
- catch(...)
- {
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TCRSM000M::FormShow(TObject *Sender)
- {
- Refresh();
- FormInit();
- TmrShow->Enabled = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TCRSM000M::FormInit()
- {
- //TvList->OptionsView->NoDataToDisplayInfoText = "<교차로교통량 CCTV 상태현황>";
- }
- //---------------------------------------------------------------------------
- void __fastcall TCRSM000M::TmrShowTimer(TObject *Sender)
- {
- TmrShow->Enabled = false;
- RefreshData();
- }
- //---------------------------------------------------------------------------
- void __fastcall TCRSM000M::BtnSearchClick(TObject *Sender)
- {
- BtnSearch->Enabled = false;
- TmrShow->Enabled = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TCRSM000M::RefreshData()
- {
- BtnSearch->Enabled = false;
- UpdateFacility();
- BtnSearch->Enabled = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TCRSM000M::BtnCloseClick(TObject *Sender)
- {
- Close();
- }
- //---------------------------------------------------------------------------
- void __fastcall TCRSM000M::FormClose(TObject *Sender, TCloseAction &Action)
- {
- CommClose();
- CRSM000M = NULL;
- Action = caFree;
- }
- //---------------------------------------------------------------------------
- void __fastcall TCRSM000M::UpdateFacility()
- {
- String sQry;
- TADOQuery *pADO = NULL;
- sQry = "SELECT A.CROSS_ID, A.NAME AS CROSS_NAME, A.CROSS_TYPE, \r\n"
- " B.CAM_ID, B.NAME AS CAM_NAME, \r\n"
- " TO_CHAR(C.CAP_DATE, 'YYYYMMDDHH24MISS') AS CLCT_DATE, \r\n"
- " (CASE WHEN NVL(C.CAP_DATE, SYSDATE-60/140) < SYSDATE - 10/1440 \r\n"
- " THEN 'Y' ELSE 'N' END) AS MISSING, \r\n"
- " C.STATUS \r\n"
- " FROM MST_CROSS A, MST_CCAM B, COL_CCAM_STATUS C \r\n"
- " WHERE A.CROSS_ID = B.CROSS_ID \r\n"
- " AND B.CAM_ID = C.CAM_ID(+) \r\n"
- " AND A.DEL_YN = 'N' \r\n"
- " AND B.DEL_YN = 'N' \r\n"
- " ORDER BY A.CROSS_ID, B.CAM_ID \r\n";
- try
- {
- int nRow = 0;
- int nDataCnt = 0;
- TcxDataController *pGDC = TvList->DataController;
- try
- {
- pADO = new TADOQuery(NULL);
- pADO->Close();
- pADO->Connection = ITSDb_GetConnection();
- pADO->SQL->Clear();
- pADO->SQL->Text = sQry;
- pADO->Prepared = true;
- pADO->Open();
- CMM_ClearGridTableView(TvList);
- TvList->BeginUpdate();
- nDataCnt = pADO->RecordCount;
- pGDC->RecordCount = nDataCnt;
- for( ; !pADO->Eof; pADO->Next(), nRow++)
- {
- String CROSS_ID = pADO->FieldByName("CROSS_ID")->AsString;
- String CROSS_NAME = pADO->FieldByName("CROSS_NAME")->AsString;
- pGDC->Values[nRow][Col00->Index] = CROSS_ID + ": " + CROSS_NAME;
- pGDC->Values[nRow][Col10->Index] = CROSS_ID;
- pGDC->Values[nRow][Col01->Index] = CROSS_NAME;
- pGDC->Values[nRow][Col15->Index] = pADO->FieldByName("CROSS_TYPE")->AsString;
- pGDC->Values[nRow][Col11->Index] = pADO->FieldByName("CAM_ID")->AsString;
- pGDC->Values[nRow][Col05->Index] = pADO->FieldByName("CAM_NAME")->AsString;
- String CLCT_DATE = pADO->FieldByName("CLCT_DATE")->AsString;
- pGDC->Values[nRow][Col06->Index] = APP_FormatStr(CLCT_DATE, STR_DATETIME);
- //pGDC->Values[nRow][Col07->Index] = pADO->FieldByName("STATUS")->AsString;
- String MISSING = pADO->FieldByName("MISSING")->AsString;
- String STATUS = pADO->FieldByName("STATUS")->AsString;
- if (MISSING == "Y" || STATUS != "1")
- {
- pGDC->Values[nRow][Col07->Index] = "이상";
- }
- else
- {
- pGDC->Values[nRow][Col07->Index] = "정상";
- }
- }
- }
- catch(EDatabaseError &E)
- {
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- DBERRORMSG("TCRSM000M::UpdateFacility", String(E.ClassName()), E.Message, sQry);
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(Exception &e)
- {
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- DBERRORMSG("TCRSM000M::UpdateFacility", String(e.ClassName()), e.Message, sQry);
- throw Exception(String(e.ClassName()) + e.Message);
- }
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- delete pADO;
- }
- TvList->EndUpdate();
- }
- CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
- }
- //---------------------------------------------------------------------------
- void __fastcall TCRSM000M::BtnExlSaveClick(TObject *Sender)
- {
- TcxGrid *pGrid = CxList;
- TcxGridTableView *pView = TvList;
- String sTitle= FTitle;
- CMM_ExportToExcelFile(sTitle, pGrid, pView, (TForm*)this);
- }
- //---------------------------------------------------------------------------
- void __fastcall TCRSM000M::ChkExpandClick(TObject *Sender)
- {
- CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
- }
- //---------------------------------------------------------------------------
- void __fastcall TCRSM000M::TvListDataControllerFilterChanged(TObject *Sender)
- {
- CMM_SetFilterLike(TvList);
- }
- //---------------------------------------------------------------------------
- void __fastcall TCRSM000M::Col07CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas,
- TcxGridTableDataCellViewInfo *AViewInfo, bool &ADone)
- {
- if( AViewInfo )
- {
- if(AViewInfo->Text == "정상")
- {
- ACanvas->Canvas->Font->Color = clTeal;
- }
- //else if(AViewInfo->Text == "통신장애")
- //{
- // ACanvas->Canvas->Font->Color = clRed;
- //}
- else if(AViewInfo->Text == "알수없음")
- {
- ACanvas->Canvas->Font->Color = clGray;
- }
- else
- {
- ACanvas->Canvas->Font->Color = clRed;
- //ACanvas->Canvas->Font->Color = clFuchsia;
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TCRSM000M::Col09CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas,
- TcxGridTableDataCellViewInfo *AViewInfo, bool &ADone)
- {
- if( AViewInfo )
- {
- if(AViewInfo->Text == "정상")
- {
- ACanvas->Canvas->Font->Color = clTeal;
- }
- else
- {
- ACanvas->Canvas->Font->Color = clRed;
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TCRSM000M::Col26CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
- bool &ADone)
- {
- if( AViewInfo )
- {
- if(AViewInfo->Text == "정상")
- {
- ACanvas->Canvas->Font->Color = clTeal;
- }
- else
- {
- ACanvas->Canvas->Font->Color = clRed;
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TCRSM000M::Col16CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
- bool &ADone)
- {
- //앞문/뒷문
- if( AViewInfo )
- {
- if(AViewInfo->Text == "닫힘")
- {
- ACanvas->Canvas->Font->Color = clTeal;
- }
- else
- {
- ACanvas->Canvas->Font->Color = clRed;
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TCRSM000M::Col18CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
- bool &ADone)
- {
- //팬/히터
- if( AViewInfo )
- {
- if(AViewInfo->Text == "중지")
- {
- ACanvas->Canvas->Font->Color = clTeal;
- }
- else
- {
- ACanvas->Canvas->Font->Color = clRed;
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TCRSM000M::Col20CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
- bool &ADone)
- {
- //비디오입력
- if( AViewInfo )
- {
- if(AViewInfo->Text.Pos("정상"))
- {
- ACanvas->Canvas->Font->Color = clTeal;
- }
- else
- {
- ACanvas->Canvas->Font->Color = clRed;
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TCRSM000M::Col21CustomDrawCell(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)
- {
- }
- }
- //---------------------------------------------------------------------------
|