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

#include <vcl.h>
#include "ITSSkinF.h"
#include "ITSUtilF.h"
#include "ITSDbF.h"
#include "AppGlobalF.h"
#pragma hdrstop

#include "SMS0020MF.h"
#include "SMS00201F.h"
#include "SMS00202F.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "cxButtons"
#pragma link "cxCalc"
#pragma link "cxCheckBox"
#pragma link "cxClasses"
#pragma link "cxContainer"
#pragma link "cxControls"
#pragma link "cxCustomData"
#pragma link "cxData"
#pragma link "cxDataStorage"
#pragma link "cxDropDownEdit"
#pragma link "cxEdit"
#pragma link "cxFilter"
#pragma link "cxGraphics"
#pragma link "cxGrid"
#pragma link "cxGridCustomTableView"
#pragma link "cxGridCustomView"
#pragma link "cxGridLevel"
#pragma link "cxGridTableView"
#pragma link "cxLabel"
#pragma link "cxLookAndFeelPainters"
#pragma link "cxLookAndFeels"
#pragma link "cxStyles"
#pragma link "cxTextEdit"
#pragma link "dxSkinBlack"
#pragma link "dxSkinBlue"
#pragma link "dxSkinCaramel"
#pragma link "dxSkinCoffee"
#pragma link "dxSkinDarkRoom"
#pragma link "dxSkinDarkSide"
#pragma link "dxSkinFoggy"
#pragma link "dxSkinGlassOceans"
#pragma link "dxSkiniMaginary"
#pragma link "dxSkinLilian"
#pragma link "dxSkinLiquidSky"
#pragma link "dxSkinLondonLiquidSky"
#pragma link "dxSkinMcSkin"
#pragma link "dxSkinMoneyTwins"
#pragma link "dxSkinOffice2007Black"
#pragma link "dxSkinOffice2007Blue"
#pragma link "dxSkinOffice2007Green"
#pragma link "dxSkinOffice2007Pink"
#pragma link "dxSkinOffice2007Silver"
#pragma link "dxSkinOffice2010Black"
#pragma link "dxSkinOffice2010Blue"
#pragma link "dxSkinOffice2010Silver"
#pragma link "dxSkinsCore"
#pragma link "dxSkinscxPCPainter"
#pragma link "dxSkinSeven"
#pragma link "dxSkinSharp"
#pragma link "dxSkinSilver"
#pragma link "dxSkinStardust"
#pragma link "cxPC"
#pragma link "cxPCdxBarPopupMenu"
#pragma resource "*.dfm"

TSMS0020M *SMS0020M = NULL;

//---------------------------------------------------------------------------
__fastcall TSMS0020M::TSMS0020M(TComponent* Owner)
    : TForm(Owner)
{
    ITSSkin_Load(this);
    CMM_LoadForm(g_sFormsDir, this);

    FTitle = "SMS 발송 관리";

    SMS00201 = new TSMS00201(cxTabSheet1, (TForm*)this);
    SMS00202 = new TSMS00202(cxTabSheet2, (TForm*)this);
}
//---------------------------------------------------------------------------

/*
 * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
 * Form과 DataModule class를 delete시킨다.
 *  arguments
 *
 *  return
 *      void
 */
void __fastcall TSMS0020M::CommClose()
{
    try
    {
        if (SMS00201)
        {
            delete SMS00201;
            SMS00201 = NULL;
        }
        if (SMS00202)
        {
            delete SMS00202;
            SMS00202 = NULL;
        }

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

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

/*
 * form 초기화
 *
 *  arguments
 *
 *  return
 *      void
 */
void __fastcall TSMS0020M::FormInit()
{
}
//---------------------------------------------------------------------------

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

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

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

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

void __fastcall TSMS0020M::FormCreate(TObject *Sender)
{
    if (SMS00201)
    {
        SMS00201->Parent = cxTabSheet1;
        SMS00201->Show();
    }
    if (SMS00202)
    {
        SMS00202->Parent = cxTabSheet2;
        SMS00202->Show();
    }
}
//---------------------------------------------------------------------------

void __fastcall TSMS0020M::cxPageControl1PageChanging(TObject *Sender, TcxTabSheet *NewPage,
          bool &AllowChange)
{
    switch(NewPage->PageIndex)
    {
    case 0:
        if (SMS00202)
        {
            if (SMS00202->FGroupChanged)
            {
                if (SMS00201)
                {
                    //SMS00201->DispData();
                    SMS00201->SelSmsGroupList();
                    SMS00201->SelSmsGroupRltnList(SMS00201->FGropId);
                }
            }
            SMS00202->FGroupChanged = false;
        }
        break;
    case 1:
        if (SMS00201)
        {
            if (SMS00201->FGroupChanged)
            {
                if (SMS00202)
                {
                    //SMS00202->DispData();
                    SMS00202->SelSmsGroupList();
                    SMS00202->SelSmsGroupRltnList(SMS00202->FGropId);
                }
            }
            SMS00201->FGroupChanged = false;
        }
        break;
    }
}
//---------------------------------------------------------------------------

