版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、目录1、绪论12、数据库设计12.1数据库分析12.1创建数据库43、界面设计43.1登陆界面43.2图书管理系统界面83.3图书信息界面93.4图书归还界面113.5图书借阅界面133.6用户信息界面153.7管理员界面163.8注册界面183.9添加图书界面194、系统测试214.1登陆功能214.2借阅图书功能224.3归还图书库功能224.4图书信息功能234.5管理员登陆功能234.6添加图书功能244.7用户信息245、连接数据库245.1连接数据库255.2操作数据库中的数据256、总结271、绪论2、数据库设计2.1数据库分析本系统利用VisualStudio2010处理数据库
2、的功能,实现对图书馆信息的管理。主要功能为管理有关用户、管理员、书籍和借阅的信息等。本系统的结构分为用户信息管理模块、书籍信息管理模块、借阅信息管理模块、管理者管理信息模块和查询处理模块。图书馆管理系统框图如图所示22创建数据库列容允许Mullifidncharl-OU5-nchr10允许Mullifuidnchar10)团usirnchar10画nB列名允许Nullf卜sidnchar(lO)Ssdatanchar(lO)圍snamenchar(lO)n列容允许MullIidTKhar(lO)Sn3、界面设计3.1登陆界面amespace图书管理系统publicpartialclassFor
3、ml:FormpublicForml()InitializeComponent();publicstaticFormfm=null;privatestaticintErrorTimes=0;privatevoidbutton3_Click(objectsender,EventArgse)this.Close();privatevoidtextBox1_TextChanged(objectsender,EventArgse)privatevoidbutton1_Click(objectsender,EventArgse)if(textBox1.Text=""|textBox2
4、.Text="")MessageBox.Show("提示:请输入用户名和密码!","警告");SqlConnectionconn=newSqlConnection("Server二PC_201402131602;IntegratedSecurity二true;DataBase=|图书管理系统");conn.Open();SqlCommandcmd=newSqlCommand("select*fromTable_1whereid='"+textBox1.Text.Trim()+"
5、'andus='"+textBox2.Text.Trim()+"'",conn);SqlDataReadersdr=cmd.ExecuteReader();sdr.Read();if(sdr.HasRows)MessageBox.Show("登录成功!","提示");Form2fm=newForm2();fm.Show();this.Hide();elseErrorTimes+;MessageBox.Show("用户名或密码不正确!您还有"+(3-ErrorTimes)+"
6、;次输入密码的机会,请重新输入!如果超过3次,系统将自动关闭");if(ErrorTimes>=3)ErrorTimes=0;conn.Close();privatevoidForm1_Load(objectsender,EventArgse)privatevoidbutton4_Click(objectsender,EventArgse)if(textBox1.Text=""|textBox2.Text="")MessageBox.Show("提示:请输入用户名和密码!","警告");SqlCon
7、nectionconn=newSqlConnection("Server二PC_201402131602;IntegratedSecurity二true;DataBase=|图书管理系统");conn.Open();SqlCommandcmd=newSqlCommand("select*fromTable_2whereuid='"+textBox1.Text.Trim()+"'andusr='"+textBox2.Text.Trim()+"'",conn);SqlDataReader
8、sdr=cmd.ExecuteReader();sdr.Read();if(sdr.HasRows)MessageBox.Show("登录成功!","提示");Form7fm=newForm7();fm.Show();this.Hide();elseErrorTimes+;MessageBox.Show("用户名或密码不正确!您还有"+(3-ErrorTimes)+次输入密码的机会,请重新输入!如果超过3次,系统将自动关闭);if(ErrorTimes>=3)ErrorTimes=0;conn.Close();privatevo
9、idbutton2_Click(objectsender,EventArgse)Form8fl二newForm8();fl.Show();privatevoidbutton5_Click(objectsender,EventArgse)this.Hide();Form10f2=newForm10();f2.Show();叫登?®面|=|回|圧|welcome3.2图书管理系统界面namespace图书管理系统publicpartialclassForm2:FormpublicForm2()InitializeComponent();privatevoidbutton5_Click(o
10、bjectsender,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("您已成功进入还书系统!");
11、privatevoidbutton1_Click(objectsender,EventArgse)Form5f5=newForm5();f5.Show();this.Close();MessageBox.Show("您已成功进入借书系统!");3.3图书信息namespace图书管理系统publicpartialclassForm3:FormpublicForm3()InitializeComponent();privatevoidForm3_Load(objectsender,EventArgse)/TODO:这行代码将数据加载到表“图书管理系统DataSet.Table
12、_3”中。您可以根据需要移动或删除它。this.table_3TableAdapter.Fill(this.图书管理系统DataSet.Table_3);privatevoidtextBoxl_TextChanged(objectsender,EventArgse)privatevoidbuttonl_Click(objectsender,EventArgse)this.Close();3.4归还图书namespace图书管理系统publicpartialclassForm4:FormpublicForm4()InitializeComponent();privatevoidbutton1_C
13、lick(objectsender,EventArgse)if(textBox1.Text="")MessageBox.Show(提示:请输入所借书籍编号!","警告);SqlConnectionconn=newSqlConnection("Server二PC_201402131602;IntegratedSecurity二true;DataBase=|图书管理系统");conn.Open();SqlCommandcmd=newSqlCommand("select*fromTable_4wheresid='"
14、;+textBox1.Text.Trim()+"'",conn);SqlDataReadersdr=cmd.ExecuteReader();sdr.Read();if(sdr.HasRows)MessageBox.Show("该书已还","提示");elsesdr.Close();stringmyinsert="insertintoTable_4(sid)values('"+textBox1.Text+"')"SqlCommandmycom=newSqlCommand(m
15、yinsert,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
16、_3”中。您可以根据需要移动或删除它。this.table_3TableAdapter.Fill(this.图书管理系统DataSet.Table_3);privatevoidbutton2_Click(objectsender,EventArgse)this.Close();Form2f2=newForm2();f2.Show();3.5已借图书namespace图书管理系统publicpartialclassForm5:FormpublicForm5()InitializeComponent();privatevoidbutton1_Click(objectsender,EventArgs
17、e)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.图书管理系
18、统DataSet.Table_3);if(textBox1.Text="")MessageBox.Show(提示:请输入所借书籍编号!","警告);privatevoidbutton2_Click(objectsender,EventArgse)SqlConnectionconn=newSqlConnection("Server二PC_201402131602;IntegratedSecurity二true;DataBase=|图书管理系统");conn.Open();SqlCommandcmd=newSqlCommand("
19、;select*fromTable_4wheresid='"+textBox1.Text.Trim()+"'",conn);SqlDataReadersdr=cmd.ExecuteReader();sdr.Read();if(sdr.HasRows)MessageBox.Show("该书已借",”提示");elsesdr.Close();stringmyinsert="insertintoTable_4(sid)values('"+textBox1.Text+"')&quo
20、t;SqlCommandmycom=newSqlCommand(myinsert,conn);mycom.ExecuteNonQuery();conn.Close();conn.Dispose();MessageBox.Show(您已借书成功!);privatevoidtextBox2_TextChanged(objectsender,EventArgse)3.6用户信息namespace图书管理系统publicpartialclassForm6:FormpublicForm6()InitializeComponent();privatevoidForm6_Load(objectsender,
21、EventArgse)/TODO:这行代码将数据加载到表“图书管理系统DataSet.Table_1”中。您可以根据需要移动或删除它。this.table_1TableAdapter.Fill(this.图书管理系统DataSet.Table_1);this.Close();privatevoidbutton2_Click(objectsender,EventArgse)用户信息1=1回3.7管理员主界面namespace图书管理系统publicpartialclassForm7:FormpublicForm7()InitializeComponent();privatevoidbutton2
22、_Click(objectsender,EventArgse)Form6fl=newForm6();fl.Show();MessageBox.Show("您已成功进入用户信息!");Form3f2=newForm3();f2.Show();privatevoidbutton3_Click(objectsender,EventArgse)MessageBox.Show("您已成功进入图书信息!");privatevoidbuttonl_Click(objectsender,EventArgse)Form9f2=newForm9();f2.Show();Me
23、ssageBox.Show("您已成功进入添加图书系统!");privatevoidbutton4_Click(objectsender,EventArgse)this.Close();3.8注册界面namespace图书管理系统publicpartialclassForm8:FormpublicForm8()InitializeComponent();privatevoidbutton1_Click(objectsender,EventArgse)if(textBox1.Text=""|textBox2.Text="")Messag
24、eBox.Show("提示:请输入用户名和密码!","警告");SqlConnectionconn=newSqlConnection("Server二PC_201402131602;IntegratedSecurity二true;DataBase=|图书管理系统");conn.Open();SqlCommandcmd=newSqlCommand("select*fromtable_1whereid='"+textBox1.Text.Trim()+"'andus='"+te
25、xtBox2.Text.Trim()+"'",conn);SqlDataReadersdr=cmd.ExecuteReader();sdr.Read();if(sdr.HasRows)MessageBox.Show("该用户已注册,请使用其他用户名","提示");elsesdr.Close();stringmyinsert="insertintotable_1(id,us)values('"+textBox1.Text+"','"+textBox2.Text+&q
26、uot;')"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图书管理系统publicpartialclassFo
27、rm9:FormpublicForm9()InitializeComponent();privatevoidbutton2_Click(objectsender,EventArgse)privatevoidbutton1_Click(objectsender,EventArgse)SqlConnectionconn=newSqlConnection("server二PC_201402131602;database二图书管理系统;integratedSecurity=true");stringsql="insertintoTable_3(sid,sdata,snam
28、e)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="成功!&qu
29、ot;MessageBox.Show("您已成功添加数据!");elselabel4.Text="失败!"4、系统测试登陆借阅图书归还图书图书信息管理员登陆添加图书用户信息5、连接数据库为数据库BookManage和本系统之间建立一个数据连接。(1) 在服务器资源管理器中右击“数据连接”节点(VS2008中操作)。在弹出的快捷菜单中执行“添加连接”命令,打开DataLinkProperties对话框。切换到Provider选项卡,选中列表框中的MicrosoftOLEDBProviderforSQLServer项。单击“下一步”切换到Connection
30、选项卡。(2) 在其中的第一个下拉列表框中选择数据库所在服务器名称。输入登录服务器信息后选择数据库BookManage,然后单击测试按钮。如果测试成功,单击“确定”按钮。5.1连接数据库(1) 定义数据库连接字符串,代码如下:PrivatestaticstringConnectString="DataSource=(local)sqlexpress;DataBase=BookManage.mdf"(2) 创建Connection对象,代码如下:SqlConnectioncon=newSqlConnection(ConnectString);(3) 打开连接,代码如下:con
31、.Open();(4) 关闭连接,代码如下:con.Close();5.2操作数据库中的数据usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Data;usingSystem.Data.SqlClient;namespaceBookManageclassDataAccessprivatestaticstringConnectString="DataSource=SQLEXPRESS;AttachDbFilename=F:BookManagedataBook
32、Manage.mdf;IntegratedSecurity=False"/数据库连接字符串/<summary>/根据表名获取数据集的表/</summary>/<paramname="table"></param>/<returns></returns>publicstaticDataTableGetDataSetByTableName(stringtable)using(SqlConnectioncon=newSqlConnection(ConnectString)/创建数据库连接对象stri
33、ngsql="select*from"+table+""/查询sql语句trySqlDataAdapteradapter=newSqlDataAdapter(sql,con);/创建适配器对象DataSetds=newDataSet();/创建数据集对象adapter.Fill(ds,"table");/填充数据集returnds.TablesO;/返回数据表catch(SqlExceptionex)thrownewException(ex.Message);publicstaticDataSetGetDataSetBySql(stringsql)using(SqlConnectioncon=newSqlConnection(ConnectString)/创建数据库连接对象SqlDataAdapteradapter=newSqlDataAdapter(sql,con);/创建适配器对象DataSetds=newDa
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 新教材同步系列2024春高中地理第一章自然资源与人类活动章末整合提升课件中图版选择性必修3
- 城镇道路雨水口技术规范
- 小学二年级看图写话大全
- 岗前培训心得体会90
- 苏幕遮语文笔记课件
- 中小学校园安全建设物业服务规范编制说明
- 《农村饮用水水站膜处理设备运行更新维护规范》 编制说明
- 博白白切 白切鸭制作技术规程-编制说明
- 北京市普通公路交通工程日常养护预算定额
- 2023年材料员之材料员专业管理实务题库及完整答案全优
- 期中测试卷(1-4单元)(试题)-2024-2025学年四年级上册数学人教版
- 2024年县域高血压合理用药与综合管理指南修订要点解读课件
- DB32-T 4844-2024 自然科学类科普教育基地建设规范
- 2024年海南省海口市海洋和渔业监察支队招聘26人历年高频500题难、易错点模拟试题附带答案详解
- 月考测试卷(第1~3单元)(试题)-2024-2025学年六年级上册数学人教版
- 智慧林业综合管理平台解决方案
- 第05讲:赏析人物形象(练习)-2024年中考语文记叙文阅读讲与练(全国)原卷版
- 2024年4月至2008年10月自考03708中国近现代史纲要历年试题及答案含解析30套
- 2024河南郑州热力集团限公司招聘高频考题难、易错点模拟试题(共500题)附带答案详解
- 《行政执法机关移送涉嫌犯罪案件的规定》详细解读
- 10以内数的分与合A4横向打印版
评论
0/150
提交评论