图书管理系统数据库实验报告.doc

上传人:大张伟 文档编号:6357540 上传时间:2020-11-01 格式:DOC 页数:16 大小:409.50KB
返回 下载 相关 举报
图书管理系统数据库实验报告.doc_第1页
第1页 / 共16页
图书管理系统数据库实验报告.doc_第2页
第2页 / 共16页
图书管理系统数据库实验报告.doc_第3页
第3页 / 共16页
图书管理系统数据库实验报告.doc_第4页
第4页 / 共16页
图书管理系统数据库实验报告.doc_第5页
第5页 / 共16页
点击查看更多>>
资源描述

《图书管理系统数据库实验报告.doc》由会员分享,可在线阅读,更多相关《图书管理系统数据库实验报告.doc(16页珍藏版)》请在三一文库上搜索。

1、科 技 学 院课程设计报告( 2013- 2014年度第2学期)名 称: 数据库原理课程设计 院 系: 信息工程系 班 级: 学 号: 学生姓名: 指导教师: 郭丰娟 王晓辉 设计周数: 1 成 绩: 日期:2014年 5 月29日数据库原理课程设计 任 务 书一、 目的与要求1. 这门课是为计算机科学与技术专业的学生在学习数据库原理后,为培养更好的解决问题和实际动手能力而设置的实践环节。通过这个环节,使学生拥有能够应用数据库原理对数据库系统进行设计的能力。为后继课程和毕业设计打下良好基础。2. 通过该实验,培养学生在建立数据库系统过程中使用关系数据理论的能力。3. 通过一个学生并不陌生的完整

2、系统的设计,可以培养学生对需求分析、方案设计、系统编码、界面设计和软件调试等各方面的能力。是一门综合考查学生数据库原理、面向对象设计方法、软件工程和信息系统分析与设计等涉及多课程的综合实验。二、 主要内容信息管理系统的设计与实现是针对一个实际中小型系统(见题目附录)进行的数据库设计,它需要管理的内容有实体以及实体之间的联系。1. 首先要求完成需求的理解和实体的设计:a) 设计实体的属性和码,以及该实体的实体完整性、用户自定义的完整性。b) 设计实体的之间的联系,包括联系的类型和联系的属性,即设计实体参照完整性。最后画出完整的E-R图。2根据设计好的E-R图及关系数据库理论知识设计数据库模式:2

3、.1 将E-R图转换为关系模式。2.2 设计关系模式间的参照完整性。2.3 用SQL语言实现数据库模式的设计。3实现信息管理系统所需的各种操作:3.1 用SQL语言实现信息的录入、删除和修改。3.2 以视图的形式完成各类查询,包括单表、多表、单条件、多条件等。4权限的设计:4.1 授权操作;4.2 收回权限的操作。5界面的设计、加密的设计。三、 进度计划序号设计(实验)内容完成时间备注1根据任务书完成信息模型的设计,并将该信息模型在选用的DBMS中实现,并录入数据1天2根据任务书完成各种数据操作,并以视图的形式保留SQL语句。并开始界面的设计与编码1天3使用可视化开发工具开发学生工作管理系统(

4、C/S或者B/S模式)1天4界面设计,权限设计和调试1天5系统的完善与验收1天四、 设计(实验)成果要求1 在DBMS(如SQL Server,DB2等)上完成完整的数据库的设计;2 使用可视化开发平台完成该系统,并要可以求正确的运行;3 完成实验报告。五、 考核方式1 在微机上检查数据库设计的模式的设计、完整性的设计等;2 在微机上检查系统的运行结果,并请学生解释所使用的技术;3 实验报告的检查。六、 题目附录1 学生信息管理信息系统2 学生成绩管理信息系统3 图书管理信息系统4 物资管理信息系统5 汽车销售管理信息系统6 超市管理信息系统7 通讯录管理信息系统8 工资管理信息系统9 酒店管

5、理信息系统10 小区物业管理信息系统学生姓名:指导教师:郭丰娟 2014 年5月29日一、实验题目:图书管理信息系统二、实验目的与要求1.培养更好的解决问题和实际动手能力。通过这个环节,使学生具备应用数据库原理对数据库系统进行设计的能力。为后继课程和毕业设计打下良好基础。2.通过该实验,培养学生在建立数据库系统过程中使用关系数据理论的能力。3.通过对一个数据库系统的设计,培养学生对数据库需求分析、数据库方案设计、系统编码、界面设计和软件调试等各方面的能力。是一门考查学生数据库原理、面向对象设计方法、软件工程和信息系统分析与设计等课程的综合实验。三、实验原理系统所使用的原理有概念模型、三层模式、

6、关系表理论、范式理论等。四、实验所需仪器、设备计算机、MicrosoftSQLServer2008、MicrosoftVisualStudio2008。五、实验内容针对一个图书管理信息系统进行数据库设计,分析系统涉及的实体、实体之间的联系,实现增加、删除、更新、查询数据记录等基本操作。1.理解系统的数据库需求,分析实体及实体间联系,画出E-R图:1)分析确定实体的属性和码,完成对该实体的实体完整性、用户自定义完整性的定义。2)设计实体之间的联系,包括联系类型和联系的属性。最后画出完整的E-R图。用户登录管理员界面普通用户界面管理操作查询图书插入图书更新图书删除图书查询用户插入用户删除用户修改用

7、户查询图书退出登录2根据设计好的E-R图及关系数据库理论知识设计数据库模式:1)把E-R图转换为逻辑模式;将上述E_R图转换成二维表(设计字段,确定字段的取值范围,字段名字,主键,字段的长度,确定自定义完整性,确定参照完整性)。 读者信息表 图书信息表 管理员信息表2)规范化设计。读者基本信息表、管理员信息表、图书信息表中均不含部分函数依赖和传递函数依赖,故此关系为3NF。3)用SQL语言完成数据库内模式的设计。3完成用户界面的设计,连接数据库,用C#语言实现系统所需的各种操作:实现数据记录的插入、删除、查询和修改;以视图的形式完成复杂查询,比如多表、多条件等。4. 使用Microsoft V

8、isual 2008的窗体进行前台界面操作1)登录界面登录界面代码:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace LibraryManagement public partial class Form1 : Form public static stri

9、ng rname; public Form1() InitializeComponent(); private void button1_Click(object sender, EventArgs e) if (this.username.Text.Trim() = & this.password.Text = ) MessageBox.Show(请输入您的用户名和密码!, 提示!); return; string level = comboBox1.Text.ToString(); try SqlConnection conn = new SqlConnection(); conn.Con

10、nectionString = Data Source=localhost;Initial Catalog=libraryMS;Integrated Security=True; conn.Open(); SqlCommand comm = new SqlCommand(); comm.Connection = conn; string a = username.Text.ToString(); string b = password.Text.ToString(); string str1=select * from reader where r_num= + a + and r_passw

11、ord= + b + ; string str2=select * from administrator where a_num= + a + and a_password= + b + ; if (level = 普通用户) comm.CommandText = str1; else comm.CommandText = str2; SqlDataReader dr = comm.ExecuteReader(); dr.Read(); if (dr.HasRows&level=普通用户) rname = drr_name.ToString(); MainForm af = new MainF

12、orm(); this.Hide(); this.username.Clear(); this.password.Clear(); af.Show(); else if (dr.HasRows & level = 管理员) rname = dra_name.ToString(); AdministratorForm ad = new AdministratorForm(); this.Hide(); ad.Show(); else MessageBox.Show(账号或密码错误!, 提示!); this.username.Clear(); this.password.Clear(); this

13、.username.Focus(); catch (Exception) MessageBox.Show(数据库无法连接!, 警告!); private void button2_Click(object sender, EventArgs e) Application.Exit(); private void Form1_Closing(object sender, EventArgs e) Application.Exit(); private void Form1_Load(object sender, EventArgs e) comboBox1.DropDownStyle = Com

14、boBoxStyle.DropDownList; comboBox1.Text = comboBox1.Items0.ToString(); 2)普通用户界面普通用户核心代码:namespace LibraryManagement public partial class MainForm : Form public string strconn = Data Source=localhost;Initial Catalog=libraryMS;Integrated Security=True; public MainForm() InitializeComponent(); private

15、void button1_Click(object sender, EventArgs e) Form1 aws = new Form1(); this.Hide(); aws.Show(); private void MainForm_Load(object sender, EventArgs e) string rname = Form1.rname; label4.Text = 欢迎 + rname + 登陆; this.AcceptButton = button2; private void button2_Click(object sender, EventArgs e) strin

16、g lno = textBox1.Text.ToString(); string lname = textBox2.Text.ToString(); string lauthor = textBox3.Text.ToString(); string StrSql = select * from book where 1=1; DataTable dt = new DataTable(); using (SqlConnection con = new SqlConnection(strconn) con.Open(); SqlCommand cmd = new SqlCommand(); usi

17、ng (cmd) if (!string.IsNullOrEmpty(lno) StrSql += and l_num=lno; SqlParameter SpSname = new SqlParameter(lno, lno); cmd.Parameters.Add(SpSname); if (!string.IsNullOrEmpty(lname) StrSql += and l_name=lname; SqlParameter SpSclass = new SqlParameter(lname, lname); cmd.Parameters.Add(SpSclass); if (!str

18、ing.IsNullOrEmpty(lauthor) StrSql += and l_author=lau; SqlParameter SpSclass1 = new SqlParameter(lau, lauthor); cmd.Parameters.Add(SpSclass1); cmd.CommandText = StrSql; cmd.Connection = con; using (SqlDataAdapter sda = new SqlDataAdapter(cmd) sda.Fill(dt); dataGridView1.DataSource = dt; 3)管理员图书管理界面管

19、理图书核心代码:public partial class AdministratorForm : Form public string strconn = Data Source=localhost;Initial Catalog=libraryMS;Integrated Security=True; public AdministratorForm() InitializeComponent(); private void button3_Click(object sender, EventArgs e) /图书查询按钮 this.dataGridView1.AutoGenerateColu

20、mns = false; string lno = textBox6.Text.ToString(); string lname = textBox7.Text.ToString(); string lauthor = textBox8.Text.ToString(); string StrSql = select * from book where 1=1; DataTable dt = new DataTable(); using (SqlConnection con = new SqlConnection(strconn) con.Open(); SqlCommand cmd = new

21、 SqlCommand(); using (cmd) if (!string.IsNullOrEmpty(lno) StrSql += and l_num=lno; SqlParameter Splnum = new SqlParameter(lno, lno); cmd.Parameters.Add(Splnum); if (!string.IsNullOrEmpty(lname) StrSql += and l_name=lname; SqlParameter Splname = new SqlParameter(lname, lname); cmd.Parameters.Add(Spln

22、ame); if (!string.IsNullOrEmpty(lauthor) StrSql += and l_author=lau; SqlParameter Splauthor = new SqlParameter(lau, lauthor); cmd.Parameters.Add(Splauthor); cmd.CommandText = StrSql; cmd.Connection = con; using (SqlDataAdapter sda = new SqlDataAdapter(cmd) sda.Fill(dt); dataGridView1.DataSource = dt

23、; private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) if (e.ColumnIndex = 5) string lno = dataGridView1.Rowse.RowIndex.Cells0.Value.ToString(); string lname = dataGridView1.Rowse.RowIndex.Cells1.Value.ToString(); string lau = dataGridView1.Rowse.RowIndex.Cells3.Value.ToS

24、tring(); string ltype = dataGridView1.Rowse.RowIndex.Cells2.Value.ToString(); string lpress = dataGridView1.Rowse.RowIndex.Cells4.Value.ToString(); textBox1.Text = lno; textBox1.ReadOnly = true; textBox2.Text = lname; textBox3.Text = lau; textBox4.Text = ltype; textBox5.Text = lpress; private void b

25、utton1_Click(object sender, EventArgs e) string lno = textBox1.Text.ToString(); string lname = textBox2.Text.ToString(); string lau = textBox4.Text.ToString(); string ltype = textBox3.Text.ToString(); string lpress = textBox5.Text.ToString(); string str = update book set l_name=lname,l_author=lau,l_

26、type=ltype,l_press=lpress where l_num=lno; SqlParameter sp1 = new SqlParameter(lname, lname); SqlParameter sp2 = new SqlParameter(lau, lau); SqlParameter sp3 = new SqlParameter(ltype, ltype); SqlParameter sp4 = new SqlParameter(lpress, lpress); SqlParameter sp5 = new SqlParameter(lno, lno); using (S

27、qlConnection conn = new SqlConnection(strconn) conn.Open(); using (SqlCommand cmd = new SqlCommand() cmd.Connection = conn; cmd.CommandText = str; cmd.Parameters.Add(sp1); cmd.Parameters.Add(sp2); cmd.Parameters.Add(sp3); cmd.Parameters.Add(sp4); cmd.Parameters.Add(sp5); int n = cmd.ExecuteNonQuery(

28、); if (n 0) MessageBox.Show(更新成功); this.textBox1.Clear(); this.textBox2.Clear(); this.textBox3.Clear(); this.textBox4.Clear(); this.textBox5.Clear(); private void button2_Click(object sender, EventArgs e) string lno = textBox1.Text.ToString(); string lname = textBox2.Text.ToString(); string lau = te

29、xtBox4.Text.ToString(); string ltype = textBox3.Text.ToString(); string lpress = textBox5.Text.ToString(); if (lno = null | lno = | lname = null | lname = | lau = null | lau = | ltype = null | ltype = | lpress = null | lpress = ) MessageBox.Show(请完善信息,各项不能为空); else string str = insert into book (l_n

30、um,l_name,l_type,l_author,l_press) values (lno,lname,ltype,lau,lpress); SqlParameter sp1 = new SqlParameter(lname, lname); SqlParameter sp2 = new SqlParameter(lau, lau); SqlParameter sp3 = new SqlParameter(ltype, ltype); SqlParameter sp4 = new SqlParameter(lpress, lpress); SqlParameter sp5 = new Sql

31、Parameter(lno, lno); using (SqlConnection conn = new SqlConnection(strconn) conn.Open(); using (SqlCommand cmd = new SqlCommand() cmd.Connection = conn; cmd.CommandText = str; cmd.Parameters.Add(sp1); cmd.Parameters.Add(sp2); cmd.Parameters.Add(sp3); cmd.Parameters.Add(sp4); cmd.Parameters.Add(sp5); int n = cmd.ExecuteNonQuery(); if (n 0) MessageBox.Show

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

当前位置:首页 > 科普知识


经营许可证编号:宁ICP备18001539号-1