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

#ifndef CDSCodeFH
#define CDSCodeFH
//---------------------------------------------------------------------------

#include <Classes.hpp>
#include <ADODB.hpp>
#include <DB.hpp>
#include "cxCustomData.hpp"
#include "ITSLibF.h"
#include "ITSDbF.h"
//---------------------------------------------------------------------------

/*
*  SubCode Detail
*/
class TItsSubCode
{
public:
    TItsSubCode();
    TItsSubCode(String ACd, String AClsfCd);
    virtual ~TItsSubCode();
    void Clear();
private:
    bool    FModified;
    bool    FCompleted;
    
public:
    String  CMMN_CD;           // VARCHAR(7 BYTE) NOT NULL,        '공통 코드';
    String  CMMN_CLSF_CD;      // VARCHAR(3 BYTE) NOT NULL,  '공통 분류 코드';
    String  CMMN_CD_KOR_NM;    // VARCHAR(60 BYTE),        '공통 코드 한글 명';
    String  CMMN_CD_ENGL_NM;   // VARCHAR(60 BYTE),       '공통 코드 영문 명';
    String  CMMN_CD_ABBR;      // VARCHAR(20 BYTE),          '공통 코드 약어';
    String  RMRK;              // VARCHAR(600 BYTE),                 '비고';
    String  ATRB1;             // VARCHAR(60 BYTE),                 '속성1';
    String  ATRB2;             // VARCHAR(60 BYTE),                 '속성2';
    String  USE_YN;            // CHAR(1 BYTE) DEFAULT 'N',        '사용 여부';
protected:

public:
    __property bool   Modified  = {read = FModified};
    __property bool   Completed = {read = FCompleted, write = FCompleted};

};

/*
*  Code class
*/
class TItsCode
{
public:
    TItsCode();
    TItsCode(String AClsfCd);
    virtual ~TItsCode();
    void Clear();
private:
    bool    FModified;
    bool    FCompleted;
    
public:
    String  CMMN_CLSF_CD;          // VARCHAR(3 BYTE) NOT NULL,                                        '공통 분류 코드';
    String  MSG_TYPE_CD;           // VARCHAR(7 BYTE),                                                '메시지 유형 코드';
    String  CMMN_CLSF_KOR_NM;      // VARCHAR(60 BYTE),                                          '공통 분류 한글 명';
    String  CMMN_CLSF_ENGL_NM;     // VARCHAR(60 BYTE),                                         '공통 분류 영문 명';
    String  USE_SYST_CD;           // VARCHAR(7 BYTE),                                                '사용 시스템 코드';
    String  RMRK;                  // VARCHAR(600 BYTE),                                                     '비고';
    String  USE_YN;                // CHAR(1 BYTE) DEFAULT 'N',                                            '사용 여부';

protected:

public:
    __property bool   Modified  = {read = FModified};
    __property bool   Completed = {read = FCompleted, write = FCompleted};

    TItsMap<String, TItsSubCode*>    FSubLists;
};
//---------------------------------------------------------------------------

/*
* Code Manager
*/
class TItsCodeManager
{
public:
    TItsCodeManager();
    virtual ~TItsCodeManager();

public:
    TItsMap<String, TItsCode*>   FLists;

public:
    bool LoadFromDb(TADOConnection *ADbConn=NULL);
    bool LoadCode(TADOConnection *ADbConn=NULL);
    bool LoadSubCode(TADOConnection *ADbConn=NULL);
};
//---------------------------------------------------------------------------
extern TItsCodeManager *ItsCodeManager;
//---------------------------------------------------------------------------


#endif

