|
// *********************************************************
// HEAD 部チェック
// 1) HEAD 部チェック
// 2) BODY 部の画面編集
// 3) BODY 部への画面遷移
// *********************************************************
void MyDlg::CheckData()
{
LboxString LWork;
// 社員コードの未入力チェック
this->EditGetText( IDC_KEY, &LWork );
LWork.Trim( " " );
if ( LWork.operator == ( "" ) ) {
MsgErr( IDC_KEY , "社員コードを入力して下さい" );
return;
}
// データベース接続
if ( !CurDb.Connect() ) {
MsgOk("接続に失敗しました \n%s", CurDb.ErrMessage.szLboxString);
return;
}
// データ読み出し
LboxString Query;
BOOL bRet;
Query.operator = ("select * from 社員マスタ");
Query.operator += (" where 社員コード = '");
Query.operator += (&LWork);
Query.operator += ("'");
bRet = CurDb.Query( &Query );
if ( bRet ) {
// 氏名
CurDb.GetText( "氏名", &LWork );
this->EditSetText( IDC_NAME, &LWork );
// 所属
CurDb.GetText( "所属", &LWork );
Syozoku->Select( Syozoku->FindData( &LWork ) );
// 作成日
CurDb.GetText( "作成日", &LWork );
CreateDate.SetDateString( &LWork, "/" );
}
// データベース接続解除
CurDb.DisConnect();
// 処理区分別の画面編集
LboxString LType;
Type->SelectedGetData( <ype );
int nType;
nType = LType.Atoi();
switch( nType ) {
// 登録
case 1:
if ( bRet ) {
MsgErr( IDC_KEY ,"既に存在します" );
return;
}
this->Disable( IDC_TYPE );
this->Disable( IDC_KEY );
this->Disable( IDC_CHECK );
this->Enable( IDC_NAME );
this->Syozoku->Enable();
this->Syozoku->Select( 0 );
this->Enable( IDC_CANCEL );
this->Enable( IDC_UPDATE );
this->EditFocus( IDC_NAME );
break;
// 修正
case 2:
if ( !bRet ) {
MsgErr( IDC_KEY ,"該当する社員コードは存在しません" );
return;
}
this->Disable( IDC_TYPE );
this->Disable( IDC_KEY );
this->Disable( IDC_CHECK );
this->Enable( IDC_NAME );
this->Syozoku->Enable();
this->CreateDate.Enable();
this->Enable( IDC_CANCEL );
this->Enable( IDC_UPDATE );
this->EditFocus( IDC_NAME );
break;
// 削除
case 3:
if ( !bRet ) {
MsgErr( IDC_KEY ,"該当する社員コードは存在しません" );
return;
}
this->Disable( IDC_TYPE );
this->Disable( IDC_KEY );
this->Disable( IDC_CHECK );
this->Enable( IDC_CANCEL );
this->Enable( IDC_UPDATE );
this->EditFocus( IDC_CANCEL );
break;
}
}
| |