#include "RoleData/RoleDataEx.h"
#include "ObjectDataFile/ObjectDataBaseFile.h"
#include <fstream>
#include <Windows.h>

#include "TableForm.h"
#include "BaseForm.h"

using namespace ObjDataEdit;
using namespace NSObjectDataFile;

template<class T >
bool SqlReadObject( T& OutData , ReaderClass<T>* Reader , SqlDataReader* sqlReader )
{
	if( sqlReader->Read() == false )
		return false;

	int		i;	
	map<string,ReadInfoStruct>*             ReadInfo ;
	map<string,ReadInfoStruct>::iterator    Iter;
	ReadInfo = Reader->ReadInfo();

	for(    Iter  = ReadInfo->begin() , i = 0 ; 
			Iter != ReadInfo->end() ; 
			Iter++ , i++ )
	{

		ReadInfoStruct *IDData = &(Iter->second);

		if( IDData->UserData & Def_Disabled_Select_Flag  )            
		{			
			i--;
			continue;
		}

		if(IDData->AddressFlag == ENUM_Direct_Address)
		{
			//不處裡直接定址模式			
			return false;
		}
		else if(IDData->AddressFlag == ENUM_Indirect_Address)
		{
			bool bindResult = false;

			int Point = (IDData->Point + int(&OutData));
			switch(IDData->Type)
			{
			case ENUM_Type_FloatPoint:
				*(float*)Point = sqlReader->GetFloat( i );
				break;

			case ENUM_Type_IntPoint:
				*(int*)Point = sqlReader->GetInt32( i );
				break;

			case ENUM_Type_ShortPoint:
				*(short*)Point = sqlReader->GetInt16( i );
				break;

			case ENUM_Type_CharString:		
				{

					MyStrcpy( (char*)Point , DotNetStr::StringToChar( sqlReader->GetString(i) ).c_str() , IDData->Size );
				}
				break;

			case ENUM_Type_WCharString:				
				break;

			case  ENUM_Type_BinaryData:
				break;

			case ENUM_Type_BitPoint:
				break;

			case ENUM_Type_SmallDateTime:
				break;
			}   
		}
	}
	return true;
}

//////////////////////////////////////////////////////////////////////////
template<class TempStruct>
void OuputTableFile( String* Account , SqlCommand* sqlCommand1, char* DBTableName , char* FileName , int GUID , ReaderClass< TempStruct >* Reader )
{
	fstream file;

	ObjFileHead FileHead;
	FileHead.Idenitfy = DEF_ITEMOBJ_FILE_ID;

	TempStruct	Table;
	memset( &Table , 0 , sizeof(&Table) );

	if( BaseForm::OutputFile_SimplifyProcess( file , FileName , "DB"  ) == false )
		return;

	FileHead.Size = sizeof( Table ) + sizeof(int);
	FileHead.Count = 0;

	sprintf( FileHead.FileInfoStr ,"%s %s %s %s" , _DEF_VERSION , DotNetStr::StringToChar( Account ).c_str() , TimeStr::Now() , DBTableName );
	file.write( (char*)&FileHead, sizeof(FileHead) );

	//	GUID = BeginGUID;
	CreateDBCmdClass<TempStruct>* _SqlMaker  = NEW CreateDBCmdClass<TempStruct > ( Reader  , DBTableName );
	sqlCommand1->CommandText = _SqlMaker->GetSelectStr("").c_str();
	SqlDataReader* mySqlReader = sqlCommand1->ExecuteReader();        


	while( SqlReadObject<TempStruct>( Table , Reader  , mySqlReader ) )
	{
		file.write( (char*)&GUID , sizeof(int) );
		file.write( (char*)&Table , sizeof(Table) );

		GUID++;
		FileHead.Count++;
	}
	file.seekg( 0 );
	file.write( (char*)&FileHead, sizeof(FileHead) );
	mySqlReader->Close();
	file.close();

}
//////////////////////////////////////////////////////////////////////////

void    TableForm::OutputFileLanguage( int )
{
    
    int     i,j;
    SqlDataReader* myReader;
    char    Buf[2048];

    ObjFileHead FileHead;
    FileHead.Idenitfy = DEF_ITEMOBJ_FILE_ID;

	fstream file;
	if( BaseForm::OutputFile_SimplifyProcess( file , "RaceTable" , "DB"  ) == false )
	{
		return;
	}
	//////////////////////////////////////////////////////////////////////////

    FileHead.Size = sizeof(FightArgumentStruct) + sizeof(int);;
    FileHead.Count = _MAX_RACE_COUNT_;

	sprintf( FileHead.FileInfoStr ,"%s %s %s RaceTable" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
    file.write( (char*)&FileHead, sizeof(FileHead) );

    int     GUID = Def_ObjectClass_Table;
    for( i = 0 ; i < _MAX_RACE_COUNT_ ; i++ , GUID++ )
    {
        sprintf( Buf , "SELECT BStrLv1, BStaLv1, BIntLv1, BMndLv1, BAgiLv1, BHpLv1, BMpLv1,BStrArg, BStaArg, BIntArg, BMndArg, BAgiArg, BHpArg, BMpArg, StrArg,StaArg, IntArg, MndArg, AgiArg, HPArg, MPArg, HpStrArg, HpStaArg, MPIntArg, MpMndArg, AtkStrArg, AtkIntArg, AtkAgiArg, DefArg, BaseReHP, BaseReMP, ReHpArg, ReMpArg, MAtkArg, MDefArg, MoveSpeed , ReSPNormal_Move , ReSPNormal_Stop  ,ReSPAttack , ReSPUnderAttack , ReSPAttackTime_Move , ReSPAttackTime_Stop , MaxSP , DmgRate FROM FightArg Where ID=%d and Type = 0" , i );
        sqlCommand1->CommandText = Buf;
        myReader = sqlCommand1->ExecuteReader();        

        if( myReader->Read( ) )
        {            
            for( j = 0 ; j < myReader->FieldCount ; j++  )
                RoleValueData::RaceArg[i].Arg[ j ] = myReader->GetFloat( j );
        }
        myReader->Close();
        file.write( (char*)&GUID , sizeof(int) );
        file.write( (char*)&RoleValueData::RaceArg[i] , sizeof(FightArgumentStruct) );
    }

    file.close();

    //---------------------------------------------------------------------------------------------------
	
	if( BaseForm::OutputFile_SimplifyProcess( file , "VocTable" , "DB"  ) == false )
	{
		return;
	}


    FileHead.Size = sizeof(FightArgumentStruct) + sizeof(int);;
    FileHead.Count = _MAX_VOCATION_COUNT_;

	sprintf( FileHead.FileInfoStr ,"%s %s %s VocTable" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
    file.write( (char*)&FileHead, sizeof(FileHead) );

    GUID = Def_ObjectClass_Table + _TABLE_BASE_VOCTABLE_;
    for( i = 0 ; i < _MAX_VOCATION_COUNT_ ; i++ )
    {
		sprintf( Buf , "SELECT BStrLv1, BStaLv1, BIntLv1, BMndLv1, BAgiLv1, BHpLv1, BMpLv1,BStrArg, BStaArg, BIntArg, BMndArg, BAgiArg, BHpArg, BMpArg, StrArg,StaArg, IntArg, MndArg, AgiArg, HPArg, MPArg, HpStrArg, HpStaArg, MPIntArg, MpMndArg, AtkStrArg, AtkIntArg, AtkAgiArg, DefArg, BaseReHP, BaseReMP, ReHpArg, ReMpArg, MAtkArg, MDefArg, MoveSpeed , ReSPNormal_Move , ReSPNormal_Stop ,ReSPAttack , ReSPUnderAttack , ReSPAttackTime_Move , ReSPAttackTime_Stop , MaxSP , DmgRate  FROM FightArg Where ID=%d and Type = 3" , i );
		sqlCommand1->CommandText = Buf;
		myReader = sqlCommand1->ExecuteReader();        

		if( myReader->Read( ) )
		{            
			for( j = 0 ; j < myReader->FieldCount ; j++ )
				RoleValueData::VocArg[i][0].Arg[ j ] = myReader->GetFloat( j );
		}
		myReader->Close();

		file.write( (char*)&GUID , sizeof(int) );
		file.write( (char*)&RoleValueData::VocArg[i][0] , sizeof(FightArgumentStruct) );
		GUID++;

        sprintf( Buf , "SELECT BStrLv1, BStaLv1, BIntLv1, BMndLv1, BAgiLv1, BHpLv1, BMpLv1,BStrArg, BStaArg, BIntArg, BMndArg, BAgiArg, BHpArg, BMpArg, StrArg,StaArg, IntArg, MndArg, AgiArg, HPArg, MPArg, HpStrArg, HpStaArg, MPIntArg, MpMndArg, AtkStrArg, AtkIntArg, AtkAgiArg, DefArg, BaseReHP, BaseReMP, ReHpArg, ReMpArg, MAtkArg, MDefArg, MoveSpeed , ReSPNormal_Move , ReSPNormal_Stop ,ReSPAttack , ReSPUnderAttack , ReSPAttackTime_Move , ReSPAttackTime_Stop , MaxSP , DmgRate  FROM FightArg Where ID=%d and Type = 1" , i );
        sqlCommand1->CommandText = Buf;
        myReader = sqlCommand1->ExecuteReader();        

        if( myReader->Read( ) )
        {            
            for( j = 0 ; j < myReader->FieldCount ; j++ )
                RoleValueData::VocArg[i][1].Arg[ j ] = myReader->GetFloat( j );
        }
	    myReader->Close();
		file.write( (char*)&GUID , sizeof(int) );
		file.write( (char*)&RoleValueData::VocArg[i][1] , sizeof(FightArgumentStruct) );
		GUID++;

		
    }
    file.close();
    //---------------------------------------------------------------------------------------------------

	if( BaseForm::OutputFile_SimplifyProcess( file , "SexTable" , "DB"  ) == false )
	{
		return;
	}

    FileHead.Size = sizeof(FightArgumentStruct) + sizeof(int);;
    FileHead.Count = _MAX_SEX_COUNT_;

	sprintf( FileHead.FileInfoStr ,"%s %s %s SexTable" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
    file.write( (char*)&FileHead, sizeof(FileHead) );

    GUID = Def_ObjectClass_Table + _TABLE_BASE_SEXTABLE_;
    for( i = 0 ; i < _MAX_SEX_COUNT_ ; i++ , GUID++)
    {
        sprintf( Buf , "SELECT BStrLv1, BStaLv1, BIntLv1, BMndLv1, BAgiLv1, BHpLv1, BMpLv1, BStrArg, BStaArg, BIntArg, BMndArg, BAgiArg, BHpArg, BMpArg,StrArg,StaArg, IntArg, MndArg, AgiArg, HPArg, MPArg, HpStrArg, HpStaArg, MPIntArg, MpMndArg, AtkStrArg, AtkIntArg, AtkAgiArg, DefArg, BaseReHP, BaseReMP, ReHpArg, ReMpArg, MAtkArg, MDefArg, MoveSpeed , ReSPNormal_Move , ReSPNormal_Stop , ReSPAttack , ReSPUnderAttack , ReSPAttackTime_Move , ReSPAttackTime_Stop , MaxSP , DmgRate FROM FightArg Where ID=%d and Type = 2" , i );
        sqlCommand1->CommandText = Buf;
        myReader = sqlCommand1->ExecuteReader();        

        if( myReader->Read( ) )
        {            
            for( j = 0 ; j < myReader->FieldCount ; j++ )
                RoleValueData::SexArg[i].Arg[ j ] = myReader->GetFloat( j );
        }
        myReader->Close();
        file.write( (char*)&GUID , sizeof(int) );
        file.write( (char*)&RoleValueData::SexArg[i] , sizeof(FightArgumentStruct) );
    }
    file.close();
    //----------------------------------------------------------------------------------------------------

	if( BaseForm::OutputFile_SimplifyProcess( file , "FixTable" , "DB"  ) == false )
	{
		return;
	}

    FileHead.Size = sizeof(FixFightArgumentStruct) + sizeof(int);;
    FileHead.Count = 0;

	sprintf( FileHead.FileInfoStr ,"%s %s %s FixTable" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
    file.write( (char*)&FileHead, sizeof(FileHead) );

    GUID = Def_ObjectClass_Table + _TABLE_BASE_FIXTABLE_;

    //取固定的Table
    sqlCommand1->CommandText = "SELECT DmgAtkArg,MDmgMAtkArg,Crit_DLV,Dmg_DLV,Miss_DLV,Miss_SecHand,Dmg_SecHand,BaseCritHit,BaseCritPower,BaseMagicCritHit,BaseMagicCritPower,Dmg_MagArg,MDmg_MagArg,MDmg_DotArg,Dmg_HealArg,Dmg_HealDotArg,BaseRateArg,BaseResistArg,DLvRateArg,DLvResistArg,PhyHit_Base,PhyHit_Range,PhyHit_AgiArg,PhyAvoid_AgiArg,MagHit_Base,MagHit_Range,MagHit_MndArg,MagAvoid_AgiArg,MagAvoid_MndArg FROM FixFightArg";
    myReader = sqlCommand1->ExecuteReader();        

    while( myReader->Read( ) )
    {   
		FileHead.Count++;
        for( j = 0 ; j < myReader->FieldCount ; j++ )
            RoleValueData::FixArgTable[0].Arg[ j ] = myReader->GetFloat( j );

		file.write( (char*)&GUID , sizeof(int) );
		file.write( (char*)&RoleValueData::FixArgTable[0] , sizeof(FixFightArgumentStruct) );
		GUID++;
    }
    myReader->Close();

	file.seekg( 0 );
	file.write( (char*)&FileHead, sizeof(FileHead) );
    file.close();
    //----------------------------------------------------------------------------------------------------

	if( BaseForm::OutputFile_SimplifyProcess( file , "SkillBaseTable" , "DB"  ) == false )
	{
		return;
	}

    FileHead.Size = sizeof(RoleValueData::SkillValueBase[ 0 ]) + sizeof(int);
    FileHead.Count = 0;

	sprintf( FileHead.FileInfoStr ,"%s %s %s SkillBase" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
    file.write( (char*)&FileHead, sizeof(FileHead) );

    GUID = Def_ObjectClass_Table + _TABLE_BASE_SKILLBASETABLE_;

    //取固定的Table
    sqlCommand1->CommandText = "SELECT GUID , S_Up , S , S_Dn , A_Up , A , A_Dn , B_Up , B , B_Dn , C_Up , C , C_Dn , D_Up , D , D_Dn , E_Up , E , E_Dn from SkillBase";
    myReader = sqlCommand1->ExecuteReader();        

    while( myReader->Read( ) )
    {   
        FileHead.Count++;
        int Level = myReader->GetInt32( 0 );

        for( j = 1 ; j < myReader->FieldCount ; j++ )
            RoleValueData::SkillValueBase[ Level ][ j - 1 ]  = myReader->GetInt32( j );

        int NowGUID = GUID + Level;
        file.write( (char*)&NowGUID , sizeof(int) );
        file.write( (char*)&RoleValueData::SkillValueBase[ Level ] , sizeof( RoleValueData::SkillValueBase[ Level ] ) );

    }
    myReader->Close();
    file.seekg( 0 );
    file.write( (char*)&FileHead, sizeof(FileHead) );

    file.close();
    //----------------------------------------------------------------------------------------------------

	if( BaseForm::OutputFile_SimplifyProcess( file , "JobSkill" , "DB"  ) == false )
		return;

    FileHead.Size = sizeof(RoleValueData::JobSkillValue[ 0 ]) + sizeof(int);
    FileHead.Count = 0;

	sprintf( FileHead.FileInfoStr ,"%s %s %s JobSkill" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
    file.write( (char*)&FileHead, sizeof(FileHead) );

    GUID = Def_ObjectClass_Table + _TABLE_BASE_JOBSKILLTABLE_;

    //取固定的Table
    sqlCommand1->CommandText = "SELECT GUID , Job1 , Job2 , Job3 , Job4 , Job5 , Job6 , Job7 , Job8 , Job9 , Job10 , Job11 , Job12 , Job13 , Job14 , Job15 , Job16 FROM JobSkillValue";
    myReader = sqlCommand1->ExecuteReader();        

    while( myReader->Read( ) )
    {   
        FileHead.Count++;
        int ID = myReader->GetInt32( 0 );

        for( j = 1 ; j < myReader->FieldCount ; j++ )
        {
            String* Str = myReader->GetString( j );

            int     ValueID = 0;
            if( Str->Compare( Str , "S+" ) == 0  )
                ValueID = 0;
            else if( Str->Compare( Str , "S" ) == 0  )
                ValueID = 1;
            else if( Str->Compare( Str , "S-" ) == 0  )
                ValueID = 2;
            else if( Str->Compare( Str , "A+" ) == 0  )
                ValueID = 3;
            else if( Str->Compare( Str , "A" ) == 0  )
                ValueID = 4;
            else if( Str->Compare( Str , "A-" ) == 0  )
                ValueID = 5;
            else if( Str->Compare( Str , "B+" ) == 0  )
                ValueID = 6;
            else if( Str->Compare( Str , "B" ) == 0  )
                ValueID = 7;
            else if( Str->Compare( Str , "B-" ) == 0  )
                ValueID = 8;
            else if( Str->Compare( Str , "C+" ) == 0  )
                ValueID = 9;
            else if( Str->Compare( Str , "C" ) == 0  )
                ValueID = 10;
            else if( Str->Compare( Str , "C-" ) == 0  )
                ValueID = 11;
            else if( Str->Compare( Str , "D+" ) == 0  )
                ValueID = 12;
            else if( Str->Compare( Str , "D" ) == 0  )
                ValueID = 13;
            else if( Str->Compare( Str , "D-" ) == 0  )
                ValueID = 14;
            else if( Str->Compare( Str , "E+" ) == 0  )
                ValueID = 15;
            else if( Str->Compare( Str , "E" ) == 0  )
                ValueID = 16;
            else if( Str->Compare( Str , "E-" ) == 0  )
                ValueID = 17;
            else 
                ValueID = 18;

            RoleValueData::JobSkillValue[ ID ][ j - 1 ]  = ValueID;
        }
        int NowGUID = GUID + ID;
        file.write( (char*)&NowGUID , sizeof(int) );
        file.write( (char*)&RoleValueData::JobSkillValue[ ID  ] , sizeof( RoleValueData::JobSkillValue[ ID ] ) );

    }
    myReader->Close();
    file.seekg( 0 );
    file.write( (char*)&FileHead, sizeof(FileHead) );

    file.close();
	//----------------------------------------------------------------------------------------------------
	if( BaseForm::OutputFile_SimplifyProcess( file , "JobEqSkillTable" , "DB"  ) == false )
		return;

	FileHead.Size = sizeof(RoleValueData::JobWearSkill ) + sizeof(int);
	FileHead.Count = 1;
	sprintf( FileHead.FileInfoStr ,"%s %s %s JobEqSkillTable" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
	file.write( (char*)&FileHead, sizeof(FileHead) );

	GUID = Def_ObjectClass_Table + _TABLE_BASE_JOBEQSKILLTABLE_;

	//取固定的Table
	sqlCommand1->CommandText = "SELECT GUID , Unarmed , Blade , Dagger , Wand , Axe , Bludgeon , Claymore , Staff , Axe_2H , Hammer_2H , Polearm , Bow , CossBow , Gun , Throw , HeavyArmed , LightArmed , Leather , Clothes , Robe , Shield , Implement , SecondHand GUID FROM EqWearSkill";
	myReader = sqlCommand1->ExecuteReader();        

	while( myReader->Read( ) )
	{   
		int Level = myReader->GetInt32( 0 );
		RoleValueData::JobWearSkill[ Level ]._Skill = 0;

		for( j = 1 ; j < myReader->FieldCount ; j++ )
		{
			
			if( myReader->GetInt32( j ) != 0 )
			{
				SetBit( RoleValueData::JobWearSkill[ Level ]._Skill , j - 1 );
			}
		}
	}
	file.write( (char*)&GUID , sizeof(int) );
	file.write( (char*)&RoleValueData::JobWearSkill , sizeof( RoleValueData::JobWearSkill ) );

	myReader->Close();
	file.seekg( 0 );
	file.write( (char*)&FileHead, sizeof(FileHead) );

	file.close();

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

	if( BaseForm::OutputFile_SimplifyProcess( file , "WeaponArgTable" , "DB"  ) == false )
		return;

	FileHead.Size = sizeof(RoleValueData::WeaponBaseDmg ) + sizeof(RoleValueData::WeaponBaseDelayTime) + sizeof(RoleValueData::WeaponBaseRand )  + sizeof(RoleValueData::WeaponBaseMAtk ) +sizeof(int);
	FileHead.Count = 1;

	sprintf( FileHead.FileInfoStr ,"%s %s %s WeaponArgTable" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
	file.write( (char*)&FileHead, sizeof(FileHead) );

	GUID = Def_ObjectClass_Table + _TABLE_BASE_WEAPONARGTABLE_;

	sqlCommand1->CommandText = "SELECT GUID , Dmg , Speed , Rand , MAtk , StandardCostRate FROM WeaponArg";
	myReader = sqlCommand1->ExecuteReader();        

	while( myReader->Read( ) )
	{   
		int ID  = myReader->GetInt32( 0 );
		RoleValueData::WeaponBaseDmg[ ID ] = myReader->GetFloat( 1 );
		RoleValueData::WeaponBaseDelayTime[ ID ] = myReader->GetInt32( 2 );
		RoleValueData::WeaponBaseRand[ ID ] = myReader->GetInt32( 3 );
		RoleValueData::WeaponBaseMAtk[ ID ] = myReader->GetFloat( 4 );
		RoleValueData::WeaponBaseCostRate[ ID ] = myReader->GetFloat( 5 );
	}
	file.write( (char*)&GUID , sizeof(int) );
	file.write( (char*)&RoleValueData::WeaponBaseDelayTime , sizeof( RoleValueData::WeaponBaseDelayTime ) );
	file.write( (char*)&RoleValueData::WeaponBaseDmg , sizeof( RoleValueData::WeaponBaseDmg ) );
	file.write( (char*)&RoleValueData::WeaponBaseRand , sizeof( RoleValueData::WeaponBaseRand ) );
	file.write( (char*)&RoleValueData::WeaponBaseMAtk , sizeof( RoleValueData::WeaponBaseMAtk ) );
	file.write( (char*)&RoleValueData::WeaponBaseCostRate , sizeof( RoleValueData::WeaponBaseCostRate ) );

	myReader->Close();
	file.seekg( 0 );
	file.write( (char*)&FileHead, sizeof(FileHead) );

	file.close();

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

	if( BaseForm::OutputFile_SimplifyProcess( file , "ArmorArgTable" , "DB"  ) == false )
		return;

	FileHead.Size = sizeof(RoleDataEx::ArmorArg ) + sizeof(int);
	FileHead.Count = 1;

	sprintf( FileHead.FileInfoStr ,"%s %s %s ArmorArgTable" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
	file.write( (char*)&FileHead, sizeof(FileHead) );

	GUID = Def_ObjectClass_Table + _TABLE_BASE_ARMORARGTABLE_;

	sqlCommand1->CommandText = "SELECT GUID , HeavyArmed , LightArmed , Leather , Clothes , Robe FROM ArmorArg";
	myReader = sqlCommand1->ExecuteReader();        

	while( myReader->Read( ) )
	{   
		int ID  = myReader->GetInt32( 0 );
		for( j = 1 ; j < myReader->FieldCount ; j++ )
		{
			RoleDataEx::ArmorArg[ID/100][ID%100][ j-1 ] = myReader->GetFloat( j );
		}
	}
	file.write( (char*)&GUID , sizeof(int) );	
	file.write( (char*)&RoleDataEx::ArmorArg , sizeof( RoleDataEx::ArmorArg ) );

	myReader->Close();
	file.seekg( 0 );
	file.write( (char*)&FileHead, sizeof(FileHead) );

	file.close();
	//----------------------------------------------------------------------------------------------------

	if( BaseForm::OutputFile_SimplifyProcess( file , "BaseMagicList" , "DB"  ) == false )
		return;

	FileHead.Size = sizeof(RoleDataEx::BaseMagicList ) + sizeof(int);
	FileHead.Count = 1;
	
	sprintf( FileHead.FileInfoStr ,"%s %s %s BaseMagicList" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
	file.write( (char*)&FileHead, sizeof(FileHead) );

	GUID = Def_ObjectClass_Table + _TABLE_BASE_BASEMAGICTABLE_;

	sqlCommand1->CommandText = "SELECT GUID ,MagicID FROM Table_BaseMagicList";
	myReader = sqlCommand1->ExecuteReader();        

	while( myReader->Read( ) )
	{   
		int ID  = myReader->GetInt32( 0 );
		if( EM_BaseMagic_MaxCount <= ID )
			break;
		RoleDataEx::BaseMagicList[ID] = myReader->GetInt32( 1 );
	}
	file.write( (char*)&GUID , sizeof(int) );	
	file.write( (char*)&RoleDataEx::BaseMagicList , sizeof( RoleDataEx::BaseMagicList ) );

	myReader->Close();
	file.seekg( 0 );
	file.write( (char*)&FileHead, sizeof(FileHead) );

	file.close();
	//----------------------------------------------------------------------------------------------------
	//經驗值表
	//----------------------------------------------------------------------------------------------------

	if( BaseForm::OutputFile_SimplifyProcess( file , "ExpTable" , "DB"  ) == false )
		return;

	LvExpRelationTable	AllExp;

	FileHead.Size = sizeof( LvExpRelationTable ) + sizeof(int);
	FileHead.Count = 0;

	sprintf( FileHead.FileInfoStr ,"%s %s %s ExpTable" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
	file.write( (char*)&FileHead, sizeof(FileHead) );

	GUID = Def_ObjectClass_Table + _TABLE_BASE_EXPTABLE_;

	//取固定的Table
	sqlCommand1->CommandText = "SELECT LV , JobExp , SkillExp,GatherExp,RefineExp , PlotExp , PlotMoney , JobExp_LvGrowRate , JobMagicExp, BaseMagicPower , MagicPowerGrowRate , AbilityPoint , DefPoint , HitPoint , HouseExpArg , MP_PowerLvCost,Pet_Exp,Pet_LifeSkill,PlantExp,PlantEffectPoint  FROM Table_Exp ORDER BY  LV";
	myReader = sqlCommand1->ExecuteReader();        

	while( myReader->Read( ) )
	{   
		AllExp.LV					= myReader->GetInt32( 0 );
		AllExp.JobExp				= myReader->GetInt32( 1 );
		AllExp.SkillExp				= myReader->GetInt32( 2 );
		AllExp.GatherExp			= myReader->GetInt32( 3 ); 
		AllExp.RefineExp			= myReader->GetInt32( 4 );
		AllExp.PlotExp				= myReader->GetInt32( 5 );
		AllExp.PlotMoney			= myReader->GetInt32( 6 );
		AllExp.JobExp_LvGrowRate	= myReader->GetFloat( 7 );
		AllExp.JobMagicExp			= myReader->GetInt32( 8 );
		AllExp.BaseMagicPower		= myReader->GetFloat( 9 );
		AllExp.MagicPowerGrowRate	= myReader->GetFloat( 10 );
		AllExp.AbilityPoint			= myReader->GetInt32( 11 );
		AllExp.DefPoint				= myReader->GetInt32( 12 );
		AllExp.HPPoint				= myReader->GetInt32( 13 );
		AllExp.HouseExpArg			= myReader->GetInt32( 14 );
		AllExp.MagicMPGrowRate		= myReader->GetFloat( 15 );
		AllExp.Pet_Exp				= myReader->GetInt32( 16 );
		AllExp.Pet_LifeSkill		= myReader->GetInt32( 17 );
		AllExp.PlantExp				= myReader->GetInt32( 18 );
		AllExp.PlantEffectPoint		= myReader->GetFloat( 19 );

		file.write( (char*)&GUID , sizeof(int) );
		file.write( (char*)&AllExp , sizeof( AllExp ) );
		GUID++;
		FileHead.Count++;
	}

	myReader->Close();
	file.seekg( 0 );
	file.write( (char*)&FileHead, sizeof(FileHead) );

	file.close();

	//----------------------------------------------------------------------------------------------------
	//　創角資訊
	//----------------------------------------------------------------------------------------------------
	{
		CreateRoleInfoTableStruct CreateRole;

		if( BaseForm::OutputFile_SimplifyProcess( file , "CreateRole" , "DB"  ) == false )
			return;

		FileHead.Size = sizeof( CreateRole ) + sizeof(int);
		FileHead.Count = 1;

		sprintf( FileHead.FileInfoStr ,"%s %s %s Table_CreateRole" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
		file.write( (char*)&FileHead, sizeof(FileHead) );

		GUID = Def_ObjectClass_Table + _TABLE_BASE_CREATEROLETABLE_;

		sqlCommand1->CommandText = "SELECT  Enabled , ID , Type , ObjID FROM Table_CreateRoleBody ORDER BY TYPE,ID";
		myReader = sqlCommand1->ExecuteReader();        

		int Count = 0;
		while( myReader->Read( ) )
		{   
			if( DEF_MAX_COUNT_CreateRoleInfo_Body <= Count )
				break;

			CreateRole.Body[ Count ].Enabled = myReader->GetBoolean( 0 );
			CreateRole.Body[ Count ].ID	  = myReader->GetInt32( 1 );
			CreateRole.Body[ Count ].Type	  = myReader->GetInt32( 2 );
			CreateRole.Body[ Count ].OrgID   = myReader->GetInt32( 3 );
			Count++;
		}
		CreateRole.BodyCount = Count;
		myReader->Close();

		sqlCommand1->CommandText = "SELECT  Enabled , ID , Type , Red , Green , Blue , Race  FROM Table_CreateRoleColor ORDER BY TYPE,ID";
		myReader = sqlCommand1->ExecuteReader();        

		Count = 0;
		while( myReader->Read( ) )
		{   
			if( DEF_MAX_COUNT_CreateRoleInfo_Color <= Count )
				break;

			CreateRole.Color[ Count ].Enabled 	= myReader->GetBoolean( 0 );
			CreateRole.Color[ Count ].ID	  	= myReader->GetInt32( 1 );
			CreateRole.Color[ Count ].Type	  	= myReader->GetInt32( 2 );
			CreateRole.Color[ Count ].R			= myReader->GetByte( 3 );
			CreateRole.Color[ Count ].G			= myReader->GetByte( 4 );
			CreateRole.Color[ Count ].B			= myReader->GetByte( 5 );
			CreateRole.Color[ Count ].Race		= (Race_ENUM)myReader->GetInt32( 6 );
			Count++;
		}
		myReader->Close();
		CreateRole.ColorCount = Count;

		sqlCommand1->CommandText = "SELECT JobID , JobKeyStr FROM Table_CreateRoleJob ";
		myReader = sqlCommand1->ExecuteReader();        

		Count = 0;
		while( myReader->Read( ) )
		{   
			if( DEF_MAX_COUNT_CreateRoleInfo_Job <= Count )
				break;

			CreateRole.JobID[ Count ]	= myReader->GetInt32( 0 );
			String* KeyStr = myReader->GetString( 1 );
			strcpy( CreateRole.JobKeyStr[Count] , DotNetStr::StringToChar( KeyStr).c_str() );
			Count++;
		}
		CreateRole.JobCount = Count;
		myReader->Close();

		file.write( (char*)&GUID , sizeof(int) );
		file.write( (char*)&CreateRole , sizeof( CreateRole ) );
		file.close();
	}

	//----------------------------------------------------------------------------------------------------
	//連攜技
	//----------------------------------------------------------------------------------------------------
	if( BaseForm::OutputFile_SimplifyProcess( file , "ComboTable" , "DB"  ) == false )
		return;

	ComboTable	Combo;

	FileHead.Size = sizeof( ComboTable ) + sizeof(int);
	FileHead.Count = 0;

	sprintf( FileHead.FileInfoStr ,"%s %s %s ComboTable" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
	file.write( (char*)&FileHead, sizeof(FileHead) );

	GUID = Def_ObjectClass_Table + _TABLE_BASE_COMBOTABLETABLE_;

	//取固定的Table
	sqlCommand1->CommandText = "SELECT GUID, ComboType1, ComboType2, ComboType3, ComboType4, ComboType5,ComboBonus, ComboFinal FROM Table_Combo";
	myReader = sqlCommand1->ExecuteReader();        

	while( myReader->Read( ) )
	{   
		
		Combo.Type[ 0 ] = myReader->GetInt32( 1 );	//連攜方式
		Combo.Type[ 1 ] = myReader->GetInt32( 2 );	//連攜方式
		Combo.Type[ 2 ] = myReader->GetInt32( 3 );	//連攜方式
		Combo.Type[ 3 ] = myReader->GetInt32( 4 );	//連攜方式
		Combo.Type[ 4 ] = myReader->GetInt32( 5 );	//連攜方式
		Combo.Bonus		= myReader->GetInt32( 6 );	//副加的法術
		Combo.Final		= myReader->GetInt32( 7 );	//結束技施展的法術

		file.write( (char*)&GUID , sizeof(int) );
		file.write( (char*)&Combo , sizeof( Combo ) );
		GUID++;
		FileHead.Count++;
	}

	myReader->Close();
	file.seekg( 0 );
	file.write( (char*)&FileHead, sizeof(FileHead) );

	file.close();

	//----------------------------------------------------------------------------------------------------
	// Motion資料
	//----------------------------------------------------------------------------------------------------
	{
		MotionTableStruct	Motion;

		if( BaseForm::OutputFile_SimplifyProcess( file , "MotionTable" , "DB"  ) == false )
			return;

		FileHead.Size = sizeof( MotionTableStruct ) + sizeof(int);
		FileHead.Count = 0;

		sprintf( FileHead.FileInfoStr ,"%s %s %s Table_Motion" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
		file.write( (char*)&FileHead, sizeof(FileHead) );

		GUID = Def_ObjectClass_Table + _TABLE_BASE_MOTIONTABLE_;

		sqlCommand1->CommandText = "SELECT  GUID , MotionID , IconStr FROM Table_Motion ORDER BY GUID";
		myReader = sqlCommand1->ExecuteReader();        


		while( myReader->Read( ) )
		{   
			Motion.ID = myReader->GetInt32( 0 )	;
			Motion.MotionID = myReader->GetInt32( 1 );
//			Motion.IconID = myReader->GetInt32( 2 );
			std::string IconStr = DotNetStr::StringToChar( myReader->GetString( 2 ) );
			strcpy( Motion.IconStr  ,  IconStr.c_str() );

			file.write( (char*)&GUID , sizeof(int) );
			file.write( (char*)&Motion , sizeof(Motion) );
			GUID++;
			FileHead.Count++;
		}
		file.seekg( 0 );
		file.write( (char*)&FileHead, sizeof(FileHead) );
		myReader->Close();
		file.close();
	}
	//----------------------------------------------------------------------------------------------------
	// Teach 資料
	//----------------------------------------------------------------------------------------------------
	{
		TeachTableStruct	Teach;
		memset( &Teach , 0 , sizeof( Teach ) );

		if( BaseForm::OutputFile_SimplifyProcess( file , "TeachTable" , "DB"  ) == false )
			return;

		FileHead.Size = sizeof( TeachTableStruct ) + sizeof(int);
		FileHead.Count = 0;

		sprintf( FileHead.FileInfoStr ,"%s %s %s Table_Teach" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
		file.write( (char*)&FileHead, sizeof(FileHead) );

		GUID = Def_ObjectClass_Table + _TABLE_BASE_TEACHTABLE_;

		sqlCommand1->CommandText = "SELECT  GUID , TypeStr , ImageStr , Height , Width FROM Table_Teach ORDER BY GUID";
		myReader = sqlCommand1->ExecuteReader();        

		while( myReader->Read( ) )
		{   
			Teach.ID = myReader->GetInt32( 0 )	;
			strcpy( Teach.TypeStr  ,  DotNetStr::StringToChar( myReader->GetString( 1 ) ).c_str() );
			strcpy( Teach.ImageStr ,  DotNetStr::StringToChar( myReader->GetString( 2 ) ).c_str() );
			Teach.Height = myReader->GetInt32( 3 )	;
			Teach.Width = myReader->GetInt32( 4 )	;

			file.write( (char*)&GUID , sizeof(int) );
			file.write( (char*)&Teach , sizeof(Teach) );
			GUID++;
			FileHead.Count++;
		}
		file.seekg( 0 );
		file.write( (char*)&FileHead, sizeof(FileHead) );
		myReader->Close();
		file.close();
	}
	//----------------------------------------------------------------------------------------------------
	// Coloring Shop 資料
	//----------------------------------------------------------------------------------------------------
	{
		ColoringShopStruct	ColoringShop;
		memset( &ColoringShop , 0 , sizeof( ColoringShop ) );

		if( BaseForm::OutputFile_SimplifyProcess( file , "ColoringShopTable" , "DB"  ) == false )
			return;

		FileHead.Size = sizeof( ColoringShopStruct ) + sizeof(int);
		FileHead.Count = 0;

		sprintf( FileHead.FileInfoStr ,"%s %s %s Table_ColoringShop" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
		file.write( (char*)&FileHead, sizeof(FileHead) );

		GUID = Def_ObjectClass_Table + _TABLE_BASE_COLORINGSHOPTABLE_;

		sqlCommand1->CommandText = "SELECT GUID, ID, Type, Red, Green, Blue, Cost ,ObjID FROM Table_ColoringShop ORDER BY GUID";
		myReader = sqlCommand1->ExecuteReader();        

		while( myReader->Read( ) )
		{   
			ColoringShop.ID			= myReader->GetInt32( 1 );
			ColoringShop.Type		= (ColoringShopTypeENUM)myReader->GetInt32( 2 );
			
			ColoringShop.Color.R	= myReader->GetByte( 3 );
			ColoringShop.Color.G	= myReader->GetByte( 4 );
			ColoringShop.Color.B	= myReader->GetByte( 5 );
			ColoringShop.Cost		= myReader->GetInt32( 6 );
			ColoringShop.ObjID		= myReader->GetInt32( 7 );

			file.write( (char*)&GUID , sizeof(int) );
			file.write( (char*)&ColoringShop , sizeof(ColoringShop) );
			GUID++;
			FileHead.Count++;
		}
		file.seekg( 0 );
		file.write( (char*)&FileHead, sizeof(FileHead) );
		myReader->Close();
		file.close();
	}
	//----------------------------------------------------------------------------------------------------
	// MapInfo 資料
	//----------------------------------------------------------------------------------------------------
	{
		WorldMapInfoStruct	WorldMapInfo;
		memset( &WorldMapInfo , 0 , sizeof( WorldMapInfo ) );

		if( BaseForm::OutputFile_SimplifyProcess( file , "WorldMapTable" , "DB"  ) == false )
			return;

		FileHead.Size = sizeof( WorldMapInfo ) + sizeof(int);
		FileHead.Count = 0;

		sprintf( FileHead.FileInfoStr ,"%s %s %s Table_MapInfo" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
		file.write( (char*)&FileHead, sizeof(FileHead) );

		GUID = Def_ObjectClass_Table + _TABLE_BASE_WORLDMAPINFO_;

		sqlCommand1->CommandText = "SELECT GUID, MapID , WorldID , Type , LX , LZ , RX , RZ , MapName,wdbFile FROM Table_MapINfo ORDER BY GUID";
		myReader = sqlCommand1->ExecuteReader();        

		String* Str;
		while( myReader->Read( ) )
		{   
			WorldMapInfo.MapID		= myReader->GetInt32( 1 );
			WorldMapInfo.WorldID	= myReader->GetInt32( 2 );
			WorldMapInfo.Type		= myReader->GetInt32( 3 );
			WorldMapInfo.LX			= myReader->GetInt32( 4 );
			WorldMapInfo.LZ			= myReader->GetInt32( 5 );
			WorldMapInfo.RX			= myReader->GetInt32( 6 );
			WorldMapInfo.RZ			= myReader->GetInt32( 7 );
			Str = myReader->GetString( 8 );
			strcpy( WorldMapInfo.MapName , DotNetStr::StringToChar( Str).c_str() );
			Str = myReader->GetString( 9 );
			strcpy( WorldMapInfo.wdbFile , DotNetStr::StringToChar( Str).c_str() );
			
			file.write( (char*)&GUID , sizeof(int) );
			file.write( (char*)&WorldMapInfo , sizeof(WorldMapInfo) );
			GUID++;
			FileHead.Count++;
		}
		file.seekg( 0 );
		file.write( (char*)&FileHead, sizeof(FileHead) );
		myReader->Close();
		file.close();
	}	
	//----------------------------------------------------------------------------------------------------
	// GuildLvInfo 資料
	//----------------------------------------------------------------------------------------------------
	{
		GuildLvInfoStruct	GuildLvInfo;
		memset( &GuildLvInfo , 0 , sizeof( GuildLvInfo ) );

		if( BaseForm::OutputFile_SimplifyProcess( file , "GuildLvInfo" , "DB"  ) == false )
			return;

		FileHead.Size = sizeof( GuildLvInfo ) + sizeof(int);
		FileHead.Count = 0;

		sprintf( FileHead.FileInfoStr ,"%s %s %s Table_GuildLv" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
		file.write( (char*)&FileHead, sizeof(FileHead) );

		GUID = Def_ObjectClass_Table + _TABLE_BASE_GUILDLVINFO_;

		sqlCommand1->CommandText = "SELECT GUID, Lv, UpgradeGold, UpgradeBonusGold, UpgradeMine, UpgradeWood, UpgradeHerb, UpgradeGuildRune, UpgradeGuildStone, MemberCount, DeclareWar, GuildFlag, GuildHouse, GuildWar, CityWar, Quest,RankCount,ChangeGuildStyle FROM Table_GuildLv ORDER BY GUID";
		myReader = sqlCommand1->ExecuteReader();        

		while( myReader->Read( ) )
		{   
			GuildLvInfo.Lv					= myReader->GetInt32( 1 );
			GuildLvInfo.UpgradeGold			= myReader->GetInt32( 2 );
			GuildLvInfo.UpgradeBonusGold	= myReader->GetInt32( 3 );
			GuildLvInfo.UpgradeMine			= myReader->GetInt32( 4 );
			GuildLvInfo.UpgradeWood			= myReader->GetInt32( 5 );
			GuildLvInfo.UpgradeHerb			= myReader->GetInt32( 6 );
			GuildLvInfo.UpgradeGuildRune	= myReader->GetInt32( 7 );
			GuildLvInfo.UpgradeGuildStone	= myReader->GetInt32( 8 );
			GuildLvInfo.MemberCount			= myReader->GetInt32( 9 );
			GuildLvInfo.DeclareWar			= myReader->GetInt32( 10 );
			GuildLvInfo.GuildFlag			= myReader->GetInt32( 11 );
			GuildLvInfo.GuildHouse			= myReader->GetInt32( 12 );
			GuildLvInfo.GuildWar			= myReader->GetInt32( 13 );
			GuildLvInfo.CityWar				= myReader->GetInt32( 14 );
			GuildLvInfo.Quest				= myReader->GetInt32( 15 );
			GuildLvInfo.RankCount			= myReader->GetInt32( 16 );
			GuildLvInfo.ChangeGuildStyle	= myReader->GetInt32( 17 );

			file.write( (char*)&GUID , sizeof(int) );
			file.write( (char*)&GuildLvInfo , sizeof(GuildLvInfo) );
			GUID++;
			FileHead.Count++;
		}
		file.seekg( 0 );
		file.write( (char*)&FileHead, sizeof(FileHead) );
		myReader->Close();
		file.close();
	}	

	//----------------------------------------------------------------------------------------------------
	// SysKeyFunction 資料
	//----------------------------------------------------------------------------------------------------
	{
		SysKeyFunctionStruct SysKeyFunction;
		memset( &SysKeyFunction , 0 , sizeof( SysKeyFunction ) );

		if( BaseForm::OutputFile_SimplifyProcess( file , "SysKeyFunction" , "DB"  ) == false )
			return;

		FileHead.Size = sizeof( SysKeyFunction ) + sizeof(int);
		FileHead.Count = 0;

		sprintf( FileHead.FileInfoStr ,"%s %s %s Table_SysKeyFunction" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
		file.write( (char*)&FileHead, sizeof(FileHead) );

		GUID = Def_ObjectClass_Table + _TABLE_BASE_SYSKEYFUNCTION_;

		sqlCommand1->CommandText = "SELECT GUID, KeyItemID , MagicID FROM Table_SysKeyFunction ORDER BY GUID";
		myReader = sqlCommand1->ExecuteReader();        

		while( myReader->Read( ) )
		{   
			SysKeyFunction.KeyItemID	= myReader->GetInt32( 1 );
			SysKeyFunction.MagicID		= myReader->GetInt32( 2 );
			

			file.write( (char*)&GUID , sizeof(int) );
			file.write( (char*)&SysKeyFunction , sizeof(SysKeyFunction) );
			GUID++;
			FileHead.Count++;
		}
		file.seekg( 0 );
		file.write( (char*)&FileHead, sizeof(FileHead) );
		myReader->Close();
		file.close();
	}
	//----------------------------------------------------------------------------------------------------
	// LotteryInfo 資料
	//----------------------------------------------------------------------------------------------------
	{
		LotteryInfoTableStruct	LotteryInfoTable;
		memset( &LotteryInfoTable , 0 , sizeof( LotteryInfoTable ) );

		if( BaseForm::OutputFile_SimplifyProcess( file , "LotteryInfoTable" , "DB"  ) == false )
			return;

		FileHead.Size = sizeof( LotteryInfoTable ) + sizeof(int);
		FileHead.Count = 0;

		sprintf( FileHead.FileInfoStr ,"%s %s %s Table_LotteryInfoTable" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
		file.write( (char*)&FileHead, sizeof(FileHead) );

		GUID = Def_ObjectClass_Table + _TABLE_BASE_LOTTERYINFO_;

		sqlCommand1->CommandText = "SELECT GUID, SelectCount, CombinationCount, Select0_Prize1, Select0_Prize2, Select0_Prize3 , Select1_Prize1, Select1_Prize2, Select1_Prize3, Select2_Prize1, Select2_Prize2, Select2_Prize3, Select3_Prize1, Select3_Prize2, Select3_Prize3, Select4_Prize1, Select4_Prize2, Select4_Prize3, Select5_Prize1, Select5_Prize2, Select5_Prize3 FROM Table_LotteryInfo";
		myReader = sqlCommand1->ExecuteReader();        

		while( myReader->Read( ) )
		{   
			LotteryInfoTable.SelectCount = myReader->GetInt32( 1 );
			LotteryInfoTable.CombinationCount = myReader->GetInt32( 2 );

			for( int i = 0 , k= 2 ; i <= 5 ; i++ )
				for( int j = 0 ; j < 3 ; j++ )
				{
					k++;
					LotteryInfoTable.SelectPrize[i][j] = myReader->GetInt32( k );
				}

			file.write( (char*)&GUID , sizeof(int) );
			file.write( (char*)&LotteryInfoTable , sizeof(LotteryInfoTable) );
			GUID++;
			FileHead.Count++;
		}
		file.seekg( 0 );
		file.write( (char*)&FileHead, sizeof(FileHead) );
		myReader->Close();
		file.close();
	}
	//----------------------------------------------------------------------------------------------------
	// SysKeyValue 資料
	//----------------------------------------------------------------------------------------------------
	{
		SysKeyValueTableStruct SysKeyValue;
		memset( &SysKeyValue , 0 , sizeof( SysKeyValue ) );

		if( BaseForm::OutputFile_SimplifyProcess( file , "SysKeyValue" , "DB"  ) == false )
			return;

		FileHead.Size = sizeof( SysKeyValueTableStruct ) + sizeof(int);
		FileHead.Count = 0;

		sprintf( FileHead.FileInfoStr ,"%s %s %s Table_SysKeyValue" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
		file.write( (char*)&FileHead, sizeof(FileHead) );

		GUID = Def_ObjectClass_Table + _TABLE_BASE_SYSKEYVALUE_;

		sqlCommand1->CommandText = "SELECT  GUID , KeyStr , Value FROM Table_SysKeyValue ORDER BY GUID";
		myReader = sqlCommand1->ExecuteReader();        

		while( myReader->Read( ) )
		{   

			strcpy( SysKeyValue.KeyStr  ,  DotNetStr::StringToChar( myReader->GetString( 1 ) ).c_str() );
			SysKeyValue.Value = myReader->GetInt32( 2 )	;

			file.write( (char*)&GUID , sizeof(int) );
			file.write( (char*)&SysKeyValue , sizeof(SysKeyValue) );
			GUID++;
			FileHead.Count++;
		}
		file.seekg( 0 );
		file.write( (char*)&FileHead, sizeof(FileHead) );
		myReader->Close();
		file.close();

	}
	//----------------------------------------------------------------------------------------------------
	// InherentRate 資料
	//----------------------------------------------------------------------------------------------------
	{
		InherentRateTableStruct	InheretRate;
		memset( &InheretRate , 0 , sizeof( InheretRate ) );

		if( BaseForm::OutputFile_SimplifyProcess( file , "InherentRate" , "DB"  ) == false )
			return;

		FileHead.Size = sizeof( InherentRateTableStruct ) + sizeof(int);
		FileHead.Count = 0;

		sprintf( FileHead.FileInfoStr ,"%s %s %s Table_InherentRate" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
		file.write( (char*)&FileHead, sizeof(FileHead) );

		GUID = Def_ObjectClass_Table + _TABLE_BASE_INHERENTRATE_;

		sqlCommand1->CommandText = "SELECT GUID, Lv, ItemLvNone, ItemLvSpacial, ItemLv1, ItemLv2, ItemLv3, ItemLv4, ItemLv5, ItemLv6, ItemLv7, ItemLv8, ItemLv9, ItemLv10, ItemLv11, ItemLv12, ItemLv13, ItemLv14, ItemLv15, ItemLv16, ItemLv17, ItemLv18, ItemLv19, ItemLv20, ItemLv21, ItemLv22, ItemLv23, ItemLv24, ItemLv25, ItemLv26, ItemLv27, ItemLv28, ItemLv29, ItemLv30, ItemLv31, ItemLv32, ItemLv33 FROM Table_InherentRate";
		myReader = sqlCommand1->ExecuteReader();        

		while( myReader->Read( ) )
		{   
			InheretRate.Lv = myReader->GetInt32( 1 );

			for( int i = 0 ; i < 35 ; i++ )
			{
				InheretRate.AllRateLv[i] = myReader->GetInt32( i + 2 );
			}
			file.write( (char*)&GUID , sizeof(int) );
			file.write( (char*)&InheretRate , sizeof(InheretRate) );
			GUID++;
			FileHead.Count++;
		}
		file.seekg( 0 );
		file.write( (char*)&FileHead, sizeof(FileHead) );
		myReader->Close();
		file.close();
	}
	//----------------------------------------------------------------------------------------------------
	// HouseShop 資料
	//----------------------------------------------------------------------------------------------------
	{
		HouseShopInfoStruct	HouseShopInfo;
		memset( &HouseShopInfo , 0 , sizeof( HouseShopInfo ) );

		if( BaseForm::OutputFile_SimplifyProcess( file , "HouseShopInfoTable" , "DB"  ) == false )
			return;

		FileHead.Size = sizeof( HouseShopInfo ) + sizeof(int);
		FileHead.Count = 0;

		sprintf( FileHead.FileInfoStr ,"%s %s %s Table_HouseShopInfo" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
		file.write( (char*)&FileHead, sizeof(FileHead) );

		GUID = Def_ObjectClass_Table + _TABLE_BASE_HOUSESHOPINFO_;

		sqlCommand1->CommandText = "SELECT GUID, FlagID , FurnitureCount , OpenEnergy , KeepEnergy , Type  FROM  Table_HouseShopInfo ORDER BY GUID";
		myReader = sqlCommand1->ExecuteReader();        

		while( myReader->Read( ) )
		{   
			HouseShopInfo.FlagID		= myReader->GetInt32( 1 );
			HouseShopInfo.FunitureCount	= myReader->GetInt32( 2 );
			HouseShopInfo.OpenEnergy	= myReader->GetInt32( 3 );
			HouseShopInfo.KeppEnergy	= myReader->GetInt32( 4 );
			HouseShopInfo.Type			= myReader->GetInt32( 5 );

			file.write( (char*)&GUID , sizeof(int) );
			file.write( (char*)&HouseShopInfo , sizeof(HouseShopInfo) );
			GUID++;
			FileHead.Count++;
		}
		file.seekg( 0 );
		file.write( (char*)&FileHead, sizeof(FileHead) );
		myReader->Close();
		file.close();
	}	
	//----------------------------------------------------------------------------------------------------	
	//----------------------------------------------------------------------------------------------------
	//Power Rate Table
	//能量換算能力加乘表
	{
		PowerRateTableStruct PowerRate;
		memset( &PowerRate , 0 , sizeof( PowerRate ) );

		if( BaseForm::OutputFile_SimplifyProcess( file , "PowerRateTable" , "DB"  ) == false )
			return;

		FileHead.Size = sizeof( PowerRate ) + sizeof(int);
		FileHead.Count = 0;

		sprintf( FileHead.FileInfoStr ,"%s %s %s PowerRateTable" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
		file.write( (char*)&FileHead, sizeof(FileHead) );

		GUID = Def_ObjectClass_Table + _TABLE_BASE_POWERRATE_;

		sqlCommand1->CommandText = "SELECT GUID, Power1, PowerRate1, Power2, PowerRate2, Power3, PowerRate3, Power4, PowerRate4, Power5, PowerRate5 FROM Table_PowerRate";
		myReader = sqlCommand1->ExecuteReader();        

		while( myReader->Read( ) )
		{   
			int ID  = myReader->GetInt32( 0 );
			for( int i = 0 ; i < 5 ; i++  )
			{
				PowerRate.Power[ i ] = myReader->GetInt32( i*2+1 );
				PowerRate.PowerRate[ i ] = myReader->GetFloat( i*2 + 2 );
			}

			file.write( (char*)&GUID , sizeof(int) );	
			file.write( (char*)&PowerRate , sizeof( PowerRate ) );
			GUID++;
			FileHead.Count++;
		}

		myReader->Close();
		file.seekg( 0 );
		file.write( (char*)&FileHead, sizeof(FileHead) );

		file.close();
	}
	//----------------------------------------------------------------------------------------------------
	//Rent Function Table
	//商城租用功能
	{
		RentFunctionTableStruct RentFunc;
		memset( &RentFunc , 0 , sizeof( RentFunc ) );

		if( BaseForm::OutputFile_SimplifyProcess( file , "RentFunctionTable" , "DB"  ) == false )
			return;

		FileHead.Size = sizeof( RentFunc ) + sizeof(int);
		FileHead.Count = 0;

		sprintf( FileHead.FileInfoStr ,"%s %s %s RentFunctionTable" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
		file.write( (char*)&FileHead, sizeof(FileHead) );

		GUID = Def_ObjectClass_Table + _TABLE_BASE_RENTFUNCTION_;

		sqlCommand1->CommandText = "SELECT GUID, MemberType, Cost, RentDay, RentFunc1, RentFunc2, RentFunc3, RentFunc4, RentFunc5, RentFunc6, RentFunc7, RentFunc8, RentFunc9, RentFunc10, RentFunc11, RentFunc12, RentFunc13, RentFunc14, RentFunc15, RentFunc16, RentFunc17, RentFunc18, RentFunc19, RentFunc20 FROM Table_RentFunction" ;
		myReader = sqlCommand1->ExecuteReader();        

		while( myReader->Read( ) )
		{   
			int ID  = myReader->GetInt32( 0 );
			RentFunc.MemberType = myReader->GetInt32( 1 );
			RentFunc.Cost = myReader->GetInt32( 2 );
			RentFunc.RentDay = myReader->GetFloat( 3 );
			for( int i = 0 ; i < 20 ; i++  )
			{
				RentFunc.RentFunc[i] = myReader->GetInt32( 4 + i );
			}

			file.write( (char*)&GUID , sizeof(int) );	
			file.write( (char*)&RentFunc , sizeof( RentFunc ) );
			GUID++;
			FileHead.Count++;
		}

		myReader->Close();
		file.seekg( 0 );
		file.write( (char*)&FileHead, sizeof(FileHead) );

		file.close();

	}
	
	//----------------------------------------------------------------------------------------------------
	//公會旗設定資訊
	{
		GuildFlagTableStruct GuildFlagTable;
		memset( &GuildFlagTable , 0 , sizeof( GuildFlagTable ) );

		if( BaseForm::OutputFile_SimplifyProcess( file , "GuildFlagTable" , "DB"  ) == false )
			return;

		FileHead.Size = sizeof( GuildFlagTable ) + sizeof(int);
		FileHead.Count = 0;

		sprintf( FileHead.FileInfoStr ,"%s %s %s GuildFlagTable" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
		file.write( (char*)&FileHead, sizeof(FileHead) );

		GUID = Def_ObjectClass_Table + _TABLE_BASE_GUIDFLAGTABLE_;

		sqlCommand1->CommandText = "SELECT GUID, Type , ID, Str FROM Table_GuildFlag" ;
		myReader = sqlCommand1->ExecuteReader();        

		while( myReader->Read( ) )
		{   

			int ID  = myReader->GetInt32( 0 );
			GuildFlagTable.Type = myReader->GetInt32( 1 );
			GuildFlagTable.ID = myReader->GetInt32( 2 );

			String* Str = myReader->GetString( 3 );
			strcpy( GuildFlagTable.Str , DotNetStr::StringToChar( Str).c_str() );

			file.write( (char*)&GUID , sizeof(int) );	
			file.write( (char*)&GuildFlagTable , sizeof( GuildFlagTable ) );

			GUID++;
			FileHead.Count++;
		}

		myReader->Close();
		file.seekg( 0 );
		file.write( (char*)&FileHead, sizeof(FileHead) );

		file.close();
	}
	//----------------------------------------------------------------------------------------------------
	// MapPointInfo 資料
	//----------------------------------------------------------------------------------------------------
	{
		MapPointStruct		MapPoint;
		memset( &MapPoint , 0 , sizeof( MapPoint ) );

		if( BaseForm::OutputFile_SimplifyProcess( file , "MapPoint" , "DB"  ) == false )
			return;

		FileHead.Size = sizeof( MapPoint ) + sizeof(int);
		FileHead.Count = 0;

		sprintf( FileHead.FileInfoStr ,"%s %s %s Table_MapPoint" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
		file.write( (char*)&FileHead, sizeof(FileHead) );

		GUID = Def_ObjectClass_Table + _TABLE_BASE_MAPPOINT_;

		sqlCommand1->CommandText = "SELECT KeyStr,wdbFile, X, Y, Z FROM Table_ZoneDB ORDER BY GUID";
		myReader = sqlCommand1->ExecuteReader();        

		String* Str;
		while( myReader->Read( ) )
		{   
			Str = myReader->GetString( 0 );
			strcpy( MapPoint.KeyStr , DotNetStr::StringToChar( Str).c_str() );
			Str = myReader->GetString( 1 );
			strcpy( MapPoint.wdbFile , DotNetStr::StringToChar( Str).c_str() );

			MapPoint.X = myReader->GetFloat( 2 );
			MapPoint.Y = myReader->GetFloat( 3 );
			MapPoint.Z = myReader->GetFloat( 4 );

			file.write( (char*)&GUID , sizeof(int) );
			file.write( (char*)&MapPoint , sizeof(MapPoint) );
			GUID++;
			FileHead.Count++;
		}
		file.seekg( 0 );
		file.write( (char*)&FileHead, sizeof(FileHead) );
		myReader->Close();
		file.close();
	}	
	//----------------------------------------------------------------------------------------------------
	// RelationMagic 資料
	//----------------------------------------------------------------------------------------------------
	{
		RelationMagicStruct		RelationMagic;
		memset( &RelationMagic , 0 , sizeof( RelationMagic ) );

		if( BaseForm::OutputFile_SimplifyProcess( file , "RelationMagic" , "DB"  ) == false )
			return;

		FileHead.Size = sizeof( RelationMagic ) + sizeof(int);
		FileHead.Count = 0;

		sprintf( FileHead.FileInfoStr ,"%s %s %s Table_RelationMagic" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
		file.write( (char*)&FileHead, sizeof(FileHead) );

		GUID = Def_ObjectClass_Table + _TABLE_BASE_RELATIONMAGIC_;

		sqlCommand1->CommandText = "SELECT  Relation, Lv, NormalMagicID, QuarterHPMagicID FROM Table_RelationMagic ORDER BY GUID";
		myReader = sqlCommand1->ExecuteReader();        

		String* Str;
		while( myReader->Read( ) )
		{   
			RelationMagic.Relation			= (RelationTypeENUM)myReader->GetInt32( 0 );
			RelationMagic.Lv				= myReader->GetInt32( 1 );
			RelationMagic.NormalMagic		= myReader->GetInt32( 2 );
			RelationMagic.Quarter_HP_Magic	= myReader->GetInt32( 3 );

			file.write( (char*)&GUID , sizeof(int) );
			file.write( (char*)&RelationMagic , sizeof(RelationMagic) );
			GUID++;
			FileHead.Count++;
		}
		file.seekg( 0 );
		file.write( (char*)&FileHead, sizeof(FileHead) );
		myReader->Close();
		file.close();
	}
	//----------------------------------------------------------------------------------------------------
	// RuneExchangeTableStruct 資料
	//----------------------------------------------------------------------------------------------------
	/*
	{
		RuneExchangeTableStruct RuneExchangeTable;
		memset( &RuneExchangeTable , 0 , sizeof( RuneExchangeTable ) );

		if( BaseForm::OutputFile_SimplifyProcess( file , "RuneExchange" , "DB"  ) == false )
			return;

		FileHead.Size = sizeof( RuneExchangeTable ) + sizeof(int);
		FileHead.Count = 0;

		sprintf( FileHead.FileInfoStr ,"%s %s %s Table_RuneExchange" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
		file.write( (char*)&FileHead, sizeof(FileHead) );

		GUID = Def_ObjectClass_Table + _TABLE_BASE_RUNEEXCHANGE_;

		sqlCommand1->CommandText = "SELECT GUID, Type0, Type1, Type2, Type3, Type4, Type5, Type6, Type7, Type8, Type9,Type10, Type11, Type12, Type13, Type14, Type15, Type16, Type17, Type18, Type19, Type20, Type21, Type22, Type23, Type24, Type25, Type26, Type27, Type28, Type29, Type30, Type31, Type32, Type33, Type34, Type35, Type36, Type37, Type38, Type39, Type40, Type41, Type42, Type43, Type44, Type45, Type46, Type47, Type48, Type49 FROM Table_RuneExchange ORDER BY GUID";
		myReader = sqlCommand1->ExecuteReader();        

		String* Str;
		while( myReader->Read( ) )
		{   
			for( int i = 0 ; i < 50 ; i++ )
				RuneExchangeTable.ExchangeTable[ i ] = myReader->GetInt32( i+1 );

			file.write( (char*)&GUID , sizeof(int) );
			file.write( (char*)&RuneExchangeTable , sizeof(RuneExchangeTable) );

			GUID++;
			FileHead.Count++;
		}
		file.seekg( 0 );
		file.write( (char*)&FileHead, sizeof(FileHead) );
		myReader->Close();
		file.close();
	}
	*/
	//----------------------------------------------------------------------------------------------------
	// GuildBuildingInfo 資料
	//----------------------------------------------------------------------------------------------------
	{
		GuildBuildingInfoTableStruct	GuildBuilding;
		memset( &GuildBuilding , 0 , sizeof( GuildBuilding ) );

		if( BaseForm::OutputFile_SimplifyProcess( file , "GuildBuilding" , "DB"  ) == false )
			return;

		FileHead.Size = sizeof( GuildBuildingInfoTableStruct ) + sizeof(int);
		FileHead.Count = 0;

		sprintf( FileHead.FileInfoStr ,"%s %s %s Table_GuildBuildingInfo" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
		file.write( (char*)&FileHead, sizeof(FileHead) );

		GUID = Def_ObjectClass_Table + _TABLE_BASE_GUIDBUILDING_;

		sqlCommand1->CommandText = "SELECT GUID, BuildPoint, TypeStr, Lv, Resource_Gold, Resource_BonusGold, Resource_Mine, Resource_Wood, Resource_Herb, Resource_GuildRune, Resource_GuildStone, NeedTypeStr1, NeedLv1, NeedTypeStr2, NeedLv2 ,BlockSizeX ,BlockSizeY,OrgObjID,ModeAllZoneVisible,ModeDrag,ModeAttack,ModeMark,SrcBuildingID,ModeRemove,MaintenanceCharge,NeedGuildLv,BuildSize,IconPath,SortID FROM Table_GuildBuildingInfo ORDER BY GUID";
		myReader = sqlCommand1->ExecuteReader();        

		GuildBuilding.Mode._Mode = 0;
		GuildBuilding.Mode.Show = 1;
		//GuildBuilding.Mode.Gravity = 1;

		String* Str;
		while( myReader->Read( ) )
		{   
			GuildBuilding.ID = myReader->GetInt32( 0 );
			String* Str = myReader->GetString( 1 );
			strcpy( GuildBuilding.BuildPoint , DotNetStr::StringToChar( Str).c_str() );

			Str = myReader->GetString( 2 );
			strcpy( GuildBuilding.TypeStr , DotNetStr::StringToChar( Str).c_str() );

			GuildBuilding.Lv					= myReader->GetInt32( 3 );
			GuildBuilding.Resource.Gold			= myReader->GetInt32( 4 );
			GuildBuilding.Resource.BonusGold	= myReader->GetInt32( 5 );
			GuildBuilding.Resource.Mine			= myReader->GetInt32( 6 );
			GuildBuilding.Resource.Wood			= myReader->GetInt32( 7 );
			GuildBuilding.Resource.Herb			= myReader->GetInt32( 8 );
			GuildBuilding.Resource.GuildRune	= myReader->GetInt32( 9 );
			GuildBuilding.Resource.GuildStone	= myReader->GetInt32( 10 );

			Str = myReader->GetString( 11 );
			strcpy( GuildBuilding.NeedTypeStr1 , DotNetStr::StringToChar( Str).c_str() );

			GuildBuilding.NeedLv1				= myReader->GetInt32( 12 );
			Str = myReader->GetString( 13 );
			strcpy( GuildBuilding.NeedTypeStr2 , DotNetStr::StringToChar( Str).c_str() );
			GuildBuilding.NeedLv2				= myReader->GetInt32( 14 );

			GuildBuilding.BlockSizeX			= myReader->GetInt32( 15 );
			GuildBuilding.BlockSizeY			= myReader->GetInt32( 16 );
			GuildBuilding.OrgObjID				= myReader->GetInt32( 17 );


			GuildBuilding.Mode._Mode = 0;
			GuildBuilding.Mode.Show = 1;
			GuildBuilding.Mode.Gravity = false;
			if( myReader->GetInt32(18) > 0 )
				GuildBuilding.Mode.IsAllZoneVisible = true;

			if( myReader->GetInt32(19) > 0 )
				GuildBuilding.Mode.Obstruct = true;

			if( myReader->GetInt32(20) > 0 )
				GuildBuilding.Mode.Fight = true;

			if( myReader->GetInt32(21) > 0 )
				GuildBuilding.Mode.Mark = true;

			GuildBuilding.SrcBuildingID = myReader->GetInt32(22);

			if( myReader->GetInt32(23) > 0 )
				GuildBuilding.Mode.Remove = true;

			GuildBuilding.MaintenanceCharge = myReader->GetInt32(24);
			GuildBuilding.NeedGuildLv = myReader->GetInt32(25);
			GuildBuilding.BuildSize= myReader->GetInt32(26);
			Str = myReader->GetString( 27 );
			strcpy( GuildBuilding.IconPath , DotNetStr::StringToChar( Str).c_str() );
			GuildBuilding.SortID= myReader->GetInt32(28);


			file.write( (char*)&GUID , sizeof(int) );
			file.write( (char*)&GuildBuilding , sizeof(GuildBuilding) );
			GUID++;
			FileHead.Count++;
		}
		file.seekg( 0 );
		file.write( (char*)&FileHead, sizeof(FileHead) );
		myReader->Close();
		file.close();
	}
	//----------------------------------------------------------------------------------------------------
	// GuildBuildingInfo 資料
	//----------------------------------------------------------------------------------------------------
	{
		GuildBaseBuildingTableStruct	GuildBaseBuilding;
		memset( &GuildBaseBuilding , 0 , sizeof( GuildBaseBuilding ) );

		if( BaseForm::OutputFile_SimplifyProcess( file , "GuildBaseBuilding" , "DB"  ) == false )
			return;

		FileHead.Size = sizeof( GuildBaseBuildingTableStruct ) + sizeof(int);
		FileHead.Count = 0;

		sprintf( FileHead.FileInfoStr ,"%s %s %s Table_GuildBaseBuilding" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
		file.write( (char*)&FileHead, sizeof(FileHead) );

		GUID = Def_ObjectClass_Table + _TABLE_BASE_GUIDBASEBUILDING_;

		sqlCommand1->CommandText = "SELECT GUID,BuildPoint,ParentID,BuildID FROM Table_GuildBaseBuilding ORDER BY GUID";
		myReader = sqlCommand1->ExecuteReader();        

		String* Str;
		while( myReader->Read( ) )
		{   
			GuildBaseBuilding.GUID = myReader->GetInt32( 0 );
			String* Str = myReader->GetString( 1 );
			strcpy(GuildBaseBuilding.BuildPoint , DotNetStr::StringToChar( Str).c_str() );
			GuildBaseBuilding.ParentID = myReader->GetInt32( 2 );
			GuildBaseBuilding.BuildID = myReader->GetInt32( 3 );
			
			file.write( (char*)&GUID , sizeof(int) );
			file.write( (char*)&GuildBaseBuilding , sizeof(GuildBaseBuilding) );
			GUID++;
			FileHead.Count++;
		}
		file.seekg( 0 );
		file.write( (char*)&FileHead, sizeof(FileHead) );
		myReader->Close();
		file.close();
	}
	//----------------------------------------------------------------------------------------------------
	//公會屋 物品頁面價錢
	{
		GuildHouseItemPageCostTableStruct	GuildHouseItemPageCostTable;
		memset( &GuildHouseItemPageCostTable , 0 , sizeof( GuildHouseItemPageCostTable ) );

		if( BaseForm::OutputFile_SimplifyProcess( file , "GuildHouseItemPageCost" , "DB"  ) == false )
			return;

		FileHead.Size = sizeof( GuildHouseItemPageCostTableStruct ) + sizeof(int);
		FileHead.Count = 0;

		sprintf( FileHead.FileInfoStr ,"%s %s %s Table_GuildHouseItemPageCost" , _DEF_VERSION , DotNetStr::StringToChar( _Account ).c_str() , TimeStr::Now() );
		file.write( (char*)&FileHead, sizeof(FileHead) );

		GUID = Def_ObjectClass_Table + _TABLE_BASE_GUIDHOUSEITEMPAGE_;

		sqlCommand1->CommandText = "SELECT GUID,PageID, Resource_Gold, Resource_BonusGold, Resource_Mine, Resource_Wood, Resource_Herb, Resource_GuildRune, Resource_GuildStone FROM Table_GuildHouseItemPageCost ORDER BY GUID";
		myReader = sqlCommand1->ExecuteReader();        

		String* Str;
		while( myReader->Read( ) )
		{   

			GuildHouseItemPageCostTable.GUID			= myReader->GetInt32(0);
			GuildHouseItemPageCostTable.ItemPageID	= myReader->GetInt32(1);
			GuildHouseItemPageCostTable.Resource.Gold		= myReader->GetInt32( 2 );
			GuildHouseItemPageCostTable.Resource.BonusGold	= myReader->GetInt32( 3 );
			GuildHouseItemPageCostTable.Resource.Mine		= myReader->GetInt32( 4 );
			GuildHouseItemPageCostTable.Resource.Wood		= myReader->GetInt32( 5 );
			GuildHouseItemPageCostTable.Resource.Herb		= myReader->GetInt32( 6 );
			GuildHouseItemPageCostTable.Resource.GuildRune	= myReader->GetInt32( 7 );
			GuildHouseItemPageCostTable.Resource.GuildStone	= myReader->GetInt32( 8 );

			file.write( (char*)&GUID , sizeof(int) );
			file.write( (char*)&GuildHouseItemPageCostTable , sizeof(GuildHouseItemPageCostTable) );

			GUID++;
			FileHead.Count++;
		}
		file.seekg( 0 );
		file.write( (char*)&FileHead, sizeof(FileHead) );
		myReader->Close();
		file.close();
	}
	/*
	//////////////////////////////////////////////////////////////////////////	
	//養寵物表
	//////////////////////////////////////////////////////////////////////////	
	OuputTableFile<CultivatePetBaseTableStruct>
		( _Account
		, sqlCommand1
		, "Table_CultivatePetBase" 
		, "CultivatePetBase" 
		, Def_ObjectClass_Table + _TABLE_BASE_CULTIVATE_PET_BASE_ 
		, GameObjDbStructEx::ObjReader_CultivatePetBase() );

	//////////////////////////////////////////////////////////////////////////	
	//寵物事件
	//////////////////////////////////////////////////////////////////////////	
	OuputTableFile<CultivatePetEventTableStruct>
		( _Account
		, sqlCommand1
		, "Table_CultivatePetEvent" 
		, "CultivatePetEvent" 
		, Def_ObjectClass_Table + _TABLE_BASE_CULTIVATE_PET_EVENT_ 
		, GameObjDbStructEx::ObjReader_CultivatePetEvent() );
	//////////////////////////////////////////////////////////////////////////	
	//寵物屬性程長表
	//////////////////////////////////////////////////////////////////////////	
	OuputTableFile<CultivatePetGrowTableStruct>
		( _Account
		, sqlCommand1
		, "Table_CultivatePetGrow" 
		, "CultivatePetGrow" 
		, Def_ObjectClass_Table + _TABLE_BASE_CULTIVATE_PET_GROW_ 
		, GameObjDbStructEx::ObjReader_CultivatePetGrow() );
	//////////////////////////////////////////////////////////////////////////	
	//寵物屬性說話表
	//////////////////////////////////////////////////////////////////////////	
	OuputTableFile<CultivatePetTalkTableStruct>
		( _Account
		, sqlCommand1
		, "Table_CultivatePetTalk" 
		, "CultivatePetTalk" 
		, Def_ObjectClass_Table + _TABLE_BASE_CULTIVATE_PET_TALK_ 
		, GameObjDbStructEx::ObjReader_CultivatePetTalk() );
	//////////////////////////////////////////////////////////////////////////	
	//寵物屬性產生法術Buff表
	//////////////////////////////////////////////////////////////////////////	
	OuputTableFile<CultivatePetValueEffectTableStruct>
		( _Account
		, sqlCommand1
		, "Table_CultivatePetValueEffect" 				 
		, "CultivatePetValueEvent" 
		, Def_ObjectClass_Table + _TABLE_BASE_CULTIVATE_PET_VALUE_EFFECT_ 
		, GameObjDbStructEx::ObjReader_CultivatePetValueEffect() );
		*/
	//////////////////////////////////////////////////////////////////////////	
	////種植 施肥資料
	//////////////////////////////////////////////////////////////////////////	
	/*
	OuputTableFile<PlantGrowActionTableStruct>
		( _Account
		, sqlCommand1
		, "Table_Plant_GrowAction" 
		, "PlantGrowAction" 
		, Def_ObjectClass_Table + _TABLE_BASE_PLANT_GROW_ACTION_ 
		, GameObjDbStructEx::ObjReader_PlantGrowAction() );
		*/
	//////////////////////////////////////////////////////////////////////////	
	//種植 收成資料
	//////////////////////////////////////////////////////////////////////////	
	OuputTableFile<PlantProductTableStruct>
		( _Account
		, sqlCommand1
		, "Table_Plant_Product" 
		, "PlantProduct" 
		, Def_ObjectClass_Table + _TABLE_BASE_PLANT_PRODUCT_ 
		, GameObjDbStructEx::ObjReader_PlantProduct() );

	//////////////////////////////////////////////////////////////////////////	
	//養寵物表
	//////////////////////////////////////////////////////////////////////////	
	/*
	OuputTableFile<CultivatePetBaseTableStruct>
		( _Account
		, sqlCommand1
		, "Table_Pet_Base" 
		, "CultivatePetBase" 
		, Def_ObjectClass_Table + _TABLE_BASE_CULTIVATE_PET_BASE_ 
		, GameObjDbStructEx::ObjReader_CultivatePetBase() );
*/
	//////////////////////////////////////////////////////////////////////////	
	//寵物事件
	//////////////////////////////////////////////////////////////////////////	
	OuputTableFile<CultivatePetLearnMagicTableStruct>
		( _Account
		, sqlCommand1
		, "Table_Pet_LearnMagic" 
		, "CultivatePetLearnMagic" 
		, Def_ObjectClass_Table + _TABLE_BASE_CULTIVATE_PET_LEARNMAGIC_ 
		, GameObjDbStructEx::ObjReader_CultivatePetLearnMagic() );
	//////////////////////////////////////////////////////////////////////////	
	//寵物生活技能
	//////////////////////////////////////////////////////////////////////////	
	OuputTableFile<CultivatePetLifeSkillTableStruct>
		( _Account
		, sqlCommand1
		, "Table_Pet_LifeSkill" 
		, "CultivatePetLifeSkill" 
		, Def_ObjectClass_Table + _TABLE_BASE_CULTIVATE_PET_LIFESKILL_ 
		, GameObjDbStructEx::ObjReader_CultivatePetLifeSkill() );

	//////////////////////////////////////////////////////////////////////////	
	//屬性賭博表
	//////////////////////////////////////////////////////////////////////////	
	OuputTableFile<GambleItemStateTableStruct>
		( _Account
		, sqlCommand1
		, "Table_GambleItemState" 
		, "GambleItemState" 
		, Def_ObjectClass_Table + _TABLE_BASE_PLANT_GAMBLEITEMSTATE_ 
		, GameObjDbStructEx::ObjReader_GambleItemState() );
	//////////////////////////////////////////////////////////////////////////	
	//女僕表
	//////////////////////////////////////////////////////////////////////////	
	OuputTableFile<ServantEventTableStruct>
		( _Account
		, sqlCommand1
		, "Table_ServantEvent" 
		, "ServantEvent" 
		, Def_ObjectClass_Table + _TABLE_BASE_SERVANT_EVENT_ 
		, GameObjDbStructEx::ObjReader_ServantEvent() );

	OuputTableFile<ServantHireTableStruct>
		( _Account
		, sqlCommand1
		, "Table_ServantHire" 
		, "ServantHire" 
		, Def_ObjectClass_Table + _TABLE_BASE_SERVANT_HIRE_ 
		, GameObjDbStructEx::ObjReader_ServantHire() );

	OuputTableFile<ServantStartValueTableStruct>
		( _Account
		, sqlCommand1
		, "Table_ServantStartValue" 
		, "ServantStartValue" 
		, Def_ObjectClass_Table + _TABLE_BASE_SERVANT_STRATVALUE_ 
		, GameObjDbStructEx::ObjReader_ServantStartValue() );

	OuputTableFile<ItemCombineStruct>
		( _Account
		, sqlCommand1
		, "Table_ItemCombine" 
		, "ItemCombine" 
		, Def_ObjectClass_Table + _TABLE_BASE_ITEM_COMBINE_ 
		, GameObjDbStructEx::ObjReader_ItemCombine() );

	OuputTableFile<RuneExchangeExTableStruct>
		( _Account
		, sqlCommand1
		, "Table_RuneExchangeEx" 
		, "RuneExchangeEx" 
		, Def_ObjectClass_Table + _TABLE_BASE_RUNEEXCHANGE_ 
		, GameObjDbStructEx::ObjReader_RuneExchangeEx() );

	OuputTableFile<LifeSkillRareExStruct>
		( _Account
		, sqlCommand1
		, "Table_LifeSkill_RareEx" 
		, "LifeSkillRareEx" 
		, Def_ObjectClass_Table + _TABLE_BASE_LIFESKILL_RARE_EX_ 
		, GameObjDbStructEx::ObjReader_LifeSkillRareEx() );

	//----------------------------------------------------------------------------------------------------
	OuputTableFile<GuildHouseNpcReplaceTableStruct>
		( _Account
		, sqlCommand1
		, "Table_GuildHouseNpcReplace" 
		, "GuildHouseNpcReplace" 
		, Def_ObjectClass_Table + _TABLE_BASE_GUILDHOUSE_NPC_REPLACE 
		, GameObjDbStructEx::ObjReader_GuildHouseNpcReplace() );

	OuputTableFile<GuildHouseNpcReplaceCostTableStruct>
		( _Account
		, sqlCommand1
		, "Table_GuildHouseNpcReplaceRightCost" 
		, "GuildHouseNpcReplaceRightCost" 
		, Def_ObjectClass_Table + _TABLE_BASE_GUILDHOUSE_NPC_REPLACE_COST 
		, GameObjDbStructEx::ObjReader_GuildHouseNpcReplaceCost() );
	//-----------------------------------------------------
	//					寵物圖鑑
	//-----------------------------------------------------
	OuputTableFile<PetCollectionTableStruct>
		( _Account
		, sqlCommand1
		, "Table_PetCollection" 
		, "PetCollection" 
		, Def_ObjectClass_Table + _TABLE_BASE_PETCOLLECTION_ 
		, GameObjDbStructEx::ObjReader_PetCollection() );
	//-----------------------------------------------------
	//					幻靈
	//-----------------------------------------------------
	OuputTableFile<AbiParametersTableStruct>
		( _Account
		, sqlCommand1
		, "Table_AbilityParameters" 
		, "AbilityParameters" 
		, Def_ObjectClass_Table + _TABLE_BASE_ABIPARAMETER_ 
		, GameObjDbStructEx::ObjReader_AbiParameters() );

	OuputTableFile<PhantomRankTableStruct>
		( _Account
		, sqlCommand1
		, "Table_PhantomRank" 
		, "PhantomRank" 
		, Def_ObjectClass_Table + _TABLE_BASE_PHANTOMRANK_ 
		, GameObjDbStructEx::ObjReader_PhantomRank() );

	OuputTableFile<PhantomLvTableStruct>
		( _Account
		, sqlCommand1
		, "Table_PhantomLv" 
		, "PhantomLv" 
		, Def_ObjectClass_Table + _TABLE_BASE_PHANTOMLV_ 
		, GameObjDbStructEx::ObjReader_PhantomLv() );

	OuputTableFile<PhantomSkillTableStruct>
		( _Account
		, sqlCommand1
		, "Table_PhantomSkill" 
		, "PhantomSkill" 
		, Def_ObjectClass_Table + _TABLE_BASE_PHANTOMSKILL_ 
		, GameObjDbStructEx::ObjReader_PhantomSkill() );
/*	OuputTableFile<RuneSystemStruct>
		( _Account
		, sqlCommand1
		, "Table_RuneSystem" 
		, "RuneSystem" 
		, Def_ObjectClass_Table + _TABLE_BASE_RUNESYSTEM_EVENT_ 
		, GameObjDbStructEx::ObjReader_RuneSystem() );*/
}
/*
template<class TempStruct>
System::Void TableForm::OuputTableFile( const char* DBTableName , const char* FileName , int GUID , ReaderClass< TempStruct >* Reader )
{
	fstream file;

	ObjFileHead FileHead;
	FileHead.Idenitfy = DEF_ITEMOBJ_FILE_ID;

	TempStruct	Table;

	if( BaseForm::OutputFile_SimplifyProcess( file , FileName , "DB"  ) == false )
		return;

	FileHead.Size = sizeof( Table ) + sizeof(int);
	FileHead.Count = 0;

	sprintf( FileHead.FileInfoStr ,"%s %s %s %s" , _DEF_VERSION , DotNetStr::StringToChar( _Account ) , TimeStr::Now() , DBTableName );
	file.write( (char*)&FileHead, sizeof(FileHead) );

//	GUID = BeginGUID;
	CreateDBCmdClass<TempStruct>* _SqlMaker  = NEW( CreateDBCmdClass<TempStruct > ( Reader  , DBTableName ) );
	sqlCommand1->CommandText = _SqlMaker->GetSelectStr("");
	SqlDataReader* mySqlReader = sqlCommand1->ExecuteReader();        


	while( SqlReadObject<TempStruct>( Table , Reader  , mySqlReader ) )
	{
		file.write( (char*)&GUID , sizeof(int) );
		file.write( (char*)&Table , sizeof(Table) );

		GUID++;
		FileHead.Count++;
	}
	file.seekg( 0 );
	file.write( (char*)&FileHead, sizeof(FileHead) );
	mySqlReader->Close();
	file.close();

}*/

System::Void TableForm::TableForm_Load(System::Object *  sender, System::EventArgs *  e)
{
	dataSet1->Clear();
    sqlDataAdapter_FightArg->Fill( dataSet1 );
    sqlDataAdapter_TableString->Fill( dataSet1 );
    sqlDataAdapter_ZoneDB->Fill( dataSet1 );
    sqlDataAdapter_SkillBase->Fill( dataSet1 );
    sqlDataAdapter_FixFightArg->Fill( dataSet1 );
	sqlDataAdapter_JobSkillValue->Fill( dataSet1 );
	sqlDataAdapter_EqWearSkill->Fill( dataSet1 );
	sqlDataAdapter_ArmorArg->Fill( dataSet1 );
	sqlDataAdapter_WeaponArg->Fill( dataSet1 );
	sqlDataAdapter_MagicList->Fill( dataSet1 );
	sqlDataAdapter_MonsterMoney->Fill( dataSet1 );	
//	sqlDataAdapter_ZoneChannel->Fill( dataSet1 );
//	sqlDataAdapter_ResistArg->Fill( dataSet1 );
	sqlDataAdapter_NPCResistList->Fill( dataSet1 );
	sqlDataAdapter_Exp->Fill( dataSet1 );
//	sqlDataAdapter_EqRefine->Fill( dataSet1 );
//	sqlDataAdapter_Dissolution->Fill( dataSet1 );
	sqlDataAdapter_NPCStrong->Fill( dataSet1 );
	sqlDataAdapter_Combo->Fill( dataSet1 );

	sqlDataAdapter_CreateRoleBody->Fill( dataSet1 );
	sqlDataAdapter_CreateRoleColor->Fill( dataSet1 );
	sqlDataAdapter_CreateRoleJob->Fill( dataSet1 );
	sqlDataAdapter_Motion->Fill( dataSet1 );
	sqlDataAdapter_Teach->Fill( dataSet1 );
	sqlDataAdapter_ColoringShop->Fill( dataSet1 );
	sqlDataAdapter_MapInfo->Fill( dataSet1 );
	sqlDataAdapter_GuildLv->Fill( dataSet1 );
//	sqlDataAdapter_AccountShopInfo->Fill( dataSet1 );
//	sqlDataAdapter_SysColorDefine->Fill( dataSet1 );
	sqlDataAdapter_SysKeyFunction->Fill( dataSet1 );
	sqlDataAdapter_LotteryInfo->Fill( dataSet1 );
	sqlDataAdapter_SysKeyValue->Fill( dataSet1 );
	sqlDataAdapter_InherentRate->Fill( dataSet1 );
	sqlDataAdapter_HouseShopInfo->Fill( dataSet1 );
	//sqlDataAdapter_HouseEnergyCost->Fill( dataSet1 );
	sqlDataAdapter_PowerRate->Fill( dataSet1 );
	sqlDataAdapter_RentFunc->Fill( dataSet1 );
	sqlDataAdapter_GuildFlagType->Fill( dataSet1 );
	sqlDataAdapter_GuildBuildingInfo->Fill( dataSet1 );
	sqlDataAdapter_GuildBaseBuilding->Fill( dataSet1 );
	sqlDataAdapter_GuildHouseItemPageCost->Fill( dataSet1 );
	sqlDataAdapter_GuildHouseNpcReplace->Fill( dataSet1 );
	sqlDataAdapter_GuildHouseNpcReplaceRightCost->Fill( dataSet1 );
	sqlDataAdapter_RelationMagic->Fill( dataSet1 );
	sqlDataAdapter_RuneExchange->Fill( dataSet1 );
	sqlDataAdapter_RuneSystem->Fill( dataSet1 );

//	sqlDataAdapter_CultivatePetBase->Fill( dataSet1 );
//	sqlDataAdapter_CultivatePetEvent->Fill( dataSet1 );
//	sqlDataAdapter_CultivatePetGrow->Fill( dataSet1 );
//	sqlDataAdapter_CultivatePetTalk->Fill( dataSet1 );
//	sqlDataAdapter_CultivatePetValueEffect->Fill( dataSet1 );
//	sqlDataAdapter_Plant_Grow->Fill( dataSet1 );
	sqlDataAdapter_Plant_Product->Fill( dataSet1 );

	sqlDataAdapter_Pet_LifeSkill->Fill( dataSet1 );
	sqlDataAdapter_Pet_LearnMagic->Fill( dataSet1 );
	sqlDataAdapter_GambleItemState->Fill( dataSet1 );
	sqlDataAdapter_ServantEvent->Fill( dataSet1 );
	sqlDataAdapter_ServantHire->Fill( dataSet1 );
	sqlDataAdapter_ServantStartValue->Fill( dataSet1 );
	sqlDataAdapter_ItemCombine->Fill( dataSet1 );
	sqlDataAdapter_LifeSkill_RareEx->Fill( dataSet1 );
	sqlDataAdapter_PetCollection->Fill( dataSet1 );
	sqlDataAdapter_AbilityParameters->Fill( dataSet1 );
	sqlDataAdapter_PhantomRank->Fill( dataSet1 );
	sqlDataAdapter_PhantomLv->Fill( dataSet1 );
	sqlDataAdapter_PhantomSkill->Fill( dataSet1 );

	TreeMenu->Nodes->Clear();
	for (int i = 0; i < dataSet1->Tables->Count; i++)
	{
		System::Data::DataTable* dt = dataSet1->Tables->Item[i];
		TreeMenu->Nodes->Add(dt->TableName);
	}

}
System::Void TableForm::BtModify_Click(System::Object *  sender, System::EventArgs *  e)
{  

    int iCol = 100;
    int iRow = 10000;
    int x , y;

    try
    {
        String* delimStr = ",\t";
        for( int i = 0 ; i < InsertStr->Lines->Length ; i++ )
        {
            String* Str = InsertStr->Lines[ i ];
            String* split[] = 0;

            split = Str->Split( delimStr->ToCharArray() , iCol );
            if( split->Length <= 1 )
                continue;

            int GUID = Convert::ToInt32( split[0] );
            for( y = 0 ; y < iRow  ; y++ )
            {             
                int ID = Convert::ToInt32( dataGrid1->Item[y][0] );
                if( ID == GUID )
                    break;
            }
            if( y == iRow )
			{
				if( GUID != 0 )
				{
//					String* Msg
//					MessageBox::Show( "是否儲存,(Yes)儲存" , "警告" , MessageBoxButtons::OK );
				}
                continue;
			}

            for( x = 1 ; x < split->Length && x < iCol; x++ )
            {
				try
				{
					dataGrid1->Item[y][x]->Value = split[x];
				}
				catch (...)
				{
					dataGrid1->Item[y][x]->Value = __box( (bool)Convert::ToInt32( split[x] ) );

					MessageBox::Show( String::Format( "資料有問題 欄位[{0}] = {1}" , __box( x ) , split[x] ) , "錯誤" , MessageBoxButtons::OK );
					break;
				}
                
            }
        }
    }
    catch(...)
    {

    }
}

System::Void TableForm::UpDate_Click(System::Object *  sender, System::EventArgs *  e)
{
    int Result = MessageBox::Show( "是否儲存,(Yes)儲存" , "警告" , MessageBoxButtons::YesNo );
    if( Result != DialogResult::Yes )
        return;

	sqlDataAdapter_FightArg->Update( dataSet1 );
	sqlDataAdapter_TableString->Update( dataSet1 );
	sqlDataAdapter_ZoneDB->Update( dataSet1 );
	sqlDataAdapter_SkillBase->Update( dataSet1 );
	sqlDataAdapter_FixFightArg->Update( dataSet1 );
	sqlDataAdapter_JobSkillValue->Update( dataSet1 );
	sqlDataAdapter_EqWearSkill->Update( dataSet1 );
	sqlDataAdapter_WeaponArg->Update( dataSet1 );
	sqlDataAdapter_ArmorArg->Update( dataSet1 );
	sqlDataAdapter_MagicList->Update( dataSet1 );
	sqlDataAdapter_MonsterMoney->Update( dataSet1 );
//	sqlDataAdapter_ZoneChannel->Update( dataSet1 );
//	sqlDataAdapter_ResistArg->Update( dataSet1 );
	sqlDataAdapter_NPCResistList->Update( dataSet1 );
	sqlDataAdapter_Exp->Update( dataSet1 );
//	sqlDataAdapter_EqRefine->Update( dataSet1 );
//	sqlDataAdapter_Dissolution->Update( dataSet1 );
	sqlDataAdapter_NPCStrong->Update( dataSet1 );
	sqlDataAdapter_Combo->Update( dataSet1 );

	sqlDataAdapter_CreateRoleBody->Update( dataSet1 );
	sqlDataAdapter_CreateRoleColor->Update( dataSet1 );
	sqlDataAdapter_CreateRoleJob->Update( dataSet1 );
	sqlDataAdapter_Motion->Update( dataSet1 );
	sqlDataAdapter_Teach->Update( dataSet1 );
	sqlDataAdapter_ColoringShop->Update( dataSet1 );
	sqlDataAdapter_MapInfo->Update( dataSet1 );
	sqlDataAdapter_GuildLv->Update( dataSet1 );

//	sqlDataAdapter_AccountShopInfo->Update( dataSet1 );
//	sqlDataAdapter_SysColorDefine->Update( dataSet1 );
	sqlDataAdapter_SysKeyFunction->Update( dataSet1 );
	sqlDataAdapter_LotteryInfo->Update( dataSet1 );
	sqlDataAdapter_SysKeyValue->Update( dataSet1 );
	sqlDataAdapter_InherentRate->Update( dataSet1 );
	sqlDataAdapter_HouseShopInfo->Update( dataSet1 );
	//sqlDataAdapter_HouseEnergyCost->Update( dataSet1 );
	sqlDataAdapter_PowerRate->Update( dataSet1 );
	sqlDataAdapter_RentFunc->Update( dataSet1 );
	sqlDataAdapter_GuildFlagType->Update( dataSet1 );
	sqlDataAdapter_GuildBuildingInfo->Update( dataSet1 );
	sqlDataAdapter_GuildBaseBuilding->Update( dataSet1 );
	sqlDataAdapter_GuildHouseItemPageCost->Update( dataSet1 );
	sqlDataAdapter_GuildHouseNpcReplace->Update( dataSet1 );
	sqlDataAdapter_GuildHouseNpcReplaceRightCost->Update( dataSet1 );

	sqlDataAdapter_RelationMagic->Update( dataSet1 );
	sqlDataAdapter_RuneExchange->Update( dataSet1 );
	sqlDataAdapter_RuneSystem->Update( dataSet1 );

//	sqlDataAdapter_CultivatePetBase->Update( dataSet1 );
//	sqlDataAdapter_CultivatePetEvent->Update( dataSet1 );
//	sqlDataAdapter_CultivatePetGrow->Update( dataSet1 );
//	sqlDataAdapter_CultivatePetTalk->Update( dataSet1 );
//	sqlDataAdapter_CultivatePetValueEffect->Update( dataSet1 );
//	sqlDataAdapter_Plant_Grow->Update( dataSet1 );
	sqlDataAdapter_Plant_Product->Update( dataSet1 );

	sqlDataAdapter_Pet_LifeSkill->Update( dataSet1 );
	sqlDataAdapter_Pet_LearnMagic->Update( dataSet1 );
	sqlDataAdapter_GambleItemState->Update( dataSet1 );

	sqlDataAdapter_ServantEvent->Update( dataSet1 );
	sqlDataAdapter_ServantHire->Update( dataSet1 );
	sqlDataAdapter_ServantStartValue->Update( dataSet1 );
	sqlDataAdapter_ItemCombine->Update( dataSet1 );
	sqlDataAdapter_LifeSkill_RareEx->Update( dataSet1 );
	sqlDataAdapter_PetCollection->Update( dataSet1 );
	sqlDataAdapter_AbilityParameters->Update( dataSet1 );
	sqlDataAdapter_PhantomRank->Update( dataSet1 );
	sqlDataAdapter_PhantomLv->Update( dataSet1 );
	sqlDataAdapter_PhantomSkill->Update( dataSet1 );
	TableForm_Load( NULL , NULL );
}


System::Void TableForm::OnOutputFile(System::Object *  sender, System::EventArgs *  e)
{
    OutputFileLanguage( 0 );
    MessageBox::Show( "資料輸出完成", "訊息" );
}

System::Void TableForm::Form_Closing(System::Object *  sender, System::ComponentModel::CancelEventArgs *  e)
{
    if( _IsExit == false )
    {
        e->Cancel = true;
        this->Hide();
    }
}
System::Void TableForm::TreeMenu_NodeMouseDoubleClick(System::Object*  sender, System::Windows::Forms::TreeNodeMouseClickEventArgs*  e)
{
	DataTable* dt = dataSet1->Tables->Item[e->Node->Text];
	dataGrid1->DataSource = dt;
}