|
#include "stdafx.h"
#include "DlgSyain.h"
//////////////////////////////////////////////////////////////////////
// 構築/消滅
//////////////////////////////////////////////////////////////////////
DlgSyain::DlgSyain()
{
}
DlgSyain::~DlgSyain()
{
}
// *********************************************************
// ダイアログ初期化イベント
// *********************************************************
void DlgSyain::WMInitdialog()
{
this->CenterWindow();
// ダイアログのプロパティでシステムメニューのチェックボックスを外して下さい
this->ChangeStyle( WS_MINIMIZEBOX | WS_SYSMENU, 0 );
this->ChangeExStyle( WS_EX_APPWINDOW, 0 );
this->ChangeIcon( this->IconId );
this->StatusCreate( 0 );
LboxString Buff;
// MySQL 接続文字列
Buff.operator = ("MySQL,lightbox,root,");
CurDb.SetConnectString( 3, &Buff );
// リストビューインスタンス作成
LView = new LboxListview( ::GetDlgItem( hDlg, this->LviewId ), 0 );
LView->Grid();
GetData();
this->MoveWindow( 0, 0 );
}
// *********************************************************
// ダイアログ終了処理
// *********************************************************
void DlgSyain::ProcEnd()
{
delete this->LView;
}
// *********************************************************
// オペレータイベント
// *********************************************************
void DlgSyain::ProcOperator()
{
switch( ControlId ) {
case IDOK:
GetData();
break;
}
}
// *********************************************************
// 問合せ処理
// *********************************************************
void DlgSyain::GetData()
{
if ( !CurDb.Connect() ) {
MsgOk("接続に失敗しました \n%s", CurDb.ErrMessage.szLboxString);
return;
}
LboxString Query;
Query.operator = ("select * from 社員マスタ");
LboxString Cond( "" );
LboxString Buff;
this->EditGetText( this->EditId, &Buff );
Buff.Trim( " " );
if ( Buff.operator != ( "" ) ) {
if ( Cond.operator == ( "" ) ) {
Cond.operator += (" where ");
}
else {
Cond.operator += (" and ");
}
Cond.operator += (" 氏名 like ");
Buff.Enclose( "%" );
Buff.Enclose( "'" );
Cond.operator += ( &Buff );
}
Query.operator += ( &Cond );
int nRet;
LView->Hide();
this->StatusSetText( "" );
nRet = CurDb.LoadSqlData( LView, 0, &Query );
switch( nRet ) {
case -1:
this->StatusSetText( &(CurDb.ErrMessage) );
break;
case 0:
this->StatusSetText( "対象データが存在しません" );
break;
default:
this->StatusPrintf( "%d 件のデータが選択されました", nRet );
break;
}
LView->Fit();
LView->Show();
CurDb.DisConnect();
}
// *********************************************************
// 初期化とオペレータイベント以外の処理
// *********************************************************
void DlgSyain::WMAll()
{
USE_LVIEW(LView)
}
// *********************************************************
// ダブルクリックイベント
// *********************************************************
void DlgSyain::LVDblclick()
{
LboxString LWork;
if ( LView->IsHandle( this->hTargetWindow ) ) {
LView->GetColumnText( 0, &Key );
LView->GetColumnText( 1, &Name );
this->ProcEnd();
::EndDialog( this->hDlg, IDOK );
}
}
| |