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

#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 "IHS0080MF.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 link "cxCalc"
#pragma link "cxGroupBox"
#pragma link "cxSplitter"
#pragma link "cxCheckBox"
#pragma resource "*.dfm"

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

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

    FCodeIST  = ItsCodeManager->FLists.Find("IST");  //돌발상황 원본 코드 : IST
    FCodeLTCU = ItsCodeManager->FLists.Find("LTCU");//LTCU"); //소통 등급 코드 : LTCU
    FCodeICM  = ItsCodeManager->FLists.Find("ICM");  //돌발상황 확인 방법 코드 : ICM
    FCodeIDTU = ItsCodeManager->FLists.Find("IDTU"); //돌발상황 유형 분류 코드 : IDTU

    FCodeACTU = ItsCodeManager->FLists.Find("ACTU"); //돌발상황 유형 코드 : ACTU, CRTU, EVTU, WETU 중 하나
    FCodeCRTU = ItsCodeManager->FLists.Find("CRTU"); //돌발상황 유형 코드 : ACTU, CRTU, EVTU, WETU 중 하나
    FCodeEVTU = ItsCodeManager->FLists.Find("EVTU"); //돌발상황 유형 코드 : ACTU, CRTU, EVTU, WETU 중 하나
    FCodeWETU = ItsCodeManager->FLists.Find("WETU"); //돌발상황 유형 코드 : ACTU, CRTU, EVTU, WETU 중 하나
    FCodeCNTU = ItsCodeManager->FLists.Find("CNTU"); //돌발상황 유형 코드 : ACTU, CRTU, EVTU, WETU 중 하나
    FCodeCATU = ItsCodeManager->FLists.Find("CATU"); //돌발상황 유형 코드 : ACTU, CRTU, EVTU, WETU 중 하나
    FCodeAETC = ItsCodeManager->FLists.Find("AETC");

    FCodeSRLU = ItsCodeManager->FLists.Find("SRLU"); //돌발상황 심각도 코드 : SRLU
    FCodePRTU = ItsCodeManager->FLists.Find("PRTU"); //통행 제한 유형 코드 : PRTU
    FCodeRSL  = ItsCodeManager->FLists.Find("RSL");  //대응 수준 코드 : RSL
    FCodeISS  = ItsCodeManager->FLists.Find("ISS");  //돌발상황 진행 단계 코드 : ISS
    FCodeICM  = ItsCodeManager->FLists.Find("ICM");  //돌발상황 종료 확인 방법 코드 : ICM
    FCodeDFW  = ItsCodeManager->FLists.Find("DFW");  //기상 코드 : DFW
    FCodeVIT  = ItsCodeManager->FLists.Find("VIT");  //VMS 돌발 유형 코드 : VIT
    FCodeIDT  = ItsCodeManager->FLists.Find("IDT");  //VMS 돌발 유형 세부 코드 : IDT
    FCodeEDT  = ItsCodeManager->FLists.Find("EDT");  //VMS 돌발 유형 세부 코드 : EDT
    FCodeVRT  = ItsCodeManager->FLists.Find("VRT");  //VMS 돌발 통제 코드 : VRT

}
//---------------------------------------------------------------------------

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

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

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

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

    DtStDate->Date = Now() - 30;
    DtEdDate->Date = Now() - 1;

    //DtEdTime->EditValue = Now().FormatString("hh");
    DtStTime->Time = StrToDateTime("00:00");
    DtEdTime->Time = StrToDateTime("23:59");

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


}
//---------------------------------------------------------------------------

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

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

void __fastcall TIHS0080M::BtnExlSave1Click(TObject *Sender)
{
    TcxGrid          *pGrid = CxList;
    TcxGridTableView *pView = TvList;
    String            sTitle= Caption;//"운영자 접속이력";

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

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

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

void __fastcall TIHS0080M::RefreshData()
{
#if 0
	FStDateTime = DtStDate->Date.FormatString("yyyymmdd") + DtStTime->Time.FormatString("hh");
	FEdDateTime = DtEdDate->Date.FormatString("yyyymmdd") + DtEdTime->Time.FormatString("hh");
#else
	FStDateTime = DtStDate->Date.FormatString("yyyymmdd") + DtStTime->Time.FormatString("hhnn");
	FEdDateTime = DtEdDate->Date.FormatString("yyyymmdd") + DtEdTime->Time.FormatString("hhnn");
#endif
	if (wcscmp(FStDateTime.c_str(), FEdDateTime.c_str()) >= 0)
	{
        Application->MessageBox(FrmLang->lblQryDtErr->Caption.c_str(),//L"시작 시각이 종료 시각 보다 작거나 같습니다.",
                                FTitle.c_str(), MB_OK|MB_ICONWARNING|MB_APPLMODAL);
        ActiveControl = DtStDate;
        return;
    }
#if 0
    FStDateTime = FStDateTime + "0000";
    FEdDateTime = FEdDateTime + "5959";
#else
    FStDateTime = FStDateTime + "00";
    FEdDateTime = FEdDateTime + "59";
#endif

    SelHistory();
}
//---------------------------------------------------------------------------

void __fastcall TIHS0080M::SelHistory()
{
    String sQry;
    TADOQuery *pADO = ADOQry;

    sQry = "SELECT *                     \r\n"
           "  FROM TB_INCD_OCRR          \r\n"
           " WHERE RGST_DT BETWEEN :p01  \r\n"
           "                   AND :p02  \r\n"
           " ORDER BY RGST_DT DESC       \r\n";

    try
    {
        //pADO->Connection = ITSDb_GetConnection();

        ITSDb_SQLText(pADO, sQry);
        ITSDb_SQLBind(pADO, "p01", FStDateTime);
        ITSDb_SQLBind(pADO, "p02", FEdDateTime);
        ITSDb_SQLOpen(pADO);

        DspHistory();
    }
    catch(EDatabaseError &E)
    {
        ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
        DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
        throw Exception(String(E.ClassName()) + E.Message);
    }
    catch(Exception &e)
    {
        ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
        DBERRORMSG(Caption, String(e.ClassName()), e.Message, sQry);
        throw Exception(String(e.ClassName()) + e.Message);
    }
}
//---------------------------------------------------------------------------

String __fastcall TIHS0080M::GetStringToDateTime(String ADateTime)
{
    if (ADateTime.Length() == 14) {
        return ADateTime.SubString( 1, 4) + "-" +
               ADateTime.SubString( 5, 2) + "-" +
               ADateTime.SubString( 7, 2) + " " +
               ADateTime.SubString( 9, 2) + ":" +
               ADateTime.SubString(11, 2) + ":" +
               ADateTime.SubString(13, 2);
    }
    return ADateTime;
}
//---------------------------------------------------------------------------

void __fastcall TIHS0080M::DspHistory()
{
    TItsSubCode *pSubCode;
    TADOQuery *pADO = ADOQry;

    try
    {
        CMM_ClearGridTableView(TvList);

        String nowDateTime = Now().FormatString("yyyymmddhhnnss");
        int nRow = 0;
        try {
            TvList->BeginUpdate();
            m_pGDC->RecordCount = pADO->RecordCount;

            for( ; !pADO->Eof; pADO->Next(), nRow++)
            {
                String RGST_DT = pADO->FieldByName("RGST_DT")->AsString;

                m_pGDC->Values[nRow][Column01->Index] = pADO->FieldByName("INCD_OCRR_ID")->AsString;
                m_pGDC->Values[nRow][Column02->Index] = GetStringToDateTime(pADO->FieldByName("RGST_DT")->AsString);

                String INCD_END_PRAR_DT = pADO->FieldByName("INCD_END_PRAR_DT")->AsString.Trim();
                m_pGDC->Values[nRow][Column35->Index] = GetStringToDateTime(pADO->FieldByName("INCD_CNFM_DT")->AsString);       // 돌발상황 확인일시
                m_pGDC->Values[nRow][Column17->Index] = ITSUtil_StrToTime(pADO->FieldByName("INCD_STRT_DT")->AsString);         //돌발상황 시작 일시
                m_pGDC->Values[nRow][Column18->Index] = ITSUtil_StrToTime(INCD_END_PRAR_DT);     //돌발상황 종료 예정 일시
                m_pGDC->Values[nRow][Column37->Index] = ITSUtil_StrToTime(pADO->FieldByName("INCD_END_DT")->AsString);          //돌발상황 종료 일시


                m_pGDC->Values[nRow][Column05->Index] = pADO->FieldByName("OCRR_LCTN_NM")->AsString;                //발생 위치 명
                m_pGDC->Values[nRow][Column06->Index] = pADO->FieldByName("LINK_ID")->AsString;                     //돌발발생 LINK ID
                m_pGDC->Values[nRow][Column07->Index] = pADO->FieldByName("X_CRDN")->AsString;                      //X 좌표
                m_pGDC->Values[nRow][Column08->Index] = pADO->FieldByName("Y_CRDN")->AsString;                      //Y 좌표
                m_pGDC->Values[nRow][Column09->Index] = pADO->FieldByName("INCD_EXPL")->AsString;                   //돌발상황 설명
                m_pGDC->Values[nRow][Column11->Index] = pADO->FieldByName("IFMR_NM")->AsString;                     //제보자 명
                m_pGDC->Values[nRow][Column14->Index] = pADO->FieldByName("INCD_TITL")->AsString;                   //돌발상황 제목


                m_pGDC->Values[nRow][Column19->Index] = pADO->FieldByName("INCD_OCRR_LANE")->AsString;              //돌발상황 발생 차로
                m_pGDC->Values[nRow][Column20->Index] = pADO->FieldByName("INCD_CLSR_LANE")->AsString;              //돌발상황 차단 차로
                m_pGDC->Values[nRow][Column21->Index] = pADO->FieldByName("DELY_LNGT")->AsString;                   //지체 길이
                m_pGDC->Values[nRow][Column22->Index] = pADO->FieldByName("INCD_LNGT")->AsString;                   //돌발상황 길이
                m_pGDC->Values[nRow][Column23->Index] = pADO->FieldByName("SMLT_VHCL_UNUM")->AsString;              //소형 차량 대수
                m_pGDC->Values[nRow][Column24->Index] = pADO->FieldByName("MDLT_VHCL_UNUM")->AsString;              //중대형 차량 대수
                m_pGDC->Values[nRow][Column25->Index] = pADO->FieldByName("INJR_PNUM")->AsString;                   //부상자 인원수
                m_pGDC->Values[nRow][Column26->Index] = pADO->FieldByName("FTLT_PNUM")->AsString;                   //사망자 인원수
                m_pGDC->Values[nRow][Column29->Index] = pADO->FieldByName("UTIS_CNCT_YN")->AsString;                //UTIS 연계 여부
                m_pGDC->Values[nRow][Column30->Index] = pADO->FieldByName("TRUB_VHCL_YN")->AsString;                //고장 차량 여부
                m_pGDC->Values[nRow][Column31->Index] = pADO->FieldByName("FALT_YN")->AsString;                     //낙하물 여부
                m_pGDC->Values[nRow][Column32->Index] = pADO->FieldByName("FRWT_YN")->AsString;                     //화재위험물 여부

                m_pGDC->Values[nRow][Column38->Index] = pADO->FieldByName("MBLZ_EQPM_CONT")->AsString;        //출동 장비 내용
                m_pGDC->Values[nRow][Column39->Index] = pADO->FieldByName("MBLZ_PNUM")->AsString;             //출동 인원수
                m_pGDC->Values[nRow][Column40->Index] = pADO->FieldByName("RECR_CONT")->AsString;             //복구 내용
                m_pGDC->Values[nRow][Column41->Index] = pADO->FieldByName("RECR_PERD")->AsString;             //복구 기간


                String sIST  = "";
                String sLTCU = "";
                String sICM  = "";
                String sEndICM = "";
                String sSRLU = "";
                String sIDTU = "";
                String sACTU = "";
                String sISS  = "";
                String sDFW  = "";
                String sRSL  = "";
                String sPRTU = "";

                String INCD_ORGN_CD          = pADO->FieldByName("INCD_ORGN_CD")->AsString;
                String CMTR_GRAD_CD          = pADO->FieldByName("CMTR_GRAD_CD")->AsString;
                String INCD_CNFM_MTHD_CD     = pADO->FieldByName("INCD_CNFM_MTHD_CD")->AsString;
                String INCD_END_CNFM_MTHD_CD = pADO->FieldByName("INCD_END_CNFM_MTHD_CD")->AsString;
                String INCD_SERN_CD          = pADO->FieldByName("INCD_SERN_CD")->AsString;
                String INCD_TYPE_CLSF_CD     = pADO->FieldByName("INCD_TYPE_CLSF_CD")->AsString;
                String INCD_TYPE_CD          = pADO->FieldByName("INCD_TYPE_CD")->AsString;
                String INCD_PRGR_STEP_CD     = pADO->FieldByName("INCD_PRGR_STEP_CD")->AsString;
                String WTHR_CD               = pADO->FieldByName("WTHR_CD")->AsString;
                String RESP_LVL_CD           = pADO->FieldByName("RESP_LVL_CD")->AsString;
                String TRVL_LMNT_TYPE_CD     = pADO->FieldByName("TRVL_LMNT_TYPE_CD")->AsString;

                if (INCD_ORGN_CD          != "") sIST     = " [" + INCD_ORGN_CD + "] ";
                if (CMTR_GRAD_CD          != "") sLTCU    = " [" + CMTR_GRAD_CD + "] ";
                if (INCD_CNFM_MTHD_CD     != "") sICM     = " [" + INCD_CNFM_MTHD_CD + "] ";
                if (INCD_END_CNFM_MTHD_CD != "") sEndICM  = " [" + INCD_END_CNFM_MTHD_CD + "] ";
                if (INCD_SERN_CD          != "") sSRLU    = " [" + INCD_SERN_CD + "] ";
                if (INCD_TYPE_CLSF_CD     != "") sIDTU    = " [" + INCD_TYPE_CLSF_CD + "] ";
                if (INCD_TYPE_CD          != "") sACTU    = " [" + INCD_TYPE_CD + "] ";
                if (INCD_PRGR_STEP_CD     != "") sISS     = " [" + INCD_PRGR_STEP_CD + "] ";
                if (WTHR_CD               != "") sDFW     = " [" + WTHR_CD + "] ";
                if (RESP_LVL_CD           != "") sRSL     = " [" + RESP_LVL_CD + "] ";
                if (TRVL_LMNT_TYPE_CD     != "") sPRTU    = " [" + TRVL_LMNT_TYPE_CD + "] ";

                if (INCD_PRGR_STEP_CD == "ISS2" && INCD_END_PRAR_DT == "") {
                    if (wcscmp(nowDateTime.c_str(), INCD_END_PRAR_DT.c_str()) >= 0)
                    {
                        INCD_PRGR_STEP_CD == "ISS3";
                    }
                }

                if (FCodeIST)
                {
                    pSubCode = FCodeIST->FSubLists.Find(INCD_ORGN_CD);
                    if (pSubCode) sIST = sIST + pSubCode->CMMN_CD_KOR_NM;
                }
                if (FCodeLTCU)
                {
                    pSubCode = FCodeLTCU->FSubLists.Find(CMTR_GRAD_CD);
                    if (pSubCode) sLTCU = sLTCU + pSubCode->CMMN_CD_KOR_NM;
                }
                if (FCodeICM)
                {
                    pSubCode = FCodeICM->FSubLists.Find(INCD_CNFM_MTHD_CD);
                    if (pSubCode) sICM = sICM + pSubCode->CMMN_CD_KOR_NM;

                    pSubCode = FCodeICM->FSubLists.Find(INCD_END_CNFM_MTHD_CD);
                    if (pSubCode) sEndICM = sEndICM + pSubCode->CMMN_CD_KOR_NM;
                }
                if (FCodeSRLU)
                {
                    pSubCode = FCodeSRLU->FSubLists.Find(INCD_SERN_CD);
                    if (pSubCode) sSRLU = sSRLU + pSubCode->CMMN_CD_KOR_NM;
                }
                if (FCodeIDTU)
                {
                    pSubCode = FCodeIDTU->FSubLists.Find(INCD_TYPE_CLSF_CD);
                    if (pSubCode) sIDTU = sIDTU + pSubCode->CMMN_CD_KOR_NM;
                }

                if (!INCD_TYPE_CLSF_CD.IsEmpty() && !INCD_TYPE_CD.IsEmpty())
                {
                    if (INCD_TYPE_CLSF_CD == "1")
                    {
                        if (FCodeACTU)
                        {
                            pSubCode = FCodeACTU->FSubLists.Find(INCD_TYPE_CD);
                            if (pSubCode) sACTU = sACTU + pSubCode->CMMN_CD_KOR_NM;
                        }
                    }
                    else if (INCD_TYPE_CLSF_CD == "2")
                    {
                        if (FCodeCRTU)
                        {
                            pSubCode = FCodeCRTU->FSubLists.Find(INCD_TYPE_CD);
                            if (pSubCode) sACTU = sACTU + pSubCode->CMMN_CD_KOR_NM;
                        }
                    }
                    else if (INCD_TYPE_CLSF_CD == "3")
                    {
                        if (FCodeEVTU)
                        {
                            pSubCode = FCodeEVTU->FSubLists.Find(INCD_TYPE_CD);
                            if (pSubCode) sACTU = sACTU + pSubCode->CMMN_CD_KOR_NM;
                        }
                    }
                    else if (INCD_TYPE_CLSF_CD == "4")
                    {
                        if (FCodeWETU)
                        {
                            pSubCode = FCodeWETU->FSubLists.Find(INCD_TYPE_CD);
                            if (pSubCode) sACTU = sACTU + pSubCode->CMMN_CD_KOR_NM;
                        }
                    }
                    else if (INCD_TYPE_CLSF_CD == "5")
                    {
                        if (FCodeCNTU)
                        {
                            pSubCode = FCodeCNTU->FSubLists.Find(INCD_TYPE_CD);
                            if (pSubCode) sACTU = sACTU + pSubCode->CMMN_CD_KOR_NM;
                        }
                    }
                    else if (INCD_TYPE_CLSF_CD == "6")
                    {
                        if (FCodeCATU)
                        {
                            pSubCode = FCodeCATU->FSubLists.Find(INCD_TYPE_CD);
                            if (pSubCode) sACTU = sACTU + pSubCode->CMMN_CD_KOR_NM;
                        }
                    }
                    else if (INCD_TYPE_CLSF_CD == "9")
                    {
                        if (FCodeAETC)
                        {
                            pSubCode = FCodeAETC->FSubLists.Find(INCD_TYPE_CD);
                            if (pSubCode) sACTU = sACTU + pSubCode->CMMN_CD_KOR_NM;
                        }
                    }
                }

                if (FCodeISS)
                {
                    pSubCode = FCodeISS->FSubLists.Find(INCD_PRGR_STEP_CD);
                    if (pSubCode) sISS = sISS + pSubCode->CMMN_CD_KOR_NM;
                }

                if (FCodeDFW)
                {
                    pSubCode = FCodeDFW->FSubLists.Find(WTHR_CD);
                    if (pSubCode) sDFW = sDFW + pSubCode->CMMN_CD_KOR_NM;
                }

                if (FCodeRSL)
                {
                    pSubCode = FCodeRSL->FSubLists.Find(RESP_LVL_CD);
                    if (pSubCode) sRSL = sRSL + pSubCode->CMMN_CD_KOR_NM;
                }

                if (FCodePRTU)
                {
                    pSubCode = FCodePRTU->FSubLists.Find(TRVL_LMNT_TYPE_CD);
                    if (pSubCode) sPRTU = sPRTU + pSubCode->CMMN_CD_KOR_NM;
                }

                m_pGDC->Values[nRow][Column03->Index] = sISS;//pObj->INCD_PRGR_STEP_CD;    //돌발상황 진행 단계 코드 : ISS
                m_pGDC->Values[nRow][Column04->Index] = sIST;//pObj->INCD_ORGN_CD;         //돌발상황 원본 코드 : IST
                m_pGDC->Values[nRow][Column10->Index] = sLTCU;//pObj->CMTR_GRAD_CD;        //소통 등급 코드 : LTCU
                m_pGDC->Values[nRow][Column12->Index] = sICM;//pObj->INCD_CNFM_MTHD_CD;    //돌발상황 확인 방법 코드 : ICM
                m_pGDC->Values[nRow][Column13->Index] = sSRLU;//pObj->INCD_SERN_CD;        //돌발상황 심각도 코드 : SRLU
                m_pGDC->Values[nRow][Column15->Index] = sIDTU;//pObj->INCD_TYPE_CLSF_CD;   //돌발상황 유형 분류 코드 : IDTU
                m_pGDC->Values[nRow][Column16->Index] = sACTU;//pObj->INCD_TYPE_CD;        //돌발상황 유형 코드 : ACTU, CRTU, EVTU, WETU 중 하나

                m_pGDC->Values[nRow][Column27->Index] = sDFW;//pObj->WTHR_CD;              //기상 코드 : DFW
                m_pGDC->Values[nRow][Column28->Index] = sRSL;//pObj->RESP_LVL_CD;          //대응 수준 코드 : RSL
                m_pGDC->Values[nRow][Column33->Index] = sPRTU;//pObj->TRVL_LMNT_TYPE_CD;   //통행 제한 유형 코드 : PRTU

                m_pGDC->Values[nRow][Column36->Index] = sEndICM;                           //돌발상황 종료 확인 방법 코드 : ICM
            }
        }
        __finally
        {
            if (pADO)
            {
                pADO->Close();
            }

            TvList->EndUpdate();
            CxList->SetFocus();

            LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + FrmLang->lblEA->Caption;//" 건";

            String sEnd = FrmLang->lblQrySel->Caption + " [" + LblRecords->Caption + "]";//"데이터 " + LblRecords->Caption + " 이 조회 되었습니다.";
            Application->MessageBox(sEnd.c_str(),
                                    FrmLang->lblQryEnd->Caption.c_str(),//L"데이터 조회 완료",
                                    MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
        }
    }
    catch(EDatabaseError &E)
    {
        ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
        DBERRORMSG(Caption, String(E.ClassName()), E.Message, pADO->SQL->Text);
        throw Exception(String(E.ClassName()) + E.Message);
    }
    catch(Exception &e)
    {
        ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
        DBERRORMSG(Caption, String(e.ClassName()), e.Message, pADO->SQL->Text);
        throw Exception(String(e.ClassName()) + e.Message);
    }
}
//---------------------------------------------------------------------------

void __fastcall TIHS0080M::BtnCloseClick(TObject *Sender)
{
    Close();
}
//---------------------------------------------------------------------------

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

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

void __fastcall TIHS0080M::TvListCellDblClick(TcxCustomGridTableView *Sender, TcxGridTableDataCellViewInfo *ACellViewInfo,
          TMouseButton AButton, TShiftState AShift, bool &AHandled)
{
    DisplayIncidentInfo();
}
//---------------------------------------------------------------------------

void __fastcall TIHS0080M::ClearDisplayField()
{
    for (int ii = 0; ii < this->ComponentCount; ii++) {
    TcxTextEdit *pEdit = dynamic_cast<TcxTextEdit*>(this->Components[ii]);
    if (pEdit) {
        pEdit->Text = "";
    }
}
}
//---------------------------------------------------------------------------

void __fastcall TIHS0080M::DisplayIncidentInfo()
{
    return;
    ClearDisplayField();
    TcxDataController *pGDC = TvList->DataController;
	int nRow = pGDC->FocusedRecordIndex;
	if( nRow <= -1 )
		return;

    try
    {
        EdINCD_OCRR_ID->Text = pGDC->Values[nRow][Column01->Index];
        EdRGST_DT->Text      = pGDC->Values[nRow][Column02->Index];
        EdINCD_ORGN_CD->Text = pGDC->Values[nRow][Column02->Index];
        EdRGST_DT->Text      = pGDC->Values[nRow][Column02->Index];
        EdRGST_DT->Text      = pGDC->Values[nRow][Column02->Index];
        EdRGST_DT->Text      = pGDC->Values[nRow][Column02->Index];
        EdRGST_DT->Text      = pGDC->Values[nRow][Column02->Index];
    }
    catch(...)
    {
    }

}
//---------------------------------------------------------------------------


