#include "KeyItemForm.h"
using namespace ObjDataEdit;
//######################################################################################################
//主要需要繼承的涵式
ReaderClass< DB_GameObjDbStruct >* KeyItemForm::ObjReader( )
{
	return  GameObjDbStructEx::ObjReader_KeyItem( );
}
void    KeyItemForm::OnActive()
{
	static bool FirstTime = true;

	//設定種族職業資訊
	if( FirstTime  == false )
		return;

	BaseForm::OnActive();

	FirstTime = false;

	SqlDataReader* myReader;

	sqlCommand_Base->CommandText = "Select KeyStr , Content from StringDB Where KeyStr LIKE ( 'SYS_STORE_TYPE___' ) ORDER BY  KeyStr";
	myReader = sqlCommand_Base->ExecuteReader();
	CB_SellType->Items->Clear();

	for( int i = 0 ; ; i++ )
	{                
		if( myReader->Read() == false )
			break;
		//int     Value =  myReader->GetInt32( 0 );
		String* KeyStr   = myReader->GetString( 0 );
		String* Content  = myReader->GetString( 1 );

		string tempStr = DotNetStr::StringToChar( KeyStr );
		const char* cKeyStr = tempStr.c_str();
		const char* cNumStr = strlen("SYS_STORE_TYPE_") + cKeyStr;
		if( i != atol( cNumStr ) )
			break;

		CB_SellType->Items->Add( Content );
	}
	myReader->Close();
}
void    KeyItemForm::OnSelectObj( bool LockOk )
{
    _ObjDB.GameData.Classification = EM_ObjectClass_KeyItem;
	_ObjDB.GameData.PricesType	= EM_ACPriceType_GameMoney;
//    panel1->Enabled = LockOk;
}
void    KeyItemForm::OnOutputObjSetting( DB_GameObjDbStruct* TempObj )
{
    TempObj->GameData.Classification = EM_ObjectClass_KeyItem;
	TempObj->GameData.PricesType	= EM_ACPriceType_GameMoney;
	TempObj->GameData.BuyUnit = 1;

	TempObj->GameData.KeyItem.LifeSkillType = (SkillValueTypeENUM)( TempObj->GameData.KeyItem.LifeSkillType + EM_SkillValueType_BlackSmith );
}
void    KeyItemForm::OnTimeProc()
{

}
int     KeyItemForm::ObjSize(  )
{
	GameObjDbStruct *P = NULL;
	int Size = sizeof( GameObjDbStruct ) - sizeof( P->Temp ) +  sizeof( P->KeyItem ) + 3;
	Size = Size & 0xfffffC;

	return Size;
    return Size;
}

void    KeyItemForm::OnValueChange( )
{
	DB_GameObjDbStruct __pin * TempObj = &_ObjDB;

	if( TempObj->GameData.KeyItem.Type == EM_KeyItemType_LifeSkillUnLock )
	{
		GB_LifeSkill->Show();
	}
	else
	{
		GB_LifeSkill->Hide();
	}
}
//######################################################################################################
