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

#include <vcl.h>
#include "ITSSkinF.h"
#include "ITSUtilF.h"
#include "ITSLangTransF.h"
#include "FrmResourceF.h"
#pragma hdrstop

#include "FrmVmColorF.h"

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

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "cxClasses"
#pragma link "cxContainer"
#pragma link "cxControls"
#pragma link "cxEdit"
#pragma link "cxGraphics"
#pragma link "cxHint"
#pragma link "cxLabel"
#pragma link "cxLookAndFeelPainters"
#pragma link "cxLookAndFeels"
#pragma link "cxMaskEdit"
#pragma link "cxPC"
#pragma link "cxPCdxBarPopupMenu"
#pragma link "cxSpinEdit"
#pragma link "cxTextEdit"
#pragma link "dxBar"
#pragma link "dxCustomHint"
#pragma link "dxRibbon"
#pragma link "dxRibbonGallery"
#pragma link "dxRibbonSkins"
#pragma link "dxRibbonStatusBar"
#pragma link "dxScreenTip"
#pragma link "dxSkinBlack"
#pragma link "dxSkinBlue"
#pragma link "dxSkinCaramel"
#pragma link "dxSkinChooserGallery"
#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 "dxSkinsdxBarPainter"
#pragma link "dxSkinsdxRibbonPainter"
#pragma link "dxSkinSeven"
#pragma link "dxSkinsForm"
#pragma link "dxSkinSharp"
#pragma link "dxSkinSilver"
#pragma link "dxSkinStardust"
#pragma link "dxStatusBar"
#pragma link "dxTabbedMDI"
#pragma link "cxButtons"
#pragma link "cxCalendar"
#pragma link "cxDropDownEdit"
#pragma link "cxGroupBox"
#pragma link "cxSplitter"
#pragma link "cxTimeEdit"
#pragma link "cxCalc"
#pragma link "cxCheckBox"
#pragma link "cxCustomData"
#pragma link "cxData"
#pragma link "cxDataStorage"
#pragma link "cxFilter"
#pragma link "cxGrid"
#pragma link "cxGridCustomTableView"
#pragma link "cxGridCustomView"
#pragma link "cxGridLevel"
#pragma link "cxGridTableView"
#pragma link "cxStyles"
#pragma resource "*.dfm"

TFrmVmColor *FrmVmColor = NULL;

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

__fastcall TFrmVmColor::TFrmVmColor(TComponent* Owner)
    : TForm(Owner)//TdxCustomRibbonForm(Owner)//TForm(Owner)
{
    CMM_SetFormPosition(g_AppCfg.bSaveForm);
    ITSSkin_Initialize(Application, g_AppCfg.sLang);

    DoubleBuffered = true;

    g_AppCfg.lMainWinHandle = (long)Handle;

    LangTrans->Translate(this, ITSDb_GetConnection());
    ITSSkin_Load(this);
    CMM_LoadForm(g_sFormsDir, this);

    SetColorScheme(g_AppCfg.sSkinName);

    CDSVmsColorManager = new TCDSVmsColorManager();
    FTitle = Caption;
    FEditMode = false;
}
//---------------------------------------------------------------------------

void __fastcall TFrmVmColor::FormCreate(TObject *Sender)
{
    Application->ShowMainForm = false;

    try {
        Application->Icon->LoadFromResourceName(((unsigned int)HInstance), "MAINICON");
    } catch(...) { ShowMessage("LoadFromResourceName failed"); }

    Application->ShowMainForm = true;
}
//---------------------------------------------------------------------------

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

void __fastcall TFrmVmColor::FormInit()
{
    m_pGDC = TvList->DataController;

    //TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;

    TcxComboBoxProperties *pcxComboBoxProperties;
    pcxComboBoxProperties = (TcxComboBoxProperties*)Column04->Properties;
    pcxComboBoxProperties->Items->Clear();
    pcxComboBoxProperties->Items->Add("Y");
    pcxComboBoxProperties->Items->Add("N");

    pcxComboBoxProperties = (TcxComboBoxProperties*)Column14->Properties;
    pcxComboBoxProperties->Items->Clear();
    pcxComboBoxProperties->Items->Add("Y");
    pcxComboBoxProperties->Items->Add("N");
}
//---------------------------------------------------------------------------

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

void __fastcall TFrmVmColor::CommClose()
{
    try
    {
        ITSSkin_Term();
        CMM_SaveForm(g_sFormsDir, this);
    }
    catch(Exception &e)
    {
    }
}
//---------------------------------------------------------------------------

void __fastcall TFrmVmColor::SetColorScheme(String ASkinName)
{
    dxSkinController1->SkinName = ASkinName;
    dxSkinController1->Refresh();
}
//---------------------------------------------------------------------------

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

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

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

    RefreshData();
    CxList->SetFocus();
}
//---------------------------------------------------------------------------
void __fastcall TFrmVmColor::RefreshData()
{
    // 검색조건에 의한 링크 데이터 조회
    SelListData();
}
//---------------------------------------------------------------------------
bool __fastcall TFrmVmColor::AddObjectItem(TCDSVmsColor *pObj, String AMode)
{
    int nRow;
    try
    {
        nRow = m_pGDC->AppendRecord();
        pObj->GridIndex = nRow;

        m_pGDC->Values[nRow][ColumnSel->Index] = false;
        m_pGDC->Values[nRow][Column00->Index]  = AMode;
        m_pGDC->Values[nRow][Column01->Index]  = pObj->VMS_FONT_COLR_CD;
        m_pGDC->Values[nRow][Column02->Index]  = pObj->VMS_FONT_COLR_NM;
        m_pGDC->Values[nRow][Column12->Index]  = pObj->VMS_FONT_COLR_NM;
        m_pGDC->Values[nRow][Column03->Index]  = pObj->VMS_FONT_COLR_VAL;
        m_pGDC->Values[nRow][Column13->Index]  = pObj->VMS_FONT_COLR_VAL;
        m_pGDC->Values[nRow][Column04->Index]  = pObj->USE_YN;
        m_pGDC->Values[nRow][Column14->Index]  = pObj->USE_YN;

        m_pGDC->Values[nRow][Column88->Index]  = 0;
        m_pGDC->Values[nRow][Column99->Index]  = (int)pObj;

        return true;
    }
    catch(...)
    {
    }
    return false;
}
//---------------------------------------------------------------------------

void __fastcall TFrmVmColor::SelListData()
{
    FUpdate = false;

    CMM_ClearGridTableView(TvList);

    CDSVmsColorManager->LoadFromDb();

    int nRow = 0;
    TcxDataController *pGDC = TvList->DataController;
    try
    {
        TvList->BeginUpdate(lsimImmediate);
        try
        {
            FOR_STL(TCDSVmsColor*, pObj, CDSVmsColorManager->FLists)
            {
                pObj->EditMode = DB_INIT;   // 미리초기화해준다.(삭제된것)
                pObj->Completed = true;
                AddObjectItem(pObj, "-");
            }
        }
        catch(Exception &e)
        {
            DBERRORMSG("VMS Information Query", String(e.ClassName()), e.Message, "");
            throw Exception(String(e.ClassName()) + e.Message);
        }
    }
    __finally
    {
        LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
        TvList->EndUpdate();
        TvList->DataController->GotoFirst();
        TvList->DataController->FocusedRecordIndex = 0;
    }
}
//---------------------------------------------------------------------------

void __fastcall TFrmVmColor::Column13CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
          bool &ADone)
{
    try
    {
        //ACanvas->Canvas->Brush->Color = m_pColor[0]->Color;
        int iIndex = AViewInfo->Item->Index;
        String val  = (String)AViewInfo->GridRecord->DisplayTexts[iIndex];
        ACanvas->Canvas->Font->Color  = (TColor)StrToInt(val.c_str());
        ACanvas->Canvas->Brush->Color = (TColor)StrToInt(val.c_str());
    }
    catch(...) {}
}
//---------------------------------------------------------------------------

void __fastcall TFrmVmColor::BtnEditClick(TObject *Sender)
{
    TListFocus tvFocus(TvList);

    if (BtnEdit->Caption == "취소")
    {
        CxList->SetFocus();
        Application->ProcessMessages();
        SaveData();
    }

    FrmLang->ITSSkin_ButtonClick(BtnSearch, BtnEdit, BtnInsert, BtnDelete, BtnApply);
    ChangeEditMode(BtnEdit->Down);
    FEditMode = BtnEdit->Down;
}
//---------------------------------------------------------------------------
void __fastcall TFrmVmColor::ChangeEditMode(bool AEdit)
{
    bool bEditing = AEdit;

    try
    {
        TvList->BeginUpdate();

        //Column00->Visible = bEditing;

        Column02->Options->Editing = bEditing;
        //Column03->Options->Editing = bEditing;
        Column04->Options->Editing = bEditing;
    }
    __finally
    {
        TvList->EndUpdate();
        if (bEditing)
        {
            BtnEdit->Caption = FrmLang->lblCancel->Caption;//"취소";
            BtnEdit->Hint    = FrmLang->lblCancel->Hint;//데이터 편집 취소";
        }
        else
        {
            BtnEdit->Caption = FrmLang->lblEdit->Caption;//"편집";
            BtnEdit->Hint    = FrmLang->lblEdit->Hint;//데이터 편집";
            Screen->Cursor = crDefault;
        }
    }
}
//---------------------------------------------------------------------------

void __fastcall TFrmVmColor::TvListMouseMove(TObject *Sender, TShiftState Shift, int X, int Y)
{
    try
    {
        if (!BtnEdit->Down) return;

        TcxGridSite *ASite = (TcxGridSite *)Sender;

        //Screen->Cursor = crDefault;

        //TcxCustomGridHitTest *AHitTest = tvSel->GetHitTest(X, Y);
        TcxCustomGridHitTest *AHitTest = dynamic_cast<TcxGridRecordHitTest*>(ASite->ViewInfo->GetHitTest(X, Y));
        if (dynamic_cast<TcxGridRecordHitTest*>(ASite->ViewInfo->GetHitTest(X, Y)))
        {
            int ARow = ((TcxGridRecordCellHitTest*)AHitTest)->GridRecord->Index;
            if (((TcxGridRecordCellHitTest*)AHitTest)->Item == NULL) return;
            int ACol = ((TcxGridRecordCellHitTest*)AHitTest)->Item->Index;

            if (ACol == Column03->Index &&
                ARow < ASite->GridView->DataController->RecordCount-1)
            {
                Screen->Cursor = FEditMode ? crHandPoint : crDefault;
            }
        }
        else
        {
            Screen->Cursor = crDefault;
        }
    }
    catch(...)
    {
    }
}
//---------------------------------------------------------------------------

void __fastcall TFrmVmColor::BtnApplyClick(TObject *Sender)
{
    FUpdate = true;
    BtnEdit->Down = false;
    BtnEdit->Click();
}
//---------------------------------------------------------------------------
bool __fastcall TFrmVmColor::IsUpdate()
{
    int nMemPtr;
    int nColorVal;
    String sName;
    String sUseYn;
    TCDSVmsColor *pObj;

    int nUpdateCnt = 0;
	int nRows = m_pGDC->RecordCount;
    try
    {
        for (int ii = 0; ii < nRows; ii++)
        {
            m_pGDC->Values[ii][Column88->Index] = 0;

            nMemPtr = m_pGDC->Values[ii][Column99->Index];
            pObj = (TCDSVmsColor*)nMemPtr;

            sName     = m_pGDC->Values[ii][Column02->Index];
            nColorVal = m_pGDC->Values[ii][Column03->Index];
            sUseYn    = m_pGDC->Values[ii][Column04->Index];

            if (sName     != pObj->VMS_FONT_COLR_NM ||
                nColorVal != pObj->VMS_FONT_COLR_VAL ||
                sUseYn    != pObj->USE_YN)
            {
                m_pGDC->Values[ii][Column88->Index] = 1;
                nUpdateCnt++;
            }
        }
    }
    catch(...)
    {
    }

    if (nUpdateCnt == 0)
    {
        return false;
    }
    return true;
}
//---------------------------------------------------------------------------
void __fastcall TFrmVmColor::RollbackListData()
{
    int nStateVal;
    int nColorVal;
    String sName, sUseYn;
    try
    {
        try
        {
            int nRows = m_pGDC->RecordCount;
            TvList->BeginUpdate();

            for (int ii = 0; ii < nRows; ii++)
            {
                nStateVal = m_pGDC->Values[ii][Column88->Index];
                if (nStateVal == 0) continue;

                sName     = m_pGDC->Values[ii][Column12->Index];
                nColorVal = m_pGDC->Values[ii][Column13->Index];
                sUseYn    = m_pGDC->Values[ii][Column14->Index];

                m_pGDC->Values[ii][Column88->Index] = 0;

                m_pGDC->Values[ii][Column02->Index] = sName;
                m_pGDC->Values[ii][Column03->Index] = nColorVal;
                m_pGDC->Values[ii][Column04->Index] = sUseYn;
            }
        }
        catch (Exception &exception)
        {
			throw Exception(String(exception.ClassName()) + exception.Message);
        }
	}
	__finally
	{
		TvList->EndUpdate();
	}
}
//---------------------------------------------------------------------------
void __fastcall TFrmVmColor::SaveData()
{
	this->Update();

    if (!IsUpdate()) return;

    if (!FUpdate)
    {
        if (Application->MessageBox(FrmLang->lblEidtConfirm->Caption.c_str(),//L"변경된 정보가 있습니다.\r\n변경된 정보를 저장 하시겠습니까?",
                                    FTitle.c_str(), MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES)
        {
            RollbackListData();
            return;
        }
    }

	int           nStateVal;
    int           nMemPtr;
    TCDSVmsColor *pObj;

    int nColorVal;
    String sName, sUseYn;

    bool bSave = false;
    int nUpdateCnt = 0;
	int nRows = m_pGDC->RecordCount;
    TADOQuery *pADO = NULL;
    String sQry;
    try
    {
        try
        {
            pADO = new TADOQuery(NULL);
			pADO->Close();
            pADO->Connection = ITSDb_GetConnection();

            TvList->BeginUpdate();

			ITSDb_GetConnection()->BeginTrans();
			{
                sQry = "MERGE INTO TB_VMS_FONT_COLR L                             \r\n"
                       "USING (SELECT                                             \r\n"
                       "              :p01 AS VMS_FONT_COLR_CD,                   \r\n"
                       "              :p02 AS VMS_FONT_COLR_NM,                   \r\n"
                       "              :p03 AS VMS_FONT_COLR_VAL,                  \r\n"
                       "              :p04 AS USE_YN                              \r\n"
                       "         FROM DUAL) M                                     \r\n"
                       "        ON (L.VMS_FONT_COLR_CD = M.VMS_FONT_COLR_CD)      \r\n"
                       "WHEN MATCHED THEN                                         \r\n"
                       "   UPDATE SET                                             \r\n"
                       "              L.VMS_FONT_COLR_NM  = M.VMS_FONT_COLR_NM,   \r\n"
                       "              L.VMS_FONT_COLR_VAL = M.VMS_FONT_COLR_VAL,  \r\n"
                       "              L.USE_YN            = M.USE_YN              \r\n"
                       "WHEN NOT MATCHED THEN                                     \r\n"
                       "   INSERT (                                               \r\n"
                       "           VMS_FONT_COLR_CD,                              \r\n"
                       "           VMS_FONT_COLR_NM,                              \r\n"
                       "           VMS_FONT_COLR_VAL,                             \r\n"
                       "           USE_YN )                                       \r\n"
                       "   VALUES (                                               \r\n"
                       "           M.VMS_FONT_COLR_CD,                            \r\n"
                       "           M.VMS_FONT_COLR_NM,                            \r\n"
                       "           M.VMS_FONT_COLR_VAL,                           \r\n"
                       "           M.USE_YN )                                     \r\n";

                ITSDb_SQLText(pADO, sQry);

                for (int ii = 0; ii < nRows; ii++)
				{
                    TSqlCursor sqlCrs;

                    nMemPtr = m_pGDC->Values[ii][Column99->Index];
                    pObj = (TCDSVmsColor*)nMemPtr;
                    if (!pObj) continue;

                    String  VMS_FONT_COLR_NM  = VarToStr(m_pGDC->Values[ii][Column02->Index]);
                    int     VMS_FONT_COLR_VAL = m_pGDC->Values[ii][Column03->Index];
                    String  USE_YN            = VarToStr(m_pGDC->Values[ii][Column04->Index]);

                    if (!pObj->Completed && pObj->EditMode != DB_NEW)
                    {
                        if (pObj->VMS_FONT_COLR_NM  == VMS_FONT_COLR_NM &&
                            pObj->VMS_FONT_COLR_VAL == VMS_FONT_COLR_VAL &&
                            pObj->USE_YN            == USE_YN
                           )
                        {
                            continue;
                        }
                    }

                    pObj->VMS_FONT_COLR_NM  = VMS_FONT_COLR_NM;
                    pObj->VMS_FONT_COLR_VAL = VMS_FONT_COLR_VAL;
                    pObj->USE_YN            = USE_YN;

                    pADO->Parameters->ParamByName("p01")->Value = pObj->VMS_FONT_COLR_CD;
                    pADO->Parameters->ParamByName("p02")->Value = pObj->VMS_FONT_COLR_NM;
                    pADO->Parameters->ParamByName("p03")->Value = pObj->VMS_FONT_COLR_VAL;
                    pADO->Parameters->ParamByName("p04")->Value = pObj->USE_YN;

					ITSDb_SQLExec(pADO);

                    m_pGDC->Values[ii][Column88->Index] = 0;

                }
				ITSDb_GetConnection()->CommitTrans();
                bSave = true;
            }
        }
        catch(EDatabaseError &E)
        {
            ITSDb_GetConnection()->RollbackTrans();
            ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
            DBERRORMSG(Caption, String(E.ClassName()), E.Message, sQry);
            throw Exception(String(E.ClassName()) + E.Message);
        }
        catch(Exception &e)
        {
            ITSDb_GetConnection()->RollbackTrans();
            ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
            DBERRORMSG(Caption, String(e.ClassName()), e.Message, sQry);
            throw Exception(String(e.ClassName()) + e.Message);
        }
	}
	__finally
	{
		TvList->EndUpdate();
        if (pADO)
        {
            pADO->Close();
            delete pADO;
        }
        if (bSave)
        {
            Application->ProcessMessages();
            Application->MessageBox(FrmLang->lblDbSave->Caption.c_str(),//L"변경된 소통등급 정보를 저장하였습니다.",
                                    FTitle.c_str(), MB_OK|MB_ICONQUESTION|MB_APPLMODAL);
            RefreshData();  //소통정보 변경을 알리기 위해 먼저 다시 읽어 놓는다.
            //POST_MSG(Application->MainForm->Handle, WM_DATABASE_REFRESH, WP_MSG_01, 0);
            //Sleep(500);
            //POST_MSG(Application->MainForm->Handle, WM_DATABASE_REFRESH, WP_MSG_06, 0); //가공서버로 보내는 메시지
        }
	}
}
//---------------------------------------------------------------------------

void __fastcall TFrmVmColor::FormCloseQuery(TObject *Sender, bool &CanClose)
{
    SaveData();
}
//---------------------------------------------------------------------------

void __fastcall TFrmVmColor::BtnInsertClick(TObject *Sender)
{
    int nMsgType = MB_OK|MB_ICONERROR|MB_APPLMODAL;

    try
    {
        try
        {
            TvList->BeginUpdate();

            TCDSVmsColor *pObj = new TCDSVmsColor();
            if (!pObj)
            {
                Application->MessageBox(FrmLang->lblMemErr->Caption.c_str(),//L"신규 휴일 정보를 생성할 수 없습니다.[메모리오류]",
                                        FTitle.c_str(), nMsgType);
                return;
            }

            pObj->VMS_FONT_COLR_CD  = CDSVmsColorManager->GetNextColorId();
            pObj->VMS_FONT_COLR_NM  = "";
            pObj->VMS_FONT_COLR_VAL = 0;
            pObj->USE_YN            = "Y";

            pObj->Completed = false;
            pObj->EditMode  = DB_NEW;

            CDSVmsColorManager->FLists.Push(pObj->VMS_FONT_COLR_CD, pObj);

            AddObjectItem(pObj, FrmLang->lblNew->Caption);//"신규");
        }
        __finally
        {
            LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
            TvList->EndUpdate();
            TvList->DataController->GotoFirst();
            TvList->DataController->FocusedRecordIndex = 0;
        }
    }
    __finally
    {
    }
}
//---------------------------------------------------------------------------

void __fastcall TFrmVmColor::TvListCellClick(TcxCustomGridTableView *Sender, TcxGridTableDataCellViewInfo *ACellViewInfo,
          TMouseButton AButton, TShiftState AShift, bool &AHandled)
{
    if (FEditMode && ACellViewInfo->Item->Index == Column03->Index)
	{
        int VMS_FONT_COLR_CD = TvList->DataController->Values[TvList->DataController->GetFocusedRecordIndex()][Column01->Index];
        if (VMS_FONT_COLR_CD >= 0 && VMS_FONT_COLR_CD <= 5)
        {
            return;
        }

		if (ColorDialog->Execute())
		{
			TvList->DataController->Values[TvList->DataController->GetFocusedRecordIndex()][Column03->Index] = (int)ColorDialog->Color;
            try
            {
                int nRows = TvList->DataController->FocusedRecordIndex;
                if (nRows < 0)
                {
                    return;
                }

                if (TvList->DataController->Values[nRows][Column03->Index] != TvList->DataController->Values[nRows][Column13->Index])
                {
                    //int nMemPtr = TvList->DataController->Values[nRows][Column99->Index];
                    //TCDSVmsColor *pObj = (TCDSVmsColor*)nMemPtr;

                    //TvList->DataController->Values[nRows][Column88->Index] = 1;
                    //TvList->DataController->Values[nRows][Column00->Index] = FrmLang->lblModify->Caption;//"수정";
                    //if (pObj) pObj->EditMode = DB_UPDATE;
                }
            }
            catch(...)
            {
            }
		}
	}
}
//---------------------------------------------------------------------------

void __fastcall TFrmVmColor::TvListCustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
          bool &ADone)
{
#if 0
    if (AViewInfo)
    {
        String sType = AViewInfo->GridRecord->DisplayTexts[Column00->Index];
        if (sType == FrmLang->lblModify->Caption)//"수정")
        {
            //ACanvas->Brush->Color = clOlive;
        }
        else if (sType == FrmLang->lblDelete->Caption)//"삭제")
        {
            //ACanvas->Brush->Color = clRed;
        }
        else if (sType == FrmLang->lblNew->Caption)//"신규")
        {
            //ACanvas->Brush->Color = clLime;
            if (AViewInfo->Focused) ACanvas->Font->Color = clBlack;
        }
    }
#endif
}
//---------------------------------------------------------------------------

void __fastcall TFrmVmColor::ColumnPropertiesValidate(TObject *Sender, Variant &DisplayValue, TCaption &ErrorText, bool &Error)

{
    if (TvList->Controller->FocusedRow->IsFilterRow) return;

    int nRow = m_pGDC->FocusedRecordIndex;
    if (nRow < 0) return;

    int nMemPtr = TvList->DataController->Values[nRow][Column99->Index];
    TCDSVmsColor *pObj = (TCDSVmsColor*)nMemPtr;
    if (pObj->Completed == false)
    {
        //신규이거나 삭제인 경우 편집 내용에 따른 변화가 필요없다.
        return;
    }

    String VMS_FONT_COLR_NM  = VarToStr(m_pGDC->Values[nRow][Column02->Index]);
    int    VMS_FONT_COLR_VAL = m_pGDC->Values[nRow][Column03->Index];
    String USE_YN            = VarToStr(m_pGDC->Values[nRow][Column04->Index]);

    TcxGridColumn *pColumn = TvList->Controller->FocusedColumn;
    if      (pColumn == Column02) VMS_FONT_COLR_NM  = DisplayValue;
    else if (pColumn == Column03) VMS_FONT_COLR_VAL = DisplayValue;
    else if (pColumn == Column04) USE_YN            = DisplayValue;

    if (pObj->VMS_FONT_COLR_NM  != VMS_FONT_COLR_NM  ||
        pObj->VMS_FONT_COLR_VAL != VMS_FONT_COLR_VAL ||
        pObj->USE_YN            != USE_YN )
    {
        m_pGDC->Values[nRow][Column00->Index] = FrmLang->lblModify->Caption;//"수정";
        pObj->EditMode = DB_UPDATE;
    }
    else
    {
        TvList->DataController->Values[nRow][Column00->Index] = "-";
        pObj->EditMode = DB_INIT;
    }

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

