版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
..目录TOC\o"1-4"\h\z\u1、绪论22、数据库设计32.1数据库分析32.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.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<"Server=PC_201402131602;IntegratedSecurity=true;DataBase=图书管理系统">;conn.Open<>;SqlCommandcmd=newSqlCommand<"select*fromTable_1whereid='"+textBox1.Text.Trim<>+"'andus='"+textBox2.Text.Trim<>+"'",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<"Server=PC_201402131602;IntegratedSecurity=true;DataBase=图书管理系统">;conn.Open<>;SqlCommandcmd=newSqlCommand<"select*fromTable_2whereuid='"+textBox1.Text.Trim<>+"'andusr='"+textBox2.Text.Trim<>+"'",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<"Server=PC_201402131602;IntegratedSecurity=true;DataBase=图书管理系统">;conn.Open<>;SqlCommandcmd=newSqlCommand<"select*fromTable_4wheresid='"+textBox1.Text.Trim<>+"'",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<"Server=PC_201402131602;IntegratedSecurity=true;DataBase=图书管理系统">;conn.Open<>;SqlCommandcmd=newSqlCommand<"select*fromTable_4wheresid='"+textBox1.Text.Trim<>+"'",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<"Server=PC_201402131602;IntegratedSecurity=true;DataBase=图书管理系统">;conn.Open<>;SqlCommandcmd=newSqlCommand<"select*fromtable_1whereid='"+textBox1.Text.Trim<>+"'andus='"+textBox2.Text.Trim<>+"'",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<"server=PC_201402131602;database=图书管理系统;integratedSecurity=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;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Data;usingSystem.Data.SqlClient;namespaceBookManage{classDataAccess{privatestaticstringConnectString=@"DataSource=SQLEXPRESS;AttachDbFilename=F:\BookManage\data\BookManage.mdf;IntegratedSecurity=False";//数据库连接字符串///<summary>///根据表名获取数据集的表///</summary>///<paramname="table"></param>///<returns></returns>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=new
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年中职法律实务技能大赛现场答辩环节试题
- 2026年武汉城市职业学院单招职业技能考试题库及答案解析
- 2026年事业单位考试逐题解析真题及答案
- 石油输送管道工程农用地转用方案
- 2026年交安考试题含答案解析
- 2026年河南信息统计职业学院单招职业适应性考试模拟测试卷带答案解析
- 2026年法律逻辑学考试真题及完整答案
- 渠系改造与水资源优化利用项目水资源论证报告书
- 2026财务招聘面试题型分布及答案
- 2025吴忠市保安服务总公司招聘38人笔试历年常考点试题专练附带答案详解
- 接口柜配线图接口柜端子信号工程施工课件
- 金属非金属矿山开采方法手册
- DBJT13-366-2021 建筑工程附着式升降脚手架应用技术标准
- 城市道路日常养护作业服务投标文件(技术方案)
- 中药热奄包疗法操作评分标准
- JT∕T 795-2023 事故汽车修复技术规范
- DZ∕T 0321-2018 方解石矿地质勘查规范(正式版)
- 趣识古文字智慧树知到期末考试答案章节答案2024年吉林师范大学
- 2024初中数学中考总复习教案
- 眼内炎病例讨论
- 110KV电缆输电线工程施工组织设计
评论
0/150
提交评论