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

#include <vcl.h>
#include "ITSSkinF.h"
#include "ITSUtilF.h"
#include "AppGlobalF.h"
#include "CDSVmsIfscF.h"
#include "ITSLangTransF.h"
#include "CDSFontF.h"
#include "CDSAtmpF.h"
#include "CDSVmsFormF.h"
#pragma hdrstop

#include "VMSM600MF.h"
#include "VMSM610MF.h"
#include "VMSM620MF.h"
#include "VMSM630MF.h"
#include "VMSM640MF.h"
#include "VMSM650MF.h"
#include "VMSM660MF.h"
#include "VMSSEL0MF.h"
#include "VMSEDT0MF.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "cxButtons"
#pragma link "cxCalendar"
#pragma link "cxContainer"
#pragma link "cxControls"
#pragma link "cxDropDownEdit"
#pragma link "cxEdit"
#pragma link "cxGraphics"
#pragma link "cxGroupBox"
#pragma link "cxLabel"
#pragma link "cxLookAndFeelPainters"
#pragma link "cxLookAndFeels"
#pragma link "cxMaskEdit"
#pragma link "cxPC"
#pragma link "cxPCdxBarPopupMenu"
#pragma link "cxSpinEdit"
#pragma link "cxSplitter"
#pragma link "cxTextEdit"
#pragma link "cxTimeEdit"
#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 "cxRadioGroup"
#pragma link "cxClasses"
#pragma link "cxCustomData"
#pragma link "cxData"
#pragma link "cxDataStorage"
#pragma link "cxDBData"
#pragma link "cxFilter"
#pragma link "cxGrid"
#pragma link "cxGridCustomTableView"
#pragma link "cxGridCustomView"
#pragma link "cxGridDBTableView"
#pragma link "cxGridLevel"
#pragma link "cxGridTableView"
#pragma link "cxStyles"
#pragma link "cxCheckBox"
#pragma link "cxImage"
#pragma link "cxButtonEdit"
#pragma link "cxBlobEdit"
#pragma link "cxColorComboBox"
#pragma link "cxCalc"
#pragma link "VmsDesignerF"
#pragma link "FRAME_VmsSchListF"
#pragma resource "*.dfm"

TVMSM600M *VMSM600M = NULL;
//---------------------------------------------------------------------------

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

    FUpdate= false;
    FTitle = Caption;//"VMS 자동 스케줄 관리";

	FListSymb = new TList;

    EditMode = false;

    FVMS_SCH_TYPE      = "A";   //자동스케쥴
    FEN_DSPL_SCH_TYPE  = enScheduleAuto;

    FRAMEVmsSchList1->PnlTop->Visible = false;
    FRAMEVmsSchList1->PnlBottom->Visible = false;
    FRAMEVmsSchList1->ColAuto->Visible = true;
    FRAMEVmsSchList1->ColFix->Visible  = false;
    FRAMEVmsSchList1->ColBase->Visible = false;

    FRAMEVmsSchList1->FEN_DSPL_SCH_TYPE = FEN_DSPL_SCH_TYPE;

    FVmsHeight = 64;

    for (int ii = 0; ii < eSchTp_max; ii++)
    {
        FButtonAdd[ii] = (TcxButton*)FindComponent("BtnListAdd"+IntToStr(ii));
        FButtonDel[ii] = (TcxButton*)FindComponent("BtnListDelete"+IntToStr(ii));
        if (FButtonAdd[ii]) FButtonAdd[ii]->Left = 4;
        if (FButtonDel[ii]) FButtonDel[ii]->Left = 4;

        FTabSheet[ii] = (TcxTabSheet*)FindComponent("TabSheet"+IntToStr(ii));
        FListFrm[ii]  = (TcxGridTableView*)FindComponent("TvForm"+IntToStr(ii));

        FLabel[ii]   = (TcxLabel*)FrmLang->FindComponent("lblSch"+IntToStr(ii));
    }

    PgVmsSch->Properties->ActivePage = TabSheet0;
    //eSchTp_incident = 1,    //1:돌발,
    if (FTabSheet[eSchTp_incident])
    {
        FTabSheet[eSchTp_incident]->TabVisible = false;
        FTabSheet[eSchTp_incident]->Visible = false;
    }
    //eSchTp_gongsa   = 2,    //2:공사행사,
    if (FTabSheet[eSchTp_gongsa])
    {
        FTabSheet[eSchTp_gongsa]->TabVisible = false;
        FTabSheet[eSchTp_gongsa]->Visible = false;
    }

    // eSchTp_deture
    if (FTabSheet[eSchTp_deture])
    {
        FTabSheet[eSchTp_deture]->TabVisible = false;
        FTabSheet[eSchTp_deture]->Visible = false;
    }
    // eSchTp_congest
    if (FTabSheet[eSchTp_congest])
    {
        FTabSheet[eSchTp_congest]->TabVisible = false;
        FTabSheet[eSchTp_congest]->Visible = false;
    }
    // eSchTp_safe
    if (FTabSheet[eSchTp_safe])
    {
        FTabSheet[eSchTp_safe]->TabVisible = false;
        FTabSheet[eSchTp_safe]->Visible = false;
    }

#if 1
    // eSchTp_video
    if (FTabSheet[eSchTp_video])
    {
        FTabSheet[eSchTp_video]->TabVisible = false;
        FTabSheet[eSchTp_video]->Visible = false;
    }
    // eSchTp_stream
    if (FTabSheet[eSchTp_stream])
    {
        FTabSheet[eSchTp_stream]->TabVisible = false;
        FTabSheet[eSchTp_stream]->Visible = false;
    }
#endif

    // eSchTp_atmp
    if (FTabSheet[eSchTp_atmp])
    {
        FTabSheet[eSchTp_atmp]->TabVisible = false;
        FTabSheet[eSchTp_atmp]->Visible = false;
    }

    // eSchTp_park
    if (FTabSheet[eSchTp_park])
    {
#ifdef USE_PARK
        FTabSheet[eSchTp_park]->TabVisible = true;
        FTabSheet[eSchTp_park]->Visible = true;
#else
        FTabSheet[eSchTp_park]->TabVisible = false;
        FTabSheet[eSchTp_park]->Visible = false;
#endif
    }

    InitTcxList(TvGrid0);
    for (int ii = 0; ii < eSchTp_max; ii++)
    {
        if (FTabSheet[ii] && (FTabSheet[ii]->TabVisible == false))
        {
            FListFrm[ii] = NULL;
        }

        if (FListFrm[ii]) InitTcxList(FListFrm[ii]);
    }
#if 0
    BtnSchWeek->Visible = true;
#else
    BtnSchWeek->Visible = false;
#endif
}
//---------------------------------------------------------------------------

void __fastcall TVMSM600M::InitTcxList(TcxGridTableView *AView)
{
    AView->OptionsView->DataRowHeight  = 0;
    AView->OptionsView->CellAutoHeight = true;
    AView->OptionsView->Indicator      = false;

    AView->OptionsCustomize->ColumnMoving  = false;
    AView->OptionsCustomize->ColumnSorting = false;

    AView->Columns[0]->Width = 40;
    AView->Columns[0]->Options->HorzSizing = false;

    AView->Columns[1]->Width = 330;
}
//---------------------------------------------------------------------------

void __fastcall TVMSM600M::CommClose()
{
    try
    {
        if (m_pEdtDesigner)
        {
            delete m_pEdtDesigner;
            m_pEdtDesigner = NULL;
        }

        APP_DelVmsSizeCombo(CbSizeType);

        ClearSymbloList();
        SAFE_DELETE(FListSymb);
        CMM_SaveForm(g_sFormsDir, this);
    }
    catch(...)
    {
    }
}
//---------------------------------------------------------------------------

void __fastcall TVMSM600M::FormCreate(TObject *Sender)
{
    m_pEdtDesigner = new TVmsFormDesigner(PnlEditForm);
    FOR_STL(TCDSFontColor*, pObj, CDSFontManager->FColors)
    {
        m_pEdtDesigner->InitFontColor(pObj->VMS_FONT_COLR_CD, (TColor)pObj->VMS_FONT_COLR_VAL);
    }
}
//---------------------------------------------------------------------------

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

void __fastcall TVMSM600M::FormInit()
{
    TvGrid0->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoSchedule->Caption;
    for (int ii = 0; ii < eSchTp_max; ii++)
    {
        if (FListFrm[ii]) FListFrm[ii]->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoForm->Caption;//"<등록되어 있는 폼 정보가 없습니다>";
    }

    //VMS사이즈
    APP_FillVmsSizeType(CbSizeType, false);

    VmsCtlrManager->LoadVmsFormUsage();
    FRAMEVmsSchList1->RefreshVmsFormUsage();

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

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

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

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

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

void __fastcall TVMSM600M::ChangeEditMode(int AEdit)
{
}
//---------------------------------------------------------------------------

void __fastcall TVMSM600M::ClearSymbloList()
{
	for(int ii = 0; ii < FListSymb->Count; ii++)
	{
		Graphics::TBitmap *bitmap = (Graphics::TBitmap *)FListSymb->Items[ii];
		delete bitmap;
	}
	FListSymb->Clear();
}
//---------------------------------------------------------------------------

void __fastcall TVMSM600M::FRAMEVmsSchList1TvListCellDblClick(TcxCustomGridTableView *Sender,
          TcxGridTableDataCellViewInfo *ACellViewInfo, TMouseButton AButton,
          TShiftState AShift, bool &AHandled)
{
	if (!ACellViewInfo) return;
    DisplayInfo();
}
//---------------------------------------------------------------------------

void __fastcall TVMSM600M::FRAMEVmsSchList1TvListFocusedRecordChanged(TcxCustomGridTableView *Sender,
          TcxCustomGridRecord *APrevFocusedRecord, TcxCustomGridRecord *AFocusedRecord,
          bool ANewItemRecordFocusingChanged)
{
    if (!AFocusedRecord) return;
    DisplayInfo();
}
//---------------------------------------------------------------------------

void __fastcall TVMSM600M::CbSizeTypePropertiesChange(TObject *Sender)
{
    BtnSearchClick(NULL);
}
//---------------------------------------------------------------------------

void __fastcall TVMSM600M::BtnSearchClick(TObject *Sender)
{
    RefreshData();

    EdFocus->SetFocus();
    ChangeEditMode(1);
}
//---------------------------------------------------------------------------

void __fastcall TVMSM600M::RefreshData()
{
    FormClear();

    TVmsSizeType *pVmsSizeType = APP_GetVmsSizeTypeObject(CbSizeType);
    if (pVmsSizeType == NULL) return;

    FVmsTypeCd = pVmsSizeType->TypeCd;
    FVmsWidth  = pVmsSizeType->Width;
    FVmsHeight = pVmsSizeType->Height;

    PnlEdtBack->Width = FVmsWidth+4;
    PnlEdtBack->Height= FVmsHeight+4;

    m_pEdtDesigner->Clear();
    m_pEdtDesigner->SizeType = FVmsTypeCd;
    m_pEdtDesigner->SetSize(FVmsWidth, FVmsHeight);
    m_pEdtDesigner->SetPos(0, 0);
    m_pEdtDesigner->BkColorCode = "0";

    m_pEdtDesigner->EditMode = true;
    m_pEdtDesigner->Show();

    FRAMEVmsSchList1->UpdateList(FVmsTypeCd);

    LoadVmsFormList(FVmsTypeCd);

    ChkAutoWidthPropertiesChange((TObject*)ChkAutoWidth);
}
//---------------------------------------------------------------------------

void __fastcall TVMSM600M::FormClear()
{
    FSelIdx = -1;

    EdVmsNmbr->Clear();

    GrpSchedule->Caption = lblTitle->Caption;//"▶ 자동 스케줄 설정";

    FNewDb = false;
}
//---------------------------------------------------------------------------
void __fastcall TVMSM600M::DisplayInfo()
{
    FormClear();

    FSelIdx = CMM_GetRecordIndex(FRAMEVmsSchList1->TvList);
	if (FSelIdx < 0) return;

    TcxDataController *pGDC = FRAMEVmsSchList1->TvList->DataController;

    String sVmsNmbr = VarToStr(pGDC->Values[FSelIdx][FRAMEVmsSchList1->Column01->Index]);
    EdVmsNmbr->Text = sVmsNmbr;

    GrpSchedule->Caption = lblTitle->Caption + " (" + VarToStr(pGDC->Values[FSelIdx][FRAMEVmsSchList1->Column02->Index]) + ": " + VarToStr(pGDC->Values[FSelIdx][FRAMEVmsSchList1->Column03->Index]) + ")";

    LoadVmsScheduleInfo(sVmsNmbr);

    DrawTrafficScenarioForm();
    //DrawVideoStreamScenarioForm(eSchTp_video);
    //DrawVideoStreamScenarioForm(eSchTp_stream);
    //DrawAtmpScenarioForm();

    TVmsCtlr *pObj = VmsCtlrManager->FLists.Find(sVmsNmbr);
    if (pObj)
    {
        PSCHEDULE_USAGE Use = &pObj->FormCnt[FEN_DSPL_SCH_TYPE];

#if 0
        for (int ii = 0; ii < eSchTp_max; ii++)
        {
            if (FTabSheet[ii] && FLabel[ii])
            {
                FTabSheet[ii]->Caption = " " + FLabel[ii]->Caption + " - " + String(Use->Use[ii]) + "/" + String(Use->Total[ii]) + " ";
            }
        }
#endif
    }

    ChangeEditMode(3);
}
//---------------------------------------------------------------------------

void __fastcall TVMSM600M::TvFormCellDblClick(TcxCustomGridTableView *Sender, TcxGridTableDataCellViewInfo *ACellViewInfo,
          TMouseButton AButton, TShiftState AShift,
          bool &AHandled)
{
	if (!ACellViewInfo) return;

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

    if (Sender->Tag >= 0 && Sender->Tag <eSchTp_max)
    {
        if (FButtonAdd[Sender->Tag])
        {
            BtnListAdd0Click((TObject*)FButtonAdd[Sender->Tag]);
        }
    }
}
//---------------------------------------------------------------------------

void __fastcall TVMSM600M::BtnListAdd0Click(TObject *Sender)
{
    String sUse = "Y";
    String sTime= "4";
    bool   bCurrDay = true;

    TcxButton *pBtn = (TcxButton*)Sender;
    int nTag = pBtn->Tag;
    if (nTag < 0 || nTag >= eSchTp_max) return;

    int nSelIdx = CMM_GetRecordIndex(FRAMEVmsSchList1->TvList);
	if (nSelIdx < 0) return;

    if (!FListFrm[nTag]) return;

    TcxGridDataController *pDcFrm = FListFrm[nTag]->DataController;
    TcxGridDataController *pDcSch = TvGrid0->DataController;

    int nFormIdx = CMM_GetRecordIndex(FListFrm[nTag]);
    if (nFormIdx < 0) return;

    if (nTag == eSchTp_traffic  ||
        nTag == eSchTp_congest  ||
        nTag == eSchTp_incident ||
        nTag == eSchTp_gongsa   ||
        nTag == eSchTp_safe     ||
        nTag == eSchTp_atmp     ||
        nTag == eSchTp_park)
    {
        bCurrDay = false;
    }
    if (nTag == eSchTp_video || nTag == eSchTp_stream)
    {
        sUse = "N";
    }
    if (nTag == eSchTp_video)
    {
        sTime= "0";
    }

    String sStrDate = "";
    String sEndDate = "";
    bool   bSelected= false;

    TVMSSEL0M *pSelDate = new TVMSSEL0M(this);

    pSelDate->FCurrDay = bCurrDay;

    pSelDate->ShowModal();
    bSelected = pSelDate->FSelected;
    sStrDate  = pSelDate->FStrTime;
    sEndDate  = pSelDate->FEndTime;
    delete pSelDate;
    pSelDate = NULL;

    if (!bSelected) return;

    int nRow = pDcSch->AppendRecord();

    pDcSch->Values[nRow][Col00->Index] = VarToStr(pDcFrm->Values[nFormIdx][0]);
    pDcSch->Values[nRow][Col01->Index] = (pDcFrm->Values[nFormIdx][1]);   //이미지데이터임
    pDcSch->Values[nRow][Col03->Index] = sTime;
    pDcSch->Values[nRow][Col04->Index] = ITSUtil_FormatStr(sStrDate, STR_HHNN);;
    pDcSch->Values[nRow][Col05->Index] = ITSUtil_FormatStr(sEndDate, STR_HHNN);;
    pDcSch->Values[nRow][Col06->Index] = sUse;
    pDcSch->Values[nRow][Col07->Index] = sStrDate;
    pDcSch->Values[nRow][Col08->Index] = sEndDate;
    pDcSch->Values[nRow][Col15->Index] = VarToStr(pDcFrm->Values[nFormIdx][2]);

    pDcSch->Values[nRow][Col20->Index] = VarToStr(pDcFrm->Values[nFormIdx][3]);
    pDcSch->Values[nRow][Col21->Index] = VarToStr(pDcFrm->Values[nFormIdx][4]);
    pDcSch->Values[nRow][Col25->Index] = "Y";   //정체표출

    String sSchType = "교통";
    switch(nTag)
    {
    case eSchTp_traffic : sSchType = "교통";         break; // = 0,    //0:교통,
    case eSchTp_incident: sSchType = "돌발";         break; // = 1,    //1:돌발,
    case eSchTp_gongsa  : sSchType = "공사";         break; // = 2,    //2:공사행사,
    case eSchTp_hongbo  : sSchType = "홍보";         break; // = 3,    //3:홍보,
    case eSchTp_deture  : sSchType = "우회";         break; // = 4,    //4:우회,
    case eSchTp_congest : sSchType = "정체";         break; // = 5,    //5:정체,
    case eSchTp_safe    : sSchType = "안전";         break; // = 6,    //6:안전,
    case eSchTp_video   : sSchType = "동영상";       break; // = 7,    //7:동영상,
    case eSchTp_stream  : sSchType = "스트리밍영상"; break; // = 8,    //8:스트리밍영상
    case eSchTp_atmp    : sSchType = "대기환경";     break; // = 9,    //9:대기환경
    case eSchTp_park    : sSchType = "주차정보";     break; // = 10,   //10:주차정보
    }
    pDcSch->Values[nRow][Col22->Index] = sSchType;
    pDcSch->Values[nRow][Col23->Index] = nTag;
    pDcSch->Values[nRow][ColWeek1->Index] = "111111111111111111111111";
    pDcSch->Values[nRow][ColWeek2->Index] = "111111111111111111111111";
    pDcSch->Values[nRow][ColWeek3->Index] = "111111111111111111111111";
    pDcSch->Values[nRow][ColWeek4->Index] = "111111111111111111111111";
    pDcSch->Values[nRow][ColWeek5->Index] = "111111111111111111111111";
    pDcSch->Values[nRow][ColWeek6->Index] = "111111111111111111111111";
    pDcSch->Values[nRow][ColWeek7->Index] = "111111111111111111111111";
}
//---------------------------------------------------------------------------

void __fastcall TVMSM600M::BtnListDelete0Click(TObject *Sender)
{
    TcxButton *pBtn = (TcxButton*)Sender;
    int nTag = pBtn->Tag;
    if (nTag >= eSchTp_max) return;

    int nSelIdx = CMM_GetRecordIndex(FRAMEVmsSchList1->TvList);
	if (nSelIdx < 0) return;

    TcxGridDataController *pDcSch = TvGrid0->DataController;

    nSelIdx = CMM_GetRecordIndex(TvGrid0);
    if (nSelIdx < 0) return;

	TvGrid0->DataController->DeleteRecord(nSelIdx);
}
//---------------------------------------------------------------------------

void __fastcall TVMSM600M::TvGridCellDblClick(TcxCustomGridTableView *Sender, TcxGridTableDataCellViewInfo *ACellViewInfo,
          TMouseButton AButton, TShiftState AShift,
          bool &AHandled)
{
	if (!ACellViewInfo) return;

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

    TcxGridDataController *pGDC = (TcxGridDataController*)Sender->DataController;

    int nColIdx = ACellViewInfo->Item->Index;
    //ShowMessage(String(Sender->Tag) + "    " + String(nColIdx));

    String sFormId  = VarToStr(pGDC->Values[nRow][0]);
    String sStrDate = VarToStr(pGDC->Values[nRow][7]);
    String sEndDate = VarToStr(pGDC->Values[nRow][8]);
    if (nColIdx == 4 || nColIdx == 5)
    {
        //표출기간설정
        TVMSSEL0M *pSelDate = new TVMSSEL0M(this);
        pSelDate->FStrTime = sStrDate;
        pSelDate->FEndTime = sEndDate;

        pSelDate->ShowModal();
        bool bSelected = pSelDate->FSelected;
        sStrDate  = pSelDate->FStrTime;
        sEndDate  = pSelDate->FEndTime;
        delete pSelDate;
        pSelDate = NULL;

        if (bSelected)
        {
            pGDC->Values[nRow][4] = ITSUtil_FormatStr(sStrDate, STR_HHNN);;
            pGDC->Values[nRow][5] = ITSUtil_FormatStr(sEndDate, STR_HHNN);;
            pGDC->Values[nRow][7] = sStrDate;
            pGDC->Values[nRow][8] = sEndDate;
        }
        return;
    }

    int nSchFormType = pGDC->Values[nRow][Col23->Index];
    int    nFormType = VarToStr(pGDC->Values[nRow][Col15->Index]).ToIntDef(0);

    if (nSchFormType == eSchTp_traffic)
    {
        if (nFormType == eFormtp_figure)
        {
#if 0
            //도형식배경 소통정보 폼
            Application->MessageBox(FrmLang->lblSchErr1->Caption.c_str(),//L"VMS 교통정보 폼 구간 설정\r\n도형식 배경소통정보 폼은 폼관리 화면에서 설정 가능합니다.",
                                    FTitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
#endif
            return;
        }

        // 소통정보 폼 정보구간 설정

        TVMSM610M *pIfscFrm = new TVMSM610M(this);
        pIfscFrm->FVmsNmbr   = EdVmsNmbr->Text;
        pIfscFrm->FFormId    = sFormId;

        pIfscFrm->FVmsTypeCd = FVmsTypeCd;
        pIfscFrm->FVmsWidth  = FVmsWidth;
        pIfscFrm->FVmsHeight = FVmsHeight;

        pIfscFrm->FIfscId[0] = VarToStr(pGDC->Values[nRow][9]);
        pIfscFrm->FIfscId[1] = VarToStr(pGDC->Values[nRow][10]);
        pIfscFrm->FIfscId[2] = VarToStr(pGDC->Values[nRow][11]);
        pIfscFrm->FIfscId[3] = VarToStr(pGDC->Values[nRow][12]);

        pIfscFrm->FIfscId[4] = VarToStr(pGDC->Values[nRow][16]);
        pIfscFrm->FIfscId[5] = VarToStr(pGDC->Values[nRow][17]);
        pIfscFrm->FIfscId[6] = VarToStr(pGDC->Values[nRow][18]);
        pIfscFrm->FIfscId[7] = VarToStr(pGDC->Values[nRow][19]);

        //pIfscFrm->FVmsType   = VarToStr(pGDC->Values[nRow][13]).ToIntDef(0);
        pIfscFrm->FFormColor = VarToStr(pGDC->Values[nRow][14]);
        pIfscFrm->FFormType  = VarToStr(pGDC->Values[nRow][15]).ToIntDef(0);

        pIfscFrm->ShowModal();
        if (pIfscFrm->FSelected)
        {
            TStream	*pImgStream = new TMemoryStream();
            try
            {
                void    *p;
                Variant  v;
                pIfscFrm->ImgForm->Picture->Bitmap->SaveToStream(pImgStream);
                int aBound[]={0, pImgStream->Size - 1};
                v = VarArrayCreate(aBound, 1, varByte);
                p = VarArrayLock(v);
                pImgStream->Position = 0;
                pImgStream->Read(p, pImgStream->Size);
                VarArrayUnlock(v);
                pGDC->Values[nRow][1] = v;
            }
            __finally
            {
                SAFE_DELETE(pImgStream);
            }

            pGDC->Values[nRow][ 9] = pIfscFrm->FIfscId[0];
            pGDC->Values[nRow][10] = pIfscFrm->FIfscId[1];
            pGDC->Values[nRow][11] = pIfscFrm->FIfscId[2];
            pGDC->Values[nRow][12] = pIfscFrm->FIfscId[3];

            pGDC->Values[nRow][16] = pIfscFrm->FIfscId[4];
            pGDC->Values[nRow][17] = pIfscFrm->FIfscId[5];
            pGDC->Values[nRow][18] = pIfscFrm->FIfscId[6];
            pGDC->Values[nRow][19] = pIfscFrm->FIfscId[7];
        }

        delete pIfscFrm;
        pIfscFrm = NULL;
    }
#if 0
    else
    if (nSchFormType == eSchTp_congest)
    {
        // 정체정보 폼 정체구간 설정
        TVMSM660M *pIfscFrm = new TVMSM660M(this);
        pIfscFrm->FVmsNmbr   = EdVmsNmbr->Text;
        pIfscFrm->FFormId    = sFormId;

        pIfscFrm->FVmsTypeCd = FVmsTypeCd;
        pIfscFrm->FVmsWidth  = FVmsWidth;
        pIfscFrm->FVmsHeight = FVmsHeight;

        pIfscFrm->FIfscId[0] = VarToStr(pGDC->Values[nRow][9]);
        pIfscFrm->FIfscId[1] = VarToStr(pGDC->Values[nRow][10]);
        pIfscFrm->FIfscId[2] = VarToStr(pGDC->Values[nRow][11]);
        pIfscFrm->FIfscId[3] = VarToStr(pGDC->Values[nRow][12]);

        pIfscFrm->FIfscId[4] = VarToStr(pGDC->Values[nRow][16]);
        pIfscFrm->FIfscId[5] = VarToStr(pGDC->Values[nRow][17]);
        pIfscFrm->FIfscId[6] = VarToStr(pGDC->Values[nRow][18]);
        pIfscFrm->FIfscId[7] = VarToStr(pGDC->Values[nRow][19]);

        pIfscFrm->FFormColor = VarToStr(pGDC->Values[nRow][14]);
        pIfscFrm->FFormType  = VarToStr(pGDC->Values[nRow][15]).ToIntDef(0);

        pIfscFrm->ShowModal();
        if (pIfscFrm->FSelected)
        {
            TStream	*pImgStream = new TMemoryStream();
            try
            {
                void    *p;
                Variant  v;
                pIfscFrm->ImgForm->Picture->Bitmap->SaveToStream(pImgStream);
                int aBound[]={0, pImgStream->Size - 1};
                v = VarArrayCreate(aBound, 1, varByte);
                p = VarArrayLock(v);
                pImgStream->Position = 0;
                pImgStream->Read(p, pImgStream->Size);
                VarArrayUnlock(v);
                pGDC->Values[nRow][1] = v;
            }
            __finally
            {
                SAFE_DELETE(pImgStream);
            }

            pGDC->Values[nRow][ 9] = pIfscFrm->FIfscId[0];
            pGDC->Values[nRow][10] = pIfscFrm->FIfscId[1];
            pGDC->Values[nRow][11] = pIfscFrm->FIfscId[2];
            pGDC->Values[nRow][12] = pIfscFrm->FIfscId[3];

            pGDC->Values[nRow][16] = pIfscFrm->FIfscId[4];
            pGDC->Values[nRow][17] = pIfscFrm->FIfscId[5];
            pGDC->Values[nRow][18] = pIfscFrm->FIfscId[6];
            pGDC->Values[nRow][19] = pIfscFrm->FIfscId[7];
        }

        delete pIfscFrm;
        pIfscFrm = NULL;
    }
#endif
    else
    if (nSchFormType == eSchTp_video)
    {
        TVMSM620M *pVideoFrm = new TVMSM620M(this);
        pVideoFrm->FVmsNmbr   = EdVmsNmbr->Text;
        pVideoFrm->FFormId    = sFormId;

        pVideoFrm->FVmsTypeCd = FVmsTypeCd;
        pVideoFrm->FVmsWidth  = FVmsWidth;
        pVideoFrm->FVmsHeight = FVmsHeight;

        pVideoFrm->FSymbLibNmbr = VarToStr(pGDC->Values[nRow][20]);
        pVideoFrm->FStreamAddr  = VarToStr(pGDC->Values[nRow][21]);

        //pVideoFrm->FVmsType   = VarToStr(pGDC->Values[nRow][13]).ToIntDef(0);
        pVideoFrm->FFormColor = VarToStr(pGDC->Values[nRow][14]);
        pVideoFrm->FFormType  = VarToStr(pGDC->Values[nRow][15]).ToIntDef(0);

        pVideoFrm->ShowModal();
        if (pVideoFrm->FSelected)
        {
            TStream	*pImgStream = new TMemoryStream();
            try
            {
                void    *p;
                Variant  v;
                pVideoFrm->ImgForm->Picture->Bitmap->SaveToStream(pImgStream);
                int aBound[]={0, pImgStream->Size - 1};
                v = VarArrayCreate(aBound, 1, varByte);
                p = VarArrayLock(v);
                pImgStream->Position = 0;
                pImgStream->Read(p, pImgStream->Size);
                VarArrayUnlock(v);
                pGDC->Values[nRow][1] = v;
            }
            __finally
            {
                SAFE_DELETE(pImgStream);
            }

            pGDC->Values[nRow][20] = pVideoFrm->FSymbLibNmbr;
            pGDC->Values[nRow][21] = pVideoFrm->FStreamAddr;
        }

        delete pVideoFrm;
        pVideoFrm = NULL;
    }
    else
    if (nSchFormType == eSchTp_stream)
    {
        TVMSM630M *pStreamFrm = new TVMSM630M(this);
        pStreamFrm->FVmsNmbr   = EdVmsNmbr->Text;
        pStreamFrm->FFormId    = sFormId;

        pStreamFrm->FVmsTypeCd = FVmsTypeCd;
        pStreamFrm->FVmsWidth  = FVmsWidth;
        pStreamFrm->FVmsHeight = FVmsHeight;

        pStreamFrm->FSymbLibNmbr = VarToStr(pGDC->Values[nRow][20]);
        pStreamFrm->FStreamAddr  = VarToStr(pGDC->Values[nRow][21]);

        //pStreamFrm->FVmsType   = VarToStr(pGDC->Values[nRow][13]).ToIntDef(0);
        pStreamFrm->FFormColor = VarToStr(pGDC->Values[nRow][14]);
        pStreamFrm->FFormType  = VarToStr(pGDC->Values[nRow][15]).ToIntDef(0);

        pStreamFrm->ShowModal();
        if (pStreamFrm->FSelected)
        {
            TStream	*pImgStream = new TMemoryStream();
            try
            {
                void    *p;
                Variant  v;
                pStreamFrm->ImgForm->Picture->Bitmap->SaveToStream(pImgStream);
                int aBound[]={0, pImgStream->Size - 1};
                v = VarArrayCreate(aBound, 1, varByte);
                p = VarArrayLock(v);
                pImgStream->Position = 0;
                pImgStream->Read(p, pImgStream->Size);
                VarArrayUnlock(v);
                pGDC->Values[nRow][1] = v;
            }
            __finally
            {
                SAFE_DELETE(pImgStream);
            }

            pGDC->Values[nRow][20] = "300"; //스트리밍인경우 300 으로 고정, //pStreamFrm->FSymbLibNmbr;
            pGDC->Values[nRow][21] = pStreamFrm->FStreamAddr;
        }

        delete pStreamFrm;
        pStreamFrm = NULL;
    }
#if 0
    else
    if (nSchFormType == eSchTp_atmp)
    {
        // 대기환경 폼 관측소 설정
        TVMSM640M *pAtmpFrm = new TVMSM640M(this);
        pAtmpFrm->FVmsNmbr   = EdVmsNmbr->Text;
        pAtmpFrm->FFormId    = sFormId;

        pAtmpFrm->FVmsTypeCd = FVmsTypeCd;
        pAtmpFrm->FVmsWidth  = FVmsWidth;
        pAtmpFrm->FVmsHeight = FVmsHeight;

        pAtmpFrm->FIfscId[0] = VarToStr(pGDC->Values[nRow][9]);

        pAtmpFrm->FFormColor = VarToStr(pGDC->Values[nRow][14]);
        pAtmpFrm->FFormType  = VarToStr(pGDC->Values[nRow][15]).ToIntDef(0);

        pAtmpFrm->ShowModal();
        if (pAtmpFrm->FSelected)
        {
            TStream	*pImgStream = new TMemoryStream();
            try
            {
                void    *p;
                Variant  v;
                pAtmpFrm->ImgForm->Picture->Bitmap->SaveToStream(pImgStream);
                int aBound[]={0, pImgStream->Size - 1};
                v = VarArrayCreate(aBound, 1, varByte);
                p = VarArrayLock(v);
                pImgStream->Position = 0;
                pImgStream->Read(p, pImgStream->Size);
                VarArrayUnlock(v);
                pGDC->Values[nRow][1] = v;
            }
            __finally
            {
                SAFE_DELETE(pImgStream);
            }

            pGDC->Values[nRow][ 9] = pAtmpFrm->FIfscId[0];
        }
        delete pAtmpFrm;
        pAtmpFrm = NULL;
    }
#endif
}
//---------------------------------------------------------------------------

void __fastcall TVMSM600M::BtnAllEditClick(TObject *Sender)
{
    TcxButton *pBtn = (TcxButton*)Sender;

    //등록되어 있는 스케줄 폼을 전체 VMS에 편집하는 기능
    int nTag = PgVmsSch->Properties->ActivePage->Tag;
    if (nTag < 0 || nTag >= eSchTp_max)
    {
        Application->MessageBox(FrmLang->lblRegErr1->Caption.c_str(),//L"VMS 스케줄 일괄 관리\r\n알수 없는 스케줄 유형입니다.",
                                FTitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
        return;
    }

    TcxGridTableView      *pTvList = TvGrid0;
    TcxGridDataController *pGDC;
    String sMode = "E";

    if (pBtn->Tag == 1)
    {
        sMode = "A";    //추가
        pTvList = FListFrm[nTag];
    }
    if (!pTvList) return;

    pGDC = pTvList->DataController;
    int nFormIdx = CMM_GetRecordIndex(pTvList);
    if (nFormIdx < 0)
    {
        Application->MessageBox(FrmLang->lblRegErr1->Caption.c_str(),//L"VMS 스케줄 일괄 관리\r\n등록되어 있는 스케줄 폼을 목록에서 먼저 선택하세요.",
                                FTitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
        return;
    }
    if (pBtn->Tag == 0)
    {
        nTag = pGDC->Values[nFormIdx][Col23->Index];
    }

    String sSymbLibNmbr;
    String sStreamAddr;
    if (pBtn->Tag == 1)
    {
        sSymbLibNmbr = VarToStr(pGDC->Values[nFormIdx][3]);
        sStreamAddr  = VarToStr(pGDC->Values[nFormIdx][4]);
    }
    else
    {
        sSymbLibNmbr = VarToStr(pGDC->Values[nFormIdx][Col20->Index]);
        sStreamAddr  = VarToStr(pGDC->Values[nFormIdx][Col21->Index]);
    }

    String sFormId = VarToStr(pGDC->Values[nFormIdx][0]);

    TVmsSizeType *pVmsSizeType = APP_GetVmsSizeTypeObject(CbSizeType);
    if (pVmsSizeType == NULL)
    {
        Application->MessageBox(FrmLang->lblRegErr3->Caption.c_str(),//L"VMS 스케줄 일괄 관리\r\nVMS 유형을 알수 없습니다. VMS 크기 유형을 먼저 선택하세요.",
                                FTitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
        return;
    }
    String sVmsType = pVmsSizeType->TypeCd;

    TVMSEDT0M *pFrmEdt = new TVMSEDT0M(this);

    pFrmEdt->FVmsTypeCd    = sVmsType;
    pFrmEdt->FScheType     = FVMS_SCH_TYPE;
    pFrmEdt->FScheFormType = String(nTag);
    pFrmEdt->FFormId       = sFormId;
    pFrmEdt->FMode         = sMode;
    pFrmEdt->FVmsNmbr      = "";
    pFrmEdt->FSymbLibNmbr  = sSymbLibNmbr;
    pFrmEdt->FStreamAddr   = sStreamAddr;
    pFrmEdt->ShowModal();

    bool bOk = pFrmEdt->FSelected;

    delete pFrmEdt;
    pFrmEdt = NULL;

    if (bOk)
    {
        DisplayInfo();
    }
    VmsCtlrManager->LoadVmsFormUsage();
    FRAMEVmsSchList1->RefreshVmsFormUsage();
}
//---------------------------------------------------------------------------

void __fastcall TVMSM600M::BtnSaveClick(TObject *Sender)
{
    //작업한 스케줄 정보를 저장한다.
	if (EdVmsNmbr->Text.Trim().IsEmpty())
	{
        Application->MessageBox(lblErr2->Caption.c_str(),//L"VMS 자동 스케줄 관리\r\nVMS 목록에서 VMS를 먼저 선택한 후 작업을 진행하세요.",
                                FTitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
		return;
	}

    bool bUpdate = true;
    String sVmsNmbr = EdVmsNmbr->Text.Trim();

    if (bUpdate)
    {
        String sMsg;
        sMsg = "VMS: " + sVmsNmbr;
        sMsg+= "\r\n" + lblErr3->Caption;//선택한 VMS의 자동 스케줄 정보를 저장하시겠습니까?";

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

    try
    {
        ITSDb_GetConnection()->BeginTrans();

        DeleteVmsScenario(sVmsNmbr);
        SaveVmsScenario(sVmsNmbr, TvGrid0);
    }
    __finally
    {
        ITSDb_GetConnection()->CommitTrans();
    }

    Application->MessageBox(lblErr4->Caption.c_str(),//L"VMS 자동 스케줄 관리\r\nVMS 자동 스케줄 정보를 저장 하였습니다.",
                            FTitle.c_str(), MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);

    VmsCtlrManager->LoadVmsFormUsage();
    FRAMEVmsSchList1->RefreshVmsFormUsage();

    CMM_SetGridRow(FRAMEVmsSchList1->CxList, FRAMEVmsSchList1->TvList, sVmsNmbr, FRAMEVmsSchList1->Column01->Index);
    DisplayInfo();
}
//---------------------------------------------------------------------------

bool __fastcall TVMSM600M::SaveVmsScenario(String AVmsNmbr, TcxGridTableView *AListSch)
{
    bool       bResult = false;
    String     sQry;
    TADOQuery *pADO = NULL;

    TcxDataController *pGDC = AListSch->DataController;

    String sTypeCd = "";

    sQry = "INSERT INTO TB_VMS_DSPL_SCH (                     \r\n"
           "                              VMS_CTLR_NMBR,      \r\n"
           "                              VMS_SCH_TYPE,       \r\n"
           "                              VMS_SCH_FORM_TYPE,  \r\n"
           "                              PHASE,              \r\n"
           "                              VMS_FORM_ID,        \r\n"
           "                              DSPL_STRT_HH,       \r\n"
           "                              DSPL_END_HH,        \r\n"
           "                              DSPL_HH,            \r\n"
           "                              FRST_VMS_IFSC_ID,   \r\n"
           "                              SECD_VMS_IFSC_ID,   \r\n"
           "                              THIR_VMS_IFSC_ID,   \r\n"
           "                              FOUR_VMS_IFSC_ID,   \r\n"
           "                              FRST_IMG_IFSC_ID,   \r\n"
           "                              SECD_IMG_IFSC_ID,   \r\n"
           "                              THIR_IMG_IFSC_ID,   \r\n"
           "                              FOUR_IMG_IFSC_ID,   \r\n"
           "                              SYMB_LIB_NMBR,      \r\n"
           "                              STRM_ADDR,          \r\n"
           "                              USE_YN,             \r\n"
           "                              SCH_WEEK1,          \r\n"
           "                              SCH_WEEK2,          \r\n"
           "                              SCH_WEEK3,          \r\n"
           "                              SCH_WEEK4,          \r\n"
           "                              SCH_WEEK5,          \r\n"
           "                              SCH_WEEK6,          \r\n"
           "                              SCH_WEEK7,          \r\n"
           "                              DSPL_CNGS_YN        \r\n"
           "                             )                    \r\n"
           "                      VALUES(                     \r\n"
           "                             :p01, :p02, :p03,    \r\n"
           "                             :p04, :p05, :p06,    \r\n"
           "                             :p07, :p08, :p09,    \r\n"
           "                             :p10, :p11, :p12,    \r\n"
           "                             :p13, :p14, :p15,    \r\n"
           "                             :p16, :p17, :p18,    \r\n"
           "                             :p19,                \r\n"
           "                             :p20,                \r\n"
           "                             :p21,                \r\n"
           "                             :p22,                \r\n"
           "                             :p23,                \r\n"
           "                             :p24,                \r\n"
           "                             :p25,                \r\n"
           "                             :p26,                \r\n"
           "                             :p27                 \r\n"
           "                             )                    \r\n";

    try
    {
        AListSch->BeginUpdate();
        pGDC->BeginUpdate();
        int nRows = pGDC->RecordCount;

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

            ITSDb_SQLText(pADO, sQry);

            int ii;
            for (ii = 0; ii < nRows; ii++)
            {
                String sFormId = VarToStr(pGDC->Values[ii][ 0]);
                String sUseYn  = VarToStr(pGDC->Values[ii][ 6]);
                if (sUseYn == "Y")
                {
                    if (!CDSVmsFormManager->IsValid(sFormId))
                    {
                        pGDC->Values[ii][ 6] = "N";
                    }
                }
            }
            for (ii = 0; ii < nRows; ii++)
            {
                String sFormId  = VarToStr(pGDC->Values[ii][Col00->Index]);
                String sDispHH  = VarToStr(pGDC->Values[ii][Col03->Index]);
                String sUseYn   = VarToStr(pGDC->Values[ii][Col06->Index]);
                String sStrTime = VarToStr(pGDC->Values[ii][Col07->Index]);
                String sEndTime = VarToStr(pGDC->Values[ii][Col08->Index]);
                String sIfscId1 = VarToStr(pGDC->Values[ii][Col09->Index]);
                String sIfscId2 = VarToStr(pGDC->Values[ii][Col10->Index]);
                String sIfscId3 = VarToStr(pGDC->Values[ii][Col11->Index]);
                String sIfscId4 = VarToStr(pGDC->Values[ii][Col12->Index]);

                String sImgIfscId1 = VarToStr(pGDC->Values[ii][Col16->Index]);
                String sImgIfscId2 = VarToStr(pGDC->Values[ii][Col17->Index]);
                String sImgIfscId3 = VarToStr(pGDC->Values[ii][Col18->Index]);
                String sImgIfscId4 = VarToStr(pGDC->Values[ii][Col19->Index]);

                String sSymbLibNmbr = VarToStr(pGDC->Values[ii][Col20->Index]);
                String sStrmAddr    = VarToStr(pGDC->Values[ii][Col21->Index]);
                sTypeCd             = VarToStr(pGDC->Values[ii][Col23->Index]);

                String sSchWeek1    = VarToStr(pGDC->Values[ii][ColWeek1->Index]);
                String sSchWeek2    = VarToStr(pGDC->Values[ii][ColWeek2->Index]);
                String sSchWeek3    = VarToStr(pGDC->Values[ii][ColWeek3->Index]);
                String sSchWeek4    = VarToStr(pGDC->Values[ii][ColWeek4->Index]);
                String sSchWeek5    = VarToStr(pGDC->Values[ii][ColWeek5->Index]);
                String sSchWeek6    = VarToStr(pGDC->Values[ii][ColWeek6->Index]);
                String sSchWeek7    = VarToStr(pGDC->Values[ii][ColWeek7->Index]);

                String sDsplCngsYn  = VarToStr(pGDC->Values[ii][Col25->Index]);
                if (sDsplCngsYn == "") sDsplCngsYn = "Y";
                if (sTypeCd == String(eSchTp_congest)) sDsplCngsYn = "Y";

                ITSDb_SQLBind(pADO, "p01", AVmsNmbr);
                ITSDb_SQLBind(pADO, "p02", FVMS_SCH_TYPE);
                ITSDb_SQLBind(pADO, "p03", sTypeCd);

                ITSDb_SQLBind(pADO, "p04", String(ii+1));
                ITSDb_SQLBind(pADO, "p05", sFormId);
                ITSDb_SQLBind(pADO, "p06", sStrTime);
                ITSDb_SQLBind(pADO, "p07", sEndTime);
                ITSDb_SQLBind(pADO, "p08", sDispHH);

                ITSDb_SQLBind(pADO, "p09", sIfscId1);
                ITSDb_SQLBind(pADO, "p10", sIfscId2);
                ITSDb_SQLBind(pADO, "p11", sIfscId3);
                ITSDb_SQLBind(pADO, "p12", sIfscId4);

                ITSDb_SQLBind(pADO, "p13", sImgIfscId1);
                ITSDb_SQLBind(pADO, "p14", sImgIfscId2);
                ITSDb_SQLBind(pADO, "p15", sImgIfscId3);
                ITSDb_SQLBind(pADO, "p16", sImgIfscId4);

                ITSDb_SQLBind(pADO, "p17", sSymbLibNmbr);
                ITSDb_SQLBind(pADO, "p18", sStrmAddr);
                ITSDb_SQLBind(pADO, "p19", sUseYn);

                ITSDb_SQLBind(pADO, "p20", sSchWeek1);
                ITSDb_SQLBind(pADO, "p21", sSchWeek2);
                ITSDb_SQLBind(pADO, "p22", sSchWeek3);
                ITSDb_SQLBind(pADO, "p23", sSchWeek4);
                ITSDb_SQLBind(pADO, "p24", sSchWeek5);
                ITSDb_SQLBind(pADO, "p25", sSchWeek6);
                ITSDb_SQLBind(pADO, "p26", sSchWeek7);
                ITSDb_SQLBind(pADO, "p27", sDsplCngsYn);

                pADO->ExecSQL();
            }

            bResult = true;
        }
        catch(EDatabaseError &E)
        {
            ITSDb_GetConnection()->RollbackTrans();
            DBERRORMSG("TVMSM600M::SaveVmsScenario", String(E.ClassName()), E.Message, sQry);
            throw Exception(String(E.ClassName()) + E.Message);
        }
        catch(Exception &e)
        {
            ITSDb_GetConnection()->RollbackTrans();
            DBERRORMSG("TVMSM600M::SaveVmsScenario", String(e.ClassName()), e.Message, sQry);
            throw Exception(String(e.ClassName()) + e.Message);
        }
    }
    __finally
    {
        if (pADO)
        {
            pADO->Close();
            delete pADO;
        }
        pGDC->EndUpdate();
        AListSch->EndUpdate();
    }
    return bResult;
}
//---------------------------------------------------------------------------

bool __fastcall TVMSM600M::SaveVmsScenarioWeek(String AVmsNmbr, TcxGridTableView *AListSch)
{
    bool       bResult = false;
#if 0
    String     sQry;
    TADOQuery *pADO = NULL;

    TcxDataController *pGDC = AListSch->DataController;

    String sTypeCd = "";

    sQry = "INSERT INTO TB_VMS_DSPL_SCH_WEEK (                \r\n"
           "                              VMS_CTLR_NMBR,      \r\n"
           "                              VMS_SCH_TYPE,       \r\n"
           "                              PHASE,              \r\n"
           "                              WEEK_CD,            \r\n"
           "                              SCH_HH              \r\n"
           "                             )                    \r\n"
           "                      VALUES(                     \r\n"
           "                             :p01, :p02, :p03,    \r\n"
           "                             :p04, :p05           \r\n"
           "                             )                    \r\n";

    try
    {
        AListSch->BeginUpdate();
        pGDC->BeginUpdate();
        int nRows = pGDC->RecordCount;

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

            ITSDb_SQLText(pADO, sQry);

            int ii;
            for (ii = 0; ii < nRows; ii++)
            {
                int PHASE = pGDC->Values[ii][Col24->Index];
                TCDSVmsDsplSch *pObj = CDSVmsDsplSchManager->FPhases.Find(PHASE);
                if (!pObj)
                {
                    continue;   //여기걸리면 안돼는데...
                }

                FOR_STL(TCDSVmsDsplSchWeek*, pWeek, pObj->FWeeks)
                {
                    ITSDb_SQLBind(pADO, "p01", AVmsNmbr);
                    ITSDb_SQLBind(pADO, "p02", FVMS_SCH_TYPE);
                    ITSDb_SQLBind(pADO, "p03", String(PHASE));
                    ITSDb_SQLBind(pADO, "p04", pWeek->WEEK_CD);
                    ITSDb_SQLBind(pADO, "p05", pWeek->SCH_HH);

                    pADO->ExecSQL();
                }
            }

            bResult = true;
        }
        catch(EDatabaseError &E)
        {
            ITSDb_GetConnection()->RollbackTrans();
            DBERRORMSG("TVMSM600M::SaveVmsScenario", String(E.ClassName()), E.Message, sQry);
            throw Exception(String(E.ClassName()) + E.Message);
        }
        catch(Exception &e)
        {
            ITSDb_GetConnection()->RollbackTrans();
            DBERRORMSG("TVMSM600M::SaveVmsScenario", String(e.ClassName()), e.Message, sQry);
            throw Exception(String(e.ClassName()) + e.Message);
        }
    }
    __finally
    {
        if (pADO)
        {
            pADO->Close();
            delete pADO;
        }
        pGDC->EndUpdate();
        AListSch->EndUpdate();
    }
#endif
    return bResult;
}
//---------------------------------------------------------------------------

bool __fastcall TVMSM600M::DeleteVmsScenario(String AVmsNmbr)
{
    bool       bResult = false;
    String     sQry;
    TADOQuery *pADO = NULL;

    sQry = "DELETE TB_VMS_DSPL_SCH       \r\n"
           " WHERE VMS_SCH_TYPE  = :p01  \r\n"
           "   AND VMS_CTLR_NMBR = :p02  \r\n";

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

            ITSDb_SQLText(pADO, sQry);
            ITSDb_SQLBind(pADO, "p01", FVMS_SCH_TYPE);
            ITSDb_SQLBind(pADO, "p02", AVmsNmbr);
			pADO->ExecSQL();

            bResult = true;
        }
        catch(EDatabaseError &E)
        {
            ITSDb_GetConnection()->RollbackTrans();
            DBERRORMSG("TVMSM600M::DeleteVmsScenario", String(E.ClassName()), E.Message, sQry);
            throw Exception(String(E.ClassName()) + E.Message);
        }
        catch(Exception &e)
        {
            ITSDb_GetConnection()->RollbackTrans();
            DBERRORMSG("TVMSM600M::DeleteVmsScenario", String(e.ClassName()), e.Message, sQry);
            throw Exception(String(e.ClassName()) + e.Message);
        }
    }
    __finally
    {
        if (pADO)
        {
            pADO->Close();
            delete pADO;
        }
    }
    return bResult;
}
//---------------------------------------------------------------------------

void __fastcall TVMSM600M::DrawTrafficScenarioForm()
{
    TcxGridTableView  *pGrid = TvGrid0;
    if (!pGrid) return;

    TcxDataController *pGDC = pGrid->DataController;
    try
    {
        pGrid->BeginUpdate();
        pGDC->BeginUpdate();
        int nRows = pGDC->RecordCount;
        try
        {
            for (int ii = 0; ii < nRows; ii++)
            {
                int nSchFormType = pGDC->Values[ii][Col23->Index];
                if (nSchFormType != eSchTp_traffic) continue;

                String sFormId    = VarToStr(pGDC->Values[ii][Col00->Index]);
                String sFormClr   = VarToStr(pGDC->Values[ii][Col14->Index]);
                int    nFormType  = VarToStr(pGDC->Values[ii][Col15->Index]).ToIntDef(0);

                FIfscId[0] = VarToStr(pGDC->Values[ii][Col09->Index]);
                FIfscId[1] = VarToStr(pGDC->Values[ii][Col10->Index]);
                FIfscId[2] = VarToStr(pGDC->Values[ii][Col11->Index]);
                FIfscId[3] = VarToStr(pGDC->Values[ii][Col12->Index]);

                FIfscId[4] = VarToStr(pGDC->Values[ii][Col16->Index]);
                FIfscId[5] = VarToStr(pGDC->Values[ii][Col17->Index]);
                FIfscId[6] = VarToStr(pGDC->Values[ii][Col18->Index]);
                FIfscId[7] = VarToStr(pGDC->Values[ii][Col19->Index]);

                switch(nFormType)
                {
                case 11:// '	소통상황(1단)
                case 12:// '	소통상황(2단)
                case 13:// '	소통상황(3단)
                case 14:// '	소통상황(4단)
                    if (LoadTrafficFormObjectInfo(sFormId, sFormClr, m_pEdtDesigner))
                    {
                        m_pEdtDesigner->GetVmsFormImage(ImgForm);
                        TStream	*pImgStream = new TMemoryStream();
                        try
                        {
                            void    *p;
                            Variant  v;
                            ImgForm->Picture->Bitmap->SaveToStream(pImgStream);
                            int aBound[]={0, pImgStream->Size - 1};
                            v = VarArrayCreate(aBound, 1, varByte);
                            p = VarArrayLock(v);
                            pImgStream->Position = 0;
                            pImgStream->Read(p, pImgStream->Size);
                            VarArrayUnlock(v);
                            pGDC->Values[ii][1] = v;
                        }
                        __finally
                        {
                            SAFE_DELETE(pImgStream);
                        }
                    }
                    break;
                }
            }
        }
        catch(Exception &e)
        {
        }
    }
    __finally
    {
        pGDC->EndUpdate();
        pGrid->EndUpdate();
    }
}
//---------------------------------------------------------------------------

void __fastcall TVMSM600M::DrawAtmpScenarioForm()
{
    TcxGridTableView  *pGrid = TvGrid0;
    if (!pGrid) return;

    TcxDataController *pGDC = pGrid->DataController;
    try
    {
        pGrid->BeginUpdate();
        pGDC->BeginUpdate();
        int nRows = pGDC->RecordCount;
        try
        {
            for (int ii = 0; ii < nRows; ii++)
            {
                int nSchFormType = pGDC->Values[ii][Col23->Index];
                if (nSchFormType != eSchTp_atmp) continue;

                String sFormId    = VarToStr(pGDC->Values[ii][Col00->Index]);
                String sFormClr   = VarToStr(pGDC->Values[ii][Col14->Index]);
                int    nFormType  = VarToStr(pGDC->Values[ii][Col15->Index]).ToIntDef(0);

                FIfscId[0] = VarToStr(pGDC->Values[ii][9]);

                switch(nFormType)
                {
                case 90:// '	소통상황(1단)
                    if (LoadTrafficFormObjectInfo(sFormId, sFormClr, m_pEdtDesigner))
                    {
                        m_pEdtDesigner->GetVmsFormImage(ImgForm);
                        TStream	*pImgStream = new TMemoryStream();
                        try
                        {
                            void    *p;
                            Variant  v;
                            ImgForm->Picture->Bitmap->SaveToStream(pImgStream);
                            int aBound[]={0, pImgStream->Size - 1};
                            v = VarArrayCreate(aBound, 1, varByte);
                            p = VarArrayLock(v);
                            pImgStream->Position = 0;
                            pImgStream->Read(p, pImgStream->Size);
                            VarArrayUnlock(v);
                            pGDC->Values[ii][1] = v;
                        }
                        __finally
                        {
                            SAFE_DELETE(pImgStream);
                        }
                    }
                    break;
                }
            }
        }
        catch(Exception &e)
        {
        }
    }
    __finally
    {
        pGDC->EndUpdate();
        pGrid->EndUpdate();
    }
}
//---------------------------------------------------------------------------

bool __fastcall TVMSM600M::LoadTrafficFormObjectInfo(String AFormId, String ABkColor, TVmsFormDesigner *ADesigner)
{
    ADesigner->Clear();

    m_pEdtDesigner->BkColorCode = ABkColor;

    String     sQry;
    TADOQuery *pADO = NULL;

    sQry = "SELECT A.*,                                       \r\n"
           "       C.VMS_FONT_NAME_NM,                        \r\n"
           "       B.IMAG_DATA AS SYMB_IMG,                   \r\n"
           "       B.SYMB_EXPL AS SYMB_IMG_NM,                \r\n"
           "       D.VMS_FORM_TYPE_CD                         \r\n"
           "  FROM TB_VMS_FORM_OBJECT  A,                     \r\n"
           "       TB_VMS_SYMB_LIB     B,                     \r\n"
           "       TB_VMS_FONT_NAME    C,                     \r\n"
           "       TB_VMS_FORM         D                      \r\n"
           " WHERE D.VMS_FORM_ID      = :p01                  \r\n"
           "   AND D.VMS_FORM_ID      = A.VMS_FORM_ID         \r\n"
           "   AND A.SYMB_LIB_NMBR    = B.SYMB_LIB_NMBR(+)    \r\n"
           "   AND A.VMS_FONT_NAME_CD = C.VMS_FONT_NAME_CD(+) \r\n"
           " ORDER BY A.VMS_FORM_OBJECT_ID ASC                \r\n";

    int VMS_FORM_TYPE_CD = -1;

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

            ITSDb_SQLText(pADO, sQry);
            ITSDb_SQLBind(pADO, "p01", AFormId);
            ITSDb_SQLOpen(pADO);

            int    nDrawType;
            String sObjKind;
            for( ; !pADO->Eof; pADO->Next())
            {
                VMS_FORM_TYPE_CD = pADO->FieldByName("VMS_FORM_TYPE_CD")->AsInteger;
                int nFormId = pADO->FieldByName("VMS_FORM_ID")->AsInteger;
                int nObjId  = pADO->FieldByName("VMS_FORM_OBJECT_ID")->AsInteger;

                int nObjType = pADO->FieldByName("VMS_FORM_OBJECT_TYPE_CD")->AsInteger;
                if (nObjType ==   1 || //심볼
                    nObjType ==   2 || //이미지
                    nObjType ==   3 || //배경이미지
                    nObjType ==  17 || //@소통정보이미지 (1열)
                    nObjType ==  27 || //@소통정보이미지2(2열)
                    nObjType ==  37 || //@소통정보이미지3(3열)
                    nObjType ==  47 || //소통이미지4
                    nObjType == 200 || //동영상
                    nObjType == 300 || //스트리밍영상
                    nObjType == 406 || //@통합대기등급 이미지
                    nObjType == 407 || //@미세먼지등급 이미지
                    nObjType == 408 || //@초미세먼지등급 이미지
                    nObjType == 413    //@오존등급이미지
                    )
                {
                    if (nObjType == 1) sObjKind = OBJKIND_IMAGEID;    //Image Id
                    else               sObjKind = OBJKIND_IMAGE;      //Image

                    nDrawType = 1;  //이미지그리기
                }
                else
                {
                    sObjKind  = OBJKIND_TEXT;  //문자열
                    nDrawType = 0;  //문자열그리기
                }

                //실재 맵핑된 구간의 정보를 표출하도록 한다.

                int    nBlinking = pADO->FieldByName("VMS_DSPL_BLINKING")->AsInteger;
                int    nPosX     = pADO->FieldByName("VMS_DSPL_XCRDN")->AsInteger;
                int    nPosY     = pADO->FieldByName("VMS_DSPL_YCRDN")->AsInteger;
                int    nDsplW    = pADO->FieldByName("VMS_DSPL_WIDTH")->AsInteger;
                int    nDsplH    = pADO->FieldByName("VMS_DSPL_HEIGHT")->AsInteger;

                TVmsFormObject *pObj = ADesigner->AddObject((VmsObjectDrawType)nDrawType);
                if (!pObj) continue;

//11	, '	@구간명
//12	, '	@시점명
//13	, '	@종점명
//14	, '	@소통상황
//15	, '	@통행시간
//16	, '	@통행속도
//17	, '	@소통이미지
                pObj->Text = pADO->FieldByName("VMS_DSPL_TXT")->AsString.Trim();
                pObj->RunText = pObj->Text;

                String sIfscId = "";
                if (nObjType >= 11 && nObjType < 17)
                    sIfscId = FIfscId[0];
                else
                if (nObjType >= 21 && nObjType < 27)
                    sIfscId = FIfscId[1];
                else
                if (nObjType >= 31 && nObjType < 37)
                    sIfscId = FIfscId[2];
                else
                if (nObjType >= 41 && nObjType < 47)
                    sIfscId = FIfscId[3];

                if (nObjType == 401)
                    sIfscId = FIfscId[0];

                switch(nObjType)
                {
                case 17: sIfscId = FIfscId[4]; break;
                case 27: sIfscId = FIfscId[5]; break;
                case 37: sIfscId = FIfscId[6]; break;
                case 47: sIfscId = FIfscId[7]; break;
                }

                if (sIfscId != "")
                {
                    if (pADO->FieldByName("VMS_FORM_TYPE_CD")->AsInteger == 90)
                    {
                        TCDSAtmp *pAtmpObj = CDSAtmpManager->FLists.Find(sIfscId);
                        if (pAtmpObj)
                        {
                            pObj->RunText = pAtmpObj->VMS_DISP_NM;
                        }
                    }
                    else
                    {
                        TVmsIfsc *pIfscObj;
                        pIfscObj = VmsIfscManager->FLists.Find(sIfscId.ToIntDef(0));
                        if (pIfscObj)
                        {
                            switch(nObjType)
                            {
                            case 11: case 21: case 31: case 41:
                                pObj->RunText = pIfscObj->VMS_IFSC_NM;
                                break;
                            case 12: case 22: case 32: case 42:
                                pObj->RunText = pIfscObj->DSPL_STRT_NODE_NM;
                                break;
                            case 13: case 23: case 33: case 43:
                                pObj->RunText = pIfscObj->DSPL_END_NODE_NM;
                                break;
                            }
                        }
                    }
                }
                else
                {
                    if (nObjType == 201)
                    {
                    }
                    else
                    if (nObjType == 301)
                    {
                    }
                }

                if (nObjType == 200 || nObjType == 300)
                {
                    pObj->EditMode = false;
                }
                pObj->ObjSeq      = nObjId;
                pObj->ObjId       = nObjId;
                pObj->ObjKind     = sObjKind;
                pObj->Tag         = pADO->FieldByName("VMS_IFSC_ID")->AsString;
                pObj->ObjType     = pADO->FieldByName("VMS_FORM_OBJECT_TYPE_CD")->AsString;
                pObj->ObjSize     = pADO->FieldByName("VMS_DSPL_SIZE")->AsInteger;
                pObj->BkColorCode = pADO->FieldByName("VMS_DSPL_BKCOLOR")->AsString;
                pObj->Blink       = nBlinking == 1 ? true : false;

                pObj->ImageId     = pADO->FieldByName("SYMB_LIB_NMBR")->AsString;

                pObj->SetPos(nPosX, nPosY);
                if (pObj->ObjKind == OBJKIND_TEXT)    // 문자열
                {
                    int nFontBold       = pADO->FieldByName("VMS_FONT_BOLD")->AsInteger;

                    pObj->FontName      = pADO->FieldByName("VMS_FONT_NAME_NM")->AsString;
                    pObj->FontNameCode  = pADO->FieldByName("VMS_FONT_NAME_CD")->AsString;
                    pObj->FontColorCode = pADO->FieldByName("VMS_FONT_COLR_CD")->AsString;
                    pObj->FontSize      = pADO->FieldByName("VMS_FONT_SIZE")->AsInteger;
                    pObj->FontBold      = nFontBold == 1 ? true : false;
                    pObj->TextAlign     = pADO->FieldByName("VMS_FONT_ALIGN")->AsInteger;
                    //pObj->SetSize(pADO->FieldByName("VMS_DSPL_WIDTH")->AsInteger, pADO->FieldByName("VMS_DSPL_HEIGHT")->AsInteger);
                    pObj->SetRuntimeText(pObj->RunText);

#if 0
                    Label1->AutoSize   = true;
                    Label1->Font->Name = pObj->FontName;
                    Label1->Font->Size = pObj->FontSize;
                    Label1->Caption    = pObj->RunText;

                    if (pObj->FontBold)
                        Label1->Font->Style = TFontStyles() << fsBold;
                    else
                        Label1->Font->Style = TFontStyles();

                    //int nWidth = pADO->FieldByName("VMS_DSPL_WIDTH")->AsInteger;
                    //nWidth = Lavel1->Width;

#if 1
                    switch(pObj->TextAlign)
                    {
                    case 0://text_align_left:
                        //좌측정력인 경우 위치조정 필요 없음.
                        break;
                    case 1://text_align_right:
                        //좌측에서 글자길이를 뺀다음 만약 음수이면 0으로 설정
                        //pADO->FieldByName("VMS_DSPL_WIDTH")->AsInteger
                        nPosX = (nPosX+pADO->FieldByName("VMS_DSPL_WIDTH")->AsInteger) - Label1->Width;
                        break;
                    case 2://text_align_center:
                        //원래 글자의 중앙값을 얻은 다음에 조정된 글자의 1/2 크기를 뺀다음 음수이면 0으로 설정
                        nPosX = (nPosX+(pADO->FieldByName("VMS_DSPL_WIDTH")->AsInteger/2)) - (Label1->Width/2);
                        break;
                    }
                    if (nPosX < 0) nPosX = 0;
                    //AVmsObj->TextWidth = pLabel->Width;
#endif
                    pObj->SetSize(Label1->Width, pADO->FieldByName("VMS_DSPL_HEIGHT")->AsInteger);

#endif
                }
                else //if (sObjKind == "1" || sObjKind == "2")    // 이미지(1), 이미지 ID(2)
                {
                    if (pObj->ObjKind == OBJKIND_IMAGEID)
                    {
                        pObj->Text = pADO->FieldByName("SYMB_LIB_NMBR")->AsString;
                    }

                    TStream *pStream = NULL;
                    pStream = pADO->CreateBlobStream(pADO->FieldByName("VMS_DSPL_FIGR"), bmRead);

                    try
                    {
                        if (pStream && pStream->Size > 0)
                        {
                            Graphics::TBitmap *Bitmap = pObj->GetBitmap();
                            pStream->Position = 0;
                            Bitmap->LoadFromStream(pStream);

                            pObj->GetImage()->AutoSize= false;
                            pObj->GetImage()->Stretch = true;
                            pObj->GetImage()->Width  = nDsplW;
                            pObj->GetImage()->Height = nDsplH;
                            pObj->SetSize(nDsplW, nDsplH);
                            pObj->SetPos(nPosX, nPosY);
                            //pObj->SetSize(Bitmap->Width, Bitmap->Height);
                        }
                    }
                    __finally
                    {
                        SAFE_DELETE(pStream);
                    }
                }

                //pObj->SetPos(nPosX, nPosY);
                pObj->Show();
                pObj->BringToFront();
            }

            if (VMS_FORM_TYPE_CD == eFormTp_traf_1)
            {
                TVmsFormObject *pArw = NULL;
                TVmsFormObject *pStr = NULL;
                TVmsFormObject *pEnd = NULL;
                int nObjCnt = ADesigner->GetObjectCount();

                for(int ii = 0; ii < nObjCnt; ii++)
                {
                    TVmsFormObject *pObj = ADesigner->GetObject(ii);
                    if (!pObj) continue;

                    int nObjType = pObj->ObjType.ToIntDef(0);
                    switch(nObjType)
                    {
                    case 12:    //	@시점명	            Y
                        pStr = pObj;
                        break;
                    case 13:    //	@종점명	            Y
                        pEnd = pObj;
                        break;
                    }
                }

                for(int ii = 0; ii < nObjCnt; ii++)
                {
                    TVmsFormObject *pObj = ADesigner->GetObject(ii);
                    if (!pObj) continue;

                    int nObjType = pObj->ObjType.ToIntDef(0);
                    switch(nObjType)
                    {
                    case  1:    //	@심볼	            Y
                    case  2:    //	@이미지	            Y
                    case 17:    //	@소통정보이미지      Y
                        //if (pFormObj->TRFC_FILL_CD == "T")
                        if (pStr && pObj->Top <= (pStr->Top+pStr->Height) )
                        {
                            pArw = pObj;
                        }
                        break;
                    }
                }

                if (pArw && pStr && pEnd)
                {
                    int nRange = pStr->Top + pStr->Height;
                    if (pArw->Top <= nRange && pEnd->Top <= nRange)
                    {
                        int ARRAWGAP =  5;
                        int nLeft = 0;
                        int nTotW = pStr->Width + ARRAWGAP +
                                    pArw->Width + ARRAWGAP +
                                    pEnd->Width;

                        if (nTotW < ADesigner->Width)
                        {
                            nLeft = (ADesigner->Width - nTotW) / 2;
                        }

                        nLeft = (ADesigner->Width - nTotW) / 2;

                        pStr->Left = nLeft;
                        pArw->Left = pStr->Left + pStr->Width + ARRAWGAP;
                        pEnd->Left = pArw->Left + pArw->Width + ARRAWGAP;
                    }
                }
            }

        }
        catch(EDatabaseError &E)
        {
            DBERRORMSG("TVMSM600M::LoadTrafficFormObjectInfo", String(E.ClassName()), E.Message, sQry);
            throw Exception(String(E.ClassName()) + E.Message);
        }
        catch(Exception &exception)
        {
            DBERRORMSG("TVMSM600M::LoadTrafficFormObjectInfo", String(exception.ClassName()), exception.Message, sQry);
            throw Exception(String(exception.ClassName()) + exception.Message);
        }
    }
    __finally
    {
        if (pADO)
        {
            pADO->Close();
            delete pADO;
        }
    }
    return true;
}
//---------------------------------------------------------------------------

void __fastcall TVMSM600M::DrawVideoStreamScenarioForm(int AFormScheType)
{
    TcxGridTableView  *pGrid = TvGrid0;
    if (!pGrid) return;

    TcxDataController *pGDC = pGrid->DataController;
    try
    {
        pGrid->BeginUpdate();
        pGDC->BeginUpdate();
        int nRows = pGDC->RecordCount;
        try
        {
            for (int ii = 0; ii < nRows; ii++)
            {
                int nSchFormType = pGDC->Values[ii][Col23->Index];
                if (nSchFormType != AFormScheType) continue;

                String sFormId      = VarToStr(pGDC->Values[ii][Col00->Index]);
                String sFormClr     = VarToStr(pGDC->Values[ii][Col14->Index]);
                int    nFormType    = VarToStr(pGDC->Values[ii][Col15->Index]).ToIntDef(0);
                String sSymbLibNmbr = VarToStr(pGDC->Values[ii][Col20->Index]);
                String sStreamAddr  = VarToStr(pGDC->Values[ii][Col21->Index]);
                switch(nFormType)
                {
                case 70:// '	동영상	Y
                case 80:// '	스트리밍영상	Y
                    if (LoadVideoStreamFormObjectInfo(sFormId, sFormClr, m_pEdtDesigner, sSymbLibNmbr, sStreamAddr))
                    {
                        m_pEdtDesigner->GetVmsFormImage(ImgForm);
                        TStream	*pImgStream = new TMemoryStream();
                        try
                        {
                            void    *p;
                            Variant  v;
                            ImgForm->Picture->Bitmap->SaveToStream(pImgStream);
                            int aBound[]={0, pImgStream->Size - 1};
                            v = VarArrayCreate(aBound, 1, varByte);
                            p = VarArrayLock(v);
                            pImgStream->Position = 0;
                            pImgStream->Read(p, pImgStream->Size);
                            VarArrayUnlock(v);
                            pGDC->Values[ii][1] = v;
                        }
                        __finally
                        {
                            SAFE_DELETE(pImgStream);
                        }
                    }
                    break;
                }
            }
        }
        catch(Exception &e)
        {
        }
    }
    __finally
    {
        pGDC->EndUpdate();
        pGrid->EndUpdate();
    }
}
//---------------------------------------------------------------------------

bool __fastcall TVMSM600M::LoadVideoStreamFormObjectInfo(String AFormId, String ABkColor, TVmsFormDesigner *ADesigner, String ASymbLibNmbr, String AStreamAddr)
{
    ADesigner->Clear();

    m_pEdtDesigner->BkColorCode = ABkColor;

    String     sQry;
    TADOQuery *pADO = NULL;

    sQry = "SELECT A.*,                                       \r\n"
           "       C.VMS_FONT_NAME_NM,                        \r\n"
           "       B.IMAG_DATA    AS SYMB_IMG,                \r\n"
           "       B.SYMB_EXPL    AS SYMB_IMG_NM,             \r\n"
           "       B.SYMB_FILE_NM AS SYMB_FILE_NM             \r\n"
           "  FROM TB_VMS_FORM_OBJECT  A,                     \r\n"
           "       TB_VMS_SYMB_LIB     B,                     \r\n"
           "       TB_VMS_FONT_NAME    C,                     \r\n"
           "       TB_VMS_FORM         D                      \r\n"
           " WHERE D.VMS_FORM_ID      = :p01                  \r\n"
           "   AND D.VMS_FORM_ID      = A.VMS_FORM_ID         \r\n"
           "   AND B.SYMB_LIB_NMBR    = :p02                  \r\n"
           "   AND A.VMS_FONT_NAME_CD = C.VMS_FONT_NAME_CD(+) \r\n"
           " ORDER BY A.VMS_FORM_OBJECT_ID ASC                \r\n";

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

            ITSDb_SQLText(pADO, sQry);
            ITSDb_SQLBind(pADO, "p01", AFormId);
            ITSDb_SQLBind(pADO, "p02", ASymbLibNmbr);
            ITSDb_SQLOpen(pADO);

            int    nDrawType;
            String sObjKind;
            for( ; !pADO->Eof; pADO->Next())
            {
                int nFormId = pADO->FieldByName("VMS_FORM_ID")->AsInteger;
                int nObjId  = pADO->FieldByName("VMS_FORM_OBJECT_ID")->AsInteger;

                int nObjType = pADO->FieldByName("VMS_FORM_OBJECT_TYPE_CD")->AsInteger;
                if (nObjType ==   1 || //심볼
                    nObjType ==   2 || //이미지
                    nObjType ==   3 || //배경이미지
                    nObjType ==  17 || //@소통정보이미지 (1열)
                    nObjType ==  27 || //@소통정보이미지2(2열)
                    nObjType ==  37 || //@소통정보이미지3(3열)
                    nObjType ==  47 || //소통이미지4
                    nObjType == 200 || //동영상
                    nObjType == 300 || //스트리밍영상
                    nObjType == 406 || //@통합대기등급 이미지
                    nObjType == 407 || //@미세먼지등급 이미지
                    nObjType == 408 || //@초미세먼지등급 이미지
                    nObjType == 413    //@오존등급이미지
                    )
                {
                    sObjKind  = OBJKIND_IMAGEID;    //Image Id
                    nDrawType = 1;  //이미지그리기
                }
                else
                {
                    sObjKind  = OBJKIND_TEXT;  //문자열
                    nDrawType = 0;  //문자열그리기
                }

                int    nBlinking = pADO->FieldByName("VMS_DSPL_BLINKING")->AsInteger;
                int    nPosX     = pADO->FieldByName("VMS_DSPL_XCRDN")->AsInteger;
                int    nPosY     = pADO->FieldByName("VMS_DSPL_YCRDN")->AsInteger;

                TVmsFormObject *pObj = ADesigner->AddObject((VmsObjectDrawType)nDrawType);
                if (!pObj) continue;

                pObj->Text = pADO->FieldByName("SYMB_IMG_NM")->AsString.Trim();
                if (AStreamAddr == "") pObj->RunText = pObj->Text;
                else                   pObj->RunText = AStreamAddr;    //pObj->Text;

                pObj->EditMode    = false;
                pObj->ObjSeq      = nObjId;
                pObj->ObjId       = nObjId;
                pObj->ObjKind     = sObjKind;
                pObj->Tag         = pADO->FieldByName("VMS_IFSC_ID")->AsString;
                pObj->ObjType     = pADO->FieldByName("VMS_FORM_OBJECT_TYPE_CD")->AsString;
                pObj->ObjSize     = pADO->FieldByName("VMS_DSPL_SIZE")->AsInteger;
                pObj->BkColorCode = pADO->FieldByName("VMS_DSPL_BKCOLOR")->AsString;
                pObj->Blink       = nBlinking == 1 ? true : false;
                pObj->ImageId     = ASymbLibNmbr;   //pADO->FieldByName("SYMB_LIB_NMBR")->AsString;

                pObj->SetPos(nPosX, nPosY);
                if (pObj->ObjKind == OBJKIND_TEXT)    // 문자열
                {
                    int nFontBold       = pADO->FieldByName("VMS_FONT_BOLD")->AsInteger;

                    pObj->FontName      = pADO->FieldByName("VMS_FONT_NAME_NM")->AsString;
                    pObj->FontNameCode  = pADO->FieldByName("VMS_FONT_NAME_CD")->AsString;
                    pObj->FontColorCode = pADO->FieldByName("VMS_FONT_COLR_CD")->AsString;
                    pObj->FontSize      = pADO->FieldByName("VMS_FONT_SIZE")->AsInteger;
                    pObj->FontBold      = nFontBold == 1 ? true : false;
                    pObj->TextAlign     = pADO->FieldByName("VMS_FONT_ALIGN")->AsInteger;
                    pObj->SetSize(pADO->FieldByName("VMS_DSPL_WIDTH")->AsInteger, pADO->FieldByName("VMS_DSPL_HEIGHT")->AsInteger);
                    pObj->SetRuntimeText(pObj->RunText);
                }
                else //if (sObjKind == "1" || sObjKind == "2")    // 이미지(1), 이미지 ID(2)
                {
                    if (pObj->ObjKind == OBJKIND_IMAGEID)
                    {
                        pObj->Text = pADO->FieldByName("SYMB_LIB_NMBR")->AsString;
                    }

                    TStream *pStream = NULL;
                    //pStream = pADO->CreateBlobStream(pADO->FieldByName("VMS_DSPL_FIGR"), bmRead);
                    pStream = pADO->CreateBlobStream(pADO->FieldByName("SYMB_IMG"), bmRead);
                    try
                    {
                        if (pStream && pStream->Size > 0)
                        {
                            Graphics::TBitmap *Bitmap = pObj->GetBitmap();
                            pStream->Position = 0;
                            Bitmap->LoadFromStream(pStream);
                            pObj->SetSize(Bitmap->Width, Bitmap->Height);
                            if (ASymbLibNmbr != "200" && ASymbLibNmbr != "300")
                                pObj->SetPos(0, 0);
                        }
                    }
                    __finally
                    {
                        SAFE_DELETE(pStream);
                    }
                }

#if 0
                switch(nObjType)
                {
                case 200: pObj->Text = ASymbLibNmbr; break;
                case 201: pObj->Text = AStreamAddr;  break;
                case 300: pObj->Text = ASymbLibNmbr; break;
                case 301: pObj->Text = AStreamAddr;  break;
                }
#endif
                pObj->Show();
                pObj->BringToFront();
            }
        }
        catch(EDatabaseError &E)
        {
            DBERRORMSG("TVMSM600M::LoadTrafficFormObjectInfo", String(E.ClassName()), E.Message, sQry);
            throw Exception(String(E.ClassName()) + E.Message);
        }
        catch(Exception &exception)
        {
            DBERRORMSG("TVMSM600M::LoadTrafficFormObjectInfo", String(exception.ClassName()), exception.Message, sQry);
            throw Exception(String(exception.ClassName()) + exception.Message);
        }
    }
    __finally
    {
        if (pADO)
        {
            pADO->Close();
            delete pADO;
        }
    }
    return true;
}
//---------------------------------------------------------------------------

void __fastcall TVMSM600M::LoadVmsScheduleInfo(String AVmsNmbr)
{
    int        ii;
    String     sQry;
    TADOQuery *pADO = NULL;

    CMM_ClearGridTableView(TvGrid0);

    sQry = "SELECT A.*,                             \r\n"
           "       B.VMS_FORM_IMAG,                 \r\n"
           "       B.VMS_TYPE_CD,                   \r\n"
           "       B.VMS_FORM_NM,                   \r\n"
           "       B.VMS_FORM_COLR_CD,              \r\n"
           "       B.VMS_FORM_TYPE_CD               \r\n"
           "  FROM TB_VMS_DSPL_SCH A,               \r\n"
           "       TB_VMS_FORM     B                \r\n"
           " WHERE A.VMS_SCH_TYPE  = :p01           \r\n"
           "   AND A.VMS_CTLR_NMBR = :p02           \r\n"
           "   AND A.VMS_FORM_ID   = B.VMS_FORM_ID  \r\n"
//           "   AND B.VALID_YN      = 'Y'            \r\n"
           " ORDER BY A.PHASE                       \r\n";

    try
    {
        TvGrid0->BeginUpdate();

        TcxDataController *pDcSch;
        int nRow;

        try
        {
            int nRow;

            pADO = new TADOQuery(NULL);
			pADO->Close();
            pADO->Connection = ITSDb_GetConnection();

            ITSDb_SQLText(pADO, sQry);
            ITSDb_SQLBind(pADO, "p01", FVMS_SCH_TYPE);
            ITSDb_SQLBind(pADO, "p02", AVmsNmbr);
            ITSDb_SQLOpen(pADO);

            int nFormType;
            for( ; !pADO->Eof; pADO->Next())
            {
                nFormType = pADO->FieldByName("VMS_SCH_FORM_TYPE")->AsInteger;
                if (nFormType < eSchTp_traffic && nFormType >= eSchTp_max) continue;

                pDcSch = TvGrid0->DataController;

                nRow = pDcSch->AppendRecord();

                String sStrDate = pADO->FieldByName("DSPL_STRT_HH")->AsString;
                String sEndDate = pADO->FieldByName("DSPL_END_HH")->AsString;

                pDcSch->Values[nRow][Col00->Index] = pADO->FieldByName("VMS_FORM_ID")->AsString;
                pDcSch->Values[nRow][Col01->Index] = pADO->FieldByName("VMS_FORM_IMAG")->AsVariant;
                pDcSch->Values[nRow][Col02->Index] = pADO->FieldByName("FRST_VMS_IFSC_ID")->AsString;
                pDcSch->Values[nRow][Col03->Index] = pADO->FieldByName("DSPL_HH")->AsString;
                pDcSch->Values[nRow][Col04->Index] = ITSUtil_FormatStr(sStrDate, STR_HHNN);;
                pDcSch->Values[nRow][Col05->Index] = ITSUtil_FormatStr(sEndDate, STR_HHNN);;
                pDcSch->Values[nRow][Col06->Index] = pADO->FieldByName("USE_YN")->AsString;
                pDcSch->Values[nRow][Col07->Index] = sStrDate;
                pDcSch->Values[nRow][Col08->Index] = sEndDate;

                pDcSch->Values[nRow][Col09->Index] = pADO->FieldByName("FRST_VMS_IFSC_ID")->AsString;
                pDcSch->Values[nRow][Col10->Index] = pADO->FieldByName("SECD_VMS_IFSC_ID")->AsString;
                pDcSch->Values[nRow][Col11->Index] = pADO->FieldByName("THIR_VMS_IFSC_ID")->AsString;
                pDcSch->Values[nRow][Col12->Index] = pADO->FieldByName("FOUR_VMS_IFSC_ID")->AsString;

                pDcSch->Values[nRow][Col13->Index] = pADO->FieldByName("VMS_TYPE_CD")->AsString;
                pDcSch->Values[nRow][Col14->Index] = pADO->FieldByName("VMS_FORM_COLR_CD")->AsString;
                pDcSch->Values[nRow][Col15->Index] = pADO->FieldByName("VMS_FORM_TYPE_CD")->AsString;

                pDcSch->Values[nRow][Col16->Index] = pADO->FieldByName("FRST_IMG_IFSC_ID")->AsString;
                pDcSch->Values[nRow][Col17->Index] = pADO->FieldByName("SECD_IMG_IFSC_ID")->AsString;
                pDcSch->Values[nRow][Col18->Index] = pADO->FieldByName("THIR_IMG_IFSC_ID")->AsString;
                pDcSch->Values[nRow][Col19->Index] = pADO->FieldByName("FOUR_IMG_IFSC_ID")->AsString;

                pDcSch->Values[nRow][Col20->Index] = pADO->FieldByName("SYMB_LIB_NMBR")->AsString;
                pDcSch->Values[nRow][Col21->Index] = pADO->FieldByName("STRM_ADDR")->AsString;

                String sSchType = "교통";
                switch(nFormType)
                {
                case eSchTp_traffic : sSchType = "교통";         break; // = 0,    //0:교통,
                case eSchTp_incident: sSchType = "돌발";         break; // = 1,    //1:돌발,
                case eSchTp_gongsa  : sSchType = "공사";         break; // = 2,    //2:공사행사,
                case eSchTp_hongbo  : sSchType = "홍보";         break; // = 3,    //3:홍보,
                case eSchTp_deture  : sSchType = "우회";         break; // = 4,    //4:우회,
                case eSchTp_congest : sSchType = "정체";         break; // = 5,    //5:정체,
                case eSchTp_safe    : sSchType = "안전";         break; // = 6,    //6:안전,
                case eSchTp_video   : sSchType = "동영상";       break; // = 7,    //7:동영상,
                case eSchTp_stream  : sSchType = "스트리밍영상"; break; // = 8,    //8:스트리밍영상
                case eSchTp_atmp    : sSchType = "대기환경";     break; // = 9,    //9:대기환경
                case eSchTp_park    : sSchType = "주차정보";     break; // = 10,   //10:주차정보
                }
                pDcSch->Values[nRow][Col22->Index] = sSchType;
                pDcSch->Values[nRow][Col23->Index] = nFormType;
                pDcSch->Values[nRow][Col24->Index] = pADO->FieldByName("PHASE")->AsInteger;
                pDcSch->Values[nRow][ColWeek1->Index] = pADO->FieldByName("SCH_WEEK1")->AsString;
                pDcSch->Values[nRow][ColWeek2->Index] = pADO->FieldByName("SCH_WEEK2")->AsString;
                pDcSch->Values[nRow][ColWeek3->Index] = pADO->FieldByName("SCH_WEEK3")->AsString;
                pDcSch->Values[nRow][ColWeek4->Index] = pADO->FieldByName("SCH_WEEK4")->AsString;
                pDcSch->Values[nRow][ColWeek5->Index] = pADO->FieldByName("SCH_WEEK5")->AsString;
                pDcSch->Values[nRow][ColWeek6->Index] = pADO->FieldByName("SCH_WEEK6")->AsString;
                pDcSch->Values[nRow][ColWeek7->Index] = pADO->FieldByName("SCH_WEEK7")->AsString;
                pDcSch->Values[nRow][Col25->Index]    = pADO->FieldByName("DSPL_CNGS_YN")->AsString;
            }
        }
        catch(EDatabaseError &E)
        {
            DBERRORMSG("TVMSM600M::LoadVmsScheduleInfo", String(E.ClassName()), E.Message, sQry);
            throw Exception(String(E.ClassName()) + E.Message);
        }
        catch(Exception &e)
        {
            DBERRORMSG("TVMSM600M::LoadVmsScheduleInfo", String(e.ClassName()), e.Message, sQry);
            throw Exception(String(e.ClassName()) + e.Message);
        }
    }
    __finally
    {
        if (pADO)
        {
            pADO->Close();
            delete pADO;
        }
        TvGrid0->EndUpdate();
        TvGrid0->ApplyBestFit(NULL, false, false);
    }
}
//---------------------------------------------------------------------------

bool __fastcall TVMSM600M::LoadVmsFormList(String AFormSizeCd)
{
    int ii;
    for (ii = 0; ii < eSchTp_max; ii++)
    {
        if (FListFrm[ii]) CMM_ClearGridTableView(FListFrm[ii]);
    }

    String sQry;
    TADOQuery *pADO = NULL;

    //스케쥴에 등록할 폼은 유효성이 Y 인 것만 목록에 표출한다.
    sQry = "SELECT A.*                   \r\n"
           "  FROM TB_VMS_FORM A         \r\n"
           " WHERE A.VMS_TYPE_CD = :p01  \r\n"
           "   AND A.VALID_YN    = 'Y'   \r\n"
           " ORDER BY A.VMS_FORM_ID      \r\n";

    try
    {
        for (ii = 0; ii < eSchTp_max; ii++)
        {
            if (FListFrm[ii]) FListFrm[ii]->BeginUpdate();
        }

        TcxDataController *pGDC;
        int nRow;
        try
        {
            pADO = new TADOQuery(NULL);
			pADO->Close();
            pADO->Connection = ITSDb_GetConnection();

            ITSDb_SQLText(pADO, sQry);
            ITSDb_SQLBind(pADO, "p01", AFormSizeCd);
            ITSDb_SQLOpen(pADO);

            int nFormTypeCd, nFormIdx;
            for( ; !pADO->Eof; pADO->Next())
            {
                nFormTypeCd = pADO->FieldByName("VMS_FORM_TYPE_CD")->AsInteger;
                nFormIdx = VmsGetFormTypeIdx(nFormTypeCd);
                if (nFormIdx < 0) continue;
                if (!FListFrm[nFormIdx]) continue;

                pGDC = FListFrm[nFormIdx]->DataController;
                nRow = pGDC->AppendRecord();
                pGDC->Values[nRow][0] = pADO->FieldByName("VMS_FORM_ID")->AsString;
                pGDC->Values[nRow][1] = pADO->FieldByName("VMS_FORM_IMAG")->AsVariant;
                pGDC->Values[nRow][2] = String(nFormTypeCd);
                pGDC->Values[nRow][9] = pADO->FieldByName("VMS_FORM_NM")->AsString;
                if (nFormTypeCd == 70)
                {
                    pGDC->Values[nRow][3] = "200";  //동영상기본이미지번호
                }
                else
                if (nFormTypeCd == 80)
                {
                    pGDC->Values[nRow][3] = "300";  //스트리밍기본이미지번호
                }
                else
                {
                    pGDC->Values[nRow][3] = "";
                }
                pGDC->Values[nRow][4] = "";
            }
        }
        catch(EDatabaseError &E)
        {
            DBERRORMSG("TVMSM600M::LoadVmsFormList", String(E.ClassName()), E.Message, sQry);
            throw Exception(String(E.ClassName()) + E.Message);
        }
        catch(Exception &e)
        {
            DBERRORMSG("TVMSM600M::LoadVmsFormList", String(e.ClassName()), e.Message, sQry);
            throw Exception(String(e.ClassName()) + e.Message);
        }
    }
    __finally
    {
        if (pADO)
        {
            pADO->Close();
            delete pADO;
        }
        for (ii = 0; ii < eSchTp_max; ii++)
        {
            if (FListFrm[ii])
            {
                FListFrm[ii]->EndUpdate();
                FListFrm[ii]->ApplyBestFit(NULL, false, false);
            }
        }
    }
    return true;
}
//---------------------------------------------------------------------------

void __fastcall TVMSM600M::BtnUpClick(TObject *Sender)
{
    try
    {
        TvGrid0->BeginUpdate();

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

        int nUpIdx = nCurIdx-1;

        try
        {
            int nCols = TvGrid0->ColumnCount;
            for (int ii = 0; ii < nCols; ii++)
            {
                Variant va = TvGrid0->DataController->Values[nCurIdx][ii];
                TvGrid0->DataController->Values[nCurIdx][ii] = TvGrid0->DataController->Values[nUpIdx][ii];
                TvGrid0->DataController->Values[nUpIdx][ii]  = va;
            }

            TvGrid0->Controller->ClearSelection();
            TvGrid0->Controller->FocusedRowIndex = nUpIdx;
            TvGrid0->ViewData->Records[nUpIdx]->Focused = true;
            TvGrid0->ViewData->Records[nUpIdx]->Selected = true;
            CxGrid0->SetFocus();
        }
        catch(...)
        {
        }
    }
    __finally
    {
        TvGrid0->EndUpdate();
    }
}
//---------------------------------------------------------------------------

void __fastcall TVMSM600M::BtnDownClick(TObject *Sender)
{
    try
    {
        TvGrid0->BeginUpdate();

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

        int nDnIdx = nCurIdx+1;

        try
        {
            int nCols = TvGrid0->ColumnCount;
            for (int ii = 0; ii < nCols; ii++)
            {
                Variant va = TvGrid0->DataController->Values[nCurIdx][ii];
                TvGrid0->DataController->Values[nCurIdx][ii] = TvGrid0->DataController->Values[nDnIdx][ii];
                TvGrid0->DataController->Values[nDnIdx][ii]  = va;
            }

            TvGrid0->Controller->ClearSelection();
            TvGrid0->Controller->FocusedRowIndex = nDnIdx;
            TvGrid0->ViewData->Records[nDnIdx]->Focused = true;
            TvGrid0->ViewData->Records[nDnIdx]->Selected = true;
            CxGrid0->SetFocus();
        }
        catch(...)
        {
        }
    }
    __finally
    {
        TvGrid0->EndUpdate();
    }
}
//---------------------------------------------------------------------------

void __fastcall TVMSM600M::ChkAutoWidthPropertiesChange(TObject *Sender)
{
    try
    {
        LockWindowUpdate(Handle);
        TvGrid0->BeginUpdate();
        if (ChkAutoWidth->Checked)
        {
            TvGrid0->OptionsView->DataRowHeight  = 58;
            TvGrid0->OptionsView->CellAutoHeight = false;
        }
        else
        {
            TvGrid0->OptionsView->DataRowHeight  = 0;
            TvGrid0->OptionsView->CellAutoHeight = true;
        }
        TvGrid0->OptionsView->ColumnAutoWidth = ChkAutoWidth->Checked;
    }
    __finally
    {
        TvGrid0->EndUpdate();
        LockWindowUpdate(0);
        //BtnBestFit->Visible = !ChkAutoWidth->Checked;
    }
}
//---------------------------------------------------------------------------

void __fastcall TVMSM600M::BtnBestFitClick(TObject *Sender)
{
    try
    {
        LockWindowUpdate(Handle);
        TvGrid0->BeginUpdate();
        TvGrid0->ApplyBestFit(NULL, false, false);
    }
    __finally
    {
        TvGrid0->EndUpdate();
        LockWindowUpdate(0);
    }
}
//---------------------------------------------------------------------------

void __fastcall TVMSM600M::BtnSchWeekClick(TObject *Sender)
{
    TcxGridTableView      *pTvList = TvGrid0;
    TcxGridDataController *pGDC;
    pGDC = pTvList->DataController;
    int nFormIdx = CMM_GetRecordIndex(pTvList);
    if (nFormIdx < 0)
    {
        Application->MessageBox(L"목록에서 VMS 스케쥴을 선택하세요.",
                                L"요일별 스케쥴 편집", MB_OK|MB_ICONERROR|MB_APPLMODAL);
        return;
    }

    //int PHASE = pGDC->Values[nFormIdx][Col24->Index];
    int nIdx = ColWeek1->Index;
    TVMSM650M *pFrm = new TVMSM650M(this);
    for (int ii = 0; ii < 7; ii++)
    {
        pFrm->FSchWeek[ii] = pGDC->Values[nFormIdx][nIdx+ii];
    }
    pFrm->ShowModal();
    if (pFrm->FSelected)
    {
        for (int ii = 0; ii < 7; ii++)
        {
            pGDC->Values[nFormIdx][nIdx+ii] = pFrm->FSchWeek[ii];
        }
    }
    delete pFrm;
    pFrm = NULL;
}
//---------------------------------------------------------------------------

void __fastcall TVMSM600M::Col05CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
          bool &ADone)
{
    int nRecordIdx = AViewInfo->GridRecord->RecordIndex;
    if (nRecordIdx < 0)
    {
        return;
    }

    try
    {
        int nItemIdx = AViewInfo->Item->Index;
    	if (VarIsNull(AViewInfo->GridRecord->DisplayTexts[nItemIdx])) return;

        String sEndDt = AViewInfo->GridRecord->DisplayTexts[nItemIdx];
        if (sEndDt < Now().FormatString(STR_HHNN))
        {
            ACanvas->Canvas->Brush->Color = clSilver;
        }
    }
    catch(Exception &e)
    {
    }
}
//---------------------------------------------------------------------------

void __fastcall TVMSM600M::Col00CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
          bool &ADone)
{
#if 0
    int nRecordIdx = AViewInfo->GridRecord->RecordIndex;
    if (nRecordIdx < 0)
    {
        return;
    }

    try
    {
        if (VarToStr(AViewInfo->GridRecord->DisplayTexts[15]).ToIntDef(0) != eFormTp_congest)
        {
            return;
        }
    	if (VarIsNull(AViewInfo->GridRecord->DisplayTexts[9]))
        {
            ACanvas->Canvas->Brush->Color = clRed;
        }
        else
        {
            String IFSC_ID = AViewInfo->GridRecord->DisplayTexts[9].Trim();
            if (IFSC_ID == "" || IFSC_ID == "0")
            {
                ACanvas->Canvas->Brush->Color = clRed;
            }
        }
    }
    catch(Exception &e)
    {
    }
#endif
}
//---------------------------------------------------------------------------

void __fastcall TVMSM600M::Col06CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
          bool &ADone)
{
    int nRecordIdx = AViewInfo->GridRecord->RecordIndex;
    if (nRecordIdx < 0)
    {
        return;
    }

    try
    {
        int nItemIdx = AViewInfo->Item->Index;
    	if (VarIsNull(AViewInfo->GridRecord->DisplayTexts[nItemIdx])) return;

        String sUseYn = AViewInfo->GridRecord->DisplayTexts[nItemIdx];
        if (sUseYn == "N")
        {
            ACanvas->Canvas->Brush->Color = clRed;
        }
    }
    catch(Exception &e)
    {
    }
}
//---------------------------------------------------------------------------

