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

#include <vcl.h>
#include "ITSSkinF.h"
#include "ITSUtilF.h"
#include "ITSDbF.h"
#include "AppGlobalF.h"
#include "WindowMsgF.h"
#include "CDSCodeF.h"
#include "CDSNodeF.h"
#include "CDSLinkF.h"
#include "ITSLangTransF.h"
#pragma hdrstop

#include "IRP00101F.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "cxButtons"
#pragma link "cxClasses"
#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 "dxSkinBlack"
#pragma link "dxSkinBlue"
#pragma link "dxSkinsCore"
#pragma link "dxSkinscxPCPainter"
#pragma link "dxmdaset"
#pragma link "cxContainer"
#pragma resource "*.dfm"

#define USE_MEMDATA 1

TIRP00101 *IRP00101 = NULL;
//---------------------------------------------------------------------------
__fastcall TIRP00101::TIRP00101(TComponent* Owner, HWND hHandle, int ARptType, String sFrom, String sTo, String ATitle)
    : TForm(Owner)
{
    LangTrans->Translate(this, ITSDb_GetConnection());
    ITSSkin_Load(this);
    CMM_LoadForm(g_sFormsDir, this);

    FParent     = hHandle;
    FStDateTime = sFrom;
    FEdDateTime = sTo;
    FRptType    = ARptType;
    FTitle      = ATitle;

    TvList->OptionsView->Header = true;

    //Caption = "보고서";
}
//---------------------------------------------------------------------------
__fastcall TIRP00101::~TIRP00101(void)
{
}
//--------------------------------------------------------------------------

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

    TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<보고서 정보>";
    LblSearch->Caption = FTitle;
}
//---------------------------------------------------------------------------

void __fastcall TIRP00101::FormShow(TObject *Sender)
{
    FormInit();
    Refresh();
    TmrShow->Enabled = true;
}
//---------------------------------------------------------------------------

void __fastcall TIRP00101::CommClose()
{
    CMM_SaveForm(g_sFormsDir, this);
    //IRP00101 = NULL;
}
//---------------------------------------------------------------------------

void __fastcall TIRP00101::TmrShowTimer(TObject *Sender)
{
    TmrShow->Enabled = false;

    CMM_ClearGridTableView(TvList);
    FRows = 0;

    Application->ProcessMessages();

#if USE_MEMDATA
    try
    {
        TvList->BeginUpdate(lsimImmediate);
#endif

        if (FRptType == 0)
        {
            SelReportFacility1();
            SelReportFacility2();
        }
        else
        {
            Column06->Visible = false;
            SelReportTraffic1();
            SelReportTraffic2();
        }
#if USE_MEMDATA
    }
    __finally
    {
        TvList->EndUpdate();
    }
#endif
    CMM_ExpandCollapseChk(TvList, true);
}
//---------------------------------------------------------------------------

void __fastcall TIRP00101::SelReportFacility1()
{
    TSqlCursor sqlCrs;

    String sQry;
    TADOQuery *pADO = ADOQry;

    sQry = "SELECT 0 AS FACSEQ, 'A' AS FACTYPE, 0 AS CMS0CNT, 0 AS CMS1CNT                                              \r\n"
           "  FROM DUAL WHERE 1 = 0                                                                                     \r\n"
#ifdef USE_VMS
           "UNION                                                                                                       \r\n"
           "SELECT 1 as FACSEQ, 'VMS' AS FACTYPE, NVL(SUM(CMS0CNT), 0) AS CMS0CNT, NVL(SUM(CMS1CNT), 0) AS CMS1CNT      \r\n"
           "  FROM (SELECT DECODE(CMNC_STTS_CD, 'CMS0', 1, 0) AS CMS0CNT,                                               \r\n"
           "               DECODE(CMNC_STTS_CD, 'CMS0', 0, 1) AS CMS1CNT                                                \r\n"
           "          FROM TB_VMS_CTLR_STTS_HS                                                                          \r\n"
           "         WHERE CRTN_DT BETWEEN :p01 AND :p02                                                                \r\n"
           "       )                                                                                                    \r\n"
#endif
#ifdef USE_CCTV
           "UNION                                                                                                       \r\n"
           "SELECT 2 as FACSEQ, 'CCTV' AS FACTYPE, NVL(SUM(CMS0CNT), 0) AS CMS0CNT, NVL(SUM(CMS1CNT), 0) AS CMS1CNT     \r\n"
           "  FROM (SELECT DECODE(CONN_STTS_CD, 'CMS0', 1, 0) AS CMS0CNT,                                               \r\n"
           "               DECODE(CONN_STTS_CD, 'CMS0', 0, 1) AS CMS1CNT                                                \r\n"
           "          FROM TB_CCTV_STTS_HS                                                                              \r\n"
           "         WHERE CRTN_DT BETWEEN :p03 AND :p04                                                                \r\n"
           "       )                                                                                                    \r\n"
#endif
#ifdef USE_WCAM
           "UNION                                                                                                       \r\n"
           "SELECT 3 as FACSEQ, '웹카메라' AS FACTYPE, NVL(SUM(CMS0CNT), 0) AS CMS0CNT, NVL(SUM(CMS1CNT), 0) AS CMS1CNT \r\n"
           "  FROM (SELECT DECODE(CMNC_STTS_CD, 'CMS0', 1, 0) AS CMS0CNT,                                               \r\n"
           "               DECODE(CMNC_STTS_CD, 'CMS0', 0, 1) AS CMS1CNT                                                \r\n"
           "          FROM TB_WCAM_CTLR_STTS_HS                                                                         \r\n"
           "         WHERE CRTN_DT BETWEEN :p05 AND :p06                                                                \r\n"
           "       )                                                                                                    \r\n"
#endif
#ifdef USE_VDS
           "UNION                                                                                                       \r\n"
           "SELECT 4 as FACSEQ, 'VDS' AS FACTYPE, NVL(SUM(CMS0CNT), 0) AS CMS0CNT, NVL(SUM(CMS1CNT), 0) AS CMS1CNT      \r\n"
           "  FROM (SELECT DECODE(CMNC_STTS_CD, 'CMS0', 1, 0) AS CMS0CNT,                                               \r\n"
           "               DECODE(CMNC_STTS_CD, 'CMS0', 0, 1) AS CMS1CNT                                                \r\n"
           "          FROM TB_VDS_CTLR_STTS_HS                                                                          \r\n"
           "         WHERE CRTN_DT BETWEEN :p07 AND :p08                                                                \r\n"
           "       )                                                                                                    \r\n"
#endif
#ifdef USE_DSRC
           "UNION                                                                                                       \r\n"
           "SELECT 6 as FACSEQ, 'DSRC' AS FACTYPE, NVL(SUM(CMS0CNT), 0) AS CMS0CNT, NVL(SUM(CMS1CNT), 0) AS CMS1CNT     \r\n"
           "  FROM (SELECT DECODE(CMNC_STTS, '0', 1, 0) AS CMS0CNT,                                                     \r\n"
           "               DECODE(CMNC_STTS, '0', 0, 1) AS CMS1CNT                                                      \r\n"
           "          FROM TB_RSE_STTS_HS                                                                               \r\n"
           "         WHERE CLCT_DT BETWEEN :p11 AND :p12                                                                \r\n"
           "       )                                                                                                    \r\n"
#endif
#ifdef USE_AVI
           "UNION                                                                                                       \r\n"
           "SELECT 5 as FACSEQ, 'AVI' AS FACTYPE, NVL(SUM(CMS0CNT), 0) AS CMS0CNT, NVL(SUM(CMS1CNT), 0) AS CMS1CNT      \r\n"
           "  FROM (SELECT DECODE(CONN_STTS_CD, 'CMS0', 1, 0) AS CMS0CNT,                                               \r\n"
           "               DECODE(CONN_STTS_CD, 'CMS0', 0, 1) AS CMS1CNT                                                \r\n"
           "          FROM TB_AVI_CTLR_STTS_HS                                                                          \r\n"
           "         WHERE CRTN_DT BETWEEN :p13 AND :p14                                                                \r\n"
           "       )                                                                                                    \r\n"
#endif
#ifdef USE_VDS
           "UNION                                                                                                       \r\n"
           "SELECT 7 as FACSEQ, 'CCAM' AS FACTYPE, NVL(SUM(CMS0CNT), 0) AS CMS0CNT, NVL(SUM(CMS1CNT), 0) AS CMS1CNT     \r\n"
           "  FROM (SELECT DECODE(CMNC_STTS_CD, 'CMS0', 1, 0) AS CMS0CNT,                                               \r\n"
           "               DECODE(CMNC_STTS_CD, 'CMS0', 0, 1) AS CMS1CNT                                                \r\n"
           "          FROM TB_CCAM_CTLR_STTS_HS                                                                         \r\n"
           "         WHERE CRTN_DT BETWEEN :p15 AND :p16                                                                \r\n"
           "       )                                                                                                    \r\n"
#endif
#ifdef USE_PARK
           "UNION                                                                                                       \r\n"
           "SELECT 8 as FACSEQ, '주차장' AS FACTYPE, NVL(SUM(CMS0CNT), 0) AS CMS0CNT, NVL(SUM(CMS1CNT), 0) AS CMS1CNT   \r\n"
           "  FROM (SELECT DECODE(CMNC_STTS_CD, 'CMS0', 1, 0) AS CMS0CNT,                                               \r\n"
           "               DECODE(CMNC_STTS_CD, 'CMS0', 0, 1) AS CMS1CNT                                                \r\n"
           "          FROM TB_PRLT_CTLR_STTS_HS                                                                         \r\n"
           "         WHERE CRTN_DT BETWEEN :p17 AND :p18                                                                \r\n"
           "       )                                                                                                    \r\n"
#endif
           " ORDER BY FACSEQ                                                                                            \r\n";

    try
    {
        ITSDb_SQLText(pADO, sQry);
#ifdef USE_VMS
        ITSDb_SQLBind(pADO, "p01", FStDateTime);
        ITSDb_SQLBind(pADO, "p02", FEdDateTime);
#endif
#ifdef USE_CCTV
        ITSDb_SQLBind(pADO, "p03", FStDateTime);
        ITSDb_SQLBind(pADO, "p04", FEdDateTime);
#endif
#ifdef USE_WCAM
        ITSDb_SQLBind(pADO, "p05", FStDateTime);
        ITSDb_SQLBind(pADO, "p06", FEdDateTime);
#endif
#ifdef USE_VDS
        ITSDb_SQLBind(pADO, "p07", FStDateTime);
        ITSDb_SQLBind(pADO, "p08", FEdDateTime);
#endif
#ifdef USE_DSRC
        ITSDb_SQLBind(pADO, "p11", FStDateTime);
        ITSDb_SQLBind(pADO, "p12", FEdDateTime);
#endif
#ifdef USE_AVI
        ITSDb_SQLBind(pADO, "p13", FStDateTime);
        ITSDb_SQLBind(pADO, "p14", FEdDateTime);
#endif
#ifdef USE_CCAM
        ITSDb_SQLBind(pADO, "p15", FStDateTime);
        ITSDb_SQLBind(pADO, "p16", FEdDateTime);
#endif
#ifdef USE_PARK
        ITSDb_SQLBind(pADO, "p17", FStDateTime);
        ITSDb_SQLBind(pADO, "p18", FEdDateTime);
#endif

        ITSDb_SQLOpen(pADO);

#if USE_MEMDATA
        dxMemData1->DisableControls();
        dxMemData1->Close();
        dxMemData1->CreateFieldsFromDataSet(pADO);
        dxMemData1->LoadFromDataSet(pADO);
        dxMemData1->Open();
        dxMemData1->First();
        dxMemData1->EnableControls();
        pADO->Close();

        DspReportFacility1MemData();
#else
        DspReportFacility1();
#endif
    }
    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 &exception)
    {
        ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
        DBERRORMSG(Caption, String(exception.ClassName()), exception.Message, sQry);
        throw Exception(String(exception.ClassName()) + exception.Message);
    }
}
//---------------------------------------------------------------------------

void __fastcall TIRP00101::DspReportFacility1()
{
    TADOQuery *pADO = ADOQry;

    try
    {
        try {
            TvList->BeginUpdate();

            FRows = m_pGDC->AppendRecord();
            m_pGDC->Values[FRows][Column01->Index] = cxLabel1->Caption;//"시설물 현황";
            m_pGDC->Values[FRows][Column02->Index] = cxLabel2->Caption;//"시설물 구분";
            m_pGDC->Values[FRows][Column03->Index] = cxLabel3->Caption;//"정상";
            m_pGDC->Values[FRows][Column04->Index] = cxLabel4->Caption;//"장애";
            m_pGDC->Values[FRows][Column90->Index] = "1";

            for( ; !pADO->Eof; pADO->Next())
            {
                FRows = m_pGDC->AppendRecord();

                m_pGDC->Values[FRows][Column01->Index] = cxLabel1->Caption;//"시설물 현황";
                m_pGDC->Values[FRows][Column02->Index] = pADO->FieldByName("FACTYPE")->AsString;
                m_pGDC->Values[FRows][Column03->Index] = pADO->FieldByName("CMS0CNT")->AsString;
                m_pGDC->Values[FRows][Column04->Index] = pADO->FieldByName("CMS1CNT")->AsString;
                m_pGDC->Values[FRows][Column90->Index] = "0";
            }
            FRows = m_pGDC->AppendRecord();
            m_pGDC->Values[FRows][Column01->Index] = cxLabel1->Caption;//"시설물 현황";
        }
        __finally
        {
            if (pADO)
            {
                pADO->Close();
            }

            TvList->EndUpdate();
        }
    }
    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 TIRP00101::DspReportFacility1MemData()
{
    try
    {
        FRows = m_pGDC->AppendRecord();
        m_pGDC->Values[FRows][Column01->Index] = cxLabel1->Caption;//"시설물 현황";
        m_pGDC->Values[FRows][Column02->Index] = cxLabel2->Caption;//"시설물 구분";
        m_pGDC->Values[FRows][Column03->Index] = cxLabel3->Caption;//"정상";
        m_pGDC->Values[FRows][Column04->Index] = cxLabel4->Caption;//"장애";
        m_pGDC->Values[FRows][Column90->Index] = "1";

        while(!dxMemData1->Eof)
        {
            FRows = m_pGDC->AppendRecord();

            m_pGDC->Values[FRows][Column01->Index] = cxLabel1->Caption;//"시설물 현황";
            m_pGDC->Values[FRows][Column02->Index] = dxMemData1->Fields->FieldByName("FACTYPE")->AsString;
            m_pGDC->Values[FRows][Column03->Index] = dxMemData1->Fields->FieldByName("CMS0CNT")->AsString;
            m_pGDC->Values[FRows][Column04->Index] = dxMemData1->Fields->FieldByName("CMS1CNT")->AsString;
            m_pGDC->Values[FRows][Column90->Index] = "0";

            dxMemData1->Next();
        }
        FRows = m_pGDC->AppendRecord();
        m_pGDC->Values[FRows][Column01->Index] = cxLabel1->Caption;//"시설물 현황";

        dxMemData1->Close();
    }
    catch(EDatabaseError &E)
    {
        throw Exception(String(E.ClassName()) + E.Message);
    }
    catch(...)
    {
        throw Exception(FrmLang->lblDbErr->Caption);//"알수없는 오류가 발생하였습니다.");
    }
}
//---------------------------------------------------------------------------

void __fastcall TIRP00101::SelReportFacility2()
{
    TSqlCursor sqlCrs;

    String sQry;
    TADOQuery *pADO = ADOQry;

    sQry = "SELECT 0 AS FACSEQ, 'A' AS FCLT_TYPE, NULL AS FCLT_ID, NULL AS FCLT_NM, NULL AS RGST_DT        \r\n"
           "  FROM DUAL WHERE 1 = 0                                                                        \r\n"
#ifdef USE_CCTV
           "UNION                                                                                          \r\n"
           "SELECT 1 as FACSEQ, 'CCTV' FCLT_TYPE, A.CCTV_CTLR_ID AS FCLT_ID, A.CCTV_NM AS FCLT_NM,         \r\n"
           "       CRTN_DT AS RGST_DT                                                                      \r\n"
           "  FROM TB_CCTV_CTLR A,                                                                         \r\n"
           "       (SELECT CCTV_CTLR_NMBR, CRTN_DT                                                         \r\n"
           "          FROM TB_CCTV_STTS_HS                                                                 \r\n"
           "         WHERE CRTN_DT BETWEEN :p01 AND :p02                                                   \r\n"
           "           AND CONN_STTS_CD = 'CMS1') B                                                        \r\n"
           " WHERE A.CCTV_CTLR_NMBR = B.CCTV_CTLR_NMBR                                                     \r\n"
#endif
#ifdef USE_VMS
           "UNION                                                                                          \r\n"
           "SELECT 2 as FACSEQ, 'VMS' FCLT_TYPE, A.VMS_CTLR_ID AS FCLT_ID, A.VMS_NM AS FCLT_NM,            \r\n"
           "       CRTN_DT AS RGST_DT                                                                      \r\n"
           "  FROM TB_VMS_CTLR A,                                                                          \r\n"
           "       (SELECT VMS_CTLR_NMBR, CRTN_DT                                                          \r\n"
           "          FROM TB_VMS_CTLR_STTS_HS                                                             \r\n"
           "         WHERE CRTN_DT BETWEEN :p03 AND :p04                                                   \r\n"
           "           AND CMNC_STTS_CD = 'CMS1') B                                                        \r\n"
           " WHERE A.VMS_CTLR_NMBR = B.VMS_CTLR_NMBR                                                       \r\n"
#endif
#ifdef USE_WCAM
           "UNION                                                                                         \r\n"
           "SELECT 3 as FACSEQ, '웹카메라' FCLT_TYPE, A.WCAM_CTLR_ID AS FCLT_ID, A.WCAM_NM AS FCLT_NM,    \r\n"
           "       CRTN_DT AS RGST_DT                                                                     \r\n"
           "  FROM TB_WCAM_CTLR A,                                                                        \r\n"
           "       (SELECT WCAM_CTLR_NMBR, CRTN_DT                                                        \r\n"
           "          FROM TB_WCAM_CTLR_STTS_HS                                                           \r\n"
           "         WHERE CRTN_DT BETWEEN :p05 AND :p06                                                  \r\n"
           "           AND CMNC_STTS_CD = 'CMS1') B                                                       \r\n"
           " WHERE A.WCAM_CTLR_NMBR = B.WCAM_CTLR_NMBR                                                    \r\n"
#endif
#ifdef USE_VDS
           "UNION                                                                                          \r\n"
           "SELECT 4 as FACSEQ, 'VDS' FCLT_TYPE, A.VDS_CTLR_ID AS FCLT_ID, A.VDS_NM AS FCLT_NM,            \r\n"
           "       CRTN_DT AS RGST_DT                                                                      \r\n"
           "  FROM TB_VDS_CTLR A,                                                                          \r\n"
           "       (SELECT VDS_CTLR_NMBR, CRTN_DT                                                          \r\n"
           "          FROM TB_VDS_CTLR_STTS_HS                                                             \r\n"
           "         WHERE CRTN_DT BETWEEN :p07 AND :p08                                                   \r\n"
           "           AND CMNC_STTS_CD = 'CMS1') B                                                        \r\n"
           " WHERE A.VDS_CTLR_NMBR = B.VDS_CTLR_NMBR                                                       \r\n"
#endif
#ifdef USE_AVI
           "UNION                                                                                          \r\n"
           "SELECT 5 as FACSEQ, 'AVI' FCLT_TYPE, A.AVI_CTLR_MNGM_NMBR AS FCLT_ID, A.AVI_LCTN_NM AS FCLT_NM,\r\n"
           "       CRTN_DT AS RGST_DT                                                                      \r\n"
           "  FROM TB_AVI_CTLR A,                                                                          \r\n"
           "       (SELECT AVI_CTLR_MNGM_NMBR, CRTN_DT                                                     \r\n"
           "          FROM TB_AVI_CTLR_STTS_HS                                                             \r\n"
           "         WHERE CRTN_DT BETWEEN :p13 AND :p14                                                   \r\n"
           "           AND CONN_STTS_CD = 'CMS1') B                                                        \r\n"
           " WHERE A.AVI_CTLR_MNGM_NMBR = B.AVI_CTLR_MNGM_NMBR                                             \r\n"
#endif
#ifdef USE_DSRC
           "UNION                                                                                          \r\n"
           "SELECT 6 as FACSEQ, 'DSRC' FCLT_TYPE, A.ID AS FCLT_ID, A.ISTL_LCTN_NM AS FCLT_NM,              \r\n"
           "       CLCT_DT AS RGST_DT                                                                      \r\n"
           "  FROM TB_RSE_MSTR A,                                                                          \r\n"
           "       (SELECT ID, CLCT_DT                                                                     \r\n"
           "          FROM TB_RSE_STTS_HS                                                                  \r\n"
           "         WHERE CLCT_DT BETWEEN :p11 AND :p12                                                   \r\n"
           "           AND CMNC_STTS = '1') B                                                              \r\n"
           " WHERE A.ID = B.ID                                                                             \r\n"
#endif
#ifdef USE_PARK
           "UNION                                                                                         \r\n"
           "SELECT 7 as FACSEQ, '주차장' FCLT_TYPE, A.PRLT_CTLR_ID AS FCLT_ID, A.PRLT_NM AS FCLT_NM,      \r\n"
           "       CRTN_DT AS RGST_DT                                                                     \r\n"
           "  FROM TB_PRLT_CTLR A,                                                                        \r\n"
           "       (SELECT PRLT_CTLR_NMBR, CRTN_DT                                                        \r\n"
           "          FROM TB_PRLT_CTLR_STTS_HS                                                           \r\n"
           "         WHERE CRTN_DT BETWEEN :p15 AND :p16                                                  \r\n"
           "           AND CMNC_STTS_CD = 'CMS1') B                                                       \r\n"
           " WHERE A.REAL_DATA_YN   = 'Y'                                                                 \r\n"
           "   AND A.PRLT_CTLR_NMBR = B.PRLT_CTLR_NMBR                                                    \r\n"
#endif
           " ORDER BY FACSEQ, FCLT_ID, RGST_DT                                                            \r\n";

    try
    {
        ITSDb_SQLText(pADO, sQry);
#ifdef USE_CCTV
        ITSDb_SQLBind(pADO, "p01", FStDateTime);
        ITSDb_SQLBind(pADO, "p02", FEdDateTime);
#endif
#ifdef USE_VMS
        ITSDb_SQLBind(pADO, "p03", FStDateTime);
        ITSDb_SQLBind(pADO, "p04", FEdDateTime);
#endif
#ifdef USE_WCAM
        ITSDb_SQLBind(pADO, "p05", FStDateTime);
        ITSDb_SQLBind(pADO, "p06", FEdDateTime);
#endif
#ifdef USE_VDS
        ITSDb_SQLBind(pADO, "p07", FStDateTime);
        ITSDb_SQLBind(pADO, "p08", FEdDateTime);
#endif
#ifdef USE_AVI
        ITSDb_SQLBind(pADO, "p13", FStDateTime);
        ITSDb_SQLBind(pADO, "p14", FEdDateTime);
#endif
#ifdef USE_DSRC
        ITSDb_SQLBind(pADO, "p11", FStDateTime);
        ITSDb_SQLBind(pADO, "p12", FEdDateTime);
#endif
#ifdef USE_DSRC
        ITSDb_SQLBind(pADO, "p15", FStDateTime);
        ITSDb_SQLBind(pADO, "p16", FEdDateTime);
#endif

        ITSDb_SQLOpen(pADO);

#if USE_MEMDATA
        dxMemData1->DisableControls();
        dxMemData1->Close();
        dxMemData1->CreateFieldsFromDataSet(pADO);
        dxMemData1->LoadFromDataSet(pADO);
        dxMemData1->Open();
        dxMemData1->First();
        dxMemData1->EnableControls();
        pADO->Close();

        DspReportFacility2MemData();
#else
        DspReportFacility2();
#endif
    }
    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(FrmLang->lblDbErr->Caption);//"알수없는 오류가 발생하였습니다.");
    }
}
//---------------------------------------------------------------------------

void __fastcall TIRP00101::DspReportFacility2()
{
    TADOQuery *pADO = ADOQry;

    try
    {
        try {
            TvList->BeginUpdate();

            FRows = m_pGDC->AppendRecord();
            m_pGDC->Values[FRows][Column01->Index] = cxLabel5->Caption;//"장애 현황";
            m_pGDC->Values[FRows][Column02->Index] = cxLabel6->Caption;//"장애일시";
            m_pGDC->Values[FRows][Column03->Index] = cxLabel7->Caption;//"장비유형";
            m_pGDC->Values[FRows][Column04->Index] = cxLabel8->Caption;//"아이디";
            m_pGDC->Values[FRows][Column05->Index] = cxLabel9->Caption;//"명칭";
            m_pGDC->Values[FRows][Column06->Index] = cxLabel10->Caption;//"통신장애";

            m_pGDC->Values[FRows][Column90->Index] = "1";

            for( ; !pADO->Eof; pADO->Next())
            {
                FRows = m_pGDC->AppendRecord();

                String sRgstDt = pADO->FieldByName("RGST_DT")->AsString;

                sRgstDt.Insert(":", 13);
                sRgstDt.Insert(":", 11);
                sRgstDt.Insert(" ",  9);
                sRgstDt.Insert("-",  7);
                sRgstDt.Insert("-",  5);

                m_pGDC->Values[FRows][Column01->Index] = cxLabel5->Caption;//"장애 현황";
                m_pGDC->Values[FRows][Column02->Index] = sRgstDt;
                m_pGDC->Values[FRows][Column03->Index] = pADO->FieldByName("FCLT_TYPE")->AsString;
                m_pGDC->Values[FRows][Column04->Index] = pADO->FieldByName("FCLT_ID")->AsString;
                m_pGDC->Values[FRows][Column05->Index] = pADO->FieldByName("FCLT_NM")->AsString;
                m_pGDC->Values[FRows][Column06->Index] = cxLabel11->Caption;//"통신두절";
                m_pGDC->Values[FRows][Column90->Index] = "0";
            }
            FRows = m_pGDC->AppendRecord();
            m_pGDC->Values[FRows][Column01->Index] = cxLabel5->Caption;//"장애 현황";
        }
        __finally
        {
            if (pADO)
            {
                pADO->Close();
            }

            TvList->EndUpdate();
        }
    }
    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 TIRP00101::DspReportFacility2MemData()
{
    try
    {
        FRows = m_pGDC->AppendRecord();
        m_pGDC->Values[FRows][Column01->Index] = cxLabel5->Caption;//"장애 현황";
        m_pGDC->Values[FRows][Column02->Index] = cxLabel6->Caption;//"장애일시";
        m_pGDC->Values[FRows][Column03->Index] = cxLabel7->Caption;//"장비유형";
        m_pGDC->Values[FRows][Column04->Index] = cxLabel8->Caption;//"아이디";
        m_pGDC->Values[FRows][Column05->Index] = cxLabel9->Caption;//"명칭";
        m_pGDC->Values[FRows][Column06->Index] = cxLabel10->Caption;//"통신장애";

        m_pGDC->Values[FRows][Column90->Index] = "1";

        while(!dxMemData1->Eof)
        {
            FRows = m_pGDC->AppendRecord();

            String sRgstDt = dxMemData1->Fields->FieldByName("RGST_DT")->AsString;

            sRgstDt.Insert(":", 13);
            sRgstDt.Insert(":", 11);
            sRgstDt.Insert(" ",  9);
            sRgstDt.Insert("-",  7);
            sRgstDt.Insert("-",  5);

            m_pGDC->Values[FRows][Column01->Index] = cxLabel5->Caption;//"장애 현황";
            m_pGDC->Values[FRows][Column02->Index] = sRgstDt;
            m_pGDC->Values[FRows][Column03->Index] = dxMemData1->Fields->FieldByName("FCLT_TYPE")->AsString;
            m_pGDC->Values[FRows][Column04->Index] = dxMemData1->Fields->FieldByName("FCLT_ID")->AsString;
            m_pGDC->Values[FRows][Column05->Index] = dxMemData1->Fields->FieldByName("FCLT_NM")->AsString;
            m_pGDC->Values[FRows][Column06->Index] = cxLabel11->Caption;//"통신두절";
            m_pGDC->Values[FRows][Column90->Index] = "0";

            dxMemData1->Next();
        }
        FRows = m_pGDC->AppendRecord();
        m_pGDC->Values[FRows][Column01->Index] = cxLabel5->Caption;//"장애 현황";

        dxMemData1->Close();
    }
    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 TIRP00101::SelReportTraffic1()
{
    TSqlCursor sqlCrs;

    String sQry;
    TADOQuery *pADO = ADOQry;

    sQry = "SELECT INCD_STRT_DT, B.CMMN_CD_KOR_NM, LINK_ID, INCD_TITL \r\n"
           "  FROM TB_INCD_OCRR A,                                    \r\n"
           "       (SELECT CMMN_CD, CMMN_CD_KOR_NM                    \r\n"
           "          FROM TB_CMMN_CD                                 \r\n"
           "         WHERE CMMN_CLSF_CD = 'IDTU'                      \r\n"
           "       ) B                                                \r\n"
           " WHERE INCD_STRT_DT BETWEEN :p01 AND :p02                 \r\n"
           "   AND INCD_PRGR_STEP_CD   = 'ISS2'                       \r\n"
           "   AND A.INCD_TYPE_CLSF_CD = B.CMMN_CD                    \r\n";
    try
    {
        ITSDb_SQLText(pADO, sQry);
        ITSDb_SQLBind(pADO, "p01", FStDateTime);
        ITSDb_SQLBind(pADO, "p02", FEdDateTime);
        ITSDb_SQLOpen(pADO);

#if USE_MEMDATA
        dxMemData1->DisableControls();
        dxMemData1->Close();
        dxMemData1->CreateFieldsFromDataSet(pADO);
        dxMemData1->LoadFromDataSet(pADO);
        dxMemData1->Open();
        dxMemData1->First();
        dxMemData1->EnableControls();
        pADO->Close();

        DspReportTraffic1MemData();
#else
        DspReportTraffic1();
#endif
    }
    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(FrmLang->lblDbErr->Caption);//"알수없는 오류가 발생하였습니다.");
    }
}
//---------------------------------------------------------------------------

void __fastcall TIRP00101::DspReportTraffic1()
{
    TADOQuery *pADO = ADOQry;

    try
    {
        try {
            TvList->BeginUpdate();

            FRows = m_pGDC->AppendRecord();
            m_pGDC->Values[FRows][Column01->Index] = cxLabel12->Caption;//"돌발 현황";
            m_pGDC->Values[FRows][Column02->Index] = cxLabel13->Caption;//"시작일시";
            m_pGDC->Values[FRows][Column03->Index] = cxLabel14->Caption;//"돌발유형";
            m_pGDC->Values[FRows][Column04->Index] = cxLabel15->Caption;//"도로명";
            m_pGDC->Values[FRows][Column05->Index] = cxLabel16->Caption;//"돌발내용";
            m_pGDC->Values[FRows][Column90->Index] = "1";

            TItsLink *pLink;
            for( ; !pADO->Eof; pADO->Next())
            {
                FRows = m_pGDC->AppendRecord();

                String sLinkId = pADO->FieldByName("LINK_ID")->AsString;
                pLink = ItsLinkManager->FLists.Find(sLinkId);
                if (pLink)
                {
                    sLinkId = pLink->ROAD_NAME;
                }

                String sStrtDt = pADO->FieldByName("INCD_STRT_DT")->AsString;
                sStrtDt.Insert(":", 13);
                sStrtDt.Insert(":", 11);
                sStrtDt.Insert(" ",  9);
                sStrtDt.Insert("-",  7);
                sStrtDt.Insert("-",  5);

                m_pGDC->Values[FRows][Column01->Index] = cxLabel12->Caption;//"돌발 현황";
                m_pGDC->Values[FRows][Column02->Index] = sStrtDt;
                m_pGDC->Values[FRows][Column03->Index] = pADO->FieldByName("CMMN_CD_KOR_NM")->AsString;
                m_pGDC->Values[FRows][Column04->Index] = sLinkId;
                m_pGDC->Values[FRows][Column05->Index] = pADO->FieldByName("INCD_TITL")->AsString;
                m_pGDC->Values[FRows][Column90->Index] = "0";
            }
            FRows = m_pGDC->AppendRecord();
            m_pGDC->Values[FRows][Column01->Index] = cxLabel12->Caption;//"돌발 현황";
        }
        __finally
        {
            if (pADO)
            {
                pADO->Close();
            }

            TvList->EndUpdate();
        }
    }
    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 TIRP00101::DspReportTraffic1MemData()
{
    try
    {
        FRows = m_pGDC->AppendRecord();
        m_pGDC->Values[FRows][Column01->Index] = cxLabel12->Caption;//"돌발 현황";
        m_pGDC->Values[FRows][Column02->Index] = cxLabel13->Caption;//"시작일시";
        m_pGDC->Values[FRows][Column03->Index] = cxLabel14->Caption;//"돌발유형";
        m_pGDC->Values[FRows][Column04->Index] = cxLabel15->Caption;//"도로명";
        m_pGDC->Values[FRows][Column05->Index] = cxLabel16->Caption;//"돌발내용";
        m_pGDC->Values[FRows][Column90->Index] = "1";

        TItsLink *pLink;
        while(!dxMemData1->Eof)
        {
            FRows = m_pGDC->AppendRecord();

            String sLinkId = dxMemData1->Fields->FieldByName("LINK_ID")->AsString;
            pLink = ItsLinkManager->FLists.Find(sLinkId);
            if (pLink)
            {
                sLinkId = pLink->ROAD_NAME;
            }

            String sStrtDt = dxMemData1->Fields->FieldByName("INCD_STRT_DT")->AsString;
            sStrtDt.Insert(":", 13);
            sStrtDt.Insert(":", 11);
            sStrtDt.Insert(" ",  9);
            sStrtDt.Insert("-",  7);
            sStrtDt.Insert("-",  5);

            m_pGDC->Values[FRows][Column01->Index] = cxLabel12->Caption;//"돌발 현황";
            m_pGDC->Values[FRows][Column02->Index] = sStrtDt;
            m_pGDC->Values[FRows][Column03->Index] = dxMemData1->Fields->FieldByName("CMMN_CD_KOR_NM")->AsString;
            m_pGDC->Values[FRows][Column04->Index] = sLinkId;
            m_pGDC->Values[FRows][Column05->Index] = dxMemData1->Fields->FieldByName("INCD_TITL")->AsString;
            m_pGDC->Values[FRows][Column90->Index] = "0";

            dxMemData1->Next();
        }
        FRows = m_pGDC->AppendRecord();
        m_pGDC->Values[FRows][Column01->Index] = cxLabel12->Caption;//"돌발 현황";

        dxMemData1->Close();
    }
    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 TIRP00101::SelReportTraffic2()
{
    TSqlCursor sqlCrs;

    String sQry;
    TADOQuery *pADO = ADOQry;

    sQry = "SELECT A.LINK_ID, B.PRCN_DT, A.CMTR_GRAD_CD, A.SPED  \r\n"
           "  FROM TB_LINK_TRAF_HS A,                            \r\n"
           "       (SELECT LINK_ID, MAX(PRCN_DT) PRCN_DT         \r\n"
           "          FROM TB_LINK_TRAF_HS                       \r\n"
           "         WHERE PRCN_DT BETWEEN :p01 AND :p02         \r\n"
           "           AND CMTR_GRAD_CD <> 'LTC1'                \r\n"
           "         GROUP BY LINK_ID                            \r\n"
           "       ) B                                           \r\n"
           " WHERE A.LINK_ID = B.LINK_ID                         \r\n"
           "   AND A.PRCN_DT = B.PRCN_DT                         \r\n"
           " ORDER BY 3 DESC                                     \r\n";
    try
    {
        ITSDb_SQLText(pADO, sQry);
        ITSDb_SQLBind(pADO, "p01", FStDateTime);
        ITSDb_SQLBind(pADO, "p02", FEdDateTime);
        ITSDb_SQLOpen(pADO);

#if USE_MEMDATA
        dxMemData1->DisableControls();
        dxMemData1->Close();
        dxMemData1->CreateFieldsFromDataSet(pADO);
        dxMemData1->LoadFromDataSet(pADO);
        dxMemData1->Open();
        dxMemData1->First();
        dxMemData1->EnableControls();
        pADO->Close();

        DspReportTraffic2MemData();
#else
        DspReportTraffic2();
#endif
    }
    catch(EDatabaseError &E)
    {
        ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
        DBERRORMSG(Caption, String(E.ClassName()), E.Message, "");
        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, "");
        throw Exception(FrmLang->lblDbErr->Caption);//"알수없는 오류가 발생하였습니다.");
    }
}
//---------------------------------------------------------------------------

void __fastcall TIRP00101::DspReportTraffic2()
{
    TADOQuery *pADO = ADOQry;

    try
    {
        try {
            TvList->BeginUpdate();

            FRows = m_pGDC->AppendRecord();
            m_pGDC->Values[FRows][Column01->Index] = cxLabel17->Caption;//"지/정체 현황";
            m_pGDC->Values[FRows][Column02->Index] = FrmLang->lblPrcsTm->Caption;//"가공시각";
            m_pGDC->Values[FRows][Column03->Index] = cxLabel18->Caption;//"속도";
            m_pGDC->Values[FRows][Column04->Index] = cxLabel15->Caption;//"도로명";
            m_pGDC->Values[FRows][Column05->Index] = cxLabel19->Caption;//"구간명";

            m_pGDC->Values[FRows][Column90->Index] = "1";

            TItsNode *pNode;
            TItsLink *pLink;
            for( ; !pADO->Eof; pADO->Next())
            {
                FRows = m_pGDC->AppendRecord();

                String sFNode, sTNode;
                sFNode = sTNode = "";

                String sLinkId = pADO->FieldByName("LINK_ID")->AsString;
                pLink = ItsLinkManager->FLists.Find(sLinkId);
                if (pLink)
                {
                    sLinkId = pLink->ROAD_NAME;
                    sFNode = pLink->F_NODE_ID;
                    pNode = ItsNodeManager->FLists.Find(pLink->F_NODE_ID);
                    if (pNode) sFNode = pNode->NODE_NAME;
                    sTNode = pLink->T_NODE_ID;
                    pNode = ItsNodeManager->FLists.Find(pLink->T_NODE_ID);
                    if (pNode) sTNode = pNode->NODE_NAME;
                }

                String sPrcnDt = pADO->FieldByName("PRCN_DT")->AsString;
                sPrcnDt.Insert(":", 13);
                sPrcnDt.Insert(":", 11);
                sPrcnDt.Insert(" ",  9);
                sPrcnDt.Insert("-",  7);
                sPrcnDt.Insert("-",  5);

                String sGrade = pADO->FieldByName("CMTR_GRAD_CD")->AsString;
                if (sGrade == "LTC2")
                    sGrade = FrmLang->lblLTC2->Caption + "(" + pADO->FieldByName("SPED")->AsString + ")";
                else
                    sGrade = FrmLang->lblLTC3->Caption + "(" + pADO->FieldByName("SPED")->AsString + ")";

                m_pGDC->Values[FRows][Column01->Index] = cxLabel17->Caption;//"지/정체 현황";
                m_pGDC->Values[FRows][Column02->Index] = sPrcnDt;
                m_pGDC->Values[FRows][Column03->Index] = sGrade;
                m_pGDC->Values[FRows][Column04->Index] = sLinkId;
                m_pGDC->Values[FRows][Column05->Index] = sFNode + "→" + sTNode;
                m_pGDC->Values[FRows][Column90->Index] = "0";
            }
            FRows = m_pGDC->AppendRecord();
            m_pGDC->Values[FRows][Column01->Index] = cxLabel17->Caption;//"지/정체 현황";
        }
        __finally
        {
            if (pADO)
            {
                pADO->Close();
            }

            TvList->EndUpdate();
        }
    }
    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 TIRP00101::DspReportTraffic2MemData()
{
    try
    {
        FRows = m_pGDC->AppendRecord();
        m_pGDC->Values[FRows][Column01->Index] = cxLabel17->Caption;//"지/정체 현황";
        m_pGDC->Values[FRows][Column02->Index] = FrmLang->lblPrcsTm->Caption;//"가공시각";
        m_pGDC->Values[FRows][Column03->Index] = cxLabel18->Caption;//"속도";
        m_pGDC->Values[FRows][Column04->Index] = cxLabel15->Caption;//"도로명";
        m_pGDC->Values[FRows][Column05->Index] = cxLabel19->Caption;//"구간명";

        m_pGDC->Values[FRows][Column90->Index] = "1";

        TItsNode *pNode;
        TItsLink *pLink;
        while(!dxMemData1->Eof)
        {
            FRows = m_pGDC->AppendRecord();

            String sFNode, sTNode;
            sFNode = sTNode = "";

            String sLinkId = dxMemData1->Fields->FieldByName("LINK_ID")->AsString;
            pLink = ItsLinkManager->FLists.Find(sLinkId);
            if (pLink)
            {
                sLinkId = pLink->ROAD_NAME;
                sFNode = pLink->F_NODE_ID;
                pNode = ItsNodeManager->FLists.Find(pLink->F_NODE_ID);
                if (pNode) sFNode = pNode->NODE_NAME;
                sTNode = pLink->T_NODE_ID;
                pNode = ItsNodeManager->FLists.Find(pLink->T_NODE_ID);
                if (pNode) sTNode = pNode->NODE_NAME;
            }

            String sPrcnDt = dxMemData1->Fields->FieldByName("PRCN_DT")->AsString;
            sPrcnDt.Insert(":", 13);
            sPrcnDt.Insert(":", 11);
            sPrcnDt.Insert(" ",  9);
            sPrcnDt.Insert("-",  7);
            sPrcnDt.Insert("-",  5);

            String sGrade = dxMemData1->Fields->FieldByName("CMTR_GRAD_CD")->AsString;
            if (sGrade == "LTC2")
                sGrade = FrmLang->lblLTC2->Caption + "(" + dxMemData1->Fields->FieldByName("SPED")->AsString + ")";//"지체(" + dxMemData1->Fields->FieldByName("SPED")->AsString + ")";
            else
                sGrade = FrmLang->lblLTC3->Caption + "(" + dxMemData1->Fields->FieldByName("SPED")->AsString + ")";//"정체(" + dxMemData1->Fields->FieldByName("SPED")->AsString + ")";

            m_pGDC->Values[FRows][Column01->Index] = cxLabel17->Caption;//"지/정체 현황";
            m_pGDC->Values[FRows][Column02->Index] = sPrcnDt;
            m_pGDC->Values[FRows][Column03->Index] = sGrade;
            m_pGDC->Values[FRows][Column04->Index] = sLinkId;
            m_pGDC->Values[FRows][Column05->Index] = sFNode + "→" + sTNode;
            m_pGDC->Values[FRows][Column90->Index] = "0";

            dxMemData1->Next();
        }
        FRows = m_pGDC->AppendRecord();
        m_pGDC->Values[FRows][Column01->Index] = cxLabel17->Caption;//"지/정체 현황";

        dxMemData1->Close();
    }
    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 TIRP00101::OnMessage(TMessage &Msg)
{
    switch (Msg.Msg)
    {
    case WM_PARAM_DATABASE:
        if (WP_DB_SELECT_OK == Msg.WParam)
        {
            //ShowMessage("Select Ok");
        }
        break;
    }
}
//---------------------------------------------------------------------------

void __fastcall TIRP00101::BtnExlSaveClick(TObject *Sender)
{
    TcxGrid          *pGrid = CxList;
    TcxGridTableView *pView = TvList;
    String            sTitle;

    if (FRptType == 1)
        sTitle = lblType1->Caption;//"교통보고서";
    else
        sTitle = lblType2->Caption;//"시설물보고서";

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

void __fastcall TIRP00101::FormClose(TObject *Sender, TCloseAction &Action)
{
    POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
    CommClose();
    //IRP00101 = NULL;
}
//---------------------------------------------------------------------------

void __fastcall TIRP00101::TvListCustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
          bool &ADone)
{
    if (AViewInfo)
    {
        String sType = AViewInfo->GridRecord->DisplayTexts[Column90->Index];
        if (sType == "1")
            ACanvas->Brush->Color = clOlive;    //컬럼소제목
    }
}
//---------------------------------------------------------------------------

void __fastcall TIRP00101::FormDestroy(TObject *Sender)
{
    CommClose();
}
//---------------------------------------------------------------------------

