123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include "ITSSkinF.h"
- #include "ITSUtilF.h"
- #include "ITSDbF.h"
- #include "AppGlobalF.h"
- #include "WindowMsgF.h"
- #include "ITSLangTransF.h"
- #include "ITS_OPLibF.h"
- #pragma hdrstop
- #include "CCAMH101F.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 "cxGridCustomTableView"
- #pragma link "cxGridCustomView"
- #pragma link "cxGridLevel"
- #pragma link "cxGridTableView"
- #pragma link "cxLabel"
- #pragma link "cxLookAndFeelPainters"
- #pragma link "cxLookAndFeels"
- #pragma link "cxStyles"
- #pragma link "cxTextEdit"
- #pragma link "dxSkinBlack"
- #pragma link "dxSkinBlue"
- #pragma link "dxSkinsCore"
- #pragma link "dxSkinscxPCPainter"
- #pragma link "dxSkinMcSkin"
- #pragma resource "*.dfm"
- TCCAMH101 *CCAMH101 = NULL;
- //---------------------------------------------------------------------------
- __fastcall TCCAMH101::TCCAMH101(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;
- //Caption = "CCAM-제어기 상태 이력";
- }
- //---------------------------------------------------------------------------
- __fastcall TCCAMH101::~TCCAMH101(void)
- {
- }
- //--------------------------------------------------------------------------
- void __fastcall TCCAMH101::FormInit()
- {
- ADOQry->Connection = ITSDb_GetConnection();
- m_pGDC = TvList->DataController;
- TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<CCAM-제어기 상태 이력 정보>";
- //TvList->ViewInfo->GroupByBoxViewInfo->Text = "그룹핑할 필드의 헤더를 이곳으로 드래그 하세요";
- LblSearch->Caption = FrmLang->lblQryCond->Caption + FStDateTime.SubString(1, 12) + " ~ " + FEdDateTime.SubString(1, 12);
- }
- //---------------------------------------------------------------------------
- void __fastcall TCCAMH101::FormShow(TObject *Sender)
- {
- FormInit();
- Refresh();
- TmrShow->Enabled = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TCCAMH101::CommClose()
- {
- CMM_SaveForm(g_sFormsDir, this);
- //CCAMH101 = NULL;
- }
- //---------------------------------------------------------------------------
- void __fastcall TCCAMH101::TmrShowTimer(TObject *Sender)
- {
- TmrShow->Enabled = false;
- Application->ProcessMessages();
- SelHistory();
- }
- //---------------------------------------------------------------------------
- void __fastcall TCCAMH101::ChkExpandClick(TObject *Sender)
- {
- CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
- }
- //---------------------------------------------------------------------------
- void __fastcall TCCAMH101::SelHistory()
- {
- TSqlCursor sqlCrs;
- String sQry;
- TADOQuery *pADO = ADOQry;
- #if 0
- sQry = "SELECT A.CCAM_CTLR_NMBR, B.CCAM_CTLR_ID, B.CCAM_CTLR_ID, B.CCAM_NM, A.VIDEO_INPUT, A.CBOX_TMPR, \r\n"
- " NVL(TO_CHAR(TO_DATE(A.CRTN_DT, 'YYYYMMDDHH24MISS'), 'YYYY-MM-DD HH24:MI:SS'), '정보없음') AS CRTN_DT, \r\n"
- " (SELECT CMMN_CD_KOR_NM FROM TB_CMMN_CD WHERE CMMN_CD = A.CMNC_STTS_CD AND CMMN_CLSF_CD = 'CMS') AS CONN_STTS_CD, \r\n"
- " (SELECT CMMN_CD_KOR_NM FROM TB_CMMN_CD WHERE CMMN_CD = A.CBOX_DOOR_STTS_CD AND CMMN_CLSF_CD = 'CDS') AS CBOX_DOOR_STTS_CD, \r\n"
- " (SELECT CMMN_CD_KOR_NM FROM TB_CMMN_CD WHERE CMMN_CD = A.FAN_STTS_CD AND CMMN_CLSF_CD = 'PAS') AS FAN_STTS_CD, \r\n"
- " (SELECT CMMN_CD_KOR_NM FROM TB_CMMN_CD WHERE CMMN_CD = A.HETR_STTS_CD AND CMMN_CLSF_CD = 'HTS') AS HETR_STTS_CD, \r\n"
- " (SELECT CMMN_CD_KOR_NM FROM TB_CMMN_CD WHERE CMMN_CD = A.VIDEO_INPUT AND CMMN_CLSF_CD = 'VDI') AS VIDEO_INPUT_CD \r\n"
- " FROM TB_CCAM_CTLR_STTS_HS A, TB_CCAM_CTLR B \r\n"
- " WHERE A.CRTN_DT BETWEEN :p01 AND :p02 \r\n"
- " AND B.CCAM_CTLR_NMBR IN(" + FIdList + ") \r\n"
- " AND A.CCAM_CTLR_NMBR = B.CCAM_CTLR_NMBR \r\n"
- " ORDER BY A.CCAM_CTLR_NMBR, A.CRTN_DT \r\n";
- #else
- sQry = "SELECT A.*, B.CCAM_CTLR_ID, B.CCAM_NM \r\n"
- " FROM TB_CCAM_CTLR_STTS_HS A, TB_CCAM_CTLR B \r\n"
- " WHERE A.CRTN_DT BETWEEN :p01 AND :p02 \r\n"
- " AND B.CCAM_CTLR_NMBR IN(" + FIdList + ") \r\n"
- " AND A.CCAM_CTLR_NMBR = B.CCAM_CTLR_NMBR \r\n"
- " ORDER BY A.CCAM_CTLR_NMBR, A.CRTN_DT \r\n";
- #endif
- try
- {
- ITSDb_SQLText(pADO, sQry);
- ITSDb_SQLBind(pADO, "p01", FStDateTime);
- ITSDb_SQLBind(pADO, "p02", FEdDateTime);
- ITSDb_SQLOpen(pADO);
- DspHistory();
- }
- catch(EDatabaseError &E)
- {
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- DBERRORMSG(Caption, 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(Caption, String(e.ClassName()), e.Message, sQry);
- throw Exception(String(e.ClassName()) + e.Message);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TCCAMH101::DspHistory()
- {
- TADOQuery *pADO = ADOQry;
- try
- {
- TcxGridChartSeries *pChart = NULL;
- CMM_ClearGridTableView(TvList);
- int nRow = 0;
- int nDataCnt = 0;
- try {
- TvList->BeginUpdate();
- nDataCnt = pADO->RecordCount;
- m_pGDC->RecordCount = nDataCnt;
- for( ; !pADO->Eof; pADO->Next(), nRow++)
- {
- m_pGDC->Values[nRow][Column00->Index] = pADO->FieldByName("CCAM_CTLR_NMBR")->AsString;
- m_pGDC->Values[nRow][Column11->Index] = pADO->FieldByName("CCAM_CTLR_ID")->AsString;
- String sDbDate = pADO->FieldByName("CRTN_DT")->AsString;
- m_pGDC->Values[nRow][Column01->Index] = APP_FormatStr(sDbDate, STR_DATETIME);
- m_pGDC->Values[nRow][Column09->Index] = pADO->FieldByName("CCAM_NM")->AsString;
- String CMNC_STTS_CD = pADO->FieldByName("CMNC_STTS_CD")->AsString;
- if (CMNC_STTS_CD == "CMS0") m_pGDC->Values[nRow][Column02->Index] = FrmLang->lblComm0->Caption;
- else
- if (CMNC_STTS_CD == "CMS1") m_pGDC->Values[nRow][Column02->Index] = FrmLang->lblComm1->Caption;
- else m_pGDC->Values[nRow][Column02->Index] = FrmLang->lblUnknown->Caption;
- #if 0
- String sCmnc = pADO->FieldByName("CONN_STTS_CD")->AsString;
- //String sPwer = pADO->FieldByName("PRNT_PWER_STTS_CD")->AsString;
- String sDoor = pADO->FieldByName("CBOX_DOOR_STTS_CD")->AsString;
- String sFan = pADO->FieldByName("FAN_STTS_CD")->AsString;
- String sHetr = pADO->FieldByName("HETR_STTS_CD")->AsString;
- String sTmpr = pADO->FieldByName("CBOX_TMPR")->AsString;
- m_pGDC->Values[nRow][Column09->Index] = pADO->FieldByName("CCAM_NM")->AsString;
- m_pGDC->Values[nRow][Column02->Index] = sCmnc;
- //m_pGDC->Values[nRow][Column03->Index] = sPwer;
- m_pGDC->Values[nRow][Column04->Index] = sDoor;
- m_pGDC->Values[nRow][Column05->Index] = sFan;
- m_pGDC->Values[nRow][Column06->Index] = sHetr;
- m_pGDC->Values[nRow][Column10->Index] = sTmpr;
- m_pGDC->Values[nRow][Column07->Index] = pADO->FieldByName("VIDEO_INPUT_CD")->AsString;
- //m_pGDC->Values[nRow][Column08->Index] = pADO->FieldByName("VIDEO_INPUT")->AsString;
- #endif
- }
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- }
- TvList->EndUpdate();
- //CxList->SetFocus();
- LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + FrmLang->lblEA->Caption;//" 건";
- String sEnd = FrmLang->lblQrySel->Caption + " [" + LblRecords->Caption + "]";//"데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
- Application->MessageBox(sEnd.c_str(),
- FrmLang->lblQryEnd->Caption.c_str(),//L"데이터 조회 완료",
- MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
- }
- }
- catch(EDatabaseError &E)
- {
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- DBERRORMSG(Caption, String(E.ClassName()), E.Message, pADO->SQL->Text);
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(Exception &e)
- {
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- DBERRORMSG(Caption, String(e.ClassName()), e.Message, pADO->SQL->Text);
- throw Exception(String(e.ClassName()) + e.Message);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TCCAMH101::OnMessage(TMessage &Msg)
- {
- switch (Msg.Msg)
- {
- case WM_PARAM_DATABASE:
- if (WP_DB_SELECT_OK == Msg.WParam)
- {
- //ShowMessage("Select Ok");
- }
- break;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TCCAMH101::BtnExlSaveClick(TObject *Sender)
- {
- TcxGrid *pGrid = CxList;
- TcxGridTableView *pView = TvList;
- String sTitle= Caption;//"CCAM-제어기 상태이력";
- CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
- }
- //---------------------------------------------------------------------------
- void __fastcall TCCAMH101::FormClose(TObject *Sender, TCloseAction &Action)
- {
- POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
- CommClose();
- //CCAMH101 = NULL;
- }
- //---------------------------------------------------------------------------
- void __fastcall TCCAMH101::Column02CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
- bool &ADone)
- {
- TColor tColor = ACanvas->Brush->Color;
- TColor tFont = clBlack;
- try
- {
- if (!VarIsNull(AViewInfo->Value))
- {
- String sTmp = AViewInfo->Value;
- if (sTmp == FrmLang->lblComm0->Caption)
- {
- tColor = clLime;
- }
- else
- if (sTmp == FrmLang->lblComm1->Caption)
- {
- tColor = clRed;
- }
- else
- {
- tColor = clSilver;
- }
- }
- ACanvas->Font->Color = tFont;
- ACanvas->SetBrushColor(tColor);
- }
- catch(...)
- {
- }
- #if 0
- if( AViewInfo )
- {
- if(AViewInfo->Text == "정상")
- {
- ACanvas->Canvas->Font->Color = clTeal;
- }
- else if(AViewInfo->Text == "장애")
- {
- ACanvas->Canvas->Font->Color = clFuchsia;
- }
- else
- {
- ACanvas->Canvas->Font->Color = clGray;
- }
- }
- #endif
- }
- //---------------------------------------------------------------------------
|