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

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

#include "ITS0030MF.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "cxButtons"
#pragma link "cxControls"
#pragma link "cxGraphics"
#pragma link "cxLookAndFeelPainters"
#pragma link "cxLookAndFeels"
#pragma link "cxPC"
#pragma link "cxPCdxBarPopupMenu"
#pragma link "dxSkinBlack"
#pragma link "dxSkinBlue"
#pragma link "dxSkinCaramel"
#pragma link "dxSkinCoffee"
#pragma link "dxSkinDarkRoom"
#pragma link "dxSkinDarkSide"
#pragma link "dxSkinFoggy"
#pragma link "dxSkinGlassOceans"
#pragma link "dxSkiniMaginary"
#pragma link "dxSkinLilian"
#pragma link "dxSkinLiquidSky"
#pragma link "dxSkinLondonLiquidSky"
#pragma link "dxSkinMcSkin"
#pragma link "dxSkinMoneyTwins"
#pragma link "dxSkinOffice2007Black"
#pragma link "dxSkinOffice2007Blue"
#pragma link "dxSkinOffice2007Green"
#pragma link "dxSkinOffice2007Pink"
#pragma link "dxSkinOffice2007Silver"
#pragma link "dxSkinOffice2010Black"
#pragma link "dxSkinOffice2010Blue"
#pragma link "dxSkinOffice2010Silver"
#pragma link "dxSkinsCore"
#pragma link "dxSkinscxPCPainter"
#pragma link "dxSkinSeven"
#pragma link "dxSkinSharp"
#pragma link "dxSkinSilver"
#pragma link "dxSkinStardust"
#pragma link "FRAME_IncidentRegistF"
#pragma link "FRAME_IncidentProcessF"
#pragma link "FRAME_IncidentEndF"
#pragma resource "*.dfm"

TITS0030M *ITS0030M = NULL;
//---------------------------------------------------------------------------
__fastcall TITS0030M::TITS0030M(TComponent* Owner)
    : TForm(Owner)
{
    ITSSkin_Load(this);
    CMM_LoadForm(g_sFormsDir, this);
    cxPageControl1->Properties->ActivePage = cxTabSheet1;
}
//---------------------------------------------------------------------------

/*
 * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
 * Form과 DataModule class를 delete시킨다.
 *  arguments
 *
 *  return
 *      void
 */
void __fastcall TITS0030M::CommClose()
{
    try
    {
        ItsIncidentManager->FAutoLists.RemoveAll();
        ItsIncidentManager->FVmsLists.RemoveAll();

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

/*
 * form 초기화
 *
 *  arguments
 *
 *  return
 *      void
 */
void __fastcall TITS0030M::FormInit()
{
    FRAMEIncidentRegist1->PnlTitle->Color  = (TColor)0x00ACACFF;
    FRAMEIncidentProcess1->PnlTitle->Color = (TColor)0x000080FF;
    FRAMEIncidentProcess1->PnlVms->Color   = clBlack;
    FRAMEIncidentEnd1->PnlTitle->Color     = (TColor)0x0049BE50;
}
//---------------------------------------------------------------------------

/*
 * Form을 보여줄때 호출되는 event 메서드이다.
 *  arguments
 *      Sender : event handler 객체
 *  return
 *      void
 */
void __fastcall TITS0030M::FormShow(TObject *Sender)
{
    Refresh();
    FormInit();
    TmrShow->Enabled = true;
}
//---------------------------------------------------------------------------

/*
 * Form이 Show되고 난 후 최초 1회 수행되는 타이머 이벤트
 *  arguments
 *      Sender : event handler 객체
 *  return
 *      void
 */
void __fastcall TITS0030M::TmrShowTimer(TObject *Sender)
{
    TmrShow->Enabled = false;
    BtnSearchClick((TObject*)BtnSearch);
}
//---------------------------------------------------------------------------

/*
 * Search 버튼 클릭 이벤트 핸들러
 *  arguments
 *      Sender : event handler 객체
 *  return
 *      void
 */
void __fastcall TITS0030M::BtnSearchClick(TObject *Sender)
{
    RefreshData();
}
//---------------------------------------------------------------------------

/*
 * Refresh Data Event Function
 *  arguments
 *
 *  return
 *      void
 */
void __fastcall TITS0030M::RefreshData()
{
    SelListData();
}
//---------------------------------------------------------------------------

void __fastcall TITS0030M::SelListData()
{
    FRAMEIncidentRegist1->UpdateList();
    FRAMEIncidentProcess1->UpdateList();
    FRAMEIncidentProcess1->UpdateAutoList();
    FRAMEIncidentEnd1->UpdateList();
}
//---------------------------------------------------------------------------

/*
 * Close 버튼 클릭 이벤트 핸들러
 *  arguments
 *      Sender : event handler 객체
 *  return
 *      void
 */
void __fastcall TITS0030M::BtnCloseClick(TObject *Sender)
{
    Close();
}
//---------------------------------------------------------------------------

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

void __fastcall TITS0030M::cxPageControl1PageChanging(TObject *Sender, TcxTabSheet *NewPage, bool &AllowChange)
{
    switch(NewPage->PageIndex)
    {
    case 0 :
        FRAMEIncidentRegist1->UpdateList();
        break;
    case 1 :
        FRAMEIncidentProcess1->UpdateList();
        FRAMEIncidentProcess1->UpdateAutoList();
        break;
    case 2 :
        FRAMEIncidentEnd1->UpdateList();
        break;
    }
}
//---------------------------------------------------------------------------

