100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > 图书馆信息管理系统源代码

图书馆信息管理系统源代码

时间:2022-10-12 10:40:53

相关推荐

图书馆信息管理系统源代码

学号:18070147

二零零四年十二月二十一日

一、实训课题

1、课题名称:

图书馆信息管理系统。

2、设计要求:

设计一个简单的《图书馆信息管理系统》计算机软件。

本系统为某学院图书馆实现图信息管理计算机化而设计。该学院图书馆现有藏书20万册,每天图书流量在500册左右。本系统要求实现该馆图书信息的计算机管理,它应当包括如下基本功能:系统登录、书目索引查询、借出管理、还书管理、图书信息录入、读者信息录入和用户信息录入等。

二、程序功能图

三、数据库设计

字段名 编号 书名 类别 作者 出版社 价格 库存数 在库数

数值类型 文本 文本 文本 文本 文本 货币 长整型 长整型

数据宽度 20 30 20 20 20 8 20 20

是否能为空 否 否 否 否 否 否 否 否

是否主键 是 否 否 否 否 否 否 否

字段名 编号 姓名 性别 单位 手机 电子邮箱 ICQ OICQ

数值类型 文本 文本 文本 文本 文本 文本 文本 文本

数据宽度 10 5 1 30 20 30 20 20

是否能为空 否 否 否 是 是 是 是 是

是否主键 是 否 否 否 否 否 否 否

字段名 用户名 密码 姓名 性别 手机 办公地址 ICQ OICQ 电子邮箱

数值类型 文本 文本 文本 文本 文本 文本 文本 文本 文本

数据宽度 20 20 5 1 20 50 20 20 30

是否能为空 否 否 否 否 是 是 是 是 是

是否主键 是 否 否 否 否 否 否 否 否

字段名 编号 读者编号 图书编号 借书日期

数值类型 长整型 文本 文本 日期时间型

数据宽度 8 10 20 8

是否能为空 否 否 否 否

是否主键 是 否 否 否

四、程序界面

五、程序代码

主窗体代码

private void Form1_Load( object sender,System.EventArgse) // 主窗体,载入时跟据权限设置相应菜单。

... {

Process[]processes;

intcount=0;

processes=Process.GetProcesses();

foreach(Processinstanceinprocesses)

...{

if(instance.ProcessName=="图书馆信息管理系统")

count++;

}

if(count>1)//如果图书馆信息管理系统已经运行,就退出。

...{

this.Close();

}

this.menuItemdzgl.Enabled=false;

this.menuItemtsgl.Enabled=false;

this.menuItemjshs.Enabled=false;

this.menuItemyggl.Enabled=false;

this.menuItemaq.Enabled=false;

this.menuItembz.Enabled=false;

this.menuItemjs.Enabled=false;

this.menuItemhs.Enabled=false;

this.menuItemsd.Enabled=false;

this.toolBarButton5.Visible=false;

dlWinMyDl=newdlWin();

if(MyDl.ShowDialog()==DialogResult.Yes)

...{

if(MyDl.SystemAdministrator)//登录成功再判断是为管理员还是为员工

...{

this.menuItemdzgl.Enabled=true;

this.menuItemtsgl.Enabled=true;

this.menuItemjshs.Enabled=true;

this.menuItemyggl.Enabled=true;

this.menuItemaq.Enabled=true;

this.menuItembz.Enabled=true;

this.menuItemjs.Enabled=true;

this.menuItemhs.Enabled=true;

this.menuItemsd.Enabled=true;

this.menuItemdzzc.Enabled=true;

this.menuItemxxxg.Enabled=true;

this.menuItemdzzx.Enabled=true;

this.menuItemtjts.Enabled=true;

this.menuItemscts.Enabled=true;

this.menuItemjlxg.Enabled=true;

this.menuItemzjyg.Enabled=true;

this.menuItemscyg.Enabled=true;

this.menuItemcxyg.Enabled=true;

this.menuItemzlxg.Enabled=true;

this.toolBarButton5.Visible=true;

}

else

...{

MessageBox.Show("非系统管理员,功能将受到限制.","登录提示:”,MessageBoxButtons.OK,MessageBoxIcon.Information);

this.menuItemdzgl.Enabled=true;

this.menuItemtsgl.Enabled=true;

this.menuItemjshs.Enabled=true;

this.menuItemyggl.Enabled=true;

this.menuItemaq.Enabled=true;

this.menuItembz.Enabled=true;

this.menuItemjs.Enabled=true;

this.menuItemhs.Enabled=true;

this.menuItemsd.Enabled=true;

this.menuItemdzzc.Enabled=false;

this.menuItemxxxg.Enabled=false;

this.menuItemdzzx.Enabled=false;

this.menuItemtjts.Enabled=false;

this.menuItemscts.Enabled=false;

this.menuItemjlxg.Enabled=false;

this.menuItemzjyg.Enabled=false;

this.menuItemscyg.Enabled=false;

this.menuItemcxyg.Enabled=false;

this.menuItemzlxg.Enabled=false;

}

}

Else//否则登录失败,退出。

...{

MessageBox.Show("登录失败,请证实你的用户名和密码后再登录!!!","登录提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.Close();

}

}

登录窗体代码

private void button1_Click( object sender,System.EventArgse) // 数据库中提取数据验证用户名与密码。

... {

try

...{

System.Data.OleDb.OleDbCommandMySelectYh=this.oleDbConnection1.CreateCommand();

System.Data.OleDb.OleDbCommandMySelectXt=this.oleDbConnection1.CreateCommand();

mandText="SELECT*FROMygxxbWHERE用户名='"+this.textBox1.Text+"'AND密码='"+this.textBox2.Text+"'";

mandText="SELECT*FROMygxxbWHERE系统管理员='是'and用户名='"+this.textBox1.Text+"'";

this.oleDbDataAdapter1.SelectCommand=MySelectYh;

this.oleDbConnection1.Open();

if(oleDbDataAdapter1.Fill(this.dataSet21,"ygxxb")==0)

...{

Dlcs++;

if(Dlcs>=3)

...{

this.DialogResult=DialogResult.No;

}

else

...{

MessageBox.Show("用户名或密码错误!你已经登录"+Dlcs.ToString()+"次.","登录提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

}

}

else

...{

this.oleDbDataAdapter1.SelectCommand=MySelectXt;

if(oleDbDataAdapter1.Fill(this.dataSet21,"ygxxb")==0)

this.ifSyAd=false;

else

this.ifSyAd=true;

this.DialogResult=DialogResult.Yes;

this.Close();

}

this.oleDbConnection1.Close();

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.Close();

}

}

private void textBox1_TextChanged( object sender,System.EventArgse)

... {

if(this.textBox1.Text!=""||this.textBox2.Text!="")

...{

this.button2.Text="重填";

}

else

...{

this.button2.Text="退出";

}

}

private void textBox2_TextChanged( object sender,System.EventArgse)

... {

this.textBox1_TextChanged(null,null);

}

private void button2_Click( object sender,System.EventArgse)

... {

if(this.button2.Text=="重填")

...{

this.textBox1.Text="";

this.textBox2.Text="";

this.textBox1.Focus();

}

else

...{

if(MessageBox.Show("你还没登录就要退出吗?","登录提示:",MessageBoxButtons.OKCancel,MessageBoxIcon.Question)==DialogResult.OK)

...{

this.DialogResult=DialogResult.No;

this.Close();

}

}

}

private void textBox1_KeyDown( object sender,System.Windows.Forms.KeyEventArgse) // 光标按键

... {

intKey=(int)e.KeyCode;

switch(Key)

...{

case27://按了Esc

if(MessageBox.Show("你还没登录就要退出吗?","登录提示:",MessageBoxButtons.OKCancel,MessageBoxIcon.Question)==DialogResult.OK)

...{

this.DialogResult=DialogResult.No;

this.Close();

}

break;

case13://按Enter

this.button1_Click(null,null);

break;

case38://按了向上和向左光标键

case37:

if(this.textBox1.Focused)

...{

this.button2.Focus();

}

else

...{

if(this.button2.Focused)

...{

this.button1.Focus();

}

else

...{

if(this.button1.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.textBox1.Focus();

}

}

}

}

break;

case40://按了向下或向右光标键

case39:

if(this.textBox1.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.button1.Focus();

}

}

break;

}

}

private void textBox2_KeyDown( object sender,System.Windows.Forms.KeyEventArgse)

... {

this.textBox1_KeyDown(null,e);

}

private void dlWin_Load( object sender,System.EventArgse)

... {

this.textBox1.Focus();

}

读者查询窗体代码

private void button1_Click( object sender,System.EventArgse)

... {//更新按钮,实现更新。

try

...{

this.dataSet21.Clear();

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

mandText="SELECT*FROMdzxxb";

this.oleDbDataAdapter1.SelectCommand=MySelect;

this.oleDbConnection1.Open();

this.oleDbDataAdapter1.Fill(this.dataSet21,"dzxxb");

this.oleDbConnection1.Close();

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void button2_Click( object sender,System.EventArgse)

... {//查看按钮,实现查看。

try

...{

this.oleDbConnection1.Open();

this.oleDbDataAdapter1.Fill(this.dataSet21,"dzxxb");

this.oleDbConnection1.Close();

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void button3_Click( object sender,System.EventArgse)

... {//返回按钮,关闭当前窗口。

this.Close();

}

private void button5_Click( object sender,System.EventArgse)

... {//返回按钮,关闭当前窗口。

this.Close();

}

private void button4_Click( object sender,System.EventArgse)

... {//按编号查询按钮,实现按编号查询。

try

...{

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

mandText="SELECT*FROMdzxxbWHERE编号='"+this.textBox1.Text+"'";

this.oleDbDataAdapter1.SelectCommand=MySelect;

this.dataSet21.Clear();

this.oleDbConnection1.Open();

this.oleDbDataAdapter1.Fill(this.dataSet21,"dzxxb");

this.oleDbConnection1.Close();

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void button5_KeyDown( object sender,System.Windows.Forms.KeyEventArgse)

... {//同上,按键处理。

switch((int)e.KeyCode)

...{

case13:

button4_Click(null,null);

break;

case27:

this.Close();

break;

case38:

case37:

if(this.button5.Focused)

...{

this.button4.Focus();

}

else

...{

if(this.button4.Focused)

...{

this.textBox1.Focus();

}

else

...{

if(this.textBox1.Focused)

...{

this.button5.Focus();

}

}

}

break;

case40:

case39:

if(this.textBox1.Focused)

...{

this.button4.Focus();

}

else

...{

if(this.button4.Focused)

...{

this.button5.Focus();

}

else

...{

if(this.button5.Focused)

...{

this.textBox1.Focus();

}

}

}

break;

}

}

private void button7_Click( object sender,System.EventArgse)

... {//返回按钮,关闭当前窗口。

this.Close();

}

private void button6_Click( object sender,System.EventArgse)

... {//按姓名查询按钮,实现按姓名查找。

try

...{

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

mandText="SELECT*FROMdzxxbWHERE姓名='"+this.textBox2.Text+"'";

this.oleDbDataAdapter1.SelectCommand=MySelect;

this.dataSet21.Clear();

this.oleDbConnection1.Open();

this.oleDbDataAdapter1.Fill(this.dataSet21,"dzxxb");

this.oleDbConnection1.Close();

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void textBox2_KeyDown( object sender,System.Windows.Forms.KeyEventArgse)

... {//同上,按键处理。

switch((int)e.KeyCode)

...{

case13:

button6_Click(null,null);

break;

case27:

this.Close();

break;

case38:

case37:

if(this.button7.Focused)

...{

this.button6.Focus();

}

else

...{

if(this.button6.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.button7.Focus();

}

}

}

break;

case40:

case39:

if(this.textBox2.Focused)

...{

this.button6.Focus();

}

else

...{

if(this.button6.Focused)

...{

this.button7.Focus();

}

else

...{

if(this.button7.Focused)

...{

this.textBox2.Focus();

}

}

}

break;

}

}

private void dzcx_Activated( object sender,System.EventArgse)

... {//每次成为当前窗使用按钮一成为焦点按钮。

this.button1.Focus();

}

读者注消窗体代码

private void button1_Click( object sender,System.EventArgse)

... {//根据用户所提供条件查询,越祥细查找越准确。

stringComStr="";

try

...{

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

if(this.textBox1.Text!="")

...{

ComStr="SELECT*FROMdzxxbWHERE编号='"+this.textBox1.Text+"'";

}

else

...{

if(this.textBox2.Text!="")

...{

if(ComStr=="")

...{

ComStr="SELECT*FROMdzxxbWHERE姓名='"+this.textBox2.Text+"'";

}

else

...{

ComStr+="AND姓名='"+this.textBox2.Text+"'";

}

}

if(this.textBox3.Text!="")

...{

if(ComStr=="")

...{

ComStr="SELECT*FROMdzxxbWHERE手机='"+this.textBox3.Text+"'";

}

else

...{

ComStr+="AND手机='"+this.textBox3.Text+"'";

}

}

if(ComStr=="")

...{

MessageBox.Show("无查询条件,默认查找所有记录.","查找提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

ComStr="SELECT*FROMdzxxb";

}

}

mandText=ComStr;

this.oleDbDataAdapter1.SelectCommand=MySelect;

this.dataSet21.Clear();

this.oleDbConnection1.Open();

this.oleDbDataAdapter1.Fill(dataSet21,"dzxxb");

this.oleDbConnection1.Close();

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void button4_Click( object sender,System.EventArgse)

... {//返回按钮,关闭当前窗口。

this.Close();

}

private void button3_Click( object sender,System.EventArgse)

... {//更新按钮,更新当前数据。

try

...{

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

mandText="SELECT*FROMdzxxb";

this.oleDbDataAdapter1.SelectCommand=MySelect;

this.dataSet21.Clear();

this.oleDbConnection1.Open();

this.oleDbDataAdapter1.Fill(this.dataSet21,"dzxxb");

this.oleDbConnection1.Close();

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void button2_Click( object sender,System.EventArgse)

... {//删除按钮,请用户确认删除当前记录。

try

...{

intReN=this.dataGrid1.CurrentRowIndex;

if(ReN==-1)

...{

MessageBox.Show("当前没有记录可以删除!!!","删除提示:",MessageBoxButtons.OK,MessageBoxIcon.Error);

}

else

...{

stringBH=dataSet21.Tables["dzxxb"].Rows[ReN]["编号"].ToString();

System.Data.OleDb.OleDbCommandMyDel=this.oleDbConnection1.CreateCommand();

mandText="DELETE*FROMdzxxbWHERE编号='"+BH+"'";

this.oleDbDataAdapter1.DeleteCommand=MyDel;

if(MessageBox.Show("删除是不可恢复的,真的要删除吗?","删除提示:",MessageBoxButtons.YesNo,MessageBoxIcon.Exclamation)==DialogResult.Yes)

...{

this.oleDbConnection1.Open();

MyDel.ExecuteNonQuery();

this.oleDbConnection1.Close();

button3_Click(null,null);

}

}

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void textBox3_KeyDown( object sender,System.Windows.Forms.KeyEventArgse)

... {//同上,按键处理。

switch((int)e.KeyCode)

...{

case27:

this.Close();

break;

case13:

if(this.button1.Focused||this.textBox1.Focused||this.textBox2.Focused||this.textBox3.Focused)

...{

button1_Click(null,null);

}

if(this.button2.Focused)

...{

button2_Click(null,null);

}

if(this.button3.Focused)

...{

button3_Click(null,null);

}

if(this.button4.Focused)

...{

this.Close();

}

break;

case38:

case37:

if(this.textBox3.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.textBox1.Focus();

}

else

...{

if(this.textBox1.Focused)

...{

this.textBox3.Focus();

}

}

}

break;

case40:

case39:

if(this.textBox1.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.textBox3.Focus();

}

else

...{

if(this.textBox3.Focused)

...{

this.textBox1.Focus();

}

}

}

break;

}

}

private void textBox3_TextChanged( object sender,System.EventArgse)

... {//手机号只为以数字,不允许用户输入非数字。

strings="";

for(inti=0;i

if(Char.IsDigit(textBox3.Text[i])==true)

s=s+textBox3.Text[i].ToString();

textBox3.Text=s;

textBox3.SelectionStart=textBox3.Text.Length;

}

private void dataGrid1_DoubleClick( object sender,System.EventArgse)

... {//双击当前记录,调用删除按钮。

button2_Click(null,null);

}

读者注册窗体代码

private void dzzc_Load( object sender,System.EventArgse)

... {//指定焦点。

this.textBox1.Focus();

}

private void button3_Click( object sender,System.EventArgse)

... {//返回按钮。

this.Close();

}

private void button2_Click( object sender,System.EventArgse)

... {//重填按钮。

this.textBox1.Text="";

this.textBox2.Text="";

this.textBox3.Text="";

this.textBox4.Text="";

this.textBox5.Text="";

this.textBox6.Text="";

this.textBox7.Text="";

this.textBox1.Focus();

}

private void button1_Click( object sender,System.EventArgse)

... {//注册按钮,实现注册。

try

...{

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

mandText="SELECT*FROMdzxxbWHERE编号='"+this.textBox1.Text+"'";

this.oleDbDataAdapter1.SelectCommand=MySelect;

if(this.textBox1.Text=="")

...{

MessageBox.Show("编号不能为空,请输入编号!","输入提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.textBox1.Focus();

}

else

...{

if(this.textBox2.Text=="")

...{

MessageBox.Show("姓名不能为空,请输入姓名!","输入提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.textBox2.Focus();

}

else

...{

this.oleDbConnection1.Open();

intIf=this.oleDbDataAdapter1.Fill(this.dataSet21,"dzxxb");

this.oleDbConnection1.Close();

if(If!=0)

...{

MessageBox.Show("该编号已经存在,请输入另外编号!","输入提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.textBox1.Focus();

}

else

...{

stringxb;

if(this.radioButton1.Checked)

xb="男";

else

xb="女";

System.Data.OleDb.OleDbCommandMyInsert=this.oleDbConnection1.CreateCommand();

mandText="INSERTINTOdzxxb(编号,姓名,性别,单位,手机,电子邮箱,ICQ,OICQ)VALUES('"+this.textBox1.Text+"','"+this.textBox2.Text+"','"+xb+"','"+this.textBox3.Text+"','"+this.textBox4.Text+"','"+this.textBox5.Text+"','"+this.textBox6.Text+"','"+this.textBox7.Text+"')";

this.oleDbDataAdapter1.InsertCommand=MyInsert;

this.oleDbConnection1.Open();

MyInsert.ExecuteNonQuery();

this.oleDbConnection1.Close();

MessageBox.Show("读者注册成功!!!","员工添加提示:",MessageBoxButtons.OK,MessageBoxIcon.Asterisk);

this.textBox1.Text="";

this.textBox2.Text="";

this.textBox3.Text="";

this.textBox4.Text="";

this.textBox5.Text="";

this.textBox6.Text="";

this.textBox7.Text="";

this.textBox1.Focus();

}

}

}

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void textBox3_KeyDown( object sender,System.Windows.Forms.KeyEventArgse)

... {//同上,按键处理。

switch((int)e.KeyCode)

...{

case27:

this.Close();

break;

case13:

if(this.button2.Focused)

...{

button2_Click(null,null);

}

else

...{

if(this.button3.Focused)

...{

this.Close();

}

else

...{

this.button1_Click(null,null);

}

}

break;

case38:

case37:

if(this.textBox7.Focused)

...{

this.textBox6.Focus();

}

else

...{

if(this.textBox6.Focused)

...{

this.textBox5.Focus();

}

else

...{

if(this.textBox5.Focused)

...{

this.textBox4.Focus();

}

else

...{

if(this.textBox4.Focused)

...{

this.textBox3.Focus();

}

else

...{

if(this.textBox3.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.textBox1.Focus();

}

else

...{

if(this.textBox1.Focused)

...{

this.textBox7.Focus();

}

}

}

}

}

}

}

break;

case40:

case39:

if(this.textBox1.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.textBox3.Focus();

}

else

...{

if(this.textBox3.Focused)

...{

this.textBox4.Focus();

}

else

...{

if(this.textBox4.Focused)

...{

this.textBox5.Focus();

}

else

...{

if(this.textBox5.Focused)

...{

this.textBox6.Focus();

}

else

...{

if(this.textBox6.Focused)

...{

this.textBox7.Focus();

}

else

...{

if(this.textBox7.Focused)

...{

this.textBox1.Focus();

}

}

}

}

}

}

}

break;

}

}

private void textBox4_TextChanged( object sender,System.EventArgse)

... {//只允许用户输入数字。

strings="";

for(inti=0;i

if(Char.IsDigit(textBox4.Text[i])==true)

s=s+textBox4.Text[i].ToString();

textBox4.Text=s;

textBox4.SelectionStart=textBox4.Text.Length;

}

private void textBox6_TextChanged( object sender,System.EventArgse)

... {//只允许用户输入数字。

strings="";

for(inti=0;i

if(Char.IsDigit(textBox6.Text[i])==true)

s=s+textBox6.Text[i].ToString();

textBox6.Text=s;

textBox6.SelectionStart=textBox6.Text.Length;

}

private void textBox7_TextChanged( object sender,System.EventArgse)

... {//只允许用户输入数字。

strings="";

for(inti=0;i

if(Char.IsDigit(textBox7.Text[i])==true)

s=s+textBox7.Text[i].ToString();

textBox7.Text=s;

textBox7.SelectionStart=textBox7.Text.Length;

}

}

读者信息修改窗体代码

private void button4_Click( object sender,System.EventArgse)

... {//返回按钮。

this.Close();

}

private void button1_Click( object sender,System.EventArgse)

... {//据据用户提供的信息查询记录,越祥细越准确。

stringComStr="";

try

...{

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

if(this.textBox1.Text!="")

...{

ComStr="SELECT*FROMdzxxbWHERE编号='"+this.textBox1.Text+"'";

}

else

...{

if(this.textBox2.Text!="")

...{

if(ComStr=="")

...{

ComStr="SELECT*FROMdzxxbWHERE姓名='"+this.textBox2.Text+"'";

}

else

...{

ComStr+="AND姓名='"+this.textBox2.Text+"'";

}

}

if(this.textBox3.Text!="")

...{

if(ComStr=="")

...{

ComStr="SELECT*FROMdzxxbWHERE手机='"+this.textBox3.Text+"'";

}

else

...{

ComStr+="AND手机='"+this.textBox3.Text+"'";

}

}

if(ComStr=="")

...{

MessageBox.Show("无查询条件,默认查找所有记录.","查找提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

ComStr="SELECT*FROMdzxxb";

}

}

mandText=ComStr;

this.oleDbDataAdapter1.SelectCommand=MySelect;

this.dataSet21.Clear();

this.oleDbConnection1.Open();

this.oleDbDataAdapter1.Fill(dataSet21,"dzxxb");

this.oleDbConnection1.Close();

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void button2_Click( object sender,System.EventArgse)

... {//更新按钮,更新当前记录。

try

...{

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

mandText="SELECT*FROMdzxxb";

this.oleDbDataAdapter1.SelectCommand=MySelect;

this.dataSet21.Clear();

this.oleDbConnection1.Open();

this.oleDbDataAdapter1.Fill(this.dataSet21,"dzxxb");

this.oleDbConnection1.Close();

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void button3_Click( object sender,System.EventArgse)

... {//保存按钮,保存记录信息。

try

...{

this.oleDbConnection1.Open();

this.oleDbDataAdapter1.Update(this.dataSet21,"dzxxb");

this.oleDbConnection1.Close();

MessageBox.Show("信息已经保存.","保存提示:",MessageBoxButtons.OK,MessageBoxIcon.Information);

this.dataSet21.Clear();

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void button2_KeyDown( object sender,System.Windows.Forms.KeyEventArgse)

... {//同上,按键处理。

switch((int)e.KeyCode)

...{

case27:

this.Close();

break;

case13:

if(this.button1.Focused||this.textBox1.Focused||this.textBox2.Focused||this.textBox3.Focused)

...{

button1_Click(null,null);

}

if(this.button2.Focused)

...{

button2_Click(null,null);

}

if(this.button3.Focused)

...{

button3_Click(null,null);

}

if(this.button4.Focused)

this.Close();

break;

case38:

case37:

if(this.textBox3.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.textBox1.Focus();

}

else

...{

if(this.textBox1.Focused)

...{

this.textBox3.Focus();

}

}

}

break;

case40:

case39:

if(this.textBox1.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.textBox3.Focus();

}

else

...{

if(this.textBox3.Focused)

...{

this.textBox1.Focus();

}

}

}

break;

}

}

private void textBox3_TextChanged( object sender,System.EventArgse)

... {//只允许用户输入数字数据。

strings="";

for(inti=0;i

if(Char.IsDigit(textBox3.Text[i])==true)

s=s+textBox3.Text[i].ToString();

textBox3.Text=s;

textBox3.SelectionStart=textBox3.Text.Length;

}

书目查询窗口代码

private void button3_Click( object sender,System.EventArgse)

... {//查找所有记录。

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

mandText="SELECT*FROMtsxxb";

this.oleDbDataAdapter1.SelectCommand=MySelect;

this.dataSet21.Clear();

try

...{

this.oleDbConnection1.Open();

this.oleDbDataAdapter1.Fill(this.dataSet21,"tsxxb");

this.oleDbConnection1.Close();

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void button2_Click( object sender,System.EventArgse)

... {//清空数据。

this.dataSet21.Clear();

}

private void button4_Click( object sender,System.EventArgse)

... {//返回按钮。

this.Close();

}

private void button1_Click( object sender,System.EventArgse)

... {//根据用户输入信息查询相应记录。

stringComStr="";

try

...{

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

if(this.textBox1.Text!="")

...{

ComStr="SELECT*FROMtsxxbWHERE编号='"+this.textBox1.Text+"'";

}

else

...{

if(this.textBox2.Text!="")

...{

if(ComStr=="")

...{

ComStr="SELECT*FROMtsxxbWHERE书名='"+this.textBox2.Text+"'";

}

else

...{

ComStr+="AND书名='"+this.textBox2.Text+"'";

}

}

if(this.textBox3.Text!="")

...{

if(ComStr=="")

...{

ComStr="SELECT*FROMtsxxbWHERE类别='"+this.textBox3.Text+"'";

}

else

...{

ComStr+="AND类别='"+this.textBox3.Text+"'";

}

}

if(this.textBox4.Text!="")

...{

if(ComStr=="")

...{

ComStr="SELECT*FROMtsxxbWHERE作者='"+this.textBox4.Text+"'";

}

else

...{

ComStr+="AND作者='"+this.textBox4.Text+"'";

}

}

if(this.textBox5.Text!="")

...{

if(ComStr=="")

...{

ComStr="SELECT*FROMtsxxbWHERE出版社='"+this.textBox5.Text+"'";

}

else

...{

ComStr+="AND出版社='"+this.textBox5.Text+"'";

}

}

if(ComStr=="")

...{

MessageBox.Show("无查询条件,默认查询所有记录.","查询提示:",MessageBoxButtons.OK,MessageBoxIcon.Information);

ComStr="SELECT*FROMtsxxb";

}

}

mandText=ComStr;

this.oleDbDataAdapter1.SelectCommand=MySelect;

this.dataSet21.Clear();

this.oleDbConnection1.Open();

this.oleDbDataAdapter1.Fill(dataSet21,"tsxxb");

this.oleDbConnection1.Close();

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void button4_KeyDown( object sender,System.Windows.Forms.KeyEventArgse)

... {//按键处理。

switch((int)e.KeyCode)

...{

case27:

this.Close();

break;

case13:

if(this.button1.Focused||this.textBox1.Focused||this.textBox2.Focused||this.textBox3.Focused||this.textBox4.Focused||this.textBox5.Focused)

...{

button1_Click(null,null);

}

if(this.button2.Focused)

...{

button2_Click(null,null);

}

if(this.button3.Focused)

...{

button3_Click(null,null);

}

if(this.button4.Focused)

...{

this.Close();

}

break;

case38:

case37:

if(this.textBox5.Focused)

...{

this.textBox4.Focus();

}

else

...{

if(this.textBox4.Focused)

...{

this.textBox3.Focus();

}

else

...{

if(this.textBox3.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.textBox1.Focus();

}

else

...{

if(this.textBox1.Focused)

...{

this.textBox5.Focus();

}

}

}

}

}

break;

case40:

case39:

if(this.textBox5.Focused)

...{

this.textBox1.Focus();

}

else

...{

if(this.textBox1.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.textBox3.Focus();

}

else

...{

if(this.textBox3.Focused)

...{

this.textBox4.Focus();

}

else

...{

if(this.textBox4.Focused)

...{

this.textBox5.Focus();

}

}

}

}

}

break;

}

}

public void CXBH(jsglV)

... {//为窗体间传递数据做准备。

V.textBox2.Text=BH;

}

private void smcx_Closing( object sender,ponentModel.CancelEventArgse)

... {//将当前记录的编号作为传递内容。

intReN=this.dataGrid1.CurrentRowIndex;

if(ReN==-1)

...{

BH="";

}

else

...{

BH=dataSet21.Tables["tsxxb"].Rows[ReN]["编号"].ToString();

}

}

添加图书窗体代码

private void textBox1_Leave( object sender,System.EventArgse)

... {//查找该图书是否已存在。

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

mandText="SELECT*FROMtsxxbWHERE编号='"+this.textBox1.Text+"'";

this.oleDbDataAdapter1.SelectCommand=MySelect;

this.dataSet21.Clear();

try

...{

if(this.oleDbDataAdapter1.Fill(this.dataSet21,"tsxxb")!=0)

...{//若存在,则只要输入购入数即可。

this.Exist=true;

this.textBox2.ReadOnly=true;

this.textBox3.ReadOnly=true;

this.textBox4.ReadOnly=true;

this.textBox5.ReadOnly=true;

this.textBox6.ReadOnly=true;

this.textBox2.Text=dataSet21.Tables["tsxxb"].Rows[0]["书名"].ToString();

this.textBox3.Text=dataSet21.Tables["tsxxb"].Rows[0]["类别"].ToString();

this.textBox4.Text=dataSet21.Tables["tsxxb"].Rows[0]["作者"].ToString();

this.textBox6.Text=dataSet21.Tables["tsxxb"].Rows[0]["出版社"].ToString();

this.textBox5.Text=dataSet21.Tables["tsxxb"].Rows[0]["价格"].ToString();

this.label10.Text=dataSet21.Tables["tsxxb"].Rows[0]["库存数"].ToString();

this.label11.Text=dataSet21.Tables["tsxxb"].Rows[0]["在库数"].ToString();

this.textBox7.Text="";

this.textBox7.Focus();

}

else

...{

this.Exist=false;

this.textBox2.ReadOnly=false;

this.textBox3.ReadOnly=false;

this.textBox4.ReadOnly=false;

this.textBox5.ReadOnly=false;

this.textBox6.ReadOnly=false;

this.textBox2.Text="";

this.textBox3.Text="";

this.textBox4.Text="";

this.textBox5.Text="";

this.textBox6.Text="";

this.textBox7.Text="";

if(this.textBox1.Text!="")

...{

this.label10.Text="0";

this.label11.Text="0";

}

else

...{

this.label10.Text="";

this.label11.Text="";

}

}

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void button3_Click( object sender,System.EventArgse)

... {//返回按钮。

this.Close();

}

private void button2_Click( object sender,System.EventArgse)

... {//重填按钮。

this.textBox1.Text="";

this.textBox2.Text="";

this.textBox3.Text="";

this.textBox4.Text="";

this.textBox5.Text="";

this.textBox6.Text="";

this.textBox7.Text="";

this.textBox1.ReadOnly=false;

this.textBox2.ReadOnly=false;

this.textBox3.ReadOnly=false;

this.textBox4.ReadOnly=false;

this.textBox5.ReadOnly=false;

this.textBox6.ReadOnly=false;

this.textBox7.ReadOnly=false;

this.label10.Text="";

this.label11.Text="";

this.textBox1.Focus();

}

private bool NotText5If()

... {//只能为数字且只允许一个小数点。

stringStr=this.textBox5.Text;

inti=0;

while(i

...{

if((Str[i]<'0'||Str[i]>'9')&&Str[i]!='.')

returntrue;

i++;

}

returnfalse;

}

private bool NotText7If()

... {//为更输入数据检测做准备。

stringStr=this.textBox7.Text;

inti=0;

while(i

...{

if(Str[i]<'0'||Str[i]>'9')

returntrue;

i++;

}

returnfalse;

}

private void button1_Click( object sender,System.EventArgse)

... {//添加按钮,添加图书。

try

...{

if(this.Exist)

...{

if(this.textBox7.Text!="")

...{

System.Data.OleDb.OleDbCommandMyUpdate=this.oleDbConnection1.CreateCommand();

mandText="UPDATEtsxxbSET库存数=库存数+"+this.textBox7.Text+",在库数=在库数+"+this.textBox7.Text+"WHERE编号='"+this.textBox1.Text+"'";

this.oleDbDataAdapter1.UpdateCommand=MyUpdate;

this.oleDbConnection1.Open();

MyUpdate.ExecuteNonQuery();

this.oleDbConnection1.Close();

MessageBox.Show("图书添加成功,请查看。","添加提示:",MessageBoxButtons.OK,MessageBoxIcon.Information);

button2_Click(null,null);

}

else

...{

MessageBox.Show("请输入你要添加的数量。","添加提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.textBox7.Focus();

}

}

else

...{

if(this.textBox1.Text=="")

...{

MessageBox.Show("编号不能为空,请输入编号。","添加提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

}

else

...{

if(this.textBox2.Text=="")

...{

MessageBox.Show("书名不能为空,请输入书名。","添加提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.textBox2.Focus();

}

else

...{

if(this.textBox3.Text=="")

...{

MessageBox.Show("类别不能为空,请输入类别。","添加提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.textBox3.Focus();

}

else

...{

if(this.textBox4.Text=="")

...{

MessageBox.Show("作者不能为空,请输入作者姓名。","添加提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.textBox4.Focus();

}

else

...{

if(this.textBox5.Text=="")

...{

MessageBox.Show("价格不能为空,请输入价格。","添加提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.textBox5.Focus();

}

else

...{

if(this.textBox6.Text=="")

...{

MessageBox.Show("出版社不能为空,请输入出版社。","添加提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.textBox6.Focus();

}

else

...{

if(this.textBox7.Text=="")

...{

MessageBox.Show("请输入你要添加的数量。","添加提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.textBox7.Focus();

}

else

...{

if(NotText5If())

...{

MessageBox.Show("价格为非数字,请重新输入.","数据输入提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.textBox5.Focus();

}

else

...{

if(NotText7If())

...{

MessageBox.Show("添加数量为非数字,请重新输入.","数据输入提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.textBox7.Focus();

}

else

...{

System.Data.OleDb.OleDbCommandMyInsert=this.oleDbConnection1.CreateCommand();

mandText="INSERTINTOtsxxbVALUES('"+this.textBox1.Text+"','"+this.textBox2.Text+"','"+this.textBox3.Text+"','"+this.textBox4.Text+"','"+this.textBox6.Text+"',"+this.textBox5.Text+","+this.textBox7.Text+","+this.textBox7.Text+")";

this.oleDbDataAdapter1.InsertCommand=MyInsert;

this.oleDbConnection1.Open();

MyInsert.ExecuteNonQuery();

this.oleDbConnection1.Close();

MessageBox.Show("图书添加成功,请查看。","添加提示:",MessageBoxButtons.OK,MessageBoxIcon.Information);

button2_Click(null,null);

}

}

}

}

}

}

}

}

}//

}

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void tjts_Activated( object sender,System.EventArgse)

... {//使焦点定位到输入框一中。

this.textBox1.Focus();

}

private void textBox4_KeyDown( object sender,System.Windows.Forms.KeyEventArgse)

... {//同上,按键处理。

switch((int)e.KeyCode)

...{

case27:

this.Close();

break;

case13:

if(this.textBox1.Focused||this.textBox2.Focused||this.textBox3.Focused||this.textBox4.Focused||this.textBox5.Focused||this.textBox6.Focused||this.textBox7.Focused||this.button1.Focused)

...{

button1_Click(null,null);

}

if(this.button2.Focused)

...{

this.button2_Click(null,null);

}

if(this.button3.Focused)

...{

this.Close();

}

break;

case38:

case37:

if(this.textBox7.Focused)

...{

this.textBox6.Focus();

}

else

...{

if(this.textBox6.Focused)

...{

this.textBox5.Focus();

}

else

...{

if(this.textBox5.Focused)

...{

this.textBox4.Focus();

}

else

...{

if(this.textBox4.Focused)

...{

this.textBox3.Focus();

}

else

...{

if(this.textBox3.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.textBox1.Focus();

}

else

...{

if(this.textBox1.Focused)

...{

this.textBox7.Focus();

}

}

}

}

}

}

}

break;

case40:

case39:

if(this.textBox1.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.textBox3.Focus();

}

else

...{

if(this.textBox3.Focused)

...{

this.textBox4.Focus();

}

else

...{

if(this.textBox4.Focused)

...{

this.textBox5.Focus();

}

else

...{

if(this.textBox5.Focused)

...{

this.textBox6.Focus();

}

else

...{

if(this.textBox6.Focused)

...{

this.textBox7.Focus();

}

else

...{

if(this.textBox7.Focused)

...{

this.textBox1.Focus();

}

}

}

}

}

}

}

break;

}

}

private void textBox5_KeyDown( object sender,System.Windows.Forms.KeyEventArgse)

... {//同上,按键处理。

if((int)e.KeyCode==13)

textBox4_KeyDown(null,e);

}

private void textBox5_TextChanged( object sender,System.EventArgse)

... {//只允许为数字,且只允许有一个小数点。

strings="";

intj=0;

for(inti=0;i

if(Char.IsDigit(textBox5.Text[i])==true||textBox5.Text[i]=='.')

...{

if(textBox5.Text[i]=='.')

...{

j++;

if(j>1)

...{

MessageBox.Show("只能有一个小数点,请重新输入。","输入提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.textBox5.Focus();

}

}

if(j<=1)

s=s+textBox5.Text[i].ToString();

}

textBox5.Text=s;

textBox5.SelectionStart=textBox5.Text.Length;

}

private void textBox7_TextChanged( object sender,System.EventArgse)

... {//只允许输入数字。

strings="";

for(inti=0;i

if(Char.IsDigit(textBox7.Text[i])==true)

s=s+textBox7.Text[i].ToString();

textBox7.Text=s;

textBox7.SelectionStart=textBox7.Text.Length;

}

删除图书窗口代码

private void button4_Click( object sender,System.EventArgse)

... {//返回按钮,关闭当前窗口。

this.Close();

}

private void button3_Click( object sender,System.EventArgse)

... {//更新按钮,更新当前数据。

try

...{

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

mandText="SELECT*FROMtsxxb";

this.oleDbDataAdapter1.SelectCommand=MySelect;

this.dataSet21.Clear();

this.oleDbConnection1.Open();

this.oleDbDataAdapter1.Fill(this.dataSet21,"tsxxb");

this.oleDbConnection1.Close();

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void button2_Click( object sender,System.EventArgse)

... {//删除当前用户选中的记录。

try

...{

intReN=this.dataGrid1.CurrentRowIndex;

if(ReN==-1)

...{

MessageBox.Show("当前没有记录可以删除!!!","删除提示:",MessageBoxButtons.OK,MessageBoxIcon.Error);

}

else

...{

stringBH=dataSet21.Tables["tsxxb"].Rows[ReN]["编号"].ToString();

System.Data.OleDb.OleDbCommandMyDel=this.oleDbConnection1.CreateCommand();

mandText="DELETE*FROMtsxxbWHERE编号='"+BH+"'";

this.oleDbDataAdapter1.DeleteCommand=MyDel;

if(MessageBox.Show("删除是不可恢复的,真的要删除吗?","删除提示:",MessageBoxButtons.YesNo,MessageBoxIcon.Exclamation)==DialogResult.Yes)

...{

this.oleDbConnection1.Open();

MyDel.ExecuteNonQuery();

this.oleDbConnection1.Close();

button3_Click(null,null);

}

}

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void button1_Click( object sender,System.EventArgse)

... {//查询按钮,按用户提供的信息查询记录。

stringComStr="";

try

...{

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

if(this.textBox1.Text!="")

...{

ComStr="SELECT*FROMtsxxbWHERE编号='"+this.textBox1.Text+"'";

}

else

...{

if(this.textBox2.Text!="")

...{

if(ComStr=="")

...{

ComStr="SELECT*FROMtsxxbWHERE书名='"+this.textBox2.Text+"'";

}

else

...{

ComStr+="AND书名='"+this.textBox2.Text+"'";

}

}

if(this.textBox3.Text!="")

...{

if(ComStr=="")

...{

ComStr="SELECT*FROMtsxxbWHERE作者='"+this.textBox3.Text+"'";

}

else

...{

ComStr+="AND作者='"+this.textBox3.Text+"'";

}

}

if(ComStr=="")

...{

MessageBox.Show("无查询条件,默认查找所有记录.","查找提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

ComStr="SELECT*FROMtsxxb";

}

}

mandText=ComStr;

this.oleDbDataAdapter1.SelectCommand=MySelect;

this.dataSet21.Clear();

this.oleDbConnection1.Open();

this.oleDbDataAdapter1.Fill(dataSet21,"tsxxb");

this.oleDbConnection1.Close();

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void textBox2_KeyDown( object sender,System.Windows.Forms.KeyEventArgse)

... {//同上,按键处理。

switch((int)e.KeyCode)

...{

case27:

this.Close();

break;

case13:

if(this.button1.Focused||this.textBox1.Focused||this.textBox2.Focused||this.textBox3.Focused)

...{

button1_Click(null,null);

}

if(this.button2.Focused)

...{

button2_Click(null,null);

}

if(this.button3.Focused)

...{

button3_Click(null,null);

}

if(this.button4.Focused)

...{

this.Close();

}

break;

case38:

case37:

if(this.textBox3.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.textBox1.Focus();

}

else

...{

if(this.textBox1.Focused)

...{

this.textBox3.Focus();

}

}

}

break;

case40:

case39:

if(this.textBox1.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.textBox3.Focus();

}

else

...{

if(this.textBox3.Focused)

...{

this.textBox1.Focus();

}

}

}

break;

}

}

private void dataGrid1_DoubleClick( object sender,System.EventArgse)

... {//双击当前记录,调用删除按钮功能。

button2_Click(null,null);

}

图书信息修改窗体代码

private void button3_Click( object sender,System.EventArgse)

... {//保存按钮,保存用户修改的信息。

try

...{

this.oleDbConnection1.Open();

this.oleDbDataAdapter1.Update(this.dataSet21,"tsxxb");

this.oleDbConnection1.Close();

MessageBox.Show("信息已经保存.","保存提示:",MessageBoxButtons.OK,MessageBoxIcon.Information);

this.dataSet21.Clear();

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void button2_Click( object sender,System.EventArgse)

... {//更新按钮,更新当前记录。

try

...{

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

mandText="SELECT*FROMtsxxb";

this.oleDbDataAdapter1.SelectCommand=MySelect;

this.dataSet21.Clear();

this.oleDbConnection1.Open();

this.oleDbDataAdapter1.Fill(this.dataSet21,"tsxxb");

this.oleDbConnection1.Close();

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void button1_Click( object sender,System.EventArgse)

... {//按用户提供信息查询,越祥细越准确。

stringComStr="";

try

...{

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

if(this.textBox1.Text!="")

...{

ComStr="SELECT*FROMtsxxbWHERE编号='"+this.textBox1.Text+"'";

}

else

...{

if(this.textBox2.Text!="")

...{

if(ComStr=="")

...{

ComStr="SELECT*FROMtsxxbWHERE书名='"+this.textBox2.Text+"'";

}

else

...{

ComStr+="AND书名='"+this.textBox2.Text+"'";

}

}

if(this.textBox3.Text!="")

...{

if(ComStr=="")

...{

ComStr="SELECT*FROMtsxxbWHERE作者='"+this.textBox3.Text+"'";

}

else

...{

ComStr+="AND作者='"+this.textBox3.Text+"'";

}

}

if(this.textBox4.Text!="")

...{

if(ComStr=="")

...{

ComStr="SELECT*FROMtsxxbWHERE出版社='"+this.textBox4.Text+"'";

}

else

...{

ComStr+="AND出版社='"+this.textBox4.Text+"'";

}

}

if(ComStr=="")

...{

MessageBox.Show("无查询条件,默认查找所有记录.","查找提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

ComStr="SELECT*FROMtsxxb";

}

}

mandText=ComStr;

this.oleDbDataAdapter1.SelectCommand=MySelect;

this.dataSet21.Clear();

this.oleDbConnection1.Open();

this.oleDbDataAdapter1.Fill(dataSet21,"tsxxb");

this.oleDbConnection1.Close();

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void textBox3_KeyDown( object sender,System.Windows.Forms.KeyEventArgse)

... {//同上,按键处理。

switch((int)e.KeyCode)

...{

case27:

this.Close();

break;

case13:

if(this.button1.Focused||this.textBox1.Focused||this.textBox2.Focused||this.textBox3.Focused||this.textBox4.Focused)

...{

button1_Click(null,null);

}

if(this.button2.Focused)

...{

button2_Click(null,null);

}

if(this.button3.Focused)

...{

button3_Click(null,null);

}

if(this.button4.Focused)

this.Close();

break;

case38:

case37:

if(this.textBox4.Focused)

...{

this.textBox3.Focus();

}

else

...{

if(this.textBox3.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.textBox1.Focus();

}

else

...{

if(this.textBox1.Focused)

...{

this.textBox4.Focus();

}

}

}

}

break;

case40:

case39:

if(this.textBox1.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.textBox3.Focus();

}

else

...{

if(this.textBox3.Focused)

...{

this.textBox4.Focus();

}

else

...{

if(this.textBox4.Focused)

...{

this.textBox1.Focus();

}

}

}

}

break;

}

}

}

借书管理窗体代码

private void button2_Click( object sender,System.EventArgse)

... {//返回按钮,关闭当前窗口。

this.Close();

}

private void JSXX()

... {//为显示读者所借书信息准备。

try

...{

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

mandText="SELECT*FROMjsxxbWHERE读者编号='"+this.textBox1.Text+"'";

this.oleDbDataAdapter3.SelectCommand=MySelect;

this.dataSet21.Clear();

this.oleDbConnection1.Open();

this.oleDbDataAdapter3.Fill(this.dataSet21,"jsxxb");

this.oleDbConnection1.Close();

string[]TSBH=newstring[dataSet21.Tables["jsxxb"].Rows.Count];

string[]JSRQ=newstring[dataSet21.Tables["jsxxb"].Rows.Count];

for(inti=0;i

...{

TSBH[i]=dataSet21.Tables["jsxxb"].Rows[i]["图书编号"].ToString();

JSRQ[i]=dataSet21.Tables["jsxxb"].Rows[i]["借书日期"].ToString();

}

intGJ=TSBH.Length;

string[]TEXT=newstring[GJ];

floatJG=0.00F;

System.Data.OleDb.OleDbCommandMySelectTs=this.oleDbConnection1.CreateCommand();

for(inti=0;i

mandText="SELECT*FROMtsxxbWHERE编号='"+TSBH[i]+"'";

this.oleDbDataAdapter2.SelectCommand=MySelectTs;

this.dataSet21.Clear();

this.oleDbDataAdapter2.Fill(this.dataSet21,"tsxxb");

TEXT[i]="书名:"+dataSet21.Tables["tsxxb"].Rows[0]["书名"].ToString()+" 价格:"+dataSet21.Tables["tsxxb"].Rows[0]["价格"].ToString()+"元 借书日期:"+JSRQ[i];

JG+=float.Parse(dataSet21.Tables["tsxxb"].Rows[0]["价格"].ToString());

}

this.labelgj.Text=GJ.ToString()+"本";

this.textBox3.Lines=TEXT;

this.labelzj.Text=JG.ToString()+"元";

}

catch (ExceptionExc)

... {

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void textBox1_Leave( object sender,System.EventArgse)

... {//显示该读者已借书的相关信息。

this.labeldzxm.Text="";

this.labeldzxb.Text="";

this.labeldzsj.Text="";

this.labelxm.Text="";

this.labelxb.Text="";

this.labelgj.Text="";

this.labelzj.Text="";

this.textBox3.Text="";

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

mandText="SELECT*FROMdzxxbWHERE编号='"+this.textBox1.Text+"'";

System.Data.OleDb.OleDbCommandMySelectCount=this.oleDbConnection1.CreateCommand();

mandText="SELECT*FROMjsxxbWHERE读者编号='"+this.textBox1.Text+"'";

this.oleDbDataAdapter1.SelectCommand=MySelect;

this.oleDbDataAdapter3.SelectCommand=MySelectCount;

this.dataSet21.Clear();

try

...{

this.oleDbConnection1.Open();

intIf=this.oleDbDataAdapter1.Fill(this.dataSet21,"dzxxb");

this.oleDbConnection1.Close();

if(If==0)

...{

DZ=true;

}

else

...{

DZ=false;

this.labeldzxm.Text=dataSet21.Tables["dzxxb"].Rows[0]["姓名"].ToString();

this.labeldzxb.Text=dataSet21.Tables["dzxxb"].Rows[0]["性别"].ToString();

this.labeldzsj.Text=dataSet21.Tables["dzxxb"].Rows[0]["手机"].ToString();

this.labelxm.Text=dataSet21.Tables["dzxxb"].Rows[0]["姓名"].ToString();

this.labelxb.Text=dataSet21.Tables["dzxxb"].Rows[0]["性别"].ToString();

JSXX();

}

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

public void textBox2_Leave( object sender,System.EventArgse)

... {//显示该图书的相关信息。

this.labeltssm.Text="";

this.labeltszz.Text="";

this.labeltsjg.Text="";

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

mandText="SELECT*FROMtsxxbWHERE编号='"+this.textBox2.Text+"'";

this.oleDbDataAdapter2.SelectCommand=MySelect;

this.dataSet21.Clear();

try

...{

this.oleDbConnection1.Open();

intIf=this.oleDbDataAdapter2.Fill(this.dataSet21,"tsxxb");

this.oleDbConnection1.Close();

if(If==0)

...{

TS=true;

}

else

...{

TS=false;

this.labeltssm.Text=dataSet21.Tables["tsxxb"].Rows[0]["书名"].ToString();

this.labeltszz.Text=dataSet21.Tables["tsxxb"].Rows[0]["作者"].ToString();

this.labeltsjg.Text=dataSet21.Tables["tsxxb"].Rows[0]["价格"].ToString();

}

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void button1_Click( object sender,System.EventArgse)

... {//借书按钮,当条件符合后就开始借书。

if(DZ)

...{

MessageBox.Show("该读者不存在,不能借书!!!","借书提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.textBox1.Focus();

}

else

...{

if(TS)

...{

MessageBox.Show("该图书不存在,不能借书!!!","借书提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.textBox2.Focus();

}

else

...{

try

...{

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

mandText="SELECT*FROMtsxxbWHERE编号='"+this.textBox2.Text+"'";

this.oleDbDataAdapter2.SelectCommand=MySelect;

this.dataSet21.Clear();

this.oleDbConnection1.Open();

intIf=this.oleDbDataAdapter2.Fill(this.dataSet21,"tsxxb");

this.oleDbConnection1.Close();

if((int)dataSet21.Tables["tsxxb"].Rows[0]["在库数"]<=0)

...{

MessageBox.Show("该图书已经借完,不能借书!!!","借书提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

}

else

...{

stringDate=DateTime.Now.Year.ToString()+"/"+DateTime.Now.Month.ToString()+"/"+DateTime.Now.Day.ToString()+""+DateTime.Now.Hour.ToString()+":"+DateTime.Now.Minute.ToString()+":"+DateTime.Now.Second.ToString();

System.Data.OleDb.OleDbCommandMyInsert=this.oleDbConnection1.CreateCommand();

mandText="INSERTINTOjsxxb(读者编号,图书编号,借书日期)VALUES('"+this.textBox1.Text+"','"+this.textBox2.Text+"','"+Date+"')";

this.oleDbDataAdapter3.InsertCommand=MyInsert;

System.Data.OleDb.OleDbCommandMyUpdate=this.oleDbConnection1.CreateCommand();

mandText="UPDATEtsxxbSET在库数=在库数-1WHERE编号='"+this.textBox2.Text+"'";

this.oleDbDataAdapter2.UpdateCommand=MyUpdate;

this.oleDbConnection1.Open();

MyInsert.ExecuteNonQuery();

MyUpdate.ExecuteNonQuery();

this.oleDbConnection1.Close();

JSXX();

stringMess="<<"+dataSet21.Tables["tsxxb"].Rows[0]["书名"].ToString()+">>借出成功!!!";

MessageBox.Show(Mess,"借书提示:",MessageBoxButtons.OK,MessageBoxIcon.Information);

}

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

}

}

private void button2_KeyDown( object sender,System.Windows.Forms.KeyEventArgse)

... {//同上,按键处理。

switch((int)e.KeyCode)

...{

case27:

this.Close();

break;

case13:

if(this.button1.Focused||this.textBox1.Focused||this.textBox2.Focused)

...{

button1_Click(null,null);

}

if(this.button2.Focused)

...{

this.Close();

}

break;

case38:

case37:

if(this.button2.Focused)

...{

this.button1.Focus();

}

else

...{

if(this.button1.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.textBox1.Focus();

}

else

...{

if(this.textBox1.Focused)

...{

this.button2.Focus();

}

}

}

}

break;

case40:

case39:

if(this.button2.Focused)

...{

this.textBox1.Focus();

}

else

...{

if(this.textBox1.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.button1.Focus();

}

else

...{

if(this.button1.Focused)

...{

this.button2.Focus();

}

}

}

}

break;

}

}

private void jsgl_Activated( object sender,System.EventArgse)

... {//设定焦点。

this.textBox1.Focus();

}

public void SetForm1(Form1v)

... {//为窗体间传递数据做准备。

this.F=v;

}

private void textBox2_DoubleClick( object sender,System.EventArgse)

... {//当双击图书编号输入框时打开书目查询窗口。

smcx2MySmcx=newsmcx2();

MySmcx.MdiParent=F;

MySmcx.CXBH(this);

MySmcx.Show();

}

private void textBox2_KeyPress( object sender,System.Windows.Forms.KeyPressEventArgse)

... {//当用户在图书编号框中输入的是问号时也打开书目查询窗口。

if(e.KeyChar==63)

textBox2_DoubleClick(null,null);

}

还书管理窗体代码

private void JSXX()

... {//为显示该读者所有已借的书的信息。

try

...{

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

mandText="SELECT*FROMjsxxbWHERE读者编号='"+this.textBox1.Text+"'";

this.oleDbDataAdapter3.SelectCommand=MySelect;

this.dataSet21.Clear();

this.oleDbConnection1.Open();

this.oleDbDataAdapter3.Fill(this.dataSet21,"jsxxb");

this.oleDbConnection1.Close();

string[]TSBH=newstring[dataSet21.Tables["jsxxb"].Rows.Count];

string[]JSRQ=newstring[dataSet21.Tables["jsxxb"].Rows.Count];

for(inti=0;i

...{

TSBH[i]=dataSet21.Tables["jsxxb"].Rows[i]["图书编号"].ToString();

JSRQ[i]=dataSet21.Tables["jsxxb"].Rows[i]["借书日期"].ToString();

}

intGJ=TSBH.Length;

string[]TEXT=newstring[GJ];

floatJG=0.00F;

System.Data.OleDb.OleDbCommandMySelectTs=this.oleDbConnection1.CreateCommand();

for(inti=0;i

mandText="SELECT*FROMtsxxbWHERE编号='"+TSBH[i]+"'";

this.oleDbDataAdapter2.SelectCommand=MySelectTs;

this.dataSet21.Clear();

this.oleDbDataAdapter2.Fill(this.dataSet21,"tsxxb");

TEXT[i]="书名:"+dataSet21.Tables["tsxxb"].Rows[0]["书名"].ToString()+" 价格:"+dataSet21.Tables["tsxxb"].Rows[0]["价格"].ToString()+"元 借书日期:"+JSRQ[i];

JG+=float.Parse(dataSet21.Tables["tsxxb"].Rows[0]["价格"].ToString());

}

this.labelgj.Text=GJ.ToString()+"本";

this.textBox3.Lines=TEXT;

this.labelzj.Text=JG.ToString()+"元";

}

catch (ExceptionExc)

... {

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void hsgl_Activated( object sender,System.EventArgse)

... {//设置当前焦点。

this.textBox1.Focus();

}

private void textBox1_Leave( object sender,System.EventArgse)

... {//查询该读者已借书的信息。

this.labeldzxm.Text="";

this.labeldzxb.Text="";

this.labeldzsj.Text="";

this.labelxm.Text="";

this.labelxb.Text="";

this.labelgj.Text="";

this.labelzj.Text="";

this.textBox3.Text="";

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

mandText="SELECT*FROMdzxxbWHERE编号='"+this.textBox1.Text+"'";

System.Data.OleDb.OleDbCommandMySelectCount=this.oleDbConnection1.CreateCommand();

mandText="SELECT*FROMjsxxbWHERE读者编号='"+this.textBox1.Text+"'";

this.oleDbDataAdapter1.SelectCommand=MySelect;

this.oleDbDataAdapter3.SelectCommand=MySelectCount;

this.dataSet21.Clear();

try

...{

this.oleDbConnection1.Open();

intIf=this.oleDbDataAdapter1.Fill(this.dataSet21,"dzxxb");

this.oleDbConnection1.Close();

if(If==0)

...{

DZ=true;

}

else

...{

DZ=false;

this.labeldzxm.Text=dataSet21.Tables["dzxxb"].Rows[0]["姓名"].ToString();

this.labeldzxb.Text=dataSet21.Tables["dzxxb"].Rows[0]["性别"].ToString();

this.labeldzsj.Text=dataSet21.Tables["dzxxb"].Rows[0]["手机"].ToString();

this.labelxm.Text=dataSet21.Tables["dzxxb"].Rows[0]["姓名"].ToString();

this.labelxb.Text=dataSet21.Tables["dzxxb"].Rows[0]["性别"].ToString();

JSXX();

}

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

public void textBox2_Leave( object sender,System.EventArgse)

... {//查询该图书的相关信息。

this.labeltssm.Text="";

this.labeltszz.Text="";

this.labeltsjg.Text="";

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

mandText="SELECT*FROMtsxxbWHERE编号='"+this.textBox2.Text+"'";

this.oleDbDataAdapter2.SelectCommand=MySelect;

this.dataSet21.Clear();

try

...{

this.oleDbConnection1.Open();

intIf=this.oleDbDataAdapter2.Fill(this.dataSet21,"tsxxb");

this.oleDbConnection1.Close();

if(If==0)

...{

TS=true;

}

else

...{

TS=false;

this.labeltssm.Text=dataSet21.Tables["tsxxb"].Rows[0]["书名"].ToString();

this.labeltszz.Text=dataSet21.Tables["tsxxb"].Rows[0]["作者"].ToString();

this.labeltsjg.Text=dataSet21.Tables["tsxxb"].Rows[0]["价格"].ToString();

}

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void button2_Click( object sender,System.EventArgse)

... {//返回按钮,关闭当前窗口。

this.Close();

}

private void textBox2_KeyDown( object sender,System.Windows.Forms.KeyEventArgse)

... {//同上,按键处理。

switch((int)e.KeyCode)

...{

case27:

this.Close();

break;

case13:

if(this.button1.Focused||this.textBox1.Focused||this.textBox2.Focused)

...{

button1_Click(null,null);

}

if(this.button2.Focused)

...{

this.Close();

}

break;

case38:

case37:

if(this.button2.Focused)

...{

this.button1.Focus();

}

else

...{

if(this.button1.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.textBox1.Focus();

}

else

...{

if(this.textBox1.Focused)

...{

this.button2.Focus();

}

}

}

}

break;

case40:

case39:

if(this.button2.Focused)

...{

this.textBox1.Focus();

}

else

...{

if(this.textBox1.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.button1.Focus();

}

else

...{

if(this.button1.Focused)

...{

this.button2.Focus();

}

}

}

}

break;

}

}

private void button1_Click( object sender,System.EventArgse)

... {//当所有条件符合时开始还书。

if(DZ)

...{

MessageBox.Show("该读者不存在,不能还书!!!","还书提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.textBox1.Focus();

}

else

...{

if(TS)

...{

MessageBox.Show("该图书不存在,不能还书!!!","还书提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.textBox2.Focus();

}

else

...{

try

...{

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

mandText="SELECT*FROMjsxxbWHERE读者编号='"+this.textBox1.Text+"'AND图书编号='"+this.textBox2.Text+"'";

this.oleDbDataAdapter3.SelectCommand=MySelect;

this.dataSet21.Clear();

this.oleDbConnection1.Open();

intR=this.oleDbDataAdapter3.Fill(dataSet21,"jsxxb");

this.oleDbConnection1.Close();

if(R==0)

...{

MessageBox.Show("该读者没有借这本书,无法完成还书操作!","还书提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

}

else

...{

stringBH=dataSet21.Tables["jsxxb"].Rows[0]["编号"].ToString();

System.Data.OleDb.OleDbCommandMyDel=this.oleDbConnection1.CreateCommand();

System.Data.OleDb.OleDbCommandMyUpdate=this.oleDbConnection1.CreateCommand();

mandText="UPDATEtsxxbSET在库数=在库数+1WHERE编号='"+this.textBox2.Text+"'";

mandText="DELETE*FROMjsxxbWHERE编号="+BH;

this.oleDbDataAdapter3.DeleteCommand=MyDel;

this.oleDbDataAdapter2.UpdateCommand=MyUpdate;

this.oleDbConnection1.Open();

MyDel.ExecuteNonQuery();

MyUpdate.ExecuteNonQuery();

this.oleDbConnection1.Close();

MessageBox.Show("该读者还书成功!","还书提示:",MessageBoxButtons.OK,MessageBoxIcon.Information);

this.textBox2.Focus();

}

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

JSXX();

}

}

}

public void SetForm1(Form1v)

... {//为窗体间传递数据做准备。

this.F=v;

}

private void textBox2_KeyPress( object sender,System.Windows.Forms.KeyPressEventArgse)

... {//当用户在图书编号输入框输入问号时显示书目查询窗口。

if(e.KeyChar==63)

textBox2_DoubleClick(null,null);

}

private void textBox2_DoubleClick( object sender,System.EventArgse)

... {//当用户在图书编号输入框双击时显示书目查询窗口。

smcx3MySmcx=newsmcx3();

MySmcx.MdiParent=F;

MySmcx.CXBH(this);

MySmcx.Show();

}

查询员工窗体代码

private void button3_Click( object sender,System.EventArgse)

... {//返回按钮,关闭当前窗口。

this.Close();

}

private void button2_Click( object sender,System.EventArgse)

... {//更新按钮,更新当前数据信息。

try

...{

this.oleDbConnection1.Open();

this.oleDbDataAdapter1.Fill(this.dataSet21,"ygxxb");

this.oleDbConnection1.Close();

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void button1_Click( object sender,System.EventArgse)

... {//查询所有员工信息按钮。

try

...{

this.dataSet21.Clear();

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

mandText="SELECT*FROMygxxb";

this.oleDbDataAdapter1.SelectCommand=MySelect;

this.oleDbConnection1.Open();

this.oleDbDataAdapter1.Fill(this.dataSet21,"ygxxb");

this.oleDbConnection1.Close();

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void button4_Click( object sender,System.EventArgse)

... {//按用户名查询员工信息。

try

...{

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

mandText="SELECT*FROMygxxbWHERE用户名='"+this.textBox1.Text+"'";

this.oleDbDataAdapter1.SelectCommand=MySelect;

this.dataSet21.Clear();

this.oleDbConnection1.Open();

this.oleDbDataAdapter1.Fill(this.dataSet21,"ygxxb");

this.oleDbConnection1.Close();

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void button5_Click( object sender,System.EventArgse)

... {//按姓名查询员工信息。

try

...{

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

mandText="SELECT*FROMygxxbWHERE姓名='"+this.textBox2.Text+"'";

this.oleDbDataAdapter1.SelectCommand=MySelect;

this.dataSet21.Clear();

this.oleDbConnection1.Open();

this.oleDbDataAdapter1.Fill(this.dataSet21,"ygxxb");

this.oleDbConnection1.Close();

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void button6_Click( object sender,System.EventArgse)

... {//返回按钮,关闭当前窗口。

this.Close();

}

private void button7_Click( object sender,System.EventArgse)

... {//返回按钮,关闭当前窗口。

this.Close();

}

private void cxyg_Load( object sender,System.EventArgse)

... {//设置当前焦点。

this.button1.Focus();

}

private void button6_KeyDown( object sender,System.Windows.Forms.KeyEventArgse)

... {//同上,按键处理。

switch((int)e.KeyCode)

...{

case13:

button4_Click(null,null);

break;

case27:

this.Close();

break;

case38:

case37:

if(this.button6.Focused)

...{

this.button4.Focus();

}

else

...{

if(this.button4.Focused)

...{

this.textBox1.Focus();

}

else

...{

if(this.textBox1.Focused)

...{

this.button6.Focus();

}

}

}

break;

case40:

case39:

if(this.textBox1.Focused)

...{

this.button4.Focus();

}

else

...{

if(this.button4.Focused)

...{

this.button6.Focus();

}

else

...{

if(this.button6.Focused)

...{

this.textBox1.Focus();

}

}

}

break;

}

}

private void button7_KeyDown( object sender,System.Windows.Forms.KeyEventArgse)

... {//同上,按键处理。

switch((int)e.KeyCode)

...{

case13:

button5_Click(null,null);

break;

case27:

this.Close();

break;

case38:

case37:

if(this.button7.Focused)

...{

this.button5.Focus();

}

else

...{

if(this.button5.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.button7.Focus();

}

}

}

break;

case40:

case39:

if(this.textBox2.Focused)

...{

this.button5.Focus();

}

else

...{

if(this.button5.Focused)

...{

this.button7.Focus();

}

else

...{

if(this.button7.Focused)

...{

this.textBox2.Focus();

}

}

}

break;

}

}

private void cxyg_Activated( object sender,System.EventArgse)

... {//设置当前焦点。

this.button1.Focus();

}

增加员工窗体代码

private void button3_Click( object sender,System.EventArgse)

... {//返回按钮,关闭当前窗口。

this.Close();

}

private void button2_Click( object sender,System.EventArgse)

... {//重填按钮。

this.textBox1.Text="";

this.textBox2.Text="";

this.textBox3.Text="否";

this.textBox4.Text="";

this.textBox5.Text="男";

this.textBox6.Text="";

this.textBox7.Text="";

this.textBox8.Text="";

this.textBox9.Text="";

this.textBox10.Text="";

this.textBox11.Text="";

this.textBox1.Focus();

}

private void button1_Click( object sender,System.EventArgse)

... {//增加员工按钮,输入合法的信息后开始增加员工。

try

...{

if(this.textBox1.Text=="")

...{

MessageBox.Show("用名不能为空,请输入用户名.","数据输入提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.textBox1.Focus();

}

else

...{

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

mandText="SELECT用户名FROMygxxbWHERE用户名='"+this.textBox1.Text+"'";

this.oleDbDataAdapter1.SelectCommand=MySelect;

this.oleDbConnection1.Open();

intIFUSER=this.oleDbDataAdapter1.Fill(this.dataSet21,"ygxxb");;

this.oleDbConnection1.Close();

if(IFUSER==0)

...{

if(this.textBox2.Text==""||this.textBox11.Text=="")

...{

MessageBox.Show("用户密码不能为空,请输入.","数据输入提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Text!=this.textBox11.Text)

...{

MessageBox.Show("两次密码不一样,请重新输入.","数据输入提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.textBox11.Focus();

}

else

...{

if(this.textBox4.Text=="")

...{

MessageBox.Show("用户姓名不能为空,请输入.","数据输入提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.textBox4.Focus();

}

else

...{

if(this.textBox3.Text=="")

...{

MessageBox.Show("是否为管理员不能为空!!!","数据输入提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.textBox3.Focus();

}

else

...{

if(this.textBox3.Text!="是"&this.textBox3.Text!="否")

...{

MessageBox.Show("管理员只有是与不是,请输入"是"或"否"","数据输入提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.textBox3.Focus();

}

else

...{

if(this.textBox5.Text=="")

...{

MessageBox.Show("用户性别不能为空,请输入.","数据输入提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.textBox5.Focus();

}

else

...{

if(this.textBox5.Text!="男"&this.textBox5.Text!="女")

...{

MessageBox.Show("用户性别只能为男或女,请重新输入.","数据输入提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.textBox5.Focus();

}

else

...{

System.Data.OleDb.OleDbCommandMyInsert=this.oleDbConnection1.CreateCommand();

mandText="INSERTINTOygxxb(用户名,密码,系统管理员,姓名,性别,手机,办公地址,ICQ,OICQ,电子邮箱)VALUES('"+this.textBox1.Text+"','"+this.textBox2.Text+"','"+this.textBox3.Text+"','"+this.textBox4.Text+"','"+this.textBox5.Text+"','"+this.textBox6.Text+"','"+this.textBox7.Text+"','"+this.textBox8.Text+"','"+this.textBox9.Text+"','"+this.textBox10.Text+"')";

this.oleDbDataAdapter1.InsertCommand=MyInsert;

this.oleDbConnection1.Open();

MyInsert.ExecuteNonQuery();

this.oleDbConnection1.Close();

MessageBox.Show("员工添加成功!!!","员工添加提示:",MessageBoxButtons.OK,MessageBoxIcon.Asterisk);

this.textBox1.Text="";

this.textBox2.Text="";

this.textBox3.Text="否";

this.textBox4.Text="";

this.textBox5.Text="男";

this.textBox6.Text="";

this.textBox7.Text="";

this.textBox8.Text="";

this.textBox9.Text="";

this.textBox10.Text="";

this.textBox11.Text="";

this.textBox1.Focus();

}

}

}

}

}

}

}

}

else

...{

MessageBox.Show("用名已经存在,请换用另外的用户名.","数据输入提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.textBox1.Focus();

}

}

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void textBox11_KeyDown( object sender,System.Windows.Forms.KeyEventArgse)

... {//同上,按键处理。

switch((int)e.KeyCode)

...{

case13:

button1_Click(null,null);

break;

case27:

this.Close();

break;

case38:

case37:

if(this.textBox10.Focused)

...{

this.textBox9.Focus();

}

else

...{

if(this.textBox9.Focused)

...{

this.textBox8.Focus();

}

else

...{

if(this.textBox8.Focused)

...{

this.textBox7.Focus();

}

else

...{

if(this.textBox7.Focused)

...{

this.textBox6.Focus();

}

else

...{

if(this.textBox6.Focused)

...{

this.textBox5.Focus();

}

else

...{

if(this.textBox5.Focused)

...{

this.textBox4.Focus();

}

else

...{

if(this.textBox4.Focused)

...{

this.textBox3.Focus();

}

else

...{

if(this.textBox3.Focused)

...{

this.textBox11.Focus();

}

else

...{

if(this.textBox11.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.textBox1.Focus();

}

else

...{

if(this.textBox1.Focused)

...{

this.textBox10.Focus();

}

}

}

}

}

}

}

}

}

}

}

break;

case40:

case39:

if(this.textBox1.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.textBox11.Focus();

}

else

...{

if(this.textBox11.Focused)

...{

this.textBox3.Focus();

}

else

...{

if(this.textBox3.Focused)

...{

this.textBox4.Focus();

}

else

...{

if(this.textBox4.Focused)

...{

this.textBox5.Focus();

}

else

...{

if(this.textBox5.Focused)

...{

this.textBox6.Focus();

}

else

...{

if(this.textBox6.Focused)

...{

this.textBox7.Focus();

}

else

...{

if(this.textBox7.Focused)

...{

this.textBox8.Focus();

}

else

...{

if(this.textBox8.Focused)

...{

this.textBox9.Focus();

}

else

...{

if(this.textBox9.Focused)

...{

this.textBox10.Focus();

}

else

...{

if(this.textBox10.Focused)

...{

this.textBox1.Focus();

}

}

}

}

}

}

}

}

}

}

}

break;

}

}

private void zjyg_Load( object sender,System.EventArgse)

... {//设置焦点,并设置部分默认值。

this.textBox1.Focus();

this.textBox3.Text="否";

this.textBox5.Text="男";

}

private void textBox6_TextChanged( object sender,System.EventArgse)

... {//不允许用户输入非数字数据。

strings="";

for(inti=0;i

if(Char.IsDigit(textBox6.Text[i])==true)

s=s+textBox6.Text[i].ToString();

textBox6.Text=s;

textBox6.SelectionStart=textBox6.Text.Length;

}

private void textBox8_TextChanged( object sender,System.EventArgse)

... {//不允许用户输入非数字数据。

strings="";

for(inti=0;i

if(Char.IsDigit(textBox8.Text[i])==true)

s=s+textBox8.Text[i].ToString();

textBox8.Text=s;

textBox8.SelectionStart=textBox8.Text.Length;

}

private void textBox9_TextChanged( object sender,System.EventArgse)

... {//不允许用户输入非数字数据

strings="";

for(inti=0;i

if(Char.IsDigit(textBox9.Text[i])==true)

s=s+textBox9.Text[i].ToString();

textBox9.Text=s;

textBox9.SelectionStart=textBox9.Text.Length;

}

删除员工窗体代码

private void button3_Click( object sender,System.EventArgse)

... {//更新按钮,更新当前数据记录。

try

...{

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

mandText="SELECT*FROMygxxb";

this.oleDbDataAdapter1.SelectCommand=MySelect;

this.dataSet21.Clear();

this.oleDbConnection1.Open();

this.oleDbDataAdapter1.Fill(this.dataSet21,"ygxxb");

this.oleDbConnection1.Close();

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void button1_Click( object sender,System.EventArgse)

... {//查询按钮,根据用户输入的信息查询相关记录。

stringComStr="";

try

...{

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

if(this.textBox1.Text!="")

...{

ComStr="SELECT*FROMygxxbWHERE用户名='"+this.textBox1.Text+"'";

}

else

...{

if(this.textBox2.Text!="")

...{

if(ComStr=="")

...{

ComStr="SELECT*FROMygxxbWHERE姓名='"+this.textBox2.Text+"'";

}

else

...{

ComStr+="AND姓名='"+this.textBox2.Text+"'";

}

}

if(this.textBox3.Text!="")

...{

if(ComStr=="")

...{

ComStr="SELECT*FROMygxxbWHERE手机='"+this.textBox3.Text+"'";

}

else

...{

ComStr+="AND手机='"+this.textBox3.Text+"'";

}

}

if(ComStr=="")

...{

MessageBox.Show("无查询条件,默认查找所有记录.","查找提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

ComStr="SELECT*FROMygxxb";

}

}

mandText=ComStr;

this.oleDbDataAdapter1.SelectCommand=MySelect;

this.dataSet21.Clear();

this.oleDbConnection1.Open();

this.oleDbDataAdapter1.Fill(dataSet21,"ygxxb");

this.oleDbConnection1.Close();

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void button2_Click( object sender,System.EventArgse)

... {//删除用户选中的记录,请用户确认。

try

...{

intReN=this.dataGrid1.CurrentRowIndex;

if(ReN==-1)

...{

MessageBox.Show("当前没有记录可以删除!!!","删除提示:",MessageBoxButtons.OK,MessageBoxIcon.Error);

}

else

...{

stringYHM=dataSet21.Tables["ygxxb"].Rows[ReN]["用户名"].ToString();

System.Data.OleDb.OleDbCommandMyDel=this.oleDbConnection1.CreateCommand();

mandText="DELETE*FROMygxxbWHERE用户名='"+YHM+"'";

this.oleDbDataAdapter1.DeleteCommand=MyDel;

if(MessageBox.Show("删除是不可恢复的,真的要删除吗?","删除提示:",MessageBoxButtons.YesNo,MessageBoxIcon.Exclamation)==DialogResult.Yes)

...{

this.oleDbConnection1.Open();

MyDel.ExecuteNonQuery();

this.oleDbConnection1.Close();

button3_Click(null,null);

}

}

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void scyg_Load( object sender,System.EventArgse)

... {//设置焦点。

this.textBox1.Focus();

}

private void textBox1_KeyDown( object sender,System.Windows.Forms.KeyEventArgse)

... {//同上,按键处理。

switch((int)e.KeyCode)

...{

case27:

this.Close();

break;

case13:

if(this.button1.Focused||this.textBox1.Focused||this.textBox2.Focused||this.textBox3.Focused)

...{

button1_Click(null,null);

}

if(this.button2.Focused)

...{

button2_Click(null,null);

}

if(this.button3.Focused)

...{

button3_Click(null,null);

}

if(this.button4.Focused)

...{

this.Close();

}

break;

case38:

case37:

if(this.textBox3.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.textBox1.Focus();

}

else

...{

if(this.textBox1.Focused)

...{

this.textBox3.Focus();

}

}

}

break;

case40:

case39:

if(this.textBox1.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.textBox3.Focus();

}

else

...{

if(this.textBox3.Focused)

...{

this.textBox1.Focus();

}

}

}

break;

}

}

private void button4_Click( object sender,System.EventArgse)

... {//返回按钮,关闭当前窗口。

this.Close();

}

private void button4_KeyDown( object sender,System.Windows.Forms.KeyEventArgse)

... {//同样,按键处理。

textBox1_KeyDown(null,null);

}

private void textBox3_TextChanged( object sender,System.EventArgse)

... {//只允许用户输入数字数据。

strings="";

for(inti=0;i

if(Char.IsDigit(textBox3.Text[i])==true)

s=s+textBox3.Text[i].ToString();

textBox3.Text=s;

textBox3.SelectionStart=textBox3.Text.Length;

}

private void dataGrid1_DoubleClick( object sender,System.EventArgse)

... {//用户双击当前记录,调用删除功能。

button2_Click(null,null);

}

员工资料修改窗体代码

private void button3_Click( object sender,System.EventArgse)

... {//返回按钮,关闭当前窗口。

this.Close();

}

private void button4_Click( object sender,System.EventArgse)

... {//返回按钮,关闭当前窗口。

this.Close();

}

private void zlxg_Load( object sender,System.EventArgse)

... {//设置当前焦点。

this.textBox1.Focus();

}

private void button2_Click( object sender,System.EventArgse)

... {//更新按钮,更新当前数据信息。

try

...{

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

mandText="SELECT*FROMygxxb";

this.oleDbDataAdapter1.SelectCommand=MySelect;

this.dataSet21.Clear();

this.oleDbConnection1.Open();

this.oleDbDataAdapter1.Fill(this.dataSet21,"ygxxb");

this.oleDbConnection1.Close();

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void button1_Click( object sender,System.EventArgse)

... {//查询按钮,根据用户提供信息查询相关信息。

stringComStr="";

try

...{

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

if(this.textBox1.Text!="")

...{

ComStr="SELECT*FROMygxxbWHERE用户名='"+this.textBox1.Text+"'";

}

else

...{

if(this.textBox2.Text!="")

...{

if(ComStr=="")

...{

ComStr="SELECT*FROMygxxbWHERE姓名='"+this.textBox2.Text+"'";

}

else

...{

ComStr+="AND姓名='"+this.textBox2.Text+"'";

}

}

if(this.textBox3.Text!="")

...{

if(ComStr=="")

...{

ComStr="SELECT*FROMygxxbWHERE手机='"+this.textBox3.Text+"'";

}

else

...{

ComStr+="AND手机='"+this.textBox3.Text+"'";

}

}

if(ComStr=="")

...{

MessageBox.Show("无查询条件,默认查找所有记录.","查找提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

ComStr="SELECT*FROMygxxb";

}

}

mandText=ComStr;

this.oleDbDataAdapter1.SelectCommand=MySelect;

this.dataSet21.Clear();

this.oleDbConnection1.Open();

this.oleDbDataAdapter1.Fill(dataSet21,"ygxxb");

this.oleDbConnection1.Close();

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void button3_Click_1( object sender,System.EventArgse)

... {//保存按钮,保存用户修改的信息。

try

...{

this.oleDbConnection1.Open();

this.oleDbDataAdapter1.Update(this.dataSet21,"ygxxb");

this.oleDbConnection1.Close();

MessageBox.Show("信息已经保存.","保存提示:",MessageBoxButtons.OK,MessageBoxIcon.Information);

this.dataSet21.Clear();

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void button2_KeyDown( object sender,System.Windows.Forms.KeyEventArgse)

... {//同上,按键处理。

switch((int)e.KeyCode)

...{

case27:

this.Close();

break;

case13:

if(this.button1.Focused||this.textBox1.Focused||this.textBox2.Focused||this.textBox3.Focused)

...{

button1_Click(null,null);

}

if(this.button2.Focused)

...{

button2_Click(null,null);

}

if(this.button3.Focused)

...{

button3_Click(null,null);

}

if(this.button4.Focused)

this.Close();

break;

case38:

case37:

if(this.textBox3.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.textBox1.Focus();

}

else

...{

if(this.textBox1.Focused)

...{

this.textBox3.Focus();

}

}

}

break;

case40:

case39:

if(this.textBox1.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.textBox3.Focus();

}

else

...{

if(this.textBox3.Focused)

...{

this.textBox1.Focus();

}

}

}

break;

}

}

private void textBox3_TextChanged( object sender,System.EventArgse)

... {//不允许用户输入非数字数据。

strings="";

for(inti=0;i

if(Char.IsDigit(textBox3.Text[i])==true)

s=s+textBox3.Text[i].ToString();

textBox3.Text=s;

textBox3.SelectionStart=textBox3.Text.Length;

}

密码修改窗体代码

private void textBox1_TextChanged( object sender,System.EventArgse)

... {//根据用户是否输入有信息而改变按钮提示。

if(this.textBox1.Text!=""||this.textBox2.Text!=""||this.textBox3.Text!=""||this.textBox4.Text!="")

...{

this.button2.Text="重填";

}

else

...{

this.button2.Text="返回";

}

}

private void textBox2_TextChanged( object sender,System.EventArgse)

... {//根据用户是否输入有信息而改变按钮提示。

textBox1_TextChanged(null,null);

}

private void textBox3_TextChanged( object sender,System.EventArgse)

... {//根据用户是否输入有信息而改变按钮提示。

textBox1_TextChanged(null,null);

}

private void textBox4_TextChanged( object sender,System.EventArgse)

... {//根据用户是否输入有信息而改变按钮提示。

textBox1_TextChanged(null,null);

}

private void mmxg_Load( object sender,System.EventArgse)

... {//设置当前焦点。

this.textBox1.Focus();

}

private void button2_Click( object sender,System.EventArgse)

... {//根据按钮信息实现清除信息或退出。

if(this.button2.Text=="重填")

...{

this.textBox1.Text="";

this.textBox2.Text="";

this.textBox3.Text="";

this.textBox4.Text="";

this.textBox1.Focus();

}

else

...{

this.Close();

}

}

private void button1_Click( object sender,System.EventArgse)

... {//符合条件就开始修改密码。

try

...{

System.Data.OleDb.OleDbCommandMySelect=this.oleDbConnection1.CreateCommand();

mandText="SELECT用户名FROMygxxbWHERE用户名='"+this.textBox1.Text+"'and密码='"+this.textBox2.Text+"'";

this.oleDbDataAdapter1.SelectCommand=MySelect;

System.Data.OleDb.OleDbCommandMyUpdata=this.oleDbConnection1.CreateCommand();

mandText="UPDATEygxxbSET密码='"+this.textBox3.Text+"'WHERE用户名='"+this.textBox1.Text+"'";

this.oleDbDataAdapter1.UpdateCommand=MyUpdata;

if(this.textBox1.Text=="")

...{

MessageBox.Show("请输入用户名!!!","修改提示:",MessageBoxButtons.OK,MessageBoxIcon.Information);

this.textBox1.Focus();

}

else

...{

if(this.textBox2.Text=="")

...{

MessageBox.Show("请输入当前密码,否则无权修改密码!!!","修改提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.textBox2.Focus();

}

else

...{

if(this.textBox3.Text=="")

...{

MessageBox.Show("为了安全,请输入新密码!!!","修改提示:",MessageBoxButtons.OK,MessageBoxIcon.Information);

this.textBox3.Focus();

}

else

...{

if(this.textBox3.Text!=this.textBox4.Text)

...{

MessageBox.Show("两次密码不一样!重新输入.","修改提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.textBox4.Focus();

}

else

...{

this.oleDbConnection1.Open();

intIf=this.oleDbDataAdapter1.Fill(this.dataSet21,"ygxxb");

this.oleDbConnection1.Close();

if(If==0)

...{

MessageBox.Show("当前密码错误,你无权修改!!!","修改提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

this.Close();

}

else

...{

this.oleDbConnection1.Open();

MyUpdata.ExecuteNonQuery();

this.oleDbConnection1.Close();

MessageBox.Show("密码修改成功,请记住你的新密码.","修改提示:",MessageBoxButtons.OK,MessageBoxIcon.Information);

this.Close();

}

}

}

}

}

}

catch(ExceptionExc)

...{

MessageBox.Show(Exc.Message);

this.oleDbConnection1.Close();

}

}

private void button1_KeyDown( object sender,System.Windows.Forms.KeyEventArgse)

... {//同上,按键处理。

intKey=(int)e.KeyCode;

switch(Key)

...{

case27:

this.Close();

break;

case13:

this.button1_Click(null,null);

break;

case38:

case37:

if(this.textBox1.Focused)

...{

this.button2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.textBox1.Focus();

}

else

...{

if(this.textBox3.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox4.Focused)

...{

this.textBox3.Focus();

}

else

...{

if(this.button1.Focused)

...{

this.textBox4.Focus();

}

else

...{

if(this.button2.Focused)

...{

this.button1.Focus();

}

}

}

}

}

}

break;

case40:

case39:

if(this.textBox1.Focused)

...{

this.textBox2.Focus();

}

else

...{

if(this.textBox2.Focused)

...{

this.textBox3.Focus();

}

else

...{

if(this.textBox3.Focused)

...{

this.textBox4.Focus();

}

else

...{

if(this.textBox4.Focused)

...{

this.button1.Focus();

}

else

...{

if(this.button1.Focused)

...{

this.button2.Focus();

}

}

}

}

}

break;

}

}

锁定系统功能的实现代码

private void menuItemsd_Click( object sender,System.EventArgse)

... {//提示用户,然后调用主窗口的登录窗口。

MessageBox.Show("请注意思关闭不安全的窗口!!!","锁定提示:",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

Form1_Load(null,null);

}

帮助窗体代码

private void bz_Load( object sender,System.EventArgse)

... {//打开帮助文件并显示其中的内容。

StreamtheStream=null;

try

...{

FileInfoFile=newFileInfo("./Help.hp");

intbyteCount=(int)File.Length;

byte[]buffer=newbyte[byteCount];

theStream=File.Open(System.IO.FileMode.Open,System.IO.FileAccess.Read,System.IO.FileShare.None);

theStream.Read(buffer,0,byteCount);

this.textBox1.Text=System.Text.Encoding.Default.GetString(buffer,0,byteCount);

theStream.Close();

}

catch(ExceptionExc)

...{

MessageBox.Show("帮助文件丢失,或"+Exc,"系统提示:",MessageBoxButtons.OK,MessageBoxIcon.Error);

theStream.Close();

}

}

关于实训窗体代码

private void gy_Click( object sender,System.EventArgse)

... {//当用户单击窗体任意地方时关闭当前窗口。

this.Close();

}

工具栏相关代码

private void toolBar1_ButtonClick( object sender,System.Windows.Forms.ToolBarButtonClickEventArgse)

... {//根据提示调用相关功能。

switch(e.Button.Text)

...{

case"借书":

menuItemjsgl_Click(null,null);

break;

case"还书":

menuItemhsgl_Click(null,null);

break;

case"查书":

menuItemsmcx_Click(null,null);

break;

case"查读者":

menuItemdzcx_Click(null,null);

break;

case"查员工":

menuItemcxyg_Click(null,null);

break;

case"密码":

menuItemmmxg_Click(null,null);

break;

case"锁定":

menuItemsdxt_Click(null,null);

break;

case"隐藏":

this.toolBar1.Visible=false;

break;

case"帮助":

menuItemsysm_Click(null,null);

break;

}

}

右键相关代码

在相关的菜单单击事件中已调用。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。