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

#ifndef CDSAtrdFH
#define CDSAtrdFH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <ADODB.hpp>
#include <DB.hpp>
#include "ITSLibF.h"
#include "CDSLayerF.h"
//---------------------------------------------------------------------------


/*
*  TItsAtrdRoad class
*/
class TItsAtrdRoad
{
public:
    TItsAtrdRoad();
    virtual ~TItsAtrdRoad();
    void Clear();
private:
    bool    FCompleted;
    int     FEditMode;
	int     FGridIndex;

public:

    String ATRD_ID;     //VARCHAR2(10)	N			간선도로 ID
    String ROAD_ID;     //NUMBER(10)	N			도로 ID
    int    ORD;         //NUMBER(3)	Y	0		순서
    String MEM_DEL;

public:
    __property bool   Completed = {read = FCompleted, write = FCompleted};
	__property int    EditMode  = {read = FEditMode,  write = FEditMode };
	__property int    GridIndex = {read = FGridIndex, write = FGridIndex };
};
//---------------------------------------------------------------------------

/*
*  Atrd class
*/
class TItsAtrd
{
public:
    TItsAtrd();
    virtual ~TItsAtrd();
    void Clear();

private:
    bool    FModified;
    bool    FCompleted;
    int     FEditMode;
	int     FGridIndex;

public:
    String  ATRD_ID;
    String  ATRD_NM;     //VARCHAR2(30)	Y			간선도로 명
    String  DRCT_CD;     //VARCHAR2(7)	Y			방향 코드
    String  AREA_CD;     //VARCHAR2(7)	Y			지역 코드
    String  DEL_YN;      //CHAR(1)	    Y	'N'		삭제 여부
    String  DRCT_NM;     //VARCHAR2(50)	Y			방향 명칭
    String  MEM_DEL;

    int    LENGTH;

    TItsMap<int, TItsAtrdRoad*> FRoads;

public:
    __property bool   Modified  = {read = FModified};
    __property bool   Completed = {read = FCompleted, write = FCompleted};
	__property int    EditMode  = {read = FEditMode,  write = FEditMode };
	__property int    GridIndex = {read = FGridIndex, write = FGridIndex };
};
//---------------------------------------------------------------------------

class TItsAtrdName
{
public:
    TItsAtrdName() { RowNo = 0; };
    virtual ~TItsAtrdName() {};
public:
    String  Name;
    int     RowNo;
    bool    IsUpAtrd;
    bool    IsDnAtrd;
    String  UpAtrdId;
    String  DnAtrdId;
    String  UpAtrdNm;
    String  DnAtrdNm;
};

class TCDSAtrdName
{
public:
    TCDSAtrdName() {};
    virtual ~TCDSAtrdName() {};
public:
    String  ATRD_NM;
    bool    IsSelected;
};

/*
* Atrd Manager
*/
class TItsAtrdManager
{
public:
    TItsAtrdManager();
    virtual ~TItsAtrdManager();

public:
    TItsMap<String, TItsAtrd*>       FLists;
    TItsMap<String, TItsAtrdName*>   FNameLists;
    TItsMap<String, TCDSAtrdName*>   FCDSNameLists;
    int                              FCDSNameSelCnt;

public:
    bool LoadFromDbAtrdName(TADOConnection *ADbConn=NULL);
    bool LoadFromDb(TADOConnection *ADbConn=NULL);
    bool LoadFromAtrdDb(TADOConnection *ADbConn=NULL);
    bool LoadFromAtrdRoadDb(TADOConnection *ADbConn=NULL);
    bool LoadAtrdLength(TADOConnection *ADbConn=NULL);

    bool DeleteAtrdRoad(TItsAtrd *AObj, TADOConnection *ADbConn=NULL);
    bool InsertAtrdRoad(TItsAtrd *AObj, TADOConnection *ADbConn=NULL);
    bool DeleteAtrd(TItsAtrd *AObj, TADOConnection *ADbConn=NULL);
    bool UpdateAtrd(TItsAtrd *AObj, TADOConnection *ADbConn=NULL);
    bool InsertAtrd(TItsAtrd *AObj, TADOConnection *ADbConn=NULL);
};
//---------------------------------------------------------------------------
extern TItsAtrdManager *ItsAtrdManager;
//---------------------------------------------------------------------------

#endif

