//---------------------------------------------------------------------------

#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 "IFM0070MF.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "cxButtons"
#pragma link "cxCalendar"
#pragma link "cxClasses"
#pragma link "cxContainer"
#pragma link "cxControls"
#pragma link "cxCustomData"
#pragma link "cxData"
#pragma link "cxDataStorage"
#pragma link "cxDropDownEdit"
#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 "cxMaskEdit"
#pragma link "cxPC"
#pragma link "cxPCdxBarPopupMenu"
#pragma link "cxSpinEdit"
#pragma link "cxStyles"
#pragma link "cxTextEdit"
#pragma link "cxTimeEdit"
#pragma link "dxSkinBlack"
#pragma link "dxSkinBlue"
#pragma link "dxSkinsCore"
#pragma link "dxSkinscxPCPainter"
#pragma link "dxSkinMcSkin"
#pragma resource "*.dfm"

TIFM0070M *IFM0070M = NULL;
//---------------------------------------------------------------------------
__fastcall TIFM0070M::TIFM0070M(TComponent* Owner)
	: TForm(Owner)
{
    LangTrans->Translate(this, ITSDb_GetConnection());
    ITSSkin_Load(this);
    CMM_LoadForm(g_sFormsDir, this);

    FTitle = Caption;//"운영자 접속 이력조회";

    CbType->ItemIndex = 0;
}
//---------------------------------------------------------------------------

void __fastcall TIFM0070M::FormShow(TObject *Sender)
{
    PgList->ActivePageIndex = 0;

    // form 초기화
    FormInit();
}
//---------------------------------------------------------------------------

void __fastcall TIFM0070M::FormInit()
{
    ADOQry->Connection = ITSDb_GetConnection();
    m_pGDC = TvList->DataController;

    TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<운영자 접속 이력 정보>";

    if (BtnSearch->Enabled)
        BtnSearch->SetFocus();
}
//---------------------------------------------------------------------------

void __fastcall TIFM0070M::CommClose()
{
    try
    {
        CMM_SaveForm(g_sFormsDir, this);
    }
    catch(...)
    {
    }
}
//---------------------------------------------------------------------------

void __fastcall TIFM0070M::TmrRefreshTimer(TObject *Sender)
{
	TmrRefresh->Enabled = false;
}
//---------------------------------------------------------------------------

void __fastcall TIFM0070M::BtnExlSaveClick(TObject *Sender)
{
    TcxGrid          *pGrid = CxList;
    TcxGridTableView *pView = TvList;
    String            sTitle= lblFacility->Caption;

    CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
}
//---------------------------------------------------------------------------

void __fastcall TIFM0070M::BtnSearchClick(TObject *Sender)
{
    Application->ProcessMessages();
    TSqlCursor sqlCrs((TControl*)BtnSearch);

	RefreshData();
}
//---------------------------------------------------------------------------

void __fastcall TIFM0070M::RefreshData()
{
    CMM_ClearGridTableView(TvList);

//  CCTV
//  VMS
//  웹카메라
//  교차로교통량 교차로
//  교차로교통량 카메라
//  차량번호인식 카메라
    try
    {
        ADOQry->Connection = ITSDb_GetConnection();
        m_pGDC = TvList->DataController;

        TvList->BeginUpdate();

        lblFacility->Caption = CbType->Text.Trim();

        int nSelType = CbType->ItemIndex;
        if (nSelType == 3)
        {
            Column12->Visible = false;  // IP Address
            Column13->Visible = true;   // 교차로
            Column03->Visible = false;  // 시설물명
            Column04->Visible = false;
            Column01->Visible = false;
            Column07->Visible = false;
            Column08->Visible = false;
            Column09->Visible = false;
            Column10->Visible = false;
            Column02->Caption = "교차로 ID";
        }
        else
        {
            Column12->Visible = true;  // IP Address
            Column13->Visible = false; // 교차로
            Column04->Visible = true;
            Column03->Visible = true;  // 시설물명
            Column01->Visible = true;
            Column07->Visible = true;
            Column08->Visible = true;
            Column09->Visible = true;
            Column10->Visible = true;
            Column02->Caption = "시설물 ID";
            Column01->Caption = "관리번호";
        }
        if (nSelType == 6)
        {
            Column01->Visible = false;  // 관리번호
            Column13->Visible = true;   // 교차로명
        }
        if (nSelType == 4)
        {
            //Column01->Visible = false;  // 관리번호
            Column01->Caption = "교차로 ID";
            //Column02->Visible = true;
        }

        switch(nSelType)
        {
        case 0: SelCctv();    break; //CCTV
        case 1: SelVms();     break; //VMS
        case 2: SelWCam();    break; //웹카메라
        case 3: SelCrs();     break; //교차로교통량
        case 4: SelCrsCam();  break; //교차로교통량 카메라
        case 5: SelLprsCam(); break; //차량번호인식 카메라
        default: return;
        }
    }
    __finally
    {
        TvList->EndUpdate();
		TvList->ApplyBestFit(NULL, false, false);
        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);
    }
}
//---------------------------------------------------------------------------

void __fastcall TIFM0070M::SelCctv()
{
    String sQry;
    TADOQuery *pADO = ADOQry;

    sQry = "SELECT X.CCTV_MNGM_NMBR AS FCLT_NMBR,                                                            \r\n"
           "       X.CCTV_CTLR_ID   AS FCLT_ID,                                                              \r\n"
           "       X.ISTL_LCTN_NM   AS LCTN_NM,                                                              \r\n"
           "       X.ISTL_LCTN_ADDR AS LCTN_ADDR,                                                            \r\n"
           "       X.X_CRDN         AS X_CRDN,                                                               \r\n"
           "       X.Y_CRDN         AS Y_CRDN,                                                               \r\n"
           "       'CCTV'           AS FCLT_TYPE_NM,                                                         \r\n"
           "       Y.ISTL_LCTN_ADDR AS FCLT_ISTL_LCTN_ADDR,                                                  \r\n"
           "       Y.ISTL_CMPY_NM   AS FCLT_ISTL_CMPY_NM,                                                    \r\n"
           "       Y.MNFC_CMPY_NM   AS FCLT_MNFC_CMPY_NM,                                                    \r\n"
           "       Y.MDL_NM         AS FCLT_MDL_NM,                                                          \r\n"
           "       X.CCTV_CTLR_IP   AS IP_ADDR,                                                              \r\n"
           "       Y.ISTL_DT        AS FCLT_ISTL_DT                                                          \r\n"
           " FROM TB_CCTV_CTLR X,                                                                            \r\n"
           "      (SELECT A.FCLT_ID, A.FCLT_TYPE, A.FCLT_LCTN, A.MDL_NM, A.ISTL_DT, A.ISTL_LCTN_ADDR,        \r\n"
           "              (SELECT CMPY_NM FROM TB_FCLT_CMPY WHERE CMPY_ID = ISTL_CMPY_ID) AS ISTL_CMPY_NM,   \r\n"
           "              (SELECT CMPY_NM FROM TB_FCLT_CMPY WHERE CMPY_ID = MNFC_CMPY_ID) AS MNFC_CMPY_NM    \r\n"
           "         FROM TB_FCLT_INFR A                                                                     \r\n"
           "      )Y                                                                                         \r\n"
           " WHERE 1 = 1                                                                                     \r\n"
           "   AND Y.FCLT_TYPE    = 'CCTV'                                                                   \r\n"
           "   AND X.DEL_YN       = 'N'                                                                      \r\n"
           "   AND X.CCTV_CTLR_ID = Y.FCLT_ID(+)                                                             \r\n"
           " ORDER BY X.CCTV_MNGM_NMBR                                                                       \r\n";

    int nRow = 0;
    try
    {
        ITSDb_SQLText(pADO, sQry);
        ITSDb_SQLOpen(pADO);

        m_pGDC->RecordCount = pADO->RecordCount;

        for( ; !pADO->Eof; pADO->Next(), nRow++)
        {
            m_pGDC->Values[nRow][Column01->Index] = pADO->FieldByName("FCLT_NMBR")->AsString;
            m_pGDC->Values[nRow][Column02->Index] = pADO->FieldByName("FCLT_ID")->AsString;
            m_pGDC->Values[nRow][Column03->Index] = pADO->FieldByName("LCTN_NM")->AsString;
            m_pGDC->Values[nRow][Column04->Index] = pADO->FieldByName("FCLT_ISTL_LCTN_ADDR")->AsString;
            m_pGDC->Values[nRow][Column05->Index] = FormatFloat("###.#######0", pADO->FieldByName("X_CRDN")->AsFloat);
            m_pGDC->Values[nRow][Column06->Index] = FormatFloat("###.#######0", pADO->FieldByName("Y_CRDN")->AsFloat);
            m_pGDC->Values[nRow][Column07->Index] = pADO->FieldByName("FCLT_MDL_NM")->AsString;

            String ISTL_DT = pADO->FieldByName("FCLT_ISTL_DT")->AsString;
            m_pGDC->Values[nRow][Column08->Index] = APP_FormatStr(ISTL_DT, STR_DATE);
            m_pGDC->Values[nRow][Column09->Index] = pADO->FieldByName("FCLT_MNFC_CMPY_NM")->AsString;
            m_pGDC->Values[nRow][Column10->Index] = pADO->FieldByName("FCLT_ISTL_CMPY_NM")->AsString;
            m_pGDC->Values[nRow][Column11->Index] = pADO->FieldByName("FCLT_TYPE_NM")->AsString;
            m_pGDC->Values[nRow][Column12->Index] = pADO->FieldByName("IP_ADDR")->AsString;
        }
    }
    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 TIFM0070M::SelVms()
{
    String sQry;
    TADOQuery *pADO = ADOQry;

    sQry = "SELECT X.VMS_CTLR_NMBR  AS FCLT_NMBR,                                                            \r\n"
           "       X.VMS_CTLR_ID    AS FCLT_ID,                                                              \r\n"
           "       X.VMS_NM         AS LCTN_NM,                                                              \r\n"
           "       X.ISTL_LCTN_ADDR AS LCTN_ADDR,                                                            \r\n"
           "       X.X_CRDN         AS X_CRDN,                                                               \r\n"
           "       X.Y_CRDN         AS Y_CRDN,                                                               \r\n"
           "       'VMS'            AS FCLT_TYPE_NM,                                                         \r\n"
           "       Y.ISTL_LCTN_ADDR AS FCLT_ISTL_LCTN_ADDR,                                                  \r\n"
           "       Y.ISTL_CMPY_NM   AS FCLT_ISTL_CMPY_NM,                                                    \r\n"
           "       Y.MNFC_CMPY_NM   AS FCLT_MNFC_CMPY_NM,                                                    \r\n"
           "       Y.MDL_NM         AS FCLT_MDL_NM,                                                          \r\n"
           "       X.VMS_CTLR_IP    AS IP_ADDR,                                                              \r\n"
           "       Y.ISTL_DT        AS FCLT_ISTL_DT                                                          \r\n"
           " FROM TB_VMS_CTLR X,                                                                             \r\n"
           "      (SELECT A.FCLT_ID, A.FCLT_TYPE, A.FCLT_LCTN, A.MDL_NM, A.ISTL_DT, A.ISTL_LCTN_ADDR,        \r\n"
           "              (SELECT CMPY_NM FROM TB_FCLT_CMPY WHERE CMPY_ID = ISTL_CMPY_ID) AS ISTL_CMPY_NM,   \r\n"
           "              (SELECT CMPY_NM FROM TB_FCLT_CMPY WHERE CMPY_ID = MNFC_CMPY_ID) AS MNFC_CMPY_NM    \r\n"
           "         FROM TB_FCLT_INFR A                                                                     \r\n"
           "      )Y                                                                                         \r\n"
           " WHERE 1 = 1                                                                                     \r\n"
           "   AND Y.FCLT_TYPE    = 'VMS'                                                                    \r\n"
           "   AND X.DEL_YN       = 'N'                                                                      \r\n"
           "   AND X.VMS_CTLR_ID  = Y.FCLT_ID(+)                                                             \r\n"
           " ORDER BY X.VMS_CTLR_NMBR                                                                        \r\n";

    int nRow = 0;
    try
    {
        ITSDb_SQLText(pADO, sQry);
        ITSDb_SQLOpen(pADO);

        m_pGDC->RecordCount = pADO->RecordCount;

        for( ; !pADO->Eof; pADO->Next(), nRow++)
        {
            m_pGDC->Values[nRow][Column01->Index] = pADO->FieldByName("FCLT_NMBR")->AsString;
            m_pGDC->Values[nRow][Column02->Index] = pADO->FieldByName("FCLT_ID")->AsString;
            m_pGDC->Values[nRow][Column03->Index] = pADO->FieldByName("LCTN_NM")->AsString;
            m_pGDC->Values[nRow][Column04->Index] = pADO->FieldByName("FCLT_ISTL_LCTN_ADDR")->AsString;
            m_pGDC->Values[nRow][Column05->Index] = FormatFloat("###.#######0", pADO->FieldByName("X_CRDN")->AsFloat);
            m_pGDC->Values[nRow][Column06->Index] = FormatFloat("###.#######0", pADO->FieldByName("Y_CRDN")->AsFloat);
            m_pGDC->Values[nRow][Column07->Index] = pADO->FieldByName("FCLT_MDL_NM")->AsString;

            String ISTL_DT = pADO->FieldByName("FCLT_ISTL_DT")->AsString;
            m_pGDC->Values[nRow][Column08->Index] = APP_FormatStr(ISTL_DT, STR_DATE);
            m_pGDC->Values[nRow][Column09->Index] = pADO->FieldByName("FCLT_MNFC_CMPY_NM")->AsString;
            m_pGDC->Values[nRow][Column10->Index] = pADO->FieldByName("FCLT_ISTL_CMPY_NM")->AsString;
            m_pGDC->Values[nRow][Column11->Index] = pADO->FieldByName("FCLT_TYPE_NM")->AsString;
            m_pGDC->Values[nRow][Column12->Index] = pADO->FieldByName("IP_ADDR")->AsString;
        }
    }
    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 TIFM0070M::SelVds()
{
    String sQry;
    TADOQuery *pADO = ADOQry;

    sQry = "SELECT X.VDS_CTLR_NMBR  AS FCLT_NMBR,                                                            \r\n"
           "       X.VDS_CTLR_ID    AS FCLT_ID,                                                              \r\n"
           "       X.VDS_NM         AS LCTN_NM,                                                              \r\n"
           "       X.ISTL_LCTN_ADDR AS LCTN_ADDR,                                                            \r\n"
           "       X.X_CRDN         AS X_CRDN,                                                               \r\n"
           "       X.Y_CRDN         AS Y_CRDN,                                                               \r\n"
           "       'VDS'            AS FCLT_TYPE_NM,                                                         \r\n"
           "       Y.ISTL_LCTN_ADDR AS FCLT_ISTL_LCTN_ADDR,                                                  \r\n"
           "       Y.ISTL_CMPY_NM   AS FCLT_ISTL_CMPY_NM,                                                    \r\n"
           "       Y.MNFC_CMPY_NM   AS FCLT_MNFC_CMPY_NM,                                                    \r\n"
           "       Y.MDL_NM         AS FCLT_MDL_NM,                                                          \r\n"
           "       X.VDS_CTLR_IP    AS IP_ADDR,                                                              \r\n"
           "       Y.ISTL_DT        AS FCLT_ISTL_DT                                                          \r\n"
           " FROM TB_VDS_CTLR X,                                                                             \r\n"
           "      (SELECT A.FCLT_ID, A.FCLT_TYPE, A.FCLT_LCTN, A.MDL_NM, A.ISTL_DT, A.ISTL_LCTN_ADDR,        \r\n"
           "              (SELECT CMPY_NM FROM TB_FCLT_CMPY WHERE CMPY_ID = ISTL_CMPY_ID) AS ISTL_CMPY_NM,   \r\n"
           "              (SELECT CMPY_NM FROM TB_FCLT_CMPY WHERE CMPY_ID = MNFC_CMPY_ID) AS MNFC_CMPY_NM    \r\n"
           "         FROM TB_FCLT_INFR A                                                                     \r\n"
           "      )Y                                                                                         \r\n"
           " WHERE 1 = 1                                                                                     \r\n"
           "   AND Y.FCLT_TYPE    = 'VDS'                                                                    \r\n"
           "   AND X.DEL_YN       = 'N'                                                                      \r\n"
           "   AND X.VDS_CTLR_ID  = Y.FCLT_ID(+)                                                             \r\n"
           " ORDER BY X.VDS_CTLR_NMBR                                                                        \r\n";

    int nRow = 0;
    try
    {
        ITSDb_SQLText(pADO, sQry);
        ITSDb_SQLOpen(pADO);

        m_pGDC->RecordCount = pADO->RecordCount;

        for( ; !pADO->Eof; pADO->Next(), nRow++)
        {
            m_pGDC->Values[nRow][Column01->Index] = pADO->FieldByName("FCLT_NMBR")->AsString;
            m_pGDC->Values[nRow][Column02->Index] = pADO->FieldByName("FCLT_ID")->AsString;
            m_pGDC->Values[nRow][Column03->Index] = pADO->FieldByName("LCTN_NM")->AsString;
            m_pGDC->Values[nRow][Column04->Index] = pADO->FieldByName("FCLT_ISTL_LCTN_ADDR")->AsString;
            m_pGDC->Values[nRow][Column05->Index] = FormatFloat("###.#######0", pADO->FieldByName("X_CRDN")->AsFloat);
            m_pGDC->Values[nRow][Column06->Index] = FormatFloat("###.#######0", pADO->FieldByName("Y_CRDN")->AsFloat);
            m_pGDC->Values[nRow][Column07->Index] = pADO->FieldByName("FCLT_MDL_NM")->AsString;

            String ISTL_DT = pADO->FieldByName("FCLT_ISTL_DT")->AsString;
            m_pGDC->Values[nRow][Column08->Index] = APP_FormatStr(ISTL_DT, STR_DATE);
            m_pGDC->Values[nRow][Column09->Index] = pADO->FieldByName("FCLT_MNFC_CMPY_NM")->AsString;
            m_pGDC->Values[nRow][Column10->Index] = pADO->FieldByName("FCLT_ISTL_CMPY_NM")->AsString;
            m_pGDC->Values[nRow][Column11->Index] = pADO->FieldByName("FCLT_TYPE_NM")->AsString;
            m_pGDC->Values[nRow][Column12->Index] = pADO->FieldByName("IP_ADDR")->AsString;
        }
    }
    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 TIFM0070M::SelWCam()
{
    String sQry;
    TADOQuery *pADO = ADOQry;

#ifdef USE_WEB_CMRA
    sQry = "SELECT X.WEB_CMRA_NMBR  AS FCLT_NMBR,                                                                \r\n"
           "       X.WEB_CMRA_ID    AS FCLT_ID,                                                                  \r\n"
           "       X.ISTL_LCTN_NM   AS LCTN_NM,                                                                  \r\n"
           "       X.ISTL_LCTN_ADDR AS LCTN_ADDR,                                                                \r\n"
           "       X.X_CRDN         AS X_CRDN,                                                                   \r\n"
           "       X.Y_CRDN         AS Y_CRDN,                                                                   \r\n"
           "       X.CMRA_IP        AS IP_ADDR,                                                                  \r\n"
           "       '웹카메라'       AS FCLT_TYPE_NM,                                                             \r\n"
           "       Y.ISTL_LCTN_ADDR AS FCLT_ISTL_LCTN_ADDR,                                                      \r\n"
           "       Y.ISTL_CMPY_NM   AS FCLT_ISTL_CMPY_NM,                                                        \r\n"
           "       Y.MNFC_CMPY_NM   AS FCLT_MNFC_CMPY_NM,                                                        \r\n"
           "       Y.MDL_NM         AS FCLT_MDL_NM,                                                              \r\n"
           "       Y.ISTL_DT        AS FCLT_ISTL_DT                                                              \r\n"
           "  FROM TB_WEB_CMRA X,                                                                                \r\n"
           "       (SELECT A.FCLT_ID, A.FCLT_TYPE, A.FCLT_LCTN, A.MDL_NM, A.ISTL_DT, A.ISTL_LCTN_ADDR,           \r\n"
           "               (SELECT CMPY_NM FROM TB_FCLT_CMPY WHERE CMPY_ID = ISTL_CMPY_ID) AS ISTL_CMPY_NM,      \r\n"
           "               (SELECT CMPY_NM FROM TB_FCLT_CMPY WHERE CMPY_ID = MNFC_CMPY_ID) AS MNFC_CMPY_NM       \r\n"
           "           FROM TB_FCLT_INFR A                                                                       \r\n"
           "       )Y                                                                                            \r\n"
           " WHERE 1 = 1                                                                                         \r\n"
           "   AND Y.FCLT_TYPE    = 'WCAM'                                                                       \r\n"
           "   AND X.DEL_YN       = 'N'                                                                          \r\n"
           "   AND X.WEB_CMRA_ID = Y.FCLT_ID(+)                                                                  \r\n"
           " ORDER BY X.WEB_CMRA_NMBR                                                                            \r\n";
#else
    sQry = "SELECT X.WCAM_CTLR_NMBR AS FCLT_NMBR,                                                            \r\n"
           "       X.WCAM_CTLR_ID   AS FCLT_ID,                                                              \r\n"
           "       X.WCAM_NM        AS LCTN_NM,                                                              \r\n"
           "       X.ISTL_LCTN_ADDR AS LCTN_ADDR,                                                            \r\n"
           "       X.X_CRDN         AS X_CRDN,                                                               \r\n"
           "       X.Y_CRDN         AS Y_CRDN,                                                               \r\n"
           "       X.WCAM_CTLR_IP   AS IP_ADDR,                                                              \r\n"
           "       (SELECT CMMN_CD_KOR_NM                                                                    \r\n"
           "          FROM TB_CMMN_CD                                                                        \r\n"
           "         WHERE CMMN_CLSF_CD = 'WCAM'                                                             \r\n"
           "           AND CMMN_CD      = X.WCAM_TYPE_CD) AS FCLT_TYPE_NM,                                   \r\n"
           "       Y.ISTL_LCTN_ADDR AS FCLT_ISTL_LCTN_ADDR,                                                  \r\n"
           "       Y.ISTL_CMPY_NM   AS FCLT_ISTL_CMPY_NM,                                                    \r\n"
           "       Y.MNFC_CMPY_NM   AS FCLT_MNFC_CMPY_NM,                                                    \r\n"
           "       Y.MDL_NM         AS FCLT_MDL_NM,                                                          \r\n"
           "       Y.ISTL_DT        AS FCLT_ISTL_DT                                                          \r\n"
           " FROM TB_WCAM_CTLR X,                                                                            \r\n"
           "      (SELECT A.FCLT_ID, A.FCLT_TYPE, A.FCLT_LCTN, A.MDL_NM, A.ISTL_DT, A.ISTL_LCTN_ADDR,        \r\n"
           "              (SELECT CMPY_NM FROM TB_FCLT_CMPY WHERE CMPY_ID = ISTL_CMPY_ID) AS ISTL_CMPY_NM,   \r\n"
           "              (SELECT CMPY_NM FROM TB_FCLT_CMPY WHERE CMPY_ID = MNFC_CMPY_ID) AS MNFC_CMPY_NM    \r\n"
           "         FROM TB_FCLT_INFR A                                                                     \r\n"
           "      )Y                                                                                         \r\n"
           " WHERE 1 = 1                                                                                     \r\n"
           "   AND Y.FCLT_TYPE    = X.WCAM_TYPE_CD                                                           \r\n"
           "   AND X.DEL_YN       = 'N'                                                                      \r\n"
           "   AND X.WCAM_CTLR_ID = Y.FCLT_ID(+)                                                             \r\n"
           " ORDER BY X.WCAM_CTLR_NMBR                                                                       \r\n";
#endif

    int nRow = 0;
    try
    {
        ITSDb_SQLText(pADO, sQry);
        ITSDb_SQLOpen(pADO);

        m_pGDC->RecordCount = pADO->RecordCount;

        for( ; !pADO->Eof; pADO->Next(), nRow++)
        {
            m_pGDC->Values[nRow][Column01->Index] = pADO->FieldByName("FCLT_NMBR")->AsString;
            m_pGDC->Values[nRow][Column02->Index] = pADO->FieldByName("FCLT_ID")->AsString;
            m_pGDC->Values[nRow][Column03->Index] = pADO->FieldByName("LCTN_NM")->AsString;
            m_pGDC->Values[nRow][Column04->Index] = pADO->FieldByName("FCLT_ISTL_LCTN_ADDR")->AsString;
            m_pGDC->Values[nRow][Column05->Index] = FormatFloat("###.#######0", pADO->FieldByName("X_CRDN")->AsFloat);
            m_pGDC->Values[nRow][Column06->Index] = FormatFloat("###.#######0", pADO->FieldByName("Y_CRDN")->AsFloat);
            m_pGDC->Values[nRow][Column07->Index] = pADO->FieldByName("FCLT_MDL_NM")->AsString;

            String ISTL_DT = pADO->FieldByName("FCLT_ISTL_DT")->AsString;
            m_pGDC->Values[nRow][Column08->Index] = APP_FormatStr(ISTL_DT, STR_DATE);
            m_pGDC->Values[nRow][Column09->Index] = pADO->FieldByName("FCLT_MNFC_CMPY_NM")->AsString;
            m_pGDC->Values[nRow][Column10->Index] = pADO->FieldByName("FCLT_ISTL_CMPY_NM")->AsString;
            m_pGDC->Values[nRow][Column11->Index] = pADO->FieldByName("FCLT_TYPE_NM")->AsString;
            m_pGDC->Values[nRow][Column12->Index] = pADO->FieldByName("IP_ADDR")->AsString;
        }
    }
    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 TIFM0070M::SelDsrc()
{
    String sQry;
    TADOQuery *pADO = ADOQry;

    sQry = "SELECT X.ID  AS FCLT_NMBR,                                                                       \r\n"
           "       X.RSE_ID    AS FCLT_ID,                                                                   \r\n"
           "       X.ISTL_LCTN_NM   AS LCTN_NM,                                                              \r\n"
           "       Y.ISTL_LCTN_ADDR AS LCTN_ADDR,                                                            \r\n"
           "       X.LCTN_X         AS X_CRDN,                                                               \r\n"
           "       X.LCTN_Y         AS Y_CRDN,                                                               \r\n"
           "       'DSRC'           AS FCLT_TYPE_NM,                                                         \r\n"
           "       Y.ISTL_LCTN_ADDR AS FCLT_ISTL_LCTN_ADDR,                                                  \r\n"
           "       Y.ISTL_CMPY_NM   AS FCLT_ISTL_CMPY_NM,                                                    \r\n"
           "       Y.MNFC_CMPY_NM   AS FCLT_MNFC_CMPY_NM,                                                    \r\n"
           "       Y.MDL_NM         AS FCLT_MDL_NM,                                                          \r\n"
           "       X.IP             AS IP_ADDR,                                                              \r\n"
           "       Y.ISTL_DT        AS FCLT_ISTL_DT                                                          \r\n"
           " FROM TB_RSE_MSTR X,                                                                             \r\n"
           "      (SELECT A.FCLT_ID, A.FCLT_TYPE, A.FCLT_LCTN, A.MDL_NM, A.ISTL_DT, A.ISTL_LCTN_ADDR,        \r\n"
           "              (SELECT CMPY_NM FROM TB_FCLT_CMPY WHERE CMPY_ID = ISTL_CMPY_ID) AS ISTL_CMPY_NM,   \r\n"
           "              (SELECT CMPY_NM FROM TB_FCLT_CMPY WHERE CMPY_ID = MNFC_CMPY_ID) AS MNFC_CMPY_NM    \r\n"
           "         FROM TB_FCLT_INFR A                                                                     \r\n"
           "      )Y                                                                                         \r\n"
           " WHERE 1 = 1                                                                                     \r\n"
           "   AND Y.FCLT_TYPE = 'DSRC'                                                                      \r\n"
           "   AND X.DEL_YN    = 'N'                                                                         \r\n"
           "   AND X.RSE_ID    = Y.FCLT_ID(+)                                                                \r\n"
           " ORDER BY X.RSE_ID                                                                               \r\n";

    int nRow = 0;
    try
    {
        ITSDb_SQLText(pADO, sQry);
        ITSDb_SQLOpen(pADO);

        m_pGDC->RecordCount = pADO->RecordCount;

        for( ; !pADO->Eof; pADO->Next(), nRow++)
        {
            m_pGDC->Values[nRow][Column01->Index] = pADO->FieldByName("FCLT_NMBR")->AsString;
            m_pGDC->Values[nRow][Column02->Index] = pADO->FieldByName("FCLT_ID")->AsString;
            m_pGDC->Values[nRow][Column03->Index] = pADO->FieldByName("LCTN_NM")->AsString;
            m_pGDC->Values[nRow][Column04->Index] = pADO->FieldByName("FCLT_ISTL_LCTN_ADDR")->AsString;
            m_pGDC->Values[nRow][Column05->Index] = FormatFloat("###.#######0", pADO->FieldByName("X_CRDN")->AsFloat);
            m_pGDC->Values[nRow][Column06->Index] = FormatFloat("###.#######0", pADO->FieldByName("Y_CRDN")->AsFloat);
            m_pGDC->Values[nRow][Column07->Index] = pADO->FieldByName("FCLT_MDL_NM")->AsString;

            String ISTL_DT = pADO->FieldByName("FCLT_ISTL_DT")->AsString;
            m_pGDC->Values[nRow][Column08->Index] = APP_FormatStr(ISTL_DT, STR_DATE);
            m_pGDC->Values[nRow][Column09->Index] = pADO->FieldByName("FCLT_MNFC_CMPY_NM")->AsString;
            m_pGDC->Values[nRow][Column10->Index] = pADO->FieldByName("FCLT_ISTL_CMPY_NM")->AsString;
            m_pGDC->Values[nRow][Column11->Index] = pADO->FieldByName("FCLT_TYPE_NM")->AsString;
            m_pGDC->Values[nRow][Column12->Index] = pADO->FieldByName("IP_ADDR")->AsString;
        }
    }
    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 TIFM0070M::SelCrs()
{
    String sQry;
    TADOQuery *pADO = ADOQry;

#ifdef USE_SC_TBL
    sQry = "SELECT X.IXR_ID       AS FCLT_NMBR,                   \r\n"
           "       X.IXR_ID       AS FCLT_ID,                     \r\n"
           "       X.IXR_NM       AS LCTN_NM,                     \r\n"
           "       X.IXR_NM       AS LCTN_ADDR,                   \r\n"
           "       TO_NUMBER(NVL(TRIM(X.Y_CRDN), '0')) AS X_CRDN, \r\n"
           "       TO_NUMBER(NVL(TRIM(X.X_CRDN), '0')) AS Y_CRDN, \r\n"
           "       '교통량 교차로'     AS FCLT_TYPE_NM            \r\n"
           "  FROM TB_SC_IXR_MNGM X                               \r\n"
           " WHERE 1=1                                            \r\n"
           "   AND X.USE_EN = 1                                   \r\n"
           " ORDER BY X.IXR_ID                                    \r\n";
#else
    sQry = "SELECT X.CROSS_ID       AS FCLT_NMBR,    \r\n"
           "       X.CROSS_ID       AS FCLT_ID,      \r\n"
           "       X.NAME           AS LCTN_NM,      \r\n"
           "       X.NAME           AS LCTN_ADDR,    \r\n"
           "       X.X              AS X_CRDN,       \r\n"
           "       X.Y              AS Y_CRDN,       \r\n"
           "       '교통량 교차로'  AS FCLT_TYPE_NM  \r\n"
           " FROM TB_CRS X                           \r\n"
           " WHERE 1 = 1                             \r\n"
           "   AND X.DEL_YN       = 'N'              \r\n"
           " ORDER BY X.CROSS_ID                     \r\n";
#endif

    int nRow = 0;
    try
    {
        ITSDb_SQLText(pADO, sQry);
        ITSDb_SQLOpen(pADO);

        m_pGDC->RecordCount = pADO->RecordCount;

        for( ; !pADO->Eof; pADO->Next(), nRow++)
        {
            //m_pGDC->Values[nRow][Column01->Index] = pADO->FieldByName("FCLT_NMBR")->AsString;
            m_pGDC->Values[nRow][Column02->Index] = pADO->FieldByName("FCLT_ID")->AsString;
            m_pGDC->Values[nRow][Column13->Index] = pADO->FieldByName("LCTN_NM")->AsString;
            m_pGDC->Values[nRow][Column05->Index] = FormatFloat("###.#######0", pADO->FieldByName("X_CRDN")->AsFloat);
            m_pGDC->Values[nRow][Column06->Index] = FormatFloat("###.#######0", pADO->FieldByName("Y_CRDN")->AsFloat);
            m_pGDC->Values[nRow][Column11->Index] = pADO->FieldByName("FCLT_TYPE_NM")->AsString;
        }
    }
    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 TIFM0070M::SelCrsCam()
{
    String sQry;
    TADOQuery *pADO = ADOQry;

#ifdef USE_SC_TBL
    sQry = "SELECT X.CROSS_ID       AS FCLT_NMBR,                                                          \r\n"
           "       X.CAM_ID         AS FCLT_ID,                                                            \r\n"
           "       X.CROSS_NM       AS CROSS_NM,                                                           \r\n"
           "       X.DRCT_LCTN      AS CAM_NM,                                                             \r\n"
           "       X.X_CRDN         AS X_CRDN,                                                             \r\n"
           "       X.Y_CRDN         AS Y_CRDN,                                                             \r\n"
           "       '교통량 카메라'  AS FCLT_TYPE_NM,                                                       \r\n"
           "       NVL(Y.ISTL_LCTN_ADDR, X.CAM_NM) AS FCLT_ISTL_LCTN_ADDR,                                 \r\n"
           "       Y.ISTL_CMPY_NM   AS FCLT_ISTL_CMPY_NM,                                                  \r\n"
           "       Y.MNFC_CMPY_NM   AS FCLT_MNFC_CMPY_NM,                                                  \r\n"
           "       Y.MDL_NM         AS FCLT_MDL_NM,                                                        \r\n"
           "       X.IP             AS IP_ADDR,                                                            \r\n"
           "       Y.ISTL_DT        AS FCLT_ISTL_DT                                                        \r\n"
           " FROM (SELECT A.IXR_ID AS CROSS_ID, A.IXR_NM AS CROSS_NM,                                      \r\n"
           "              B.CMRA_ID AS CAM_ID,   B.ISTL_LCTN AS CAM_NM, B.CMRA_IP AS IP,                   \r\n"
           "              TO_NUMBER(NVL(TRIM(B.CMRA_Y_CRDN), '0')) AS X_CRDN,                              \r\n"
           "              TO_NUMBER(NVL(TRIM(B.CMRA_X_CRDN), '0')) AS Y_CRDN,                              \r\n"
           "              C.DRCT_LCTN                                                                      \r\n"
           "         FROM TB_SC_IXR_MNGM A, TB_SC_CMRA_MNGM B, TB_SC_CMRA_DRCT_MNGM C                      \r\n"
           "        WHERE A.USE_EN   = 1                                                                   \r\n"
           "          AND B.USE_EN   = 1                                                                   \r\n"
           "          AND A.IXR_ID  = B.IXR_ID                                                             \r\n"
           "          AND B.IXR_ID  = C.IXR_ID                                                             \r\n"
           "          AND B.CMRA_ID = C.CMRA_ID) X,                                                        \r\n"
           "      (SELECT A.FCLT_ID, A.FCLT_TYPE, A.FCLT_LCTN, A.MDL_NM, A.ISTL_DT, A.ISTL_LCTN_ADDR,      \r\n"
           "              (SELECT CMPY_NM FROM TB_FCLT_CMPY WHERE CMPY_ID = ISTL_CMPY_ID) AS ISTL_CMPY_NM, \r\n"
           "              (SELECT CMPY_NM FROM TB_FCLT_CMPY WHERE CMPY_ID = MNFC_CMPY_ID) AS MNFC_CMPY_NM  \r\n"
           "         FROM TB_FCLT_INFR A                                                                   \r\n"
           "      ) Y                                                                                      \r\n"
           " WHERE 1 = 1                                                                                   \r\n"
           "   AND Y.FCLT_TYPE = 'CRSCAM'                                                                  \r\n"
           "   AND X.CAM_ID    = Y.FCLT_ID(+)                                                              \r\n"
           " ORDER BY X.CROSS_ID, X.CAM_ID                                                                 \r\n";
#else
    sQry = "SELECT X.CROSS_ID       AS FCLT_NMBR,                                                              \r\n"
           "       X.CAM_ID         AS FCLT_ID,                                                                \r\n"
           "       X.CROSS_NM       AS CROSS_NM,                                                               \r\n"
           "       X.CAM_NM         AS CAM_NM,                                                                 \r\n"
           "       X.X_CRDN         AS X_CRDN,                                                                 \r\n"
           "       X.Y_CRDN         AS Y_CRDN,                                                                 \r\n"
           "       '교통량 카메라'  AS FCLT_TYPE_NM,                                                           \r\n"
           "       Y.ISTL_LCTN_ADDR AS FCLT_ISTL_LCTN_ADDR,                                                    \r\n"
           "       Y.ISTL_CMPY_NM   AS FCLT_ISTL_CMPY_NM,                                                      \r\n"
           "       Y.MNFC_CMPY_NM   AS FCLT_MNFC_CMPY_NM,                                                      \r\n"
           "       Y.MDL_NM         AS FCLT_MDL_NM,                                                            \r\n"
           "       X.IP             AS IP_ADDR,                                                                \r\n"
           "       Y.ISTL_DT        AS FCLT_ISTL_DT                                                            \r\n"
           " FROM (SELECT A.CROSS_ID, A.NAME AS CROSS_NM,                                                      \r\n"
           "              B.CAM_ID,   B.NAME AS CAM_NM, B.IP,                                                  \r\n"
           "              C.X AS X_CRDN, C.Y AS Y_CRDN                                                         \r\n"
           "         FROM TB_CRS A, TB_CRS_CMRA B, TB_CRS_CMRA_DIR C                                           \r\n"
           "        WHERE A.DEL_YN   = 'N'                                                                     \r\n"
           "          AND B.DEL_YN   = 'N'                                                                     \r\n"
           "          AND A.CROSS_ID = B.CROSS_ID                                                              \r\n"
           "          AND B.CAM_ID   = C.CAM_ID) X,                                                            \r\n"
           "      (SELECT A.FCLT_ID, A.FCLT_TYPE, A.FCLT_LCTN, A.MDL_NM, A.ISTL_DT, A.ISTL_LCTN_ADDR,          \r\n"
           "              (SELECT CMPY_NM FROM TB_FCLT_CMPY WHERE CMPY_ID = ISTL_CMPY_ID) AS ISTL_CMPY_NM,     \r\n"
           "              (SELECT CMPY_NM FROM TB_FCLT_CMPY WHERE CMPY_ID = MNFC_CMPY_ID) AS MNFC_CMPY_NM      \r\n"
           "         FROM TB_FCLT_INFR A                                                                       \r\n"
           "      )Y                                                                                           \r\n"
           " WHERE 1 = 1                                                                                       \r\n"
           "   AND Y.FCLT_TYPE = 'CRSCAM'                                                                      \r\n"
           "   AND X.CAM_ID    = Y.FCLT_ID(+)                                                                  \r\n"
           " ORDER BY X.CROSS_ID, X.CAM_ID                                                                     \r\n";
#endif

    int nRow = 0;
    try
    {
        ITSDb_SQLText(pADO, sQry);
        ITSDb_SQLOpen(pADO);

        m_pGDC->RecordCount = pADO->RecordCount;

        for( ; !pADO->Eof; pADO->Next(), nRow++)
        {
            m_pGDC->Values[nRow][Column01->Index] = pADO->FieldByName("FCLT_NMBR")->AsString;
            m_pGDC->Values[nRow][Column13->Index] = pADO->FieldByName("CROSS_NM")->AsString;
            m_pGDC->Values[nRow][Column02->Index] = pADO->FieldByName("FCLT_ID")->AsString;
            m_pGDC->Values[nRow][Column03->Index] = pADO->FieldByName("CAM_NM")->AsString;
            m_pGDC->Values[nRow][Column04->Index] = pADO->FieldByName("FCLT_ISTL_LCTN_ADDR")->AsString;
            m_pGDC->Values[nRow][Column05->Index] = FormatFloat("###.#######0", pADO->FieldByName("X_CRDN")->AsFloat);
            m_pGDC->Values[nRow][Column06->Index] = FormatFloat("###.#######0", pADO->FieldByName("Y_CRDN")->AsFloat);
            m_pGDC->Values[nRow][Column07->Index] = pADO->FieldByName("FCLT_MDL_NM")->AsString;

            String ISTL_DT = pADO->FieldByName("FCLT_ISTL_DT")->AsString;
            m_pGDC->Values[nRow][Column08->Index] = APP_FormatStr(ISTL_DT, STR_DATE);
            m_pGDC->Values[nRow][Column09->Index] = pADO->FieldByName("FCLT_MNFC_CMPY_NM")->AsString;
            m_pGDC->Values[nRow][Column10->Index] = pADO->FieldByName("FCLT_ISTL_CMPY_NM")->AsString;
            m_pGDC->Values[nRow][Column11->Index] = pADO->FieldByName("FCLT_TYPE_NM")->AsString;
            m_pGDC->Values[nRow][Column12->Index] = pADO->FieldByName("IP_ADDR")->AsString;
        }
    }
    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 TIFM0070M::SelLprsCam()
{
    String sQry;
    TADOQuery *pADO = ADOQry;

#ifndef USE_LPRS
    return;
#endif

    Column01->Visible = false;
    Column02->Caption = "카메라 ID";

    sQry = "SELECT X.NMBR_IDNT_CMRA_ID      AS FCLT_NMBR,                                                    \r\n"
           "       X.NMBR_IDNT_CMRA_ID      AS FCLT_ID,                                                      \r\n"
           "       X.ISTL_LCTN              AS LCTN_NM,                                                      \r\n"
           "       X.ISTL_LCTN              AS LCTN_ADDR,                                                    \r\n"
           "       0                        AS X_CRDN,                                                       \r\n"
           "       0                        AS Y_CRDN,                                                       \r\n"
           "       '차량번호인식 카메라'    AS FCLT_TYPE_NM,                                                 \r\n"
           "       Y.ISTL_LCTN_ADDR         AS FCLT_ISTL_LCTN_ADDR,                                          \r\n"
           "       Y.ISTL_CMPY_NM           AS FCLT_ISTL_CMPY_NM,                                            \r\n"
           "       Y.MNFC_CMPY_NM           AS FCLT_MNFC_CMPY_NM,                                            \r\n"
           "       Y.MDL_NM                 AS FCLT_MDL_NM,                                                  \r\n"
           "       X.CMRA_IP                AS IP_ADDR,                                                      \r\n"
           "       Y.ISTL_DT                AS FCLT_ISTL_DT                                                  \r\n"
           " FROM TB_SC_NMBR_IDNT_CMRA_MNGM X,                                                               \r\n"
           "      (SELECT A.FCLT_ID, A.FCLT_TYPE, A.FCLT_LCTN, A.MDL_NM, A.ISTL_DT, A.ISTL_LCTN_ADDR,        \r\n"
           "              (SELECT CMPY_NM FROM TB_FCLT_CMPY WHERE CMPY_ID = ISTL_CMPY_ID) AS ISTL_CMPY_NM,   \r\n"
           "              (SELECT CMPY_NM FROM TB_FCLT_CMPY WHERE CMPY_ID = MNFC_CMPY_ID) AS MNFC_CMPY_NM    \r\n"
           "         FROM TB_FCLT_INFR A                                                                     \r\n"
           "      )Y                                                                                         \r\n"
           " WHERE 1 = 1                                                                                     \r\n"
           "   AND Y.FCLT_TYPE    = 'LPRS'                                                                   \r\n"
           "   AND X.NMBR_IDNT_CMRA_ID  = Y.FCLT_ID(+)                                                       \r\n"
           " ORDER BY X.NMBR_IDNT_CMRA_ID                                                                    \r\n";

    int nRow = 0;
    try
    {
        ITSDb_SQLText(pADO, sQry);
        ITSDb_SQLOpen(pADO);

        m_pGDC->RecordCount = pADO->RecordCount;

        for( ; !pADO->Eof; pADO->Next(), nRow++)
        {
            m_pGDC->Values[nRow][Column01->Index] = pADO->FieldByName("FCLT_NMBR")->AsString;
            m_pGDC->Values[nRow][Column02->Index] = pADO->FieldByName("FCLT_ID")->AsString;
            m_pGDC->Values[nRow][Column03->Index] = pADO->FieldByName("LCTN_NM")->AsString;
            m_pGDC->Values[nRow][Column04->Index] = pADO->FieldByName("FCLT_ISTL_LCTN_ADDR")->AsString;
            m_pGDC->Values[nRow][Column05->Index] = FormatFloat("###.#######0", pADO->FieldByName("X_CRDN")->AsFloat);
            m_pGDC->Values[nRow][Column06->Index] = FormatFloat("###.#######0", pADO->FieldByName("Y_CRDN")->AsFloat);
            m_pGDC->Values[nRow][Column07->Index] = pADO->FieldByName("FCLT_MDL_NM")->AsString;

            String ISTL_DT = pADO->FieldByName("FCLT_ISTL_DT")->AsString;
            m_pGDC->Values[nRow][Column08->Index] = APP_FormatStr(ISTL_DT, STR_DATE);
            m_pGDC->Values[nRow][Column09->Index] = pADO->FieldByName("FCLT_MNFC_CMPY_NM")->AsString;
            m_pGDC->Values[nRow][Column10->Index] = pADO->FieldByName("FCLT_ISTL_CMPY_NM")->AsString;
            m_pGDC->Values[nRow][Column11->Index] = pADO->FieldByName("FCLT_TYPE_NM")->AsString;
            m_pGDC->Values[nRow][Column12->Index] = pADO->FieldByName("IP_ADDR")->AsString;
        }
    }
    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 TIFM0070M::BtnCloseClick(TObject *Sender)
{
    Close();
}
//---------------------------------------------------------------------------

void __fastcall TIFM0070M::FormClose(TObject *Sender, TCloseAction &Action)
{
    CommClose();
    IFM0070M = NULL;
    Action = caFree;
}
//---------------------------------------------------------------------------

void __fastcall TIFM0070M::OnMessage(TMessage &Msg)
{
    switch (Msg.Msg)
    {
    case WM_PARAM_DATABASE:
        if (WP_DB_SELECT_OK == Msg.WParam)
        {
            //ShowMessage("Select Ok");
        }
        break;
    }
}
//---------------------------------------------------------------------------

void __fastcall TIFM0070M::TvListDataControllerFilterChanged(TObject *Sender)
{
    CMM_SetFilterLike(TvList);
}
//---------------------------------------------------------------------------

