《数据库原理》课程设计报告农产品信息管理系统_第1页
《数据库原理》课程设计报告农产品信息管理系统_第2页
《数据库原理》课程设计报告农产品信息管理系统_第3页
《数据库原理》课程设计报告农产品信息管理系统_第4页
《数据库原理》课程设计报告农产品信息管理系统_第5页
已阅读5页,还剩41页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、 数据库原理课程设计报告 农产品信息管理系统系 部: 计算机与信息科学系 学生姓名: 指导教师: 专 业: 计算机与信息科学 班 级: 信本0902班 完成时间: 2011年6月15日 目 录1 引 言12 设计目的与任务23 数据库设计33.1 需求分析33.1.1 数据需求33.1.2 数据字典43.2 概念设计63.2.1 实体集63.2.2 e-r图73.2.3 概念模型73.3 逻辑设计83.3.1 物理模型83.3.2 关系模型93.4 数据库实现103.4.1建立数据库模式及视图103.4.2源代码124 结 论405 致 谢416 参考文献427 附 录431 引 言随着计算机

2、行业的兴起,信息管理技术在现实生活中得到了越来越广泛的应用,信息管理系统的实施在技术上已逐步成熟。信息管理系统是一个不断发展的新型学科,任何一个单位要生存要发展,要高效率地把内部活动有机地组织起来,就必须建立与自身特点相适应的管理系统。对于农产品生产机构而言,能有一个完善的农产品信息的管理系统来方便快捷的完成对农产品信息和仓库管理员信息的查询、修改和管理,在提高管理效率和查找农产品信息效率上是不可缺少的。对于我们而言,通过完成每期的课程设计,不但可以不断的提升自己的动手能力,加强的我们的团队合作精神,培养我们敏捷的思维能力。还可以提升我们对专业认识,更好的理解和掌握我们的专业知识。2 设计目的

3、与任务通过本次课程设计,学习数据库设计工具的使用,掌握数据库设计的流程和基本方法。熟练vb与数据库之间的链接,完成对某一小型数据库设计和相应文档的编写工作。从而更加深入地掌握数据库系统分析与设计的基本概念和基本方法,提高从事数据库系统建设和管理工作的基本技能和能力。本课程设计要求设计一个农产品信息管理系统,能对数据库中的农产品信息随时进行新增、修改和删除。数据库中包含农产品信息表,职员信息表和仓库信息表和用户表。同时创建基本视图,实现对数据的查询、新增、修改和删除。用户登录需验证用户的身份,对于不合权限的用户,拒绝其登录本系统。3 数据库设计3.1 需求分析3.1.1 数据需求通过与农产品信息

4、管理系统数据库用户的交谈、团队的分析、市场需求等方式,获得了农产品信息管理系统的数据需求。有多个用户可以访问该数据库,为了数据库的安全,对于每个用户登录前都需通过身份认证,认证通过后方能进入该系统。一个农产品公司可生产多种农产品,不同农产品存放在不同的仓库,每个仓库有固定的管理员。每个农产品信息包含产品编号、仓库号、产品名、入库时间、库存量和总值。每个仓库信息包含仓库号、面积和电话号码。每位管理员信息包括管理员号、姓名、性别、出生年月和联系方式。图3.11农产品信息管理系统数据流图3.1.2 数据字典 以下将对本数据库设计中的各个数据表名称进行解释。表3.1农产品信息管理清单表名解释农产品信息

5、表用来记录农产品的相关信息用户用来记录登录用户的用户名和密码职员表用来记录管理员的相关信息仓库信息表用来记录仓库里农产品的相关信息表3.2农产品信息表农产品信息表是否主键属性名数据类型长度可 空约 束缺省值备 注是产品编号char(10)10仓库号char(10)10产品名char(10)10入库时间char(20)10库存量char(10)20总 值 char(10)10表3.3用户信息表用户是否主键属性名数据类型长度可空约 束缺省值备 注是用户名char(10)10密码char(20)20表3.4职员信息表职员信息表是否主键属性名数据类型长度可空约 束缺省值备 注是管理员号char(10)

6、10姓名char(10)10性别char(2)2出生年月char(40)40联系方式char(14)14表3.5仓库信息表仓库信息表是否主键属性名数据类型长度可 空约 束缺省值备 注是仓库号char(10)10面 积char(20)10电话号码char(14)103.2 概念设计3.2.1 实体集 本数据库e-r图设计中包含4个实体,其中4个实体都是强实体集。实体的具体属性可见下表。表3.6农产品信息管理系统实体集农产品信息管理系统实体集实体集属性农产品信息表产品编号、仓库号、产品名、入库时间、库存量、总值职员信息表管理员号、姓名、性别、出生年月、联系方式仓库信息表仓库号、面积、电话号码用户用

7、户名、密码3.2.2 e-r图图3.22 农产品信息管理系统数据库e-r图3.2.3 概念模型由图3.1的e-r图中实体之间的联系,利用powerdesigner工具概念模型。最终概念模型图如图2所示图3.23农产品信息管理系统数据库概念模型 3.3 逻辑设计3.3.1 物理模型根据图3.2的概念模型图,可以利用powerdesigner导出农产品管理系统数据库的物理模型图。图3.31农产品信息管理系统数据库物理模型3.3.2 关系模型根据关系模式转换规则,把图1e-r图转换为关系模式,如下所示(有实下划线的为主码):农产品信息=(产品编号,仓库号,产品名,入库时间,库存量,总值)仓库信息=(

8、仓库号,面积,电话号码)职员信息=(管理员号,姓名,性别,出生年月,联系方式)用户=(用户名,密码)管理=(仓库号,管理员号)3.4 数据库实现3.4.1建立数据库模式及视图 以下将对数据库进行实现,实现的环境为sqlserver2008。create database 农产品信息管理on primary( name=农产品信息管理_data, filename= d:数据库课程设计农产品信息.mdf , size=10, filegrowth=10%, maxsize=unlimited )log on( name=农产品信息管理_log, filename=d: 数据库课程设计农产品信息.

9、ldf, size=1, filegrowth=10%, maxsize=5)1.建立农产品信息表create table 农产品信息表 ( 产品编号 char(10) primary key ,仓库号 char(10) 产品名 char(10),入库时间 char(10) not null,库存量char(10)总 值char(10)2.仓库信息表create table 仓库信息表( 仓库号 char(10) primary key ,面 积 char(10) not null,电话号码 char(10),)3.职员信息表create table 职员信息表( 管理员号char(10) p

10、rimary key ,姓 名 char(10),性 别 char(10),出生年月 char(10),联系方式char(10),)4.用户create table 用户( 用户名 char(10) primary key ,密 码 char(30)*新建视图*建立农产品信息视图create view 农产品信息(产品编号,仓库号,入库时间,库存量,总值)asselect 产品编号,仓库号,入库时间,库存量,总值from 农产品信息表建立仓库信息视图create view 仓库信息(仓库号,面积,电话号码)asselect 仓库号,面积,电话号码from 仓库信息表建立职员信息create v

11、iew 职员信息(管理员号,姓名,性别,出生年月,联系方式)asselect 管理员号,姓名,性别,出生年月,联系方式from 管理员信息表3.4.2源代码用户登录private sub command1_click() adodc1.recordset.movefirst adodc1.recordset.find 用户名= & text1.text & sql = select 用户名 from 用户 whree 用户名 like text1.text adodc1.recordsource = sql static i as integer if adodc1.recordset.eof

12、 and i 3 then msgbox 用户名错误,请重新输入!, 32, 提示信息 i = i + 1 text1.text = text1.setfocus exit sub end if adodc1.recordset.movefirst adodc1.recordset.find 密码= & text2.text & sql = select 密码 from 用户 whree 用户名 like text1.text adodc1.recordsource = sql if adodc1.recordset.eof and i 3 then msgbox 密码错误,请重新输入!, 3

13、2, 提示信息 i = i + 1 text2.text = text2.setfocus exit sub end if if i = 3 then msgbox 请不起,您无权登录本系统!, 16, 提示信息 form3.show form2.hide exit sub end if form5.show form2.hide text1.text = text2.text = end subprivate sub text2_keyup(keycode as integer, shift as integer) if keycode = 13 then adodc1.recordset.

14、movefirst adodc1.recordset.find 用户名= & text1.text & sql = select 用户名 from 用户 whree 用户名 like text1.text adodc1.recordsource = sql static i as integer if adodc1.recordset.eof and i 3 then msgbox 用户名错误,请重新输入!, 32, 提示信息 i = i + 1 text1.text = text1.setfocus exit sub end if adodc1.recordset.movefirst ado

15、dc1.recordset.find 密码= & text2.text & sql = select 密码 from 用户 whree 用户名 like text1.text adodc1.recordsource = sql if adodc1.recordset.eof and i 3 then msgbox 密码错误,请重新输入!, 32, 提示信息 i = i + 1 text2.text = text2.setfocus exit sub end if if i = 3 then msgbox 请不起,您无权登录本系统!, 16, 提示信息 form3.show form2.hide

16、 exit sub end if form5.show form2.hide text1.text = text2.text = end ifend sub密码修改private sub command1_click() if text2.text text3.text then msgbox 两次新密码输入不一致,请重新输入!, 32, 提示信息 text2.text = text3.text = text2.setfocus exit sub end if if keycode = 13 and text2.text = text3.text then adodc1.recordset.m

17、ovefirst adodc1.recordset.find 用户名= & text4.text & sql = select 用户名 from 用户 whree 用户名 like text4.text adodc1.recordsource = sql adodc1.recordset(用户名) = trim$(text4.text) adodc1.recordset(密码) = trim$(text2.text) adodc1.recordset.update msgbox 密码修改成功!, vbinformation text1.text = text2.text = text3.tex

18、t = text4.text = exit sub end ifend subprivate sub text1_keyup(keycode as integer, shift as integer) if keycode = 13 then adodc1.recordset.movefirst adodc1.recordset.find 密码= & text1.text & sql = select 密码 from 用户 whree 用户名 like text4.text adodc1.recordsource = sql if adodc1.recordset.eof and i 3 th

19、en msgbox 旧密码密码输入错误,请重新输入!, 32, 提示信息 i = i + 1 text1.text = text1.setfocus exit sub end if if i = 3 then msgbox 请不起,您无权修改本用户密码!, 16, 提示信息 form2.show form4.hide exit sub end if text2.setfocus end ifend subprivate sub text3_keyup(keycode as integer, shift as integer) if keycode = 13 and text2.text tex

20、t3.text then msgbox 两次新密码输入不一致,请重新输入!, 32, 提示信息 text2.text = text3.text = text2.setfocus exit sub end if if keycode = 13 and text2.text = text3.text then adodc1.recordset.movefirst adodc1.recordset.find 用户名= & text4.text & sql = select 用户名 from 用户 whree 用户名 like text4.text adodc1.recordsource = sql

21、adodc1.recordset(用户名) = trim$(text4.text) adodc1.recordset(密码) = trim$(text2.text) adodc1.recordset.update msgbox 密码修改成功!, vbinformation text1.text = text2.text = text3.text = text4.text = exit sub end ifend subprivate sub text4_keyup(keycode as integer, shift as integer) if keycode = 13 then adodc1

22、.recordset.movefirst adodc1.recordset.find 用户名= & text4.text & sql = select 用户名 from 用户 whree 用户名 like text4.text adodc1.recordsource = sql static i as integer if adodc1.recordset.eof then msgbox 用户名输入错误,请重新输入!, 32, 提示信息 text4.text = text4.setfocus exit sub end if text1.setfocus end ifend sub农产品信息查询

23、private sub command1_click() adodc1.recordset.movefirst adodc1.recordset.find 产品名= & text1.text & sql = select 产品名 from 农产品信息表 whree 产品名 like text1.text adodc1.recordsource = sql if adodc1.recordset.eof then msgbox 请不起,暂时还没有您要查找的信息!, 32, 提示信息 text1.text = text1.setfocus exit sub end if text2.text =

24、adodc1.recordset(产品编号) text3.text = adodc1.recordset(仓库号) text4.text = adodc1.recordset(产品名) text5.text = adodc1.recordset(入库时间) text6.text = adodc1.recordset(库存量) text7.text = adodc1.recordset(总值)end subprivate sub command6_click() dim i as integer i = msgbox(确定要删除当前记录吗?, 4 + 48, 警告) if i = vbyes t

25、hen adodc1.recordset.delete adodc1.recordset.movenext text1.text = text2.text = text3.text = text4.text = text5.text = text6.text = text7.text = msgbox 删除成功!, vbinformation, 提示信息 end ifend subprivate sub text1_keyup(keycode as integer, shift as integer) if keycode = 13 then adodc1.recordset.movefirs

26、t adodc1.recordset.find 产品名= & text1.text & sql = select 产品名 from 农产品信息表 whree 产品名 like text1.text adodc1.recordsource = sql if adodc1.recordset.eof then msgbox 请不起,暂时还没有您要查找的信息!, 32, 提示信息 text1.text = text1.setfocus exit sub end if text2.text = adodc1.recordset(产品编号) text3.text = adodc1.recordset(仓

27、库号) text4.text = adodc1.recordset(产品名) text5.text = adodc1.recordset(入库时间) text6.text = adodc1.recordset(库存量) text7.text = adodc1.recordset(总值) end ifend sub仓库信息查询private sub command1_click() adodc1.recordset.movefirst adodc1.recordset.find 仓库号= & text1.text & sql = select 仓库号 from 仓库信息表 whree 仓库号 l

28、ike text1.text adodc1.recordsource = sql if adodc1.recordset.eof then msgbox 请不起,暂时还没有您要查找的信息!, 32, 提示信息 text1.text = text1.setfocus exit sub end if text2.text = adodc1.recordset(仓库号) text3.text = adodc1.recordset(面积) text7.text = adodc1.recordset(电话号码)end subprivate sub command4_click() dim i as in

29、teger i = msgbox(确定要删除当前记录吗?, 4 + 48, 警告) if i = vbyes then adodc1.recordset.delete adodc1.recordset.movenext text1.text = text2.text = text3.text = text7.text = msgbox 删除成功!, vbinformation, 提示信息 end ifend subprivate sub text1_keyup(keycode as integer, shift as integer) if keycode = 13 then adodc1.r

30、ecordset.movefirst adodc1.recordset.find 仓库号= & text1.text & sql = select 仓库号 from 仓库信息表 whree 仓库号 like text1.text adodc1.recordsource = sql if adodc1.recordset.eof then msgbox 请不起,暂时还没有您要查找的信息!, 32, 提示信息 text1.text = text1.setfocus exit sub end if text2.text = adodc1.recordset(仓库号) text3.text = ado

31、dc1.recordset(面积) text7.text = adodc1.recordset(电话号码) end ifend sub职员信息查询private sub command1_click() adodc1.recordset.movefirst adodc1.recordset.find 姓名= & text1.text & sql = select 姓名 from 职员信息表 whree 姓名 like text1.text adodc1.recordsource = sql if adodc1.recordset.eof then msgbox 请不起,暂时还没有您要查找的信息

32、!, 32, 提示信息 text1.text = text1.setfocus exit sub end if text2.text = adodc1.recordset(管理员号) text3.text = adodc1.recordset(姓名) text4.text = adodc1.recordset(性别) text5.text = adodc1.recordset(出生年月) text6.text = adodc1.recordset(联系方式)end subprivate sub command6_click() dim i as integer i = msgbox(确定要删除

33、当前记录吗?, 4 + 48, 警告) if i = vbyes then adodc1.recordset.delete text1.text = text2.text = text3.text = text4.text = text5.text = text6.text = msgbox 删除成功!, vbinformation, 提示信息 end ifend subprivate sub text1_keyup(keycode as integer, shift as integer) if keycode = 13 then adodc1.recordset.movefirst ado

34、dc1.recordset.find 姓名= & text1.text & sql = select 姓名 from 职员信息表 whree 姓名 like text1.text adodc1.recordsource = sql if adodc1.recordset.eof then msgbox 请不起,暂时还没有您要查找的信息!, 32, 提示信息 text1.text = text1.setfocus exit sub end if text2.text = adodc1.recordset(管理员号) text3.text = adodc1.recordset(姓名) text4.

35、text = adodc1.recordset(性别) text5.text = adodc1.recordset(出生年月) text6.text = adodc1.recordset(联系方式) end ifend sub新增农产品信息private sub command2_click() if text1.text = then msgbox 请输入农产品编名!, vbexclamation text1.setfocus exit sub end if if text2.text = then msgbox 请输入农产品名!, vbexclamation text2.setfocus

36、exit sub end if if text3.text = then msgbox 请输入农产品入库号!, vbexclamation text3.setfocus exit sub end if adodc1.refresh adodc1.recordset.find (产品编号= & text1.text & ) if not adodc1.recordset.eof then msgbox 产品号重复,请重新输入!, vbexclamation text1.setfocus exit sub end if adodc1.recordset.find (产品名= & text3.tex

37、t & ) if not adodc1.recordset.eof then msgbox 产品名重复,请重新输入!, vbexclamation text2.setfocus exit sub else adodc1.recordset.addnew adodc1.recordset.fields(0) = trim$(text1.text) adodc1.recordset.fields(1) = trim$(text2.text) adodc1.recordset.fields(2) = trim$(text3.text) adodc1.recordset.fields(3) = tri

38、m$(text4.text) adodc1.recordset.fields(4) = trim$(text5.text) adodc1.recordset.fields(5) = trim$(text6.text) adodc1.recordset.update msgbox 农产品信息已经添加成功!, vbinformation adodc1.refresh text1.text = text2.text = text3.text = text4.text = text5.text = text6.text = end ifend subprivate sub text6_change()

39、 if keycode = 13 then if text1.text = then msgbox 请输入农产品编名!, vbexclamation text1.setfocus exit sub end if if text2.text = then msgbox 请输入农产品名!, vbexclamation text2.setfocus exit sub end if if text3.text = then msgbox 请输入农产品入库号!, vbexclamation text3.setfocus exit sub end if adodc1.refresh adodc1.reco

40、rdset.find (产品编号= & text1.text & ) if not adodc1.recordset.eof then msgbox 产品号重复,请重新输入!, vbexclamation text1.setfocus exit sub end if adodc1.recordset.find (产品名= & text3.text & ) if not adodc1.recordset.eof then msgbox 产品名重复,请重新输入!, vbexclamation ext2.setfocus exit sub else adodc1.recordset.addnew a

41、dodc1.recordset.fields(0) = trim$(text1.text) adodc1.recordset.fields(1) = trim$(text2.text) adodc1.recordset.fields(2) = trim$(text3.text) adodc1.recordset.fields(3) = trim$(text4.text) adodc1.recordset.fields(4) = trim$(text5.text) adodc1.recordset.fields(5) = trim$(text6.text) adodc1.recordset.up

42、date msgbox 农产品信息已经添加成功!, vbinformation adodc1.refresh text1.text = text2.text = text3.text = text4.text = text5.text = text6.text = end if end ifend sub新增仓库信息private sub command1_click() if text1.text = then msgbox 请输入仓库号!, vbexclamation text1.setfocus exit sub end if if text2.text = then msgbox 请输入面积!, vbexclamation text2.setfocus exit sub end if adodc1.refresh adodc1.recordset.find (仓库号= & text1.text & ) if not adodc1.recordset.eof then msgbox 仓库号重复,请重新输入!, vbexclamation text1.setfocus exit sub else

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论