c图书馆管理系统.docx

上传人:b****5 文档编号:28138295 上传时间:2023-07-08 格式:DOCX 页数:21 大小:37.23KB
下载 相关 举报
c图书馆管理系统.docx_第1页
第1页 / 共21页
c图书馆管理系统.docx_第2页
第2页 / 共21页
c图书馆管理系统.docx_第3页
第3页 / 共21页
c图书馆管理系统.docx_第4页
第4页 / 共21页
c图书馆管理系统.docx_第5页
第5页 / 共21页
点击查看更多>>
下载资源
资源描述

c图书馆管理系统.docx

《c图书馆管理系统.docx》由会员分享,可在线阅读,更多相关《c图书馆管理系统.docx(21页珍藏版)》请在冰豆网上搜索。

c图书馆管理系统.docx

c图书馆管理系统

1、绪论2

2、数据库设计3

2.1数据库分析3

2.1创建数据库4

3、界面设计4

3.1登陆界面4

3.2图书管理系统界面8

3.3图书信息界面9

3.4图书归还界面11

3.5图书借阅界面13

3.6用户信息界面15

3.7管理员界面16

3.8注册界面18

3.9添加图书界面19

4、系统测试21

4.1登陆功能21

4.2借阅图书功能22

4.3归还图书库功能22

4.4图书信息功能23

4.5管理员登陆功能23

4.6添加图书功能24

4.7用户信息24

5、连接数据库24

5.1连接数据库25

5.2操作数据库中的数据25

6、总结27

1、绪论

2、数据库设计

2.1数据库分析

本系统利用VisualStudio2010处理数据库的功能,实现对图书馆信息的管理。

主要功能为管理有关用户、管理员、书籍和借阅的信息等。

  本系统的结构分为用户信息管理模块、书籍信息管理模块、借阅信息管理模块、管理者管理信息模块和查询处理模块。

图书馆管理系统框图如图所示

失败

成功

2.2创建数据库

3、界面设计

3.1登陆界面

amespace图书管理系统

{

publicpartialclassForm1:

Form

{

publicForm1()

{

InitializeComponent();

}

publicstaticFormfm=null;

privatestaticintErrorTimes=0;

privatevoidbutton3_Click(objectsender,EventArgse)

{

this.Close();

}

privatevoidtextBox1_TextChanged(objectsender,EventArgse)

{

}

privatevoidbutton1_Click(objectsender,EventArgse)

{

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

{MessageBox.Show("提示:

请输入用户名和密码!

","警告");}

SqlConnectionconn=newSqlConnection(Security=true;DataBase=图书管理系统");

conn.Open();

SqlCommandcmd=newSqlCommand("select*fromTable_1whereid='"+textB+"'andus='"++"'",conn);

SqlDataReadersdr=cmd.ExecuteReader();

sdr.Read();

if(sdr.HasRows)

{

MessageBox.Show("登录成功!

","提示");

Form2fm=newForm2();

fm.Show();

this.Hide();

}

else

{

ErrorTimes++;

MessageBox.Show("用户名或密码不正确!

您还有"+(3-ErrorTimes)+"次输入密码的机会,请重新输入!

如果超过3次,系统将自动关闭");

if(ErrorTimes>=3)

{

ErrorTimes=0;

conn.Close();

}

}

}

privatevoidForm1_Load(objectsender,EventArgse)

{

}

privatevoidbutton4_Click(objectsender,EventArgse)

{

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

{MessageBox.Show("提示:

请输入用户名和密码!

","警告");}

SqlConnectionconn=newSqlConnection(Security=true;DataBase=图书管理系统");

conn.Open();

SqlCommandcmd=newSqlCommand("select*fromTable_2whereuid='"+text+"'andusr='"++"'",conn);

SqlDataReadersdr=cmd.ExecuteReader();

sdr.Read();

if(sdr.HasRows)

{

MessageBox.Show("登录成功!

","提示");

Form7fm=newForm7();

fm.Show();

this.Hide();

}

else

{

ErrorTimes++;

MessageBox.Show("用户名或密码不正确!

您还有"+(3-ErrorTimes)+"次输入密码的机会,请重新输入!

如果超过3次,系统将自动关闭");

if(ErrorTimes>=3)

{

ErrorTimes=0;

conn.Close();

}

}

}

privatevoidbutton2_Click(objectsender,EventArgse)

{

Form8f1=newForm8();

f1.Show();

}

privatevoidbutton5_Click(objectsender,EventArgse)

{

this.Hide();

Form10f2=newForm10();

f2.Show();

}

}

}

3.2图书管理系统界面

namespace图书管理系统

{

publicpartialclassForm2:

Form

{

publicForm2()

{

InitializeComponent();

}

privatevoidbutton5_Click(objectsender,EventArgse)

{

this.Close();

}

privatevoidbutton3_Click(objectsender,EventArgse)

{

Form3f2=newForm3();

f2.Show();

this.Close();

MessageBox.Show("您已成功进入----图书信息!

");

}

privatevoidbutton2_Click(objectsender,EventArgse)

{

Form4f4=newForm4();

f4.Show();

this.Close();

MessageBox.Show("您已成功进入----还书系统!

");

}

privatevoidbutton1_Click(objectsender,EventArgse)

{

Form5f5=newForm5();

f5.Show();

this.Close();

MessageBox.Show("您已成功进入----借书系统!

");

}

}

}

3.3图书信息

namespace图书管理系统

{

publicpartialclassForm3:

Form

{

publicForm3()

{

InitializeComponent();

}

privatevoidForm3_Load(objectsender,EventArgse)

{

//TODO:

这行代码将数据加载到表“图书管理系统DataSet.Table_3”中。

您可以根据需要移动或删除它。

this.table_3TableAdapter.Fill(this.图书管理系统DataSet.Table_3);

}

privatevoidtextBox1_TextChanged(objectsender,EventArgse)

{

}

privatevoidbutton1_Click(objectsender,EventArgse)

{

this.Close();

}

}

}

3.4归还图书

namespace图书管理系统

{

publicpartialclassForm4:

Form

{

publicForm4()

{

InitializeComponent();

}

privatevoidbutton1_Click(objectsender,EventArgse)

{

if(textBox1.Text=="")

{MessageBox.Show("提示:

请输入所借书籍编号!

","警告");}

SqlConnectionconn=newSqlConnection(Security=true;DataBase=图书管理系统");

conn.Open();

SqlCommandcmd=newSqlCommand("select*fromTable_4wheresid='"++"'",conn);

SqlDataReadersdr=cmd.ExecuteReader();

sdr.Read();

if(sdr.HasRows)

{MessageBox.Show("该书已还","提示");}

else

{

sdr.Close();

stringmyinsert="insertintoTable_4(sid)values('"+textBox1.Text+"')";

SqlCommandmycom=newSqlCommand(myinsert,conn);

mycom.ExecuteNonQuery();

conn.Close();

conn.Dispose();

MessageBox.Show("您已还书成功!

");

}

}

privatevoidForm4_Load(objectsender,EventArgse)

{

//TODO:

这行代码将数据加载到表“图书管理系统DataSet.Table_4”中。

您可以根据需要移动或删除它。

this.table_4TableAdapter.Fill(this.图书管理系统DataSet.Table_4);

//TODO:

这行代码将数据加载到表“图书管理系统DataSet.Table_3”中。

您可以根据需要移动或删除它。

this.table_3TableAdapter.Fill(this.图书管理系统DataSet.Table_3);

}

privatevoidbutton2_Click(objectsender,EventArgse)

{

this.Close();

Form2f2=newForm2();

f2.Show();

}

}

}

3.5已借图书

namespace图书管理系统

{

publicpartialclassForm5:

Form

{

publicForm5()

{

InitializeComponent();

}

privatevoidbutton1_Click(objectsender,EventArgse)

{

this.Close();

Form2f2=newForm2();

f2.Show();

}

privatevoidForm5_Load(objectsender,EventArgse)

{

//TODO:

这行代码将数据加载到表“图书管理系统DataSet.Table_4”中。

您可以根据需要移动或删除它。

this.table_4TableAdapter.Fill(this.图书管理系统DataSet.Table_4);

//TODO:

这行代码将数据加载到表“图书管理系统DataSet.Table_3”中。

您可以根据需要移动或删除它。

this.table_3TableAdapter.Fill(this.图书管理系统DataSet.Table_3);

}

privatevoidbutton2_Click(objectsender,EventArgse)

{

if(textBox1.Text=="")

{MessageBox.Show("提示:

请输入所借书籍编号!

","警告");}

SqlConnectionconn=newSqlConnection(Security=true;DataBase=图书管理系统");

conn.Open();

SqlCommandcmd=newSqlCommand("select*fromTable_4wheresid='"++"'",conn);

SqlDataReadersdr=cmd.ExecuteReader();

sdr.Read();

if(sdr.HasRows)

{MessageBox.Show("该书已借","提示");}

else

{

sdr.Close();

stringmyinsert="insertintoTable_4(sid)values('"+textBox1.Text+"')";

SqlCommandmycom=newSqlCommand(myinsert,conn);

mycom.ExecuteNonQuery();

conn.Close();

conn.Dispose();

MessageBox.Show("您已借书成功!

");

}

}

privatevoidtextBox2_TextChanged(objectsender,EventArgse)

{

}

}

3.6用户信息

namespace图书管理系统

{

publicpartialclassForm6:

Form

{

publicForm6()

{

InitializeComponent();

}

privatevoidForm6_Load(objectsender,EventArgse)

{

//TODO:

这行代码将数据加载到表“图书管理系统DataSet.Table_1”中。

您可以根据需要移动或删除它。

this.table_1TableAdapter.Fill(this.图书管理系统DataSet.Table_1);

}

privatevoidbutton1_Click(objectsender,EventArgse)

{

this.Close();

}

}

}

3.7管理员主界面

namespace图书管理系统

{

publicpartialclassForm7:

Form

{

publicForm7()

{

InitializeComponent();

}

privatevoidbutton2_Click(objectsender,EventArgse)

{

Form6f1=newForm6();

f1.Show();

MessageBox.Show("您已成功进入----用户信息!

");

}

privatevoidbutton3_Click(objectsender,EventArgse)

{

Form3f2=newForm3();

f2.Show();

MessageBox.Show("您已成功进入----图书信息!

");

}

privatevoidbutton1_Click(objectsender,EventArgse)

{

Form9f2=newForm9();

f2.Show();

MessageBox.Show("您已成功进入----添加图书系统!

");

}

privatevoidbutton4_Click(objectsender,EventArgse)

{

this.Close();

}

}

}

3.8注册界面

namespace图书管理系统

{

publicpartialclassForm8:

Form

{

publicForm8()

{

InitializeComponent();

}

privatevoidbutton1_Click(objectsender,EventArgse)

{

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

{MessageBox.Show("提示:

请输入用户名和密码!

","警告");}

SqlConnectionconn=newSqlConnection(Security=true;DataBase=图书管理系统");

conn.Open();

SqlCommandcmd=newSqlCommand("select*fromtable_1whereid='"++"'andus='"++"'",conn);

SqlDataReadersdr=cmd.ExecuteReader();

sdr.Read();

if(sdr.HasRows)

{MessageBox.Show("该用户已注册,请使用其他用户名","提示");}

else

{

sdr.Close();

stringmyinsert="insertintotable_1(id,us)values('"+textBox1.Text+"','"+textBox2.Text+"')";

SqlCommandmycom=newSqlCommand(myinsert,conn);

mycom.ExecuteNonQuery();

conn.Close();

conn.Dispose();

MessageBox.Show("您已注册成功!

");

}

}

privatevoidbutton2_Click(objectsender,EventArgse)

{

this.Close();

}

privatevoidForm8_Load(objectsender,EventArgse)

{

}

}

}

3.9添加图书

namespace图书管理系统

{

publicpartialclassForm9:

Form

{

publicForm9()

{

InitializeComponent();

}

privatevoidbutton2_Click(objectsender,EventArgse)

{

}

privatevoidbutton1_Click(objectsender,EventArgse)

{

SqlConnectionconn=newSqlConnection(Security=true");

stringsql="insertintoTable_3(sid,sdata,sname)values('"+textBox1.Text+"','"+textBox2.Text+"','"+textBox3.Text+"')";

conn.Open();

SqlCommandcomm=newSqlCommand(sql,conn);

if(conn.State==ConnectionState.Closed)

{

conn.Open();

}

if(Convert.ToInt32(comm.ExecuteNonQuery())>0)

{

label4.Text="成功!

";

MessageBox.Show("您已成功添加数据!

");

}

else

{

label4.Text="失败!

";

}

}

}

}

4、系统测试

登陆

借阅图书

归还图书

图书信息

管理员登陆

添加图书

用户信息

5、连接数据库

为数据库BookManage和本系统之间建立一个数据连接。

  

(1)在服务器资源管理器中右击“数据连接”节点(VS2008中操作)。

在弹出的快捷菜单中执行“添加连接”命令,打开DataLinkProperties对话框。

切换到Provider选项卡,选中列表框中的MicrosoftOLEDBProviderforSQLServer项。

单击“下一步”切换到Connection选项卡。

(2)在其中的第一个下拉列表框中选择数据库所在服务器名称。

输入登录服务器信息后选择数据库BookManage,然后单击测试按钮。

如果测试成功,单击“确定”按钮。

5.1连接数据库

(1)定义数据库连接字符串,代码如下:

PrivatestaticstringConnectString="DataSource=(local)\\sqlexpress;DataBase=BookManage.mdf";

(2)创建Connection对象,代码如下:

SqlConnectioncon=newSqlConnection(ConnectString);

(3)打开连接,代码如下:

con.Open();

(4)关闭连接,代码如下:

con.Close();

5.2操作数据库中的数据

usingSystem;

using

usingSystem.Linq;

usingSystem.Text;

usingSystem.Data;

using

namespaceBookManage

{classDataAccess

{privatestaticstringConnectString=@"DataSource=SQLEXPRESS;AttachDbFilename=F:

\BookManage\data\BookManage.mdf;IntegratedSecurity=False";//数据库连接字符串

///

///根据表名获取数据集的表

///

///

///

publicstaticDataTableGetDataSetByTableName(stringtable)

{using(SqlConnectioncon=newSqlConnection(ConnectString))//创建数据库连接对象

{stringsql="select*from"+table+"";//查询sql语句

try

{SqlDataAdapteradapter=newSqlDataAdapter(sql,con);//创建适配器对象

DataSetds=newDataSet();//创建数据集对象

adapter.Fill(ds,"table");//填充数据集

returnds.Tables[0];//返回数据表}

catch(SqlExceptionex)

{thrownewException(ex.Message);;}}}

publicstaticDataSetGetDataSetBySql(stringsql)

{using(SqlConnectioncon=newSqlConnection(ConnectString))//创建数据库连接对象

{SqlDataAdapteradapter=newSqlDataAdapter(sql,con);//创建适配器对象

DataSetds=newDataSet();//创建数据集对象

try

{adapter.Fill(ds);//填充数据集

returnds;//返回数据集}

catch(SqlExceptionex)

{thrownewException(ex.Message)}}

publicstaticSqlDataReaderGetDataReaderByID(intid)

{using(SqlConnectioncon=newSqlConnection(ConnectString))

{stringsql="select*frombo

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 高考

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1