《数据库原理与应用》课程设计影碟出租数据库系统设计与实现_第1页
《数据库原理与应用》课程设计影碟出租数据库系统设计与实现_第2页
《数据库原理与应用》课程设计影碟出租数据库系统设计与实现_第3页
《数据库原理与应用》课程设计影碟出租数据库系统设计与实现_第4页
《数据库原理与应用》课程设计影碟出租数据库系统设计与实现_第5页
已阅读5页,还剩20页未读 继续免费阅读

下载本文档

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

文档简介

1、数据库原理与应用课程设计题 目: 影碟出租数据库系统设计与实现 系 别: 数学与信息工程学院 专业(含班级): 09计算机科学与技术(嵌入式) 学 号: 姓 名: 指导教师: 职称 副教授 填表日期: 2011 年 12 月 26 日前 言一、选题的依据及意义1. 依据熟悉c#、sql程序设计的基本语法知识及常用技巧。2. 意义本课程的课程设计实际是学生学习完数据库系统概论课程后,进行的一次全面的综合训练,其目的在于加深对编程技术基本知识的理解,掌握运用开发应用程序的基本方法及基本技巧。二、本课程设计内容1. 出租、归还碟片信息的统计:会员账号,影碟编号,出租时间,归还时间,租金等2. 影片信

2、息的查询的统计:影碟编号,名称,类型,国家,主演,单价,购入时间,库存量。3.营业员和会员资料的查询的统计:营业员账号,会员账号, 密码,姓名,办理时间,剩余可租碟数,工作时间。4.营业员、会员及碟片的添加或删除。三、研究目标1. 碟片出租系统是一个面向碟片出租者的管理信息系统。有会员(租借者),营业员,店长三方组成。该系统的工作目标就是要碟片的出租能有计划地进行,以利于出租者管理。2. 本系统开发将综合采用结构化系统开发方法和面向对象开发方法,充分发挥两种开发方法的优势。实 现 方 案一、开发平台选择1. sql server 20002. c#二、需求分析在对世面上的影碟出租公司进行了初步

3、的了解后,发现其业务主要是集中在影碟的管理和录像的出租归还上。对影碟的管理工作量较大,采用手工的方式还容易出错,并且不能满足顾客对影碟的详细信息的查询功能。在现有的影碟出租中对会员的管理也很重要,传统的登记方式不仅费时而且不能对其出租日志进行系统的管理,造成了不必要的经济损失。综上说述,在影碟出租数据库设计中应考虑和克服了上诉的诸多问题,增强了实用性。2.1数据需求影片信息数据:录像id、片名、导演、主演、类型、介绍、上映时间。录像信息数据:录像id、格式、语言、进货时间、状态、库存数量。租借记录数据:记录id、租借时间。租借项记录数据:记录项id、租借数量、归还时间、租金。租金信息数据:租借

4、类型、租借天数、每日金额。会员信息数据:会员id、会员姓名、会员性别、身份证id、电话、地址。2.2功能需求会员信息管理部分:可以查询会员资料、可以对会员进行增删。影片信息管理部分:可以查询影片本身的信息、可以对影片信息实行增删。租借信息管理部分:可以查询影片的租借状态。租金信息管理部分:可以查询各类影片的租金情况、会员应付的租金情况。数据流图:2.业务流程图: 图1:影碟出租管理系统业务流程图三、概要结构设计 图2:影碟出租管理系统e-r图四、逻辑结构设计:1.选课系统关系模式:(1)店长(店长账号,密码,姓名);(2)营业员(营业员账号,密码,姓名,性别,工作时间,店长账号);(3)会员(

5、会员帐号,密码,姓名,办理时间,剩余可租碟数,营业员账号);(4)影碟查询(影碟编号,名称,类型,国家,主演,单价,购入时间,库存量)(5)影碟出租、归还(影碟编号,出租时间,营业员账号,会员账号)2. 数据库关系图:图3:影碟出租管理系统关系图五、功能模块设计影碟出租管理系统营业员租借查询登陆添加店长修改密码退出出租影碟返还影碟影碟查询 会员查询退碟查询新营业员新入会员影碟类别会员级别营业员图4:影碟出租管理系统功能模块图六、主界面设计1.登录界面: 图4:影碟出租管理系统登陆页面2. 主界面:图4:影碟出租管理系统主页面图5:会员管理主页面八、主要功能的源代码1.连接数据库string c

6、onnstr = integrated security=sspi;persist security info=false;initial catalog=影碟出租管理系统;data source=pc-20100331fomn; string selectcmd = select * from 影碟信息 where 影碟编号= + 影碟编号.text + ; /建立选择查询 string insertcmd = insert into 影碟信息 values( + 影碟编号.text + , + 名称.text + , + 类型.text + , + 国家.text + , + 主演.tex

7、t + ,+单价.text+,+购入时间.text+,+库存量.text+);/建立插入查询 sqlconnection conn = new sqlconnection(connstr); /建立数据库连接 conn.open(); sqlcommand cmd1 = new sqlcommand(selectcmd, conn); /建立数据库命令 sqldatareader reader = cmd1.executereader();2.查询3.增加private void 添加_click(object sender, eventargs e) 账号.focus(); if (账号.t

8、ext != & 密码.text != & 姓名.text != & 剩余可租碟数.text != & 营业员账号.text != ) /*项上不能为空 string connstr = integrated security=sspi;persist security info=false;initial catalog=影碟出租管理系统;data source=pc-20100331fomn; string selectcmd = select * from 会员 where 会员账号= + 账号.text + ; /建立选择查询 string insertcmd = insert int

9、o 会员 values( + 账号.text + , + 密码.text + , + 姓名.text + , + 办理时间.text + , + 剩余可租碟数.text + , + 营业员账号.text + );/建立插入查询 sqlconnection conn = new sqlconnection(connstr); /建立数据库连接 conn.open(); sqlcommand cmd1 = new sqlcommand(selectcmd, conn); /建立数据库命令 sqldatareader reader = cmd1.executereader(); if (!reade

10、r.read() /读取数据 reader.close(); sqlcommand cmd = new sqlcommand(insertcmd, conn); /建立新的数据库命令 try cmd.executenonquery(); /执行操作命令 messagebox.show(添加成功!); 账号.text = ; 密码.text = ; 姓名.text = ; 办理时间.text = ; 剩余可租碟数.text = ; 营业员账号.text = ; catch (exception ex) messagebox.show(添加出错!错误原因为:n + ex.message + n);

11、 else /账号已存在 reader.close(); messagebox.show(对不起,此账号已经被使用,请更改账号!, 会员账号检验!, messageboxbuttons.ok, messageboxicon.warning); /用户名已 账号.text = ; conn.close(); else messagebox.show(带*项不能为空!, 会员账号核查, messageboxbuttons.ok, messageboxicon.warning); string updatecmd, updatecmd1, updatecmd2, updatecmd3, update

12、cmd4; private void 修改_click(object sender, eventargs e) 账号.focus(); if (账号.text != ) /*项上不能为空 string connstr = integrated security=sspi;persist security info=false;initial catalog=影碟出租管理系统;data source=pc-20100331fomn; string selectcmd = select * from 会员 where 会员账号= + 账号.text + ; /建立选择查询 if (密码.text

13、!= ) updatecmd = update 会员 set 密码= + 密码.text + where 会员账号= + 账号.text + ; if (姓名.text != ) updatecmd1 = update 会员 set 姓名= + 姓名.text + where 会员账号= + 账号.text + ; if (办理时间.text != ) updatecmd2 = update 会员 set 办理时间= + 办理时间.text + where 会员账号= + 账号.text + ; if (剩余可租碟数.text != ) updatecmd3 = update 会员 set 剩

14、余可租碟数= + 剩余可租碟数.text + where 会员账号= + 账号.text + ; if (营业员账号.text != ) updatecmd4 = update 会员 set 营业员账号= + 营业员账号.text + where 会员账号= + 账号.text + ; /建立更新查询 sqlconnection conn = new sqlconnection(connstr); /建立数据库连接 conn.open(); sqlcommand cmd = new sqlcommand(selectcmd, conn); /建立数据库命令 sqldatareader read

15、er = cmd.executereader(); if (reader.read() /读取数据 reader.close(); try if (密码.text != ) sqlcommand cmd1 = new sqlcommand(updatecmd, conn); /建立新的数据库命令 cmd1.executenonquery(); if (姓名.text != ) sqlcommand cmd2 = new sqlcommand(updatecmd1, conn); /建立新的数据库命令 cmd2.executenonquery(); if (办理时间.text != ) sqlc

16、ommand cmd3 = new sqlcommand(updatecmd2, conn); /建立新的数据库命令 cmd3.executenonquery(); if (剩余可租碟数.text != ) sqlcommand cmd4 = new sqlcommand(updatecmd3, conn); /建立新的数据库命令 cmd4.executenonquery(); if (营业员账号.text != ) sqlcommand cmd5 = new sqlcommand(updatecmd4, conn); /建立新的数据库命令 cmd5.executenonquery(); me

17、ssagebox.show(修改成功!); 账号.text = ; 密码.text = ; 姓名.text = ; 办理时间.text = ; 剩余可租碟数.text = ; 营业员账号.text = ; catch (exception ex) messagebox.show(修改出错!错误原因为:n + ex.message + n); 账号.text = ; 密码.text = ; 姓名.text = ; 办理时间.text = ; 剩余可租碟数.text = ; 营业员账号.text = ; else /影碟编号已存在 reader.close(); messagebox.show(对

18、不起,无此会员,请更改会员编号!, 会员账号检验!, messageboxbuttons.ok, messageboxicon.warning); /用户名已 账号.text = ; conn.close(); private void 删除_click(object sender, eventargs e) string connstr = integrated security=sspi;persist security info=false;initial catalog=影碟出租管理系统;data source=pc-20100331fomn; sqlconnection conn =

19、 new sqlconnection(connstr); conn.open(); string select = select * from 出租关系 where 会员账号= + 账号.text + ; sqlcommand cmd1 = new sqlcommand(select, conn); sqldatareader reader1 = cmd1.executereader(); if (!reader1.read() string selectcmd = select * from 会员 where 会员账号= + 账号.text + ; sqlcommand cmd = new

20、sqlcommand(selectcmd, conn); sqldatareader reader = cmd.executereader(); if (!reader.read() messagebox.show(不存在此会员!, , messageboxbuttons.ok, messageboxicon.warning); else reader.close(); dialogresult result = messagebox.show(确实要删除此会员吗?, , messageboxbuttons.yesno, messageboxicon.question); if (result

21、 = dialogresult.yes) string delstr = delete from 会员 where 会员账号= + 账号.text + ; cmd = new sqlcommand(delstr, conn); cmd.executenonquery(); messagebox.show(已成功删除了此会员!); 账号.text = ; else messagebox.show(此会员有影碟未归还,不能删除!, , messageboxbuttons.ok, messageboxicon.warning); private void 查询_click(object sender

22、, eventargs e) string source = integrated security=sspi;persist security info=false;initial catalog=影碟出租管理系统;data source=pc-20100331fomn; string select = select * from 会员 where 会员账号= + 账号.text + ; string select1 = select * from 会员 where 姓名= + 姓名.text + ; string select2 = select * from 会员 where 营业员账号

23、= + 营业员账号.text + ; sqlconnection conn = new sqlconnection(source); conn.open(); sqldataadapter adapter = new sqldataadapter(select, conn); sqldataadapter adapter1 = new sqldataadapter(select1, conn); sqldataadapter adapter2 = new sqldataadapter(select2, conn); dataset ds = new dataset(); if (账号.text

24、 != ) if (会员信息.columns.count 0) 会员信息.columns.clear(); adapter.fill(ds, 会员); datatablereader dtr = ds.createdatareader(); if (dtr.read() 会员信息.datasource = ds.tables会员; 账号.text = ; 密码.text = ; 姓名.text = ; 办理时间.text = ; 剩余可租碟数.text = ; 营业员账号.text = ; else dtr.close(); messagebox.show(不存在此会员,请重新输入会员账号!)

25、; 账号.text = ; 密码.text = ; 姓名.text = ; 办理时间.text = ; 剩余可租碟数.text = ; 营业员账号.text = ; else if (姓名.text != ) if (会员信息.columns.count 0) 会员信息.columns.clear(); adapter1.fill(ds, 会员); datatablereader dtr = ds.createdatareader(); if (dtr.read() 会员信息.datasource = ds.tables会员; 账号.text = ; 密码.text = ; 姓名.text =

26、 ; 办理时间.text = ; 剩余可租碟数.text = ; 营业员账号.text = ; else messagebox.show(不存在此会员,请重新输入会员账号!); 账号.text = ; 密码.text = ; 姓名.text = ; 办理时间.text = ; 剩余可租碟数.text = ; 营业员账号.text = ; else if (营业员账号.text!=) if (会员信息.columns.count 0) 会员信息.columns.clear(); adapter2.fill(ds, 会员); datatablereader dtr = ds.createdatar

27、eader(); if (dtr.read() 会员信息.datasource = ds.tables会员; 账号.text = ; 密码.text = ; 姓名.text = ; 办理时间.text = ; 剩余可租碟数.text = ; 营业员账号.text = ; else messagebox.show(不存在此会员,请重新输入会员账号!); 账号.text = ; 密码.text = ; 姓名.text = ; 办理时间.text = ; 剩余可租碟数.text = ; 营业员账号.text = ; else messagebox.show(请输入会员账号!); 账号.text =

28、; conn.close(); private void 浏览_click(object sender, eventargs e) if (会员信息.columns.count 0) 会员信息.columns.clear(); string source = integrated security=sspi;persist security info=false;initial catalog=影碟出租管理系统;data source=pc-20100331fomn; string select = select 会员账号,姓名,办理时间,剩余可租碟数,营业员账号 from 会员; sqlco

29、nnection conn = new sqlconnection(source); conn.open(); sqldataadapter adapter = new sqldataadapter(select, conn); dataset ds = new dataset(); adapter.fill(ds, 会员); datatablereader dtr = ds.createdatareader(); if (dtr.read() 会员信息.datasource = ds.tables会员; else messagebox.show(不存在此会员!); conn.close();

30、 private void 会员移交_click(object sender, eventargs e) this.hide(); 会员移交 from = new 会员移交(); from.show(); 4.删除5.修改private void 修改_click(object sender, eventargs e) 账号.focus(); if (账号.text != ) /*项上不能为空 string connstr = integrated security=sspi;persist security info=false;initial catalog=影碟出租管理系统;data s

31、ource=pc-20100331fomn; string selectcmd = select * from 会员 where 会员账号= + 账号.text + ; /建立选择查询 if (密码.text != ) updatecmd = update 会员 set 密码= + 密码.text + where 会员账号= + 账号.text + ; if (姓名.text != ) updatecmd1 = update 会员 set 姓名= + 姓名.text + where 会员账号= + 账号.text + ; if (办理时间.text != ) updatecmd2 = upda

32、te 会员 set 办理时间= + 办理时间.text + where 会员账号= + 账号.text + ; if (剩余可租碟数.text != ) updatecmd3 = update 会员 set 剩余可租碟数= + 剩余可租碟数.text + where 会员账号= + 账号.text + ; if (营业员账号.text != ) updatecmd4 = update 会员 set 营业员账号= + 营业员账号.text + where 会员账号= + 账号.text + ; /建立更新查询 sqlconnection conn = new sqlconnection(conn

33、str); /建立数据库连接 conn.open(); sqlcommand cmd = new sqlcommand(selectcmd, conn); /建立数据库命令 sqldatareader reader = cmd.executereader(); if (reader.read() /读取数据 reader.close(); try if (密码.text != ) sqlcommand cmd1 = new sqlcommand(updatecmd, conn); /建立新的数据库命令 cmd1.executenonquery(); if (姓名.text != ) sqlcommand cmd2 = new

温馨提示

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

评论

0/150

提交评论