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

上传人:b****6 文档编号:5825250 上传时间:2023-01-01 格式:DOCX 页数:19 大小:287.89KB
下载 相关 举报
图书管理系统数据库实验报告.docx_第1页
第1页 / 共19页
图书管理系统数据库实验报告.docx_第2页
第2页 / 共19页
图书管理系统数据库实验报告.docx_第3页
第3页 / 共19页
图书管理系统数据库实验报告.docx_第4页
第4页 / 共19页
图书管理系统数据库实验报告.docx_第5页
第5页 / 共19页
点击查看更多>>
下载资源
资源描述

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

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

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

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

 

科技学院

课程设计报告

(2013--2014年度第2学期)

 

名称:

数据库原理课程设计

院系:

信息工程系

班级:

学号:

学生姓名:

指导教师:

郭丰娟王晓辉

设计周数:

1

成绩:

日期:

2014年5月29日

《数据库原理》课程设计

任务书

一、目的与要求

1.这门课是为计算机科学与技术专业的学生在学习数据库原理后,为培养更好的解决问题和实际动手能力而设置的实践环节。

通过这个环节,使学生拥有能够应用数据库原理对数据库系统进行设计的能力。

为后继课程和毕业设计打下良好基础。

2.通过该实验,培养学生在建立数据库系统过程中使用关系数据理论的能力。

3.通过一个学生并不陌生的完整系统的设计,可以培养学生对需求分析、方案设计、系统编码、界面设计和软件调试等各方面的能力。

是一门综合考查学生数据库原理、面向对象设计方法、软件工程和信息系统分析与设计等涉及多课程的综合实验。

二、主要内容

信息管理系统的设计与实现是针对一个实际中小型系统(见题目附录)进行的数据库设计,它需要管理的内容有实体以及实体之间的联系。

1.首先要求完成需求的理解和实体的设计:

a)设计实体的属性和码,以及该实体的实体完整性、用户自定义的完整性。

b)设计实体的之间的联系,包括联系的类型和联系的属性,即设计实体参照完整性。

最后画出完整的E-R图。

2.根据设计好的E-R图及关系数据库理论知识设计数据库模式:

2.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

使用可视化开发工具开发学生工作管理系统(C/S或者B/S模式)

1天

4

界面设计,权限设计和调试

1天

5

系统的完善与验收

1天

四、设计(实验)成果要求

1.在DBMS(如SQLServer,DB2等)上完成完整的数据库的设计;

2.使用可视化开发平台完成该系统,并要可以求正确的运行;

3.完成实验报告。

五、考核方式

1.在微机上检查数据库设计的模式的设计、完整性的设计等;

2.在微机上检查系统的运行结果,并请学生解释所使用的技术;

3.实验报告的检查。

六、题目附录

1.学生信息管理信息系统

2.学生成绩管理信息系统

3.图书管理信息系统

4.物资管理信息系统

5.汽车销售管理信息系统

6.超市管理信息系统

7.通讯录管理信息系统

8.工资管理信息系统

9.酒店管理信息系统

10.小区物业管理信息系统

学生姓名:

指导教师:

郭丰娟

2014年5月29日

一、实验题目:

图书管理信息系统

二、实验目的与要求

1. 培养更好的解决问题和实际动手能力。

通过这个环节,使学生具备应用数据库原理对数据库系统进行设计的能力。

为后继课程和毕业设计打下良好基础。

2. 通过该实验,培养学生在建立数据库系统过程中使用关系数据理论的能力。

3. 通过对一个数据库系统的设计,培养学生对数据库需求分析、数据库方案设计、系统编码、界面设计和软件调试等各方面的能力。

是一门考查学生数据库原理、面向对象设计方法、软件工程和信息系统分析与设计等课程的综合实验。

三、实验原理

系统所使用的原理有概念模型、三层模式、关系表理论、范式理论等。

 

四、实验所需仪器、设备

计算机、Microsoft SQL Server 2008、Microsoft Visual Studio 2008。

五、实验内容

针对一个图书管理信息系统进行数据库设计,分析系统涉及的实体、实体之间的联系,实现增加、删除、更新、查询数据记录等基本操作。

 

1. 理解系统的数据库需求,分析实体及实体间联系,画出E-R图:

 

1) 分析确定实体的属性和码,完成对该实体的实体完整性、用户自定义完整性的

定义。

2) 设计实体之间的联系,包括联系类型和联系的属性。

最后画出完整的E-R图。

 

2.根据设计好的E-R图及关系数据库理论知识设计数据库模式:

 

1)把E-R图转换为逻辑模式;

将上述E_R图转换成二维表(设计字段,确定字段的取值范围,字段名字,主键,字段的长度,确定自定义完整性,确定参照完整性)。

 

读者信息表图书信息表

 

管理员信息表

2)规范化设计。

 

读者基本信息表、管理员信息表、图书信息表中均不含部分函数依赖和传递函数依赖,故此关系为3NF。

  

3)用SQL语言完成数据库内模式的设计。

 

3.完成用户界面的设计,连接数据库,用C#语言实现系统所需的各种操作:

实现数据记录的插入、删除、查询和修改;以视图的形式完成复杂查询,比如多表、多条件等。

4.使用MicrosoftVisual2008的窗体进行前台界面操作 

1)登录界面

 

登录界面代码:

usingSystem;

usingSystem.Collections.Generic;

usingSystem.ComponentModel;

usingSystem.Data;

usingSystem.Drawing;

usingSystem.Text;

usingSystem.Windows.Forms;

usingSystem.Data.SqlClient;

namespaceLibraryManagement

{

publicpartialclassForm1:

Form

{

publicstaticstringrname;

publicForm1()

{

InitializeComponent();

}

privatevoidbutton1_Click(objectsender,EventArgse)

{

if(this.username.Text.Trim()==""&&this.password.Text=="")

{

MessageBox.Show("请输入您的用户名和密码!

","提示!

");

return;

}

stringlevel=comboBox1.Text.ToString();

try

{

SqlConnectionconn=newSqlConnection();

conn.ConnectionString="DataSource=localhost;InitialCatalog=libraryMS;IntegratedSecurity=True";

conn.Open();

SqlCommandcomm=newSqlCommand();

comm.Connection=conn;

stringa=username.Text.ToString();

stringb=password.Text.ToString();

stringstr1="select*fromreaderwherer_num='"+a+"'andr_password='"+b+"'";

stringstr2="select*fromadministratorwherea_num='"+a+"'anda_password='"+b+"'";

if(level=="普通用户")

comm.CommandText=str1;

else

comm.CommandText=str2;

SqlDataReaderdr=comm.ExecuteReader();

dr.Read();

if(dr.HasRows&&level=="普通用户")

{

rname=dr["r_name"].ToString();

MainFormaf=newMainForm();

this.Hide();

this.username.Clear();

this.password.Clear();

af.Show();

}

elseif(dr.HasRows&&level=="管理员")

{

rname=dr["a_name"].ToString();

AdministratorFormad=newAdministratorForm();

this.Hide();

ad.Show();

}

else

{

MessageBox.Show("账号或密码错误!

","提示!

");

this.username.Clear();

this.password.Clear();

this.username.Focus();

}

}

catch(Exception)

{

MessageBox.Show("数据库无法连接!

","警告!

");

}

}

privatevoidbutton2_Click(objectsender,EventArgse)

{

Application.Exit();

}

privatevoidForm1_Closing(objectsender,EventArgse)

{

Application.Exit();

}

privatevoidForm1_Load(objectsender,EventArgse)

{

comboBox1.DropDownStyle=ComboBoxStyle.DropDownList;

comboBox1.Text=comboBox1.Items[0].ToString();

}

}

}

2)普通用户界面

 

普通用户核心代码:

namespaceLibraryManagement

{

publicpartialclassMainForm:

Form

{

publicstringstrconn="DataSource=localhost;InitialCatalog=libraryMS;IntegratedSecurity=True";

publicMainForm()

{

InitializeComponent();

}

privatevoidbutton1_Click(objectsender,EventArgse)

{

Form1aws=newForm1();

this.Hide();

aws.Show();

}

privatevoidMainForm_Load(objectsender,EventArgse)

{

stringrname=Form1.rname;

label4.Text="欢迎"+rname+"登陆";

this.AcceptButton=button2;

}

privatevoidbutton2_Click(objectsender,EventArgse)

{

stringlno=textBox1.Text.ToString();

stringlname=textBox2.Text.ToString();

stringlauthor=textBox3.Text.ToString();

stringStrSql="select*frombookwhere1=1";

DataTabledt=newDataTable();

using(SqlConnectioncon=newSqlConnection(strconn))

{

con.Open();

SqlCommandcmd=newSqlCommand();

using(cmd)

{

if(!

string.IsNullOrEmpty(lno))

{

StrSql+="andl_num=@lno";

SqlParameterSpSname=newSqlParameter("@lno",lno);

cmd.Parameters.Add(SpSname);

}

if(!

string.IsNullOrEmpty(lname))

{

StrSql+="andl_name=@lname";

SqlParameterSpSclass=newSqlParameter("@lname",lname);

cmd.Parameters.Add(SpSclass);

}

if(!

string.IsNullOrEmpty(lauthor))

{

StrSql+="andl_author=@lau";

SqlParameterSpSclass1=newSqlParameter("@lau",lauthor);

cmd.Parameters.Add(SpSclass1);

}

cmd.CommandText=StrSql;

cmd.Connection=con;

using(SqlDataAdaptersda=newSqlDataAdapter(cmd))

{

sda.Fill(dt);

dataGridView1.DataSource=dt;

}

}

}

}

}

}

3)管理员图书管理界面

 

管理图书核心代码:

publicpartialclassAdministratorForm:

Form

{

publicstringstrconn="DataSource=localhost;InitialCatalog=libraryMS;IntegratedSecurity=True";

publicAdministratorForm()

{

InitializeComponent();

}

privatevoidbutton3_Click(objectsender,EventArgse)//图书查询按钮

{

this.dataGridView1.AutoGenerateColumns=false;

stringlno=textBox6.Text.ToString();

stringlname=textBox7.Text.ToString();

stringlauthor=textBox8.Text.ToString();

stringStrSql="select*frombookwhere1=1";

DataTabledt=newDataTable();

using(SqlConnectioncon=newSqlConnection(strconn))

{

con.Open();

SqlCommandcmd=newSqlCommand();

using(cmd)

{

if(!

string.IsNullOrEmpty(lno))

{

StrSql+="andl_num=@lno";

SqlParameterSplnum=newSqlParameter("@lno",lno);

cmd.Parameters.Add(Splnum);

}

if(!

string.IsNullOrEmpty(lname))

{

StrSql+="andl_name=@lname";

SqlParameterSplname=newSqlParameter("@lname",lname);

cmd.Parameters.Add(Splname);

}

if(!

string.IsNullOrEmpty(lauthor))

{

StrSql+="andl_author=@lau";

SqlParameterSplauthor=newSqlParameter("@lau",lauthor);

cmd.Parameters.Add(Splauthor);

}

cmd.CommandText=StrSql;

cmd.Connection=con;

using(SqlDataAdaptersda=newSqlDataAdapter(cmd))

{

sda.Fill(dt);

dataGridView1.DataSource=dt;

}

}

}

}

privatevoiddataGridView1_CellClick(objectsender,DataGridViewCellEventArgse)

{

if(e.ColumnIndex==5)

{

stringlno=dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();

stringlname=dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();

stringlau=dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();

stringltype=dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();

stringlpress=dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString();

textBox1.Text=lno;

textBox1.ReadOnly=true;

textBox2.Text=lname;

textBox3.Text=lau;

textBox4.Text=ltype;

textBox5.Text=lpress;

}

}

privatevoidbutton1_Click(objectsender,EventArgse)

{

stringlno=textBox1.Text.ToString();

stringlname=textBox2.Text.ToString();

stringlau=textBox4.Text.ToString();

stringltype=textBox3.Text.ToString();

stringlpress=textBox5.Text.ToString();

stringstr="updatebooksetl_name=@lname,l_author=@lau,l_type=@ltype,l_press=@lpresswherel_num=@lno";

SqlParametersp1=newSqlParameter("@lname",lname);

SqlParametersp2=newSqlParameter("@lau",lau);

SqlParametersp3=newSqlParameter("@ltype",ltype);

SqlParametersp4=newSqlParameter("@lpress",lpress);

SqlParametersp5=newSqlParameter("@lno",lno);

using(SqlConnectionconn=newSqlConnection(strconn))

{

conn.Open();

using(SqlCommandcmd=newSqlCommand())

{

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);

intn=cmd.ExecuteNonQuery();

if(n>0)

{

MessageBox.Show("更新成功");

this.textBox1.Clear();

this.textBox2.Clear();

this.textBox3.Clear();

this.textBox4.Clear();

this.textBox5.Clear();

}

}

}

}

privatevoidbutton2_Click(objectsender,EventArgse)

{

stringlno=textBox1.Text.ToString();

stringlname=textBox2.Text.ToString();

stringlau=textBox4.Text.ToString();

stringltype=textBox3.Text.ToString();

stringlpress=textBox5.Text.ToString();

if(lno==null||lno==""||lname==null||lname==""||lau==null||lau==""||ltype==null||ltype==""||lpress==null||lpress=="")

MessageBox.Show("请完善信息,各项不能为空");

else

{

stringstr="insertintobook(l_num,l_name,l_type,l_author,l_press)values(@lno,@lname,@ltype,@lau,@lpress)";

SqlParametersp1=newSqlParamet

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

当前位置:首页 > 经管营销

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

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