123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include "AppGlobalF.h"
- #include "ITSSkinF.h"
- #include "ITSUtilF.h"
- #include "ITSLangTransF.h"
- #pragma hdrstop
- #include "CCAM010MF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "cxButtons"
- #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 resource "*.dfm"
- TCCAM010M *CCAM010M = NULL;
- //---------------------------------------------------------------------------
- __fastcall TCCAM010M::TCCAM010M(TComponent* Owner)
- : TForm(Owner)
- {
- LangTrans->Translate(this, ITSDb_GetConnection());
- ITSSkin_Load(this);
- LoadLocalSkin();
- FTitle = Caption;
- CMM_LoadForm(g_sFormsDir, this);
- }
- //---------------------------------------------------------------------------
- void __fastcall TCCAM010M::CommClose()
- {
- try
- {
- CMM_SaveForm(g_sFormsDir, this);
- }
- catch(...)
- {
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TCCAM010M::FormCreate(TObject *Sender)
- {
- //
- }
- //---------------------------------------------------------------------------
- void __fastcall TCCAM010M::FormShow(TObject *Sender)
- {
- Refresh();
- Application->ProcessMessages();
- TmrShow->Enabled = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TCCAM010M::LoadLocalSkin()
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TCCAM010M::TmrShowTimer(TObject *Sender)
- {
- TmrShow->Enabled = false;
- BtnSearchClick(NULL);
- }
- //---------------------------------------------------------------------------
- void __fastcall TCCAM010M::FormClose(TObject *Sender, TCloseAction &Action)
- {
- try {
- CommClose();
- CCAM010M = NULL;
- Action = caFree;
- } catch(...) {}
- }
- //---------------------------------------------------------------------------
- void __fastcall TCCAM010M::OnMainFormMessage(TMessage &Msg)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TCCAM010M::Refreshtatus(bool ARealtime/*=false*/)
- {
- String sQry;
- TADOQuery *pADO = NULL;
- sQry = "SELECT B.CCAM_CTLR_NMBR, B.CCAM_CTLR_ID, B.CCAM_NM, B.CCAM_CTLR_IP, \r\n"
- " A.UPDT_DT, A.CMNC_STTS_CD \r\n"
- " FROM (SELECT * \r\n"
- " FROM TB_CCAM_CTLR_STTS \r\n"
- " WHERE UPDT_DT >= TO_CHAR(SYSDATE-5/1440, 'YYYYMMDDHH24MISS') \r\n"
- " ) A, \r\n"
- " TB_CCAM_CTLR B \r\n"
- " WHERE A.CCAM_CTLR_NMBR(+) = B.CCAM_CTLR_NMBR \r\n";
- CMM_ClearGridTableView(TvList);
- try
- {
- int nRow;
- TvList->BeginUpdate();
- try
- {
- pADO = new TADOQuery(NULL);
- pADO->Close();
- pADO->Connection = ITSDb_GetConnection();
- pADO->SQL->Clear();
- pADO->SQL->Text = sQry;
- pADO->Prepared = true;
- pADO->Open();
- for( ; !pADO->Eof; pADO->Next())
- {
- nRow = TvList->DataController->AppendRecord();
- TvList->DataController->Values[nRow][ColNmbr->Index] = pADO->FieldByName("CCAM_CTLR_NMBR")->AsString;
- TvList->DataController->Values[nRow][ColId->Index] = pADO->FieldByName("CCAM_CTLR_ID")->AsString;
- TvList->DataController->Values[nRow][ColName->Index] = pADO->FieldByName("CCAM_NM")->AsString;
- String UPDT_DT = pADO->FieldByName("UPDT_DT")->AsString;
- if (UPDT_DT != "")
- {
- TvList->DataController->Values[nRow][ColUpdtDt->Index] = ITSUtil_StrToDateTime(UPDT_DT).FormatString(STR_DATETIME);
- String CMNC_STTS_CD = pADO->FieldByName("CMNC_STTS_CD")->AsString;
- if (CMNC_STTS_CD == "CMS0") TvList->DataController->Values[nRow][ColCommS->Index] = FrmLang->lblComm0->Caption;
- else
- if (CMNC_STTS_CD == "CMS1") TvList->DataController->Values[nRow][ColCommS->Index] = FrmLang->lblComm1->Caption;
- else TvList->DataController->Values[nRow][ColCommS->Index] = FrmLang->lblUnknown->Caption;
- }
- else
- {
- TvList->DataController->Values[nRow][ColUpdtDt->Index] = "-";
- TvList->DataController->Values[nRow][ColCommS->Index] = FrmLang->lblUnknown->Caption;
- }
- }
- }
- catch(EDatabaseError &E)
- {
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- DBERRORMSG("TCCAM010M::Refreshtatus", String(E.ClassName()), E.Message, sQry);
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(Exception &exception)
- {
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- DBERRORMSG("TCCAM010M::Refreshtatus", String(exception.ClassName()), exception.Message, sQry);
- throw Exception(String(exception.ClassName()) + exception.Message);
- }
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- delete pADO;
- }
- TvList->EndUpdate();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TCCAM010M::RefreshData()
- {
- try
- {
- LockWindowUpdate(Handle);
- Refreshtatus();
- }
- __finally
- {
- LockWindowUpdate(0);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TCCAM010M::BtnSearchClick(TObject *Sender)
- {
- RefreshData();
- }
- //---------------------------------------------------------------------------
- void __fastcall TCCAM010M::ColCommSCustomDrawCell(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(...)
- {
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TCCAM010M::BtnCloseClick(TObject *Sender)
- {
- Close();
- }
- //---------------------------------------------------------------------------
|