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

#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 "CDSIfscF.h"
#include "CDSRoadF.h"
#include "ITSLangTransF.h"
#pragma hdrstop

#include "ITS0030MF.h"
#include "FrmIncidVmsInfoF.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "FRAME_IncidentRegistF"
#pragma link "FRAME_IncidentProcessF"
#pragma link "FRAME_IncidentEndF"
#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 "dxSkinsCore"
#pragma link "dxSkinscxPCPainter"
#pragma link "dxSkinMcSkin"
#pragma resource "*.dfm"

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

void __fastcall TITS0030M::CommClose()
{
    try
    {
        ItsIncidentManager->FAutoLists.RemoveAll();
        ItsIncidentManager->FVmsLists.RemoveAll();

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

void __fastcall TITS0030M::FormInit()
{
    FRAMEIncidentRegist1->PnlTitle->Color  = (TColor)0x00ACACFF;
    FRAMEIncidentProcess1->PnlTitle->Color = (TColor)0x000080FF;
    FRAMEIncidentProcess1->PnlVms->Color   = clBlack;
    FRAMEIncidentEnd1->PnlTitle->Color     = (TColor)0x0049BE50;
}
//---------------------------------------------------------------------------

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

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

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

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

void __fastcall TITS0030M::RefreshData()
{
    SelListData();
}
//---------------------------------------------------------------------------

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

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

void __fastcall TITS0030M::FormClose(TObject *Sender, TCloseAction &Action)
{
    try
    {
        if (FrmIncidVmsInfo)
        {
            FrmIncidVmsInfo->Close();
            FrmIncidVmsInfo = NULL;
        }
    }
    catch(...)
    {
    }

    CommClose();
    ITS0030M = NULL;
    Action = caFree;    
}
//---------------------------------------------------------------------------

void __fastcall TITS0030M::cxPageControl1PageChanging(TObject *Sender, TcxTabSheet *NewPage, bool &AllowChange)
{
    try
    {
        if (FrmIncidVmsInfo)
        {
            FrmIncidVmsInfo->Close();
            FrmIncidVmsInfo = NULL;
        }
    }
    catch(...)
    {
    }

    switch(NewPage->PageIndex)
    {
    case 0 :
        FRAMEIncidentRegist1->UpdateList();
        FRAMEIncidentRegist1->UpdateAutoList();
        break;
    case 1 :
        FRAMEIncidentProcess1->UpdateList();
        //FRAMEIncidentProcess1->UpdateAutoList();
        break;
    case 2 :
        FRAMEIncidentEnd1->UpdateList();
        break;
    }
}
//---------------------------------------------------------------------------

