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

#include <vcl.h>
#include "ITSSkinF.h"
#include "ITSUtilF.h"
#include "AppGlobalF.h"
#include "CDSIfsc_VMSF.h"
#include "ITSLangTransF.h"
#include "ITSMapF.h"
#include "WindowMsgF.h"
#pragma hdrstop

#include "VMSM200MF.h"
#include "VMSM210MF.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "cxButtons"
#pragma link "cxCheckBox"
#pragma link "cxClasses"
#pragma link "cxContainer"
#pragma link "cxControls"
#pragma link "cxCustomData"
#pragma link "cxData"
#pragma link "cxDataStorage"
#pragma link "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 "cxGroupBox"
#pragma link "cxLabel"
#pragma link "cxLookAndFeelPainters"
#pragma link "cxLookAndFeels"
#pragma link "cxMaskEdit"
#pragma link "cxSplitter"
#pragma link "cxStyles"
#pragma link "cxTextEdit"
#pragma link "dxSkinBlack"
#pragma link "dxSkinBlue"
#pragma link "dxSkinCaramel"
#pragma link "dxSkinCoffee"
#pragma link "dxSkinDarkRoom"
#pragma link "dxSkinDarkSide"
#pragma link "dxSkinFoggy"
#pragma link "dxSkinGlassOceans"
#pragma link "dxSkiniMaginary"
#pragma link "dxSkinLilian"
#pragma link "dxSkinLiquidSky"
#pragma link "dxSkinLondonLiquidSky"
#pragma link "dxSkinMcSkin"
#pragma link "dxSkinMoneyTwins"
#pragma link "dxSkinOffice2007Black"
#pragma link "dxSkinOffice2007Blue"
#pragma link "dxSkinOffice2007Green"
#pragma link "dxSkinOffice2007Pink"
#pragma link "dxSkinOffice2007Silver"
#pragma link "dxSkinOffice2010Black"
#pragma link "dxSkinOffice2010Blue"
#pragma link "dxSkinOffice2010Silver"
#pragma link "dxSkinsCore"
#pragma link "dxSkinscxPCPainter"
#pragma link "dxSkinSeven"
#pragma link "dxSkinSharp"
#pragma link "dxSkinSilver"
#pragma link "dxSkinStardust"
#pragma link "FRAME_VmsIfscListF"
#pragma link "FRAME_OpenMapF"
#pragma link "cxClasses"
#pragma link "cxCustomData"
#pragma link "cxData"
#pragma link "cxDataStorage"
#pragma link "cxFilter"
#pragma link "cxGrid"
#pragma link "cxGridCustomTableView"
#pragma link "cxGridCustomView"
#pragma link "cxGridLevel"
#pragma link "cxGridTableView"
#pragma link "cxStyles"
#pragma link "dxSkinscxPCPainter"
#pragma link "FRAME_VmsIfscListF"
#pragma link "cxCalc"
#pragma resource "*.dfm"

TVMSM200M *VMSM200M = NULL;
//---------------------------------------------------------------------------
void TVMSM200M_MapCallback(TObject *ASender, const String AFunc, const String AArgs, const bool AFirst)
{
    try
    {
        if (!VMSM200M) return;
        VMSM200M->OpenMapCallback(ASender, AFunc, AArgs, AFirst);
    }
    catch(Exception &exception)
    {
    }
}
//---------------------------------------------------------------------------

__fastcall TVMSM200M::TVMSM200M(TComponent* Owner)
    : TForm(Owner)
{
    LangTrans->Translate(this, ITSDb_GetConnection());
    ITSSkin_Load(this);
    CMM_LoadForm(g_sFormsDir, this);
    UpdateSkin();

    FUpdate= false;
    FTitle = Caption;//"VMS 정보제공구간 관리";

    m_pGDC = FRAMEVmsIfscList1->TvList->DataController;

    FRAMEVmsIfscList1->PnlTop->Visible = false;
    FRAMEVmsIfscList1->PnlBottom->Visible = false;
    FRAMEVmsIfscList1->ColumnSel->Visible = false;

    FLayerIdx = LyrTp_Vms;
    FRAMEOpenMap1->LayerIdx = FLayerIdx;
    FRAMEOpenMap1->ChkShowNmbr->Visible = false;
    FRAMEOpenMap1->BtnMapSelect->Visible = false;
    FRAMEOpenMap1->MapCallbackFunc = TVMSM200M_MapCallback;

    EditMode = false;
}
//---------------------------------------------------------------------------

void __fastcall TVMSM200M::UpdateSkin()
{
    Label17->Transparent = false;
    Label18->Transparent = false;
    Label19->Transparent = false;
    Label01->Transparent = false;
    Label02->Transparent = false;
    Label03->Transparent = false;

    Label17->ParentColor = false;
    Label17->Color = clSilver;
    Label18->ParentColor = false;
    Label18->Color = clSilver;
    Label19->ParentColor = false;
    Label19->Color = clSilver;

    Label01->ParentColor = false;
    Label01->Color = clRed;
    Label02->ParentColor = false;
    Label02->Color = clYellow;
    Label03->ParentColor = false;
    Label03->Color = clLime;
}
//---------------------------------------------------------------------------

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

void __fastcall TVMSM200M::FillDetrList(int ADetrId)
{
    CbDetr->Properties->Items->Clear();

    CbDetr->Properties->Items->Add(lblNone->Caption);//"없음");
    FOR_STL(TVmsIfsc *, pObj, VmsIfscManager->FLists)
    {
        if (pObj->DEL_YN == "Y") continue;
        if (ADetrId == pObj->VMS_IFSC_ID) continue;

        CbDetr->Properties->Items->Add(" [" + String(pObj->VMS_IFSC_ID) + "] " + pObj->VMS_IFSC_NM);
    }
    CbDetr->ItemIndex = 0;
}
//---------------------------------------------------------------------------

void __fastcall TVMSM200M::FormShow(TObject *Sender)
{
    Refresh();
    UpdateSkin();

    FRAMEOpenMap1->OpenMap();

    FormInit();
    ChangeEditMode(1);
    TmrShow->Enabled = true;
}
//---------------------------------------------------------------------------

void __fastcall TVMSM200M::FormInit()
{
    //제공구간목록이 초기화되기전에 이전정보를 지도에서 지워준다.
    if (FRAMEOpenMap1->MapStart)
    {
        int nRow;
        TcxDataController *pGDC = TvLink->DataController;
        try
        {
            int nSeq = 1;
            for (int ii = 0; ii < pGDC->RecordCount; ii++)
            {
                String sLinkId = pGDC->Values[ii][ColLink2->Index];

                sJs.printf(L"updateEditLink('%s', 0)", sLinkId.c_str());
                FRAMEOpenMap1->ExecScript(sJs);
            }
        }
        catch(...)
        {
        }
    }

    EdIfscId->Text = "";
    EdIfscNm->Text = "";
    EdStrNm->Text = "";
    EdEndNm->Text = "";
    EdRoadNm->Text = "";
    EdSpotNm->Text = "";
    CbDetr->ItemIndex = 0;

    CMM_ClearGridTableView(TvLink);
    EdLinkId->Text = "";

    EdMin1->Text = "20"; EdMax1->Text = "180";
    EdMin2->Text = "10"; EdMax2->Text =  "19";
    EdMin3->Text =  "0"; EdMax3->Text =   "9";

    EdCngsSpd->Text = "10";

    ChkAxisYn->Checked = false;

    FNewDb = false;
}
//---------------------------------------------------------------------------

bool __fastcall TVMSM200M::CheckSpeedValue()
{
    if (EdMin1->Text == "" || EdMax1->Text == "" ||
        EdMin2->Text == "" || EdMax2->Text == "" ||
        EdMin3->Text == "" || EdMax3->Text == "" )
    {
        Application->MessageBox(lblSpdErr->Caption.c_str(),//L"속도정보가 정확하지 않습니다.\r\n속도정보를 확인하세요.",
                                FTitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
        return false;
    }
    return true;
}
//---------------------------------------------------------------------------

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

    UpdateList();
}
//---------------------------------------------------------------------------

void __fastcall TVMSM200M::UpdateList()
{
    FRAMEVmsIfscList1->UpdateList();
    FillDetrList(0);
}
//---------------------------------------------------------------------------

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

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

void __fastcall TVMSM200M::FormCloseQuery(TObject *Sender, bool &CanClose)
{
    if (FUpdate)
    {
        POST_MSG(Application->MainForm->Handle, WM_DATABASE_REFRESH, WP_MSG_14, 0);
    }

    FRAMEVmsIfscList1->OnCloseQuery(CanClose);
    FRAMEOpenMap1->OnCloseQuery(CanClose);
}
//---------------------------------------------------------------------------

void __fastcall TVMSM200M::DisplayInfo(TVmsIfsc* AObj)
{
    FormInit();

    if (!AObj) return;

    EdIfscId->Text = String(AObj->VMS_IFSC_ID);
    EdIfscNm->Text = AObj->VMS_IFSC_NM;
    EdStrNm->Text  = AObj->DSPL_STRT_NODE_NM;
    EdEndNm->Text  = AObj->DSPL_END_NODE_NM;
    EdRoadNm->Text = AObj->ROAD_NM;
    EdSpotNm->Text = AObj->SPOT_NM;

    if (AObj->DETR_ID == 0)
        CbDetr->ItemIndex = 0;
    else
        APP_SetCode(CbDetr, String(AObj->DETR_ID));

    EdMin1->Text = String(AObj->MIN[0]); EdMax1->Text = String(AObj->MAX[0]);
    EdMin2->Text = String(AObj->MIN[1]); EdMax2->Text = String(AObj->MAX[1]);
    EdMin3->Text = String(AObj->MIN[2]); EdMax3->Text = String(AObj->MAX[2]);

    EdCngsSpd->Text = String(AObj->CNGS_SPD);

    ChkAxisYn->Checked = AObj->AXIS_YN == "Y" ? true : false;

    ChangeEditMode(3);

    DisplayLink(AObj);
}
//---------------------------------------------------------------------------

void __fastcall TVMSM200M::DisplayLink(TVmsIfsc* AObj)
{
    if (!AObj) return;

    CMM_ClearGridTableView(TvLink);

    String sLinkIds = "";
    try
    {
        int nRow;
        TcxDataController *pGDC = TvLink->DataController;
        TvLink->BeginUpdate();

        FOR_STL(TVmsLinkIfsc *, pObj, AObj->FLists)
        {
            nRow = pGDC->AppendRecord();
            pGDC->Values[nRow][ColLink2->Index] = pObj->IFSC_ID;
            pGDC->Values[nRow][ColLink3->Index] = pObj->IFSC_NM;

            TIfsc *pTmp = IfscManager->FLists.Find(pObj->IFSC_ID);
            if (pTmp)
            {
                pGDC->Values[nRow][ColLink4->Index] = pTmp->STRT_NM;
                pGDC->Values[nRow][ColLink5->Index] = pTmp->END_NM;
            }
            if (sLinkIds == "") sLinkIds = pObj->IFSC_ID;
            else                sLinkIds = sLinkIds + ","+pObj->IFSC_ID;
        }
    }
    __finally
    {
        TvLink->EndUpdate();
    }

    RefreshLink();

    if (sLinkIds != "")
    {
        sJs.printf(L"extentLayerObject(%d, '%s')", LyrTp_Traffic, sLinkIds.c_str());
        FRAMEOpenMap1->ExecScript(sJs);
    }
}
//---------------------------------------------------------------------------

void __fastcall TVMSM200M::BtnEditClick(TObject *Sender)
{
    if (BtnEdit->Caption == FrmLang->lblEdit->Caption)//"편집")
    {
        ChangeEditMode(0);
        FNewDb = false;
    }
    else
    {
        String sId = EdIfscId->Text;

        ChangeEditMode(1);

        CMM_SetGridRow(FRAMEVmsIfscList1->CxList, FRAMEVmsIfscList1->TvList, sId, FRAMEVmsIfscList1->Column01->Index);
        int nRow = FRAMEVmsIfscList1->TvList->DataController->FocusedRecordIndex;
        if( nRow <= -1 )
            return;

        int nMemPtr = FRAMEVmsIfscList1->TvList->DataController->Values[nRow][FRAMEVmsIfscList1->Column99->Index];
        TVmsIfsc* pObj = (TVmsIfsc*)nMemPtr;
        DisplayInfo(pObj);
    }
}
//---------------------------------------------------------------------------

void __fastcall TVMSM200M::ChangeEditMode(int AEdit)
{
    bool bGisEdit = true;
    bool bEnabled = false;

    switch(AEdit)
    {
    case 0: //편집버튼클릭
        {
            BtnEdit->Enabled = true;
            BtnInsert->Enabled = false;
            BtnDelete->Enabled = false;
            BtnSave->Enabled = true;

            BtnEdit->Caption = FrmLang->lblCancel->Caption;//"취소";
            BtnEdit->Hint    = FrmLang->lblCancel->Hint;//데이터 편집 취소";
            EditMode = true;
        }
        break;
    case 1: //편집[취소]버튼클릭
        {
            FormInit(); //화면을 모두 지운다.
            BtnEdit->Enabled = false;
            BtnInsert->Enabled = true;
            BtnDelete->Enabled = false;
            BtnSave->Enabled = false;

            BtnEdit->Caption = FrmLang->lblEdit->Caption;//"편집";
            BtnEdit->Hint    = FrmLang->lblEdit->Hint;//데이터 편집";
            bEnabled = true;
            bGisEdit = false;
            EditMode = false;
        }
        break;
    case 2: //추가
        {
            BtnEdit->Enabled = true;
            BtnInsert->Enabled = false;
            BtnDelete->Enabled = false;
            BtnSave->Enabled = true;

            BtnEdit->Caption = FrmLang->lblCancel->Caption;//"취소";
            BtnEdit->Hint    = FrmLang->lblCancel->Hint;//데이터 편집 취소";
            EditMode = true;
        }
        break;
    case 3: //수정모드
        {
            BtnEdit->Enabled = true;
            BtnInsert->Enabled = true;
            BtnDelete->Enabled = true;
            BtnSave->Enabled = false;

            BtnEdit->Caption = FrmLang->lblEdit->Caption;//"편집";
            BtnEdit->Hint    = FrmLang->lblEdit->Hint;//데이터 편집";
            bEnabled = true;
            EditMode = false;
        }
        break;
    }

    if (AEdit == 0 || AEdit == 2)
    {
        FRAMEVmsIfscList1->CxList->Enabled = false;
    }
    else
    {
        FRAMEVmsIfscList1->CxList->Enabled = true;
    }

    GrpInfo->Enabled = EditMode;
    //GrpLink->Enabled = EditMode;
    PnlLink->Enabled = EditMode;

    //BtnLinkAdd->Enabled = !bEnabled;
    BtnLinkDel->Enabled = !bEnabled;

#if 0
    FRAMEGisMap1->ImgSel->Enabled = false;
    if (FRAMEGisMap1->MapStart)
    {
        //TCommFlash::CallFunc(FRAMEGisMap1->ShockwaveFlash1, "ClearSelLink", "0");
        RefreshLink();
        FRAMEGisMap1->ImgSel->Enabled = bGisEdit;
        if (bGisEdit == false)
        {
            TCommFlash::CallFunc(FRAMEGisMap1->ShockwaveFlash1, "SelectMode", "0");   //PAN
        }
    }
#endif
}
//---------------------------------------------------------------------------


void __fastcall TVMSM200M::BtnInsertClick(TObject *Sender)
{
    FormInit();

    //신규아이디를 얻어와서 화면을 초기화한다.
    int nIfscId;
    if (!VmsIfscManager->GetNextVmsIfscId(nIfscId))
    {
        Application->MessageBox(lblText1->Caption.c_str(),//L"새로운 VMS 정보제공구간정보를 생성하지 못하였습니다.\r\n프로그램 종료후에 다시 시도해 보세요.",
                                FTitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
        return;
    }

    EdIfscId->Text = String(nIfscId);

    ChangeEditMode(2);
    FNewDb = true;
}
//---------------------------------------------------------------------------

bool __fastcall TVMSM200M::CheckDeleteIfsc(String AIfscId)
{
    String sQry;
    TADOQuery *pADO = NULL;

    try
    {
        try
        {
            pADO = new TADOQuery(NULL);
			pADO->Close();
            pADO->Connection = ITSDb_GetConnection();
			pADO->SQL->Clear();

sQry = "SELECT COUNT(1) AS CNT FROM TB_VMS_RLTN_IFSC WHERE VMS_IFSC_ID = :p01";
            ITSDb_SQLText(pADO, sQry);
			ITSDb_SQLBind(pADO, "p01", AIfscId);
            ITSDb_SQLOpen(pADO);
            if (pADO->FieldByName("CNT")->AsInteger > 0)
            {
                Application->MessageBox(lblText2->Caption.c_str(),//L"삭제할 제공구간이 VMS 제어기에 맵핑되어 있습니다.\r\n먼저 해당 제어기에서 삭제해주시기 바랍니다.",
                                        FTitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
                return false;
            }

sQry = "SELECT COUNT(1) AS CNT FROM TB_VMS_IFSC WHERE DETR_ID = :p01";
            ITSDb_SQLText(pADO, sQry);
			ITSDb_SQLBind(pADO, "p01", AIfscId);
            ITSDb_SQLOpen(pADO);
            if (pADO->FieldByName("CNT")->AsInteger > 0)
            {
                Application->MessageBox(lblText3->Caption.c_str(),//L"삭제할 제공구간이 우회도로로 맵핑되어있습니다.\r\n먼저 해당 우회도록에서 삭제해주시기 바랍니다.",
                                        FTitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
                return false;
            }

        }
        catch(EDatabaseError &E)
        {
            DBERRORMSG("VMS Section delete", String(E.ClassName()), E.Message, sQry);
            throw Exception(String(E.ClassName()) + E.Message);
        }
        catch(Exception &e)
        {
            DBERRORMSG("VMS Section delete", String(e.ClassName()), e.Message, sQry);
            throw Exception(String(e.ClassName()) + e.Message);
        }
    }
    __finally
    {
        if (pADO)
        {
            pADO->Close();
            delete pADO;
        }
    }

    return true;
}
//---------------------------------------------------------------------------

void __fastcall TVMSM200M::BtnDeleteClick(TObject *Sender)
{
    int nIdx = m_pGDC->FocusedRecordIndex;
    if (nIdx < 0) return;

    String sIfscId = EdIfscId->Text;

    TVmsIfsc *pObj = VmsIfscManager->FLists.Find(sIfscId.ToIntDef(0));
    if (!pObj)
    {
        Application->MessageBox(lblText4->Caption.c_str(),//L"삭제할 제공구간정보를 목록에서 선택하세요.\r\n목록에서 더블클릭하여 선택합니다.",
                                FTitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
        return;
    }
    if (sIfscId.IsEmpty())
    {
        Application->MessageBox(lblText4->Caption.c_str(),//L"삭제할 제공구간정보를 목록에서 선택하세요.\r\n목록에서 더블클릭하여 선택합니다.",
                                FTitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
        return;
    }

    if (!CheckDeleteIfsc(sIfscId))
    {
        return;
    }

    String sMsg;
    sMsg = lblText5->Caption + ": " + sIfscId;//"정보제공구간 ID: " + sIfscId;
    sMsg+= "\r\n" + lblText6->Caption;//"선택하신 정보제공구간 정보를 삭제하시겠습니까?";

    if (Application->MessageBox(sMsg.c_str(), FTitle.c_str(), MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return;

    if (VmsIfscManager->DeleteVmsIfsc(pObj))
    {
        pObj->DEL_YN = "Y";
        pObj->USE_YN = "N";

        UpdateList();

        Application->MessageBox(lblText7->Caption.c_str(),//L"정보제공구간 정보 삭제\r\n정보제공구간 정보를 삭제 하였습니다.",
                                FTitle.c_str(), MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
    }

    FUpdate = true;

    FormInit();
    ChangeEditMode(1);
}
//---------------------------------------------------------------------------

void __fastcall TVMSM200M::BtnSaveClick(TObject *Sender)
{
    TVmsIfsc *pObj;

	if (EdIfscId->Text.IsEmpty()        ||
        EdIfscNm->Text.Trim().IsEmpty() ||
        EdStrNm->Text.Trim().IsEmpty()  ||
        EdEndNm->Text.Trim().IsEmpty())
	{
        Application->MessageBox(FrmLang->lblNecessary->Caption.c_str(),//L"★항목은 필수 입력 항목입니다.\r\n모두 입력후 진행해 주세요.",
                                FTitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
		return;
	}

    if (!CheckSpeedValue()) return;
    if (EdCngsSpd->Text == "") EdCngsSpd->Text = "10";

    String sIfscId = EdIfscId->Text;
    int    nIfscId = sIfscId.ToInt();
    String sDetrId = "";
    int    nDetrId = 0;
    if (CbDetr->ItemIndex == 0)
        nDetrId = 0;
    else
    {
        String sDetrId = APP_GetCode(CbDetr);
        nDetrId = sDetrId.ToIntDef(0);
    }
    if (nDetrId == nIfscId)
    {
        Application->MessageBox(lblText8->Caption.c_str(),//L"우회도로 입력오류\r\n우회도로는 자기자신을 등록할 수 없습니다.",
                                FTitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
		return;
    }


    if (FNewDb)
    {
        pObj = new TVmsIfsc();
    }
    else
        pObj = VmsIfscManager->FLists.Find(nIfscId);

    if (!pObj)
    {
        return;
    }

    if (pObj)
    {

        pObj->VMS_IFSC_ID       = nIfscId;
        pObj->VMS_IFSC_NM       = EdIfscNm->Text.Trim();
        pObj->DSPL_STRT_NODE_NM = EdStrNm->Text.Trim();
        pObj->DSPL_END_NODE_NM  = EdEndNm->Text.Trim();
        pObj->ROAD_NM           = EdRoadNm->Text.Trim();
        pObj->SPOT_NM           = EdSpotNm->Text.Trim();
        pObj->DETR_ID           = nDetrId;
        pObj->AXIS_YN           = ChkAxisYn->Checked ? "Y" : "N";

        if (FNewDb)
            pObj->USE_YN = "Y";
        else
            pObj->USE_YN = "Y";

        pObj->MIN[0] = EdMin1->Text.ToInt(); pObj->MAX[0] = EdMax1->Text.ToInt();
        pObj->MIN[1] = EdMin2->Text.ToInt(); pObj->MAX[1] = EdMax2->Text.ToInt();
        pObj->MIN[2] = EdMin3->Text.ToInt(); pObj->MAX[2] = EdMax3->Text.ToInt();
        pObj->CNGS_SPD = EdCngsSpd->Text.ToInt();

        pObj->DEL_YN      = "N";

        pObj->Completed   = true;
        pObj->MEM_DEL     = "N";

        pObj->FLists.RemoveAll();

        try {
            TvLink->BeginUpdate();
            for (int ii = 0; ii < TvLink->DataController->RecordCount; ii++)
            {
                String sLinkId = VarToStr(TvLink->DataController->Values[ii][ColLink2->Index]);
                String sLinkNm = VarToStr(TvLink->DataController->Values[ii][ColLink3->Index]);
                String sStrNm  = VarToStr(TvLink->DataController->Values[ii][ColLink4->Index]);
                String sEndNm  = VarToStr(TvLink->DataController->Values[ii][ColLink5->Index]);

				TVmsLinkIfsc *pObjLnk = new TVmsLinkIfsc();

                pObjLnk->VMS_IFSC_ID       = pObj->VMS_IFSC_ID;
                pObjLnk->IFSC_ID           = sLinkId;
                pObjLnk->ORD               = ii+1;
                //pObjLnk->DSPL_STRT_NODE_NM = sStrNm;
                //pObjLnk->DSPL_END_NODE_NM  = sEndNm;
                pObjLnk->IFSC_NM           = sLinkNm;

				pObj->FLists.Push(pObjLnk->ORD, pObjLnk);
            }
        }
        __finally
        {
            TvLink->EndUpdate();
        }

        bool bResult;
        if (FNewDb)
            bResult = VmsIfscManager->InsertVmsIfsc(pObj);
        else
            bResult = VmsIfscManager->UpdateVmsIfsc(pObj);

        if (bResult)
        {
            Application->MessageBox(lblText9->Caption.c_str(),//L"정보제공구간정보저장\r\n정보제공구간정보를 저장 하였습니다.",
                                    FTitle.c_str(), MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);

            if (FNewDb)
            {
                VmsIfscManager->FLists.Push(pObj->VMS_IFSC_ID, pObj);
            }

            FUpdate = true;

            UpdateList();
            CMM_SetGridRow(FRAMEVmsIfscList1->CxList, FRAMEVmsIfscList1->TvList, sIfscId, FRAMEVmsIfscList1->Column01->Index);

            int nRow = FRAMEVmsIfscList1->TvList->DataController->FocusedRecordIndex;
            if( nRow <= -1 )
                return;

            int nMemPtr = FRAMEVmsIfscList1->TvList->DataController->Values[nRow][FRAMEVmsIfscList1->Column99->Index];
            TVmsIfsc* pObj = (TVmsIfsc*)nMemPtr;
            DisplayInfo(pObj);
        }
    }
}
//---------------------------------------------------------------------------

void __fastcall TVMSM200M::RefreshLink()
{
    if (!FRAMEOpenMap1->MapStart) return;

    try
    {
        int nRow;
        TcxDataController *pGDC = TvLink->DataController;
        TvLink->BeginUpdate();
        try
        {
            int nSeq = 1;
            for (int ii = 0; ii < pGDC->RecordCount; ii++)
            {
                pGDC->Values[ii][ColSeq->Index] = nSeq;
                String sLinkId = pGDC->Values[ii][ColLink2->Index];

                sJs.printf(L"updateEditLink('%s', %d)", sLinkId.c_str(), nSeq);
                FRAMEOpenMap1->ExecScript(sJs);
                if (nSeq++ > ITSMAP_MAX_DISPCOLOR) nSeq = 1;
            }
        }
        catch(...)
        {
        }
    }
    __finally
    {
        TvLink->EndUpdate();
    }
}
//---------------------------------------------------------------------------

void __fastcall TVMSM200M::UpdateIcon()
{
    if (!FRAMEOpenMap1->MapStart) return;

    String arrObj = "";
    String sTemp;
    try
    {
        VmsCtlrManager->FLists.Lock();
        try
        {
            FOR_STL(TVmsCtlr*, pObj, VmsCtlrManager->FLists)
            {
                if (pObj->DEL_YN == "Y") continue;

                if (arrObj != "") arrObj += "|";

                sTemp.printf(L"%s,%s,%s,%.6f,%.6f,0,0,0,0", pObj->VMS_CTLR_NMBR.c_str(), pObj->VMS_CTLR_ID.c_str(), pObj->VMS_NM.c_str(), pObj->X_CRDN, pObj->Y_CRDN);
                arrObj += sTemp;
            }
        }
        __finally
        {
            VmsCtlrManager->FLists.UnLock();
            if (arrObj != "")
            {
                sJs.printf(L"addFacility(%d, '%s')", FLayerIdx, arrObj.c_str());
                FRAMEOpenMap1->ExecScript(sJs);

                sJs.printf(L"showLayerText(%d, %d)", FLayerIdx, (ChkViewIcon->Checked) ? 1: 0);
                FRAMEOpenMap1->ExecScript(sJs);
            }
        }
    }
    catch(...)
    {
    }
}
//---------------------------------------------------------------------------

void __fastcall TVMSM200M::UpdateEditLink()
{
    if (!FRAMEOpenMap1->MapStart) return;

    try
    {
        IfscManager->FLists.Lock();
        try
        {
            FOR_STL(TIfsc*, pObj, IfscManager->FLists)
            {
                if (pObj->DEL_YN == "Y")   continue;
                if (pObj->vertex == false) continue;

                sJs.printf(L"addEditLink('%s', '%s', '%s', '%s', '%s', '%s')",
                    pObj->IFSC_ID.c_str(),
                    pObj->IFSC_NM.c_str(),
                    pObj->STRT_NM.c_str(),
                    pObj->END_NM.c_str(),
                    pObj->X_CRDN_ARR.c_str(),
                    pObj->Y_CRDN_ARR.c_str());

                FRAMEOpenMap1->ExecScript(sJs);
            }
        }
        __finally
        {
            IfscManager->FLists.UnLock();
        }
        FRAMEOpenMap1->ExecScript("makeEditLinkLayer()");
    }
    catch(...)
    {
    }
}
//---------------------------------------------------------------------------

void __fastcall TVMSM200M::TvLinkCellDblClick(TcxCustomGridTableView *Sender, TcxGridTableDataCellViewInfo *ACellViewInfo,
          TMouseButton AButton, TShiftState AShift, bool &AHandled)
{
    if (!FRAMEOpenMap1->MapStart) return;

	if (!ACellViewInfo) return;
	int nRow = TvLink->DataController->FocusedRecordIndex;
	if( nRow <= -1 )
		return;

    String sLinkId = TvLink->DataController->Values[nRow][ColLink2->Index];
    sJs.printf(L"extentLayerObject(%d, '%s')", LyrTp_Traffic, sLinkId.c_str());
    FRAMEOpenMap1->ExecScript(sJs);
}
//---------------------------------------------------------------------------

void __fastcall TVMSM200M::FRAMEVmsIfscList1TvListCellDblClick(TcxCustomGridTableView *Sender,
          TcxGridTableDataCellViewInfo *ACellViewInfo, TMouseButton AButton,
          TShiftState AShift, bool &AHandled)
{
	if (!ACellViewInfo) return;
	int nRow = FRAMEVmsIfscList1->TvList->DataController->FocusedRecordIndex;
	if( nRow <= -1 )
		return;

    int nMemPtr = FRAMEVmsIfscList1->TvList->DataController->Values[nRow][FRAMEVmsIfscList1->Column99->Index];
    TVmsIfsc* pObj = (TVmsIfsc*)nMemPtr;

    DisplayInfo(pObj);
}
//---------------------------------------------------------------------------

void __fastcall TVMSM200M::EdMin3KeyPress(TObject *Sender, wchar_t &Key)
{
    if (Key > '9' || Key < '0')
    {
        if (Key != VK_BACK && Key != VK_TAB && Key != '-')
            Key = 0;
    }
}
//---------------------------------------------------------------------------

void __fastcall TVMSM200M::BtnSaveAllClick(TObject *Sender)
{
    String sMsg;
    sMsg = "";
    sMsg+= "\r\n" + lblText10->Caption;//"제공구간 속도정보를 전체 제공구간에 동일하게 적용 하시겠습니까?";

    if (Application->MessageBox(sMsg.c_str(), FTitle.c_str(), MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return;

    if (!CheckSpeedValue()) return;

    int MIN1 = EdMin1->Text.ToInt();
    int MAX1 = EdMax1->Text.ToInt();
    int MIN2 = EdMin2->Text.ToInt();
    int MAX2 = EdMax2->Text.ToInt();
    int MIN3 = EdMin3->Text.ToInt();
    int MAX3 = EdMax3->Text.ToInt();



    TVmsIfsc* pObj = NULL;
    try
    {
        pObj = new TVmsIfsc();
        pObj->MIN[0] = EdMin1->Text.ToInt(); pObj->MAX[0] = EdMax1->Text.ToInt();
        pObj->MIN[1] = EdMin2->Text.ToInt(); pObj->MAX[1] = EdMax2->Text.ToInt();
        pObj->MIN[2] = EdMin3->Text.ToInt(); pObj->MAX[2] = EdMax3->Text.ToInt();

        if (VmsIfscManager->UpdateIfscSpeedInfo(pObj))
        {
            FUpdate = true;

            FOR_STL(TVmsIfsc*, pTmpObj, VmsIfscManager->FLists)
            {
                if (pTmpObj->DEL_YN == "Y") continue;

                for(int ii = 0; ii < 3; ii++)
                {
                    pTmpObj->MIN[ii] = pObj->MIN[ii];
                    pTmpObj->MAX[ii] = pObj->MAX[ii];
                }
            }

            Application->MessageBox(lblText11->Caption.c_str(),//L"제공구간 속도정보저장\r\n제공구간 속도 정보를 전체 제공구간에 적용 하였습니다.",
                                    FTitle.c_str(), MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
        }
    }
    __finally
    {
        if (pObj)
        {
            delete pObj;
            pObj = NULL;
        }
    }
}
//---------------------------------------------------------------------------

void __fastcall TVMSM200M::AddRemoveLink(String ALinkId)
{
    TIfsc* pObj = IfscManager->FLists.Find(ALinkId);
    if (!pObj) return;

    try
    {
        int nRow;
        TcxDataController *pGDC = TvLink->DataController;
        TvLink->BeginUpdate();

        for (int ii = 0; ii < pGDC->RecordCount; ii++)
        {
            String sLinkId = pGDC->Values[ii][ColLink2->Index];
            if (ALinkId == sLinkId)
            {
                //pGDC->DeleteRecord(ii);
                return;
            }
        }

        nRow = pGDC->AppendRecord();
        pGDC->Values[nRow][ColLink2->Index] = ALinkId;
        pGDC->Values[nRow][ColLink3->Index] = pObj->IFSC_NM;
        pGDC->Values[nRow][ColLink4->Index] = pObj->STRT_NM;
        pGDC->Values[nRow][ColLink5->Index] = pObj->END_NM;
    }
    __finally
    {
        TvLink->EndUpdate();
        RefreshLink();
    }
}
//---------------------------------------------------------------------------

void __fastcall TVMSM200M::BtnLinkCopyClick(TObject *Sender)
{
    String sIfscId = EdLinkId->Text.Trim();
    int nIfscId = sIfscId.ToIntDef(0);

    TVmsIfsc *pIfsc = VmsIfscManager->FLists.Find(nIfscId);
    if (!pIfsc) return;

    try
    {
        int nRow;
        TcxDataController *pGDC = TvLink->DataController;
        TvLink->BeginUpdate();

        FOR_STL(TVmsLinkIfsc *, pObj, pIfsc->FLists)
        {
            nRow = pGDC->AppendRecord();
            pGDC->Values[nRow][ColLink2->Index] = pObj->IFSC_ID;
            pGDC->Values[nRow][ColLink3->Index] = pObj->IFSC_NM;

            TIfsc *pTmp = IfscManager->FLists.Find(pObj->IFSC_ID);
            if (pTmp)
            {
                pGDC->Values[nRow][ColLink4->Index] = pTmp->STRT_NM;
                pGDC->Values[nRow][ColLink5->Index] = pTmp->END_NM;
            }
        }
    }
    __finally
    {
        TvLink->EndUpdate();
    }
    RefreshLink();
}
//---------------------------------------------------------------------------

void __fastcall TVMSM200M::BtnLinkDelClick(TObject *Sender)
{
    int nSelRows = TvLink->Controller->SelectedRowCount;
    if (nSelRows <= 0)
    {
        Application->MessageBox(lblText13->Caption.c_str(),//L"삭제를 원하는 구간을 목록에서 선택하세요.",
                                FTitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
        return;
    }
    for (int ii = 0; ii < nSelRows; ii++)
    {
        int nSelIdx = TvLink->Controller->SelectedRows[ii]->RecordIndex;

        String sLinkId = TvLink->DataController->Values[nSelIdx][ColLink2->Index];
        sJs.printf(L"updateEditLink('%s', 0)", sLinkId.c_str());
        FRAMEOpenMap1->ExecScript(sJs);
    }
    TvLink->Controller->DeleteSelection();
}
//---------------------------------------------------------------------------

void __fastcall TVMSM200M::BtnUpClick(TObject *Sender)
{
    try
    {
        TvLink->BeginUpdate();

        int nCurIdx = TvLink->DataController->FocusedRowIndex;//FocusedRecordIndex;
        if (nCurIdx <= 0)
        {
            return;
        }

        int nUpIdx = nCurIdx-1;

        try
        {
            String sVal1 = VarToStr(TvLink->DataController->Values[nCurIdx][ColLink1->Index]);
            String sVal2 = VarToStr(TvLink->DataController->Values[nCurIdx][ColLink2->Index]);
            String sVal3 = VarToStr(TvLink->DataController->Values[nCurIdx][ColLink3->Index]);
            String sVal4 = VarToStr(TvLink->DataController->Values[nCurIdx][ColLink4->Index]);
            String sVal5 = VarToStr(TvLink->DataController->Values[nCurIdx][ColLink5->Index]);

            TvLink->DataController->Values[nCurIdx][ColLink1->Index] = TvLink->DataController->Values[nUpIdx][ColLink1->Index];
            TvLink->DataController->Values[nCurIdx][ColLink2->Index] = TvLink->DataController->Values[nUpIdx][ColLink2->Index];
            TvLink->DataController->Values[nCurIdx][ColLink3->Index] = TvLink->DataController->Values[nUpIdx][ColLink3->Index];
            TvLink->DataController->Values[nCurIdx][ColLink4->Index] = TvLink->DataController->Values[nUpIdx][ColLink4->Index];
            TvLink->DataController->Values[nCurIdx][ColLink5->Index] = TvLink->DataController->Values[nUpIdx][ColLink5->Index];

            TvLink->DataController->Values[nUpIdx][ColLink1->Index] = sVal1;
            TvLink->DataController->Values[nUpIdx][ColLink2->Index] = sVal2;
            TvLink->DataController->Values[nUpIdx][ColLink3->Index] = sVal3;
            TvLink->DataController->Values[nUpIdx][ColLink4->Index] = sVal4;
            TvLink->DataController->Values[nUpIdx][ColLink5->Index] = sVal5;

            TvLink->Controller->ClearSelection();
            TvLink->Controller->FocusedRowIndex = nUpIdx;
            //TvLink->Controller->FocusedRecordIndex = nUpIdx;
            TvLink->ViewData->Records[nUpIdx]->Focused = true;
            TvLink->ViewData->Records[nUpIdx]->Selected = true;
            CxLink->SetFocus();
            //TcxCustomGridRow* ARow = TvLink->ViewData->Rows[TvLink->DataController->FocusedRowIndex];
        }
        catch(...)
        {
        }
    }
    __finally
    {
        TvLink->EndUpdate();
    }
     RefreshLink();
}
//---------------------------------------------------------------------------

void __fastcall TVMSM200M::BtnDownClick(TObject *Sender)
{
    try
    {
        TvLink->BeginUpdate();

        int nCurIdx = TvLink->DataController->FocusedRowIndex;//FocusedRecordIndex;
        //int nCurIdx = TvLink->DataController->FocusedRecordIndex;
        if (nCurIdx < 0)
        {
            return;
        }
        if (nCurIdx == TvLink->DataController->RecordCount-1)
        {
            return;
        }

        int nDnIdx = nCurIdx+1;

        try
        {
            String sVal1 = VarToStr(TvLink->DataController->Values[nCurIdx][ColLink1->Index]);
            String sVal2 = VarToStr(TvLink->DataController->Values[nCurIdx][ColLink2->Index]);
            String sVal3 = VarToStr(TvLink->DataController->Values[nCurIdx][ColLink3->Index]);
            String sVal4 = VarToStr(TvLink->DataController->Values[nCurIdx][ColLink4->Index]);
            String sVal5 = VarToStr(TvLink->DataController->Values[nCurIdx][ColLink5->Index]);

            TvLink->DataController->Values[nCurIdx][ColLink1->Index] = TvLink->DataController->Values[nDnIdx][ColLink1->Index];
            TvLink->DataController->Values[nCurIdx][ColLink2->Index] = TvLink->DataController->Values[nDnIdx][ColLink2->Index];
            TvLink->DataController->Values[nCurIdx][ColLink3->Index] = TvLink->DataController->Values[nDnIdx][ColLink3->Index];
            TvLink->DataController->Values[nCurIdx][ColLink4->Index] = TvLink->DataController->Values[nDnIdx][ColLink4->Index];
            TvLink->DataController->Values[nCurIdx][ColLink5->Index] = TvLink->DataController->Values[nDnIdx][ColLink5->Index];

            TvLink->DataController->Values[nDnIdx][ColLink1->Index] = sVal1;
            TvLink->DataController->Values[nDnIdx][ColLink2->Index] = sVal2;
            TvLink->DataController->Values[nDnIdx][ColLink3->Index] = sVal3;
            TvLink->DataController->Values[nDnIdx][ColLink4->Index] = sVal4;
            TvLink->DataController->Values[nDnIdx][ColLink5->Index] = sVal5;

            TvLink->Controller->ClearSelection();
            TvLink->Controller->FocusedRowIndex = nDnIdx;
            //TvLink->Controller->FocusedRecordIndex = nDnIdx;
            TvLink->ViewData->Records[nDnIdx]->Focused = true;
            TvLink->ViewData->Records[nDnIdx]->Selected = true;
            CxLink->SetFocus();
            //TcxCustomGridRow* ARow = TvLink->ViewData->Rows[TvLink->DataController->FocusedRowIndex];
        }
        catch(...)
        {
        }
    }
    __finally
    {
        TvLink->EndUpdate();
    }
     RefreshLink();
}
//---------------------------------------------------------------------------

void __fastcall TVMSM200M::ChkViewIconClick(TObject *Sender)
{
    if (!FRAMEOpenMap1->MapStart) return;
    sJs.printf(L"showLayerText(%d, %d)", FLayerIdx, (ChkViewIcon->Checked) ? 1: 0);
    FRAMEOpenMap1->ExecScript(sJs);
}
//---------------------------------------------------------------------------

void __fastcall TVMSM200M::BtnVmsIfscSetClick(TObject *Sender)
{
    FORMSHOW(VMSM210M);
}
//---------------------------------------------------------------------------

void __fastcall TVMSM200M::ColSeqCustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
          bool &ADone)
{
	if (AViewInfo->GridRecord->RecordIndex < 0)
		return;
	if (VarIsNull(AViewInfo->Value))
		return;

	try
	{
		int nIdx = AViewInfo->Value;
		if (nIdx < 0)
			return;

		ACanvas->Brush->Color = ITSMap_GetDisplayColor(nIdx);
		ACanvas->Font->Color  = ACanvas->Brush->Color;
	}
	catch(...)
	{
	}
}
//---------------------------------------------------------------------------
void __fastcall TVMSM200M::OpenMapCallback(TObject *ASender, const String AFunc, const String AArgs, const bool AFirst)
{
    try
    {
        if (AFirst)
        {
            //지도를 편집모드로 변경
            sJs.printf(L"setEditMode(%d, 1)", FLayerIdx);
            FRAMEOpenMap1->ExecScript(sJs);

            //편집레이어 생성
            FRAMEOpenMap1->ExecScript("initEditLayer()");

            //배경링크레이어 생성
            UpdateEditLink();

            //시설물아이콘 등록
            UpdateIcon();

            //화면을 시설물 여역으로 확대
            sJs.printf(L"extentLayer(%d)", FLayerIdx);
            FRAMEOpenMap1->ExecScript(sJs);

            return;
        }

        if (AFunc.Pos("onlinkclick"))
        {
            TStringList *pStringList = new TStringList;
            pStringList->CommaText = AArgs;

            try
            {
                String sLyrType = pStringList->Strings[0];
                String sLinkId  = pStringList->Strings[1];
                if (EditMode)
                {
                    AddRemoveLink(sLinkId);
                }
            }
            catch(Exception &e)
            {
            }
            delete pStringList;
        }
        if (AFunc.Pos("onfacilityclick"))
        {
            if (BtnEdit->Caption == FrmLang->lblEdit->Caption)
            {
                FormInit();

                CMM_ClearGridTableView(TvLink);
                String sLinkIds = "";

                TStringList *pStringList = new TStringList;
                pStringList->CommaText = AArgs;

                try
                {
                    String sZoom = pStringList->Strings[0];
                    String sNmbr = pStringList->Strings[1];

                    try
                    {
                        int nRow;
                        TcxDataController *pGDC = TvLink->DataController;
                        TvLink->BeginUpdate();

                        int nSeq = 1;
                        TVmsCtlr *pVms = VmsCtlrManager->FLists.Find(sNmbr);
                        if (pVms)
                        {
                            FOR_STL(TVmsIfscRltn *, pObj, pVms->FIfscRltn)
                            {
                                TVmsIfsc *pVmsIfsc = VmsIfscManager->FLists.Find(pObj->VMS_IFSC_ID);
                                if (pVmsIfsc)
                                {
                                    FOR_STL(TVmsLinkIfsc *, pIfsc, pVmsIfsc->FLists)
                                    {
                                        FRAMEOpenMap1->reMsg->Lines->Add(pIfsc->IFSC_ID);

                                        nRow = pGDC->AppendRecord();
                                        pGDC->Values[nRow][ColSeq->Index] = nSeq;
                                        pGDC->Values[nRow][ColLink2->Index] = pIfsc->IFSC_ID;
                                        pGDC->Values[nRow][ColLink3->Index] = pIfsc->IFSC_NM;

                                        TIfsc *pTmp = IfscManager->FLists.Find(pIfsc->IFSC_ID);
                                        if (pTmp)
                                        {
                                            pGDC->Values[nRow][ColLink4->Index] = pTmp->STRT_NM;
                                            pGDC->Values[nRow][ColLink5->Index] = pTmp->END_NM;
                                        }

                                        sJs.printf(L"updateEditLink('%s', %d)", pIfsc->IFSC_ID.c_str(), nSeq);
                                        FRAMEOpenMap1->ExecScript(sJs);
                                    }
                                    if (nSeq++ > ITSMAP_MAX_DISPCOLOR) nSeq = 1;
                                }
                            }
                        }
                    }
                    __finally
                    {
                        TvLink->EndUpdate();
                    }

                    //RefreshLink();
                }
                catch(Exception &e)
                {
                }
                delete pStringList;
            }
        }
    }
    catch(Exception &exception)
    {
    }
}
//---------------------------------------------------------------------------

void __fastcall TVMSM200M::BtnSaveCngsSpdClick(TObject *Sender)
{
    String sMsg;
    sMsg = "";
    sMsg+= "\r\n제공구간 정체폼 정체판정 속도정보를 전체 제공구간에 동일하게 적용 하시겠습니까?";//lblText10->Caption;//"제공구간 속도정보를 전체 제공구간에 동일하게 적용 하시겠습니까?";

    if (Application->MessageBox(sMsg.c_str(), FTitle.c_str(), MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return;

    if (EdCngsSpd->Text == "")
    {
        Application->MessageBox(lblSpdErr->Caption.c_str(),//L"속도정보가 정확하지 않습니다.\r\n속도정보를 확인하세요.",
                                FTitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
        return;
    }

    int CngsSpd = EdCngsSpd->Text.ToIntDef(0);

    try
    {
        if (VmsIfscManager->UpdateIfscCngsSpeedInfo(CngsSpd))
        {
            FUpdate = true;

            FOR_STL(TVmsIfsc*, pTmpObj, VmsIfscManager->FLists)
            {
                if (pTmpObj->DEL_YN == "Y") continue;
                pTmpObj->CNGS_SPD = CngsSpd;
            }

            Application->MessageBox(L"제공구간 정체폼 정체판정 속도정보저장\r\n제공구간 정체폼 정체판정 속도 정보를 전체 제공구간에 적용 하였습니다.",//lblText11->Caption.c_str(),//L"제공구간 속도정보저장\r\n제공구간 속도 정보를 전체 제공구간에 적용 하였습니다.",
                                    FTitle.c_str(), MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
        }
    }
    __finally
    {
    }
}
//---------------------------------------------------------------------------

