数据库课程设计报告——图书馆管理系统.doc

上传人:文库蛋蛋多 文档编号:2395760 上传时间:2023-02-17 格式:DOC 页数:23 大小:324KB
返回 下载 相关 举报
数据库课程设计报告——图书馆管理系统.doc_第1页
第1页 / 共23页
数据库课程设计报告——图书馆管理系统.doc_第2页
第2页 / 共23页
数据库课程设计报告——图书馆管理系统.doc_第3页
第3页 / 共23页
数据库课程设计报告——图书馆管理系统.doc_第4页
第4页 / 共23页
数据库课程设计报告——图书馆管理系统.doc_第5页
第5页 / 共23页
点击查看更多>>
资源描述

《数据库课程设计报告——图书馆管理系统.doc》由会员分享,可在线阅读,更多相关《数据库课程设计报告——图书馆管理系统.doc(23页珍藏版)》请在三一办公上搜索。

1、数据库课程设计报告1.需求分析说明书31.1.数据库分析31.2. 系统功能分析32.E-R模型设计33.数据库设计44.系统功能实现54.1连接数据库54.2用户登录界面64.3系统主界面94.4借还图书94.4.1. 借阅图书104.4.2当前借阅124.4.3归还处理134.5书库操作154.5.1书库管理154.5.2书库列表164.5.3查找图书174.6. 读者操作184.6.1读者管理184.6.2读者列表194.6.3读者查询204.7. 用户管理214.7.1系统用户管理214.7.2系统设置23课程设计题目:图书馆管理系统1. 需求分析说明书1.1. 数据库分析通过对图书馆

2、管理系统功能的分析和实际调查情况,所设计的图书馆管理系统包括以下数据库信息: (1)管理员基本信息:管理员ID、密码。(2)图书信息:包括图书ID、图书名称、作者、单价、借书人、以及借出标记。(3)借书信息:借书人、所借的的书名。(4)读者信息:包括读者编号、读者姓名、班级、以及所借书籍。(5)系统设置:启动动画、背景图片、开机登录窗口初始。1.2. 系统功能分析本系统功能模块取决于登陆者的身份,若以管理员身份登录,拥有以下功能:(1) 书库管理:包括新书登记、图书信息查询、修改图书信息等功能。(2) 读者管理:其提供办理借阅证、借阅证信息查询、修改借阅证等功能。(3) 系统管理:包括添加账号

3、、修改密码和退出系统等功能。 若以读者身份登录本系统,拥有以下功能:(1) 借书功能:查询想要借的书本,然后即可借阅。(2) 借阅查询:查询已借书本。(3) 还书功能:归还所借书籍。 2. E-R模型设计 3. 数据库设计基本表的设计如下:(1) 管理员基本信息表 管理员基本信息表(users)包含了图书馆管理员的基本信息,其结构如表1所示。表1 管理员基本信息表字 段 名 称数 据 类 型可 否 为 空约 束 条 件说 明name_nameVARCHAR2(50)NOT NULL主键姓名Name_passVARCHAR2(50)NOT NULL无密码(2) 图书信息表图书信息表(Book)包

4、含了图书馆所有图书的基本信息,用来方便读者查询和借阅,其结构如表2所示。表2:图书信息表字 段 名 称数 据 类 型可 否 为 空约 束 条 件说 明Book_noVARCHAR(50)NOT NULL主键书籍号码Book_NameVARCHAR(50)NOT NULL无书名Book_jgVARCHAR(50)无无书籍价格Book_znameVARCHAR(50)无无作者Book_jnameVARCHAR(50)无无借书人FlagVARCHAR(50)无无借出标记(3) 读者信息表读者信息表(readname)包含了所有读者的借阅卡信息,用来方便读者借阅和管理员,其结构如表3所示。表3:读者信

5、息表字 段 名 称数 据 类 型可 否 为 空约 束 条 件说 明Name_noVARCHAR(50)NOT NULL主键读者号码Name_nameVARCHAR(50)NOT NULL无姓名Name_classVARCHAR(50)NOT NULL无班级Name_bookVARCHAR(50)NOT NULL无所借书籍(4) 借书信息表借书信息表(namebook)包含了每个读者所借书籍信息(最多五本),其结构如表4所示。表4:借书信息表字 段 名 称数 据 类 型可 否 为 空约 束 条 件说 明NameVARCHAR(50)无无借书人姓名Book1VARCHAR(50)无无书本1Book

6、2VARCHAR(50)无无书本2Book3VARCHAR(50)无无书本3Book4VARCHAR(50)无无书本4Book5VARCHAR(50)无无书本5 (5) 系统初始表 系统初始表(sz)包含了启动程序的初始设置值,其结构表如表5所示。表5 罚单信息表字 段 名 称数 据 类 型可 否 为 空约 束 条 件说 明StartVARCHAR(50)无无登录窗口选择BmpVARCHAR(50)无无背景图片选择FlagVARCHAR(50)无无开机动画标记4. 系统功能实现4.1连接数据库 该系统是通过PowerBuilder和SQL server2000共同制作完成的。由SQLserve

7、r设计完数据库book后,将book添加到ODBC数据源中。在PowerBuilder中database中的ODBC中新建book_profile,连接数据源book,即完成了PowerBuilder和数据库的连接。并通过以下代码实现数据源的连接:SQLCA.DBMS = ODBCSQLCA.AutoCommit = FalseSQLCA.DBParm = ConnectString=DSN=book;UID=zhuzi;PWD=123connect using sqlca;if sqlca.sqlcode0 thenmessagebox(错误,数据库连接错误,请检查后重试!,stopsign

8、!)returnend ifopen(w_splash)4.2用户登录界面本系统包括两个登陆界面:管理员登陆界面和读者登陆界面。管理员登陆后可以实现书库管理,读者管理,与系统管理,界面如下:完成代码如下: string id,getname,fftime d_date d_date=now()ff=string(d_date)id=trim(sle_no.text)getname=trim(sle_name.text)if id= or id= thenMessageBox(系统提示,请输入读者证号!)returnend if/密码不能为空if getname= or getname= the

9、nMessageBox(系统提示,请输入姓名!)returnend if/读者登陆select name_no,name_nameinto :ls_no,:ls_namefrom readnamewhere name_no=:id;if sqlca.sqlcode0 then messagebox(系统提示,无此读者!)sle_no.text=sle_name.text=sle_no.setfocus()returnend ifif getnametrim(ls_name) thenmessagebox(警告,姓名错误!)sle_name.text=sle_name.setfocus()ret

10、urnend ifmessagebox(Welcome!,欢迎你的到来,+ls_name+!+现在是:+ff) m_main.m_1.m_2.enabled=truem_main.m_1.m_还书处理.enabled=truem_main.m_1.m_当前借阅.enabled=truem_main.m_书库操作.m_书库管理.enabled=false m_main.m_读者操作.m_读者管理.enabled=false m_main.m_用户管理.m_系统用户管理.enabled=false w_main.title=图书馆管理系统-当前读者: +ls_namename=ls_nameclo

11、se(w_ptlogin)读者登陆界面:读者登录后可以实现借阅图书,借书查询,还书功能。string id,getpasswordid=trim(sle_name.text)getpassword=trim(sle_pw.text)if id= or id= thenMessageBox(系统提示,请输入用户名!)returnend if/密码不能为空if getpassword= or getpassword= thenMessageBox(系统提示,请输入密码!)returnend if/管理员登陆select name_name,name_passinto :ls_name,:ls_pa

12、ssfrom userswhere name_name=:id;if sqlca.sqlcode0 then messagebox(系统提示,无此管理员!)sle_pw.text=sle_name.text=sle_name.setfocus()returnend ifif getpasswordtrim(ls_pass) thenmessagebox(警告,口令错误!)sle_pw.text=sle_pw.setfocus()returnend if/进入管理员管理界面messagebox(系统登入成功,欢迎你的到来,+ls_name+!) m_main.m_1.m_2.enabled=fa

13、lse m_main.m_1.m_当前借阅.enabled=false m_main.m_1.m_还书处理.enabled=falsem_main.m_书库操作.m_书库管理.enabled=true m_main.m_读者操作.m_读者管理.enabled=true m_main.m_用户管理.m_系统用户管理.enabled=true w_main.title=图书馆管理系统-当前管理员: +ls_nameclose(w_gjlogin)4.3系统主界面系统主界面包括如下功能:(1) 系统处理:系统初始化,读者登录,管理员登陆,退出。(2) 借还图书:借阅图书,当前借阅,还书处理。(3)

14、书库操作:书库管理,书库列表,查找图书。(4) 读者操作:读者管理,读者列表,读者查询。(5) 用户管理:系统用户管理,系统设置。(6) 帮助:关于,帮助文件。系统初始化后,相当于当前登录到系统中的用户既不是管理员也不是读者,所以只能实现查看图书以及查询读者的功能。初始化通过以下代码实现:m_main.m_书库操作.m_书库管理.enabled=falsem_main.m_读者操作.m_读者管理.enabled=falsem_main.m_用户管理.m_系统用户管理.enabled=falsem_main.m_1.m_2.enabled=falsem_main.m_1.m_当前借阅.enabl

15、ed=falsem_main.m_1.m_还书处理.enabled=falsew_main.title=图书馆管理系统name=0messagebox(提示,系统初始化成功!)。其它功能以下详细介绍。4.4借还图书借还图书包括借阅图书,当前借阅,归还处理三个模块。 4.4.1. 借阅图书上图为借阅图书截图,该模块可以实现以下功能:首先在输入栏中输入想要借的书籍,点击查询即可获得,然后点击“借出”即可借阅。一个读者最多可借五本书。其中,查询书籍的代码是通过书名查询的,实现代码如下:string lookforconditionlookforcondition=book_name+=+sle_1.

16、text+dw_1.setfilter(lookforcondition)filter(dw_1)if dw_1.retrieve()=0 then messagebox(提示,图书馆没有此书!)。借书功能通过以下代码实现:string a,a1,a2,a3,a4,a5int b=0integer c=0a=trim(sle_1.text) /a为要借的书select book1,book2,book3,book4,book5into :a1,:a2,:a3,:a4,:a5from namebookwhere name=:name; /a1,a2,a3,a4,a5为已经借的书if a1 the

17、n c=c+1if a2 then c=c+1if a3 then c=c+1if a4 then c=c+1if a5 then c=c+1if c=5 thenmessagebox(,您所借的书不能超过五本!)b=1goto aaelseif a=a1 or a=a2 or a=a3 or a=a4 or a=a5 thenmessagebox(,您已经借了这本书!)b=1 goto aaend ifchoose case ccase 0 update namebook set book1=:a where name=:name; update book set book_jname=:n

18、ame where book_name=:a; update book set flag=已借出 where book_name=:a;case 1 update namebook set book2=:a where name=:name; update book set book_jname=:name where book_name=:a; update book set flag=已借出 where book_name=:a;case 2 update namebook set book3=:a where name=:name; update book set book_jname=

19、:name where book_name=:a; update book set flag=已借出 where book_name=:a;case 3 update namebook set book4=:a where name=:name; update book set book_jname=:name where book_name=:a; update book set flag=已借出 where book_name=:a;case 4 update namebook set book5=:a where name=:name; update book set book_jnam

20、e=:name where book_name=:a; update book set flag=已借出 where book_name=:a;end chooseaa:if b=0 then messagebox(成功,借书成功!)dw_1.retrieve()return4.4.2当前借阅当前借阅模块显示当前读者所借的书籍:姓名栏中即为当前登录的读者姓名,其余栏中为读者所借的书籍,该对话框的open()函数编码如下:string lookforconditionthis.X=(w_main.WorkSpaceWidth() - this.Width)/2this.Y=(w_main.Wor

21、kSpaceHeight() - w_main.mdi_1.MicroHelpHeight - this.Height)/2 - 50dw_1.settransobject(sqlca)lookforcondition=name+=+ls_name+ /name即为读者的name name=lsnamedw_1.setfilter(lookforcondition) /过滤dw_1filter(dw_1)dw_1.retrieve()该段代码实现数据窗口中显现的为当前读者的借书信息。4.4.3归还处理勾选想要归还的书名,点击确认还这些书即可完成归还功能:string aif cbx_1.che

22、cked=true then a=dw_1.getitemstring(dw_1.getrow(),book1) update namebook set book1=null where name=:ls_name; update book set book_jname=null where book_name=:a; update book set flag=未借出 where book_name=:a;end ifif cbx_2.checked=true then a=dw_1.getitemstring(dw_1.getrow(),book2) update namebook set

23、book2=null where name=:ls_name; update book set book_jname=null where book_name=:a; update book set flag=未借出 where book_name=:a;end ifif cbx_3.checked=true then a=dw_1.getitemstring(dw_1.getrow(),book3) update namebook set book3=null where name=:ls_name; update book set book_jname=null where book_na

24、me=:a; update book set flag=未借出 where book_name=:a;end ifif cbx_4.checked=true then a=dw_1.getitemstring(dw_1.getrow(),book4) update namebook set book4=null where name=:ls_name; update book set book_jname=null where book_name=:a; update book set flag=未借出 where book_name=:a;end ifif cbx_5.checked=tru

25、e then a=dw_1.getitemstring(dw_1.getrow(),book5) update namebook set book5=null where name=:ls_name; update book set book_jname=null where book_name=:a; update book set flag=未借出 where book_name=:a;end ifif cbx_1.checked=true or cbx_2.checked=true or cbx_3.checked=true or cbx_4.checked=true or cbx_5.

26、checked=true then messagebox(提示,成功!)else messagebox(提示,您还没有还书!)end ifclose(parent)4.5书库操作书库操作包括书库管理,书库列表,书库查询三个功能。4.5.1书库管理书库管理必须通过管理员权限才能够实现:书库管理可以实现增加图书,删除图书的功能。新增记录通过以下代码实现:dw_1.ScrollToRow(dw_1.InsertRow(0)dw_1.SetFocus()删除记录通过以下代码实现:deleterow(dw_1,dw_1.getrow()保存实现编码:if update(dw_1)=1 thendw_1.

27、resetupdate() commit;messagebox(成功,数据已成功保存!)elserollback;messagebox(失败,数据保存失败!)end if退出实现编码:int mcount,updateORnot /修改后没有保存的行数,是否修改mcount=w_book.dw_1.modifiedcount()if mcount=0 then/无未保存的修改close(w_book)elseif mcount0 thenupdateORnot=messagebox(保存修改,您已修改数据,是否保存?,Question!,YesNoCancel!)if updateORnot=

28、1 then/保存if update(w_book.dw_1,true,false)=1 then/保存成功,提交修改w_book.dw_1.resetupdate()commit;elserollback;messagebox(错误!,保存失败)end ifclose(w_book)elseif updateORnot=2 then/不保存rollback;close(w_book) end ifend if4.5.2书库列表书库列表模块实现显示书库中所有图书的信息,截图如下:4.5.3查找图书该模块实现搜索图书的功能,有四种搜错方式:按书号,按书名,按价格,按作者。按书号通过以下编码实现:

29、string lookforconditionlookforcondition=book_no+=+sle_1.text+dw_1.setfilter(lookforcondition)filter(dw_1)if dw_1.retrieve()=0 then messagebox(提示,图书馆没有此书!)按书名通过以下编码实现:string lookforconditionlookforcondition=book_name+=+sle_3.text+dw_1.setfilter(lookforcondition)filter(dw_1)if dw_1.retrieve()=0 then m

30、essagebox(提示,图书馆没有此书!)按价格通过如下实现:string lookforconditionlookforcondition=book_jg+ddplb_1.text+sle_4.textdw_1.setfilter(lookforcondition)filter(dw_1)if dw_1.retrieve()=0 then messagebox(提示,图书馆没有此书!)按作者:string lookforconditionlookforcondition=book_zname+=+sle_5.text+dw_1.setfilter(lookforcondition)filt

31、er(dw_1)if dw_1.retrieve()=0 then messagebox(提示,图书馆没有此书!)4.6. 读者操作读者操作包括三个功能:读者管理,读者列表,读者查询。4.6.1读者管理读者管理必须有管理员权限才能进行操作,实现读者的增删功能。新增功能:dw_1.ScrollToRow(dw_1.InsertRow(0)dw_1.SetFocus()删除功能:deleterow(dw_1,dw_1.getrow()保存:string fdw_1.scrolltorow(dw_1.rowcount()f=dw_1.getitemstring(dw_1.getrow(),name_

32、name)insert namebook(name)values (:f);if update(dw_1)=1 thendw_1.resetupdate() commit;messagebox(成功,数据已成功保存!)elserollback;messagebox(失败,数据保存失败!)end if退出编码实现如下:int mcount,updateORnot /修改后没有保存的行数,是否修改mcount=w_book.dw_1.modifiedcount()if mcount=0 then/无未保存的修改close(w_book)elseif mcount0 thenupdateORnot=

33、messagebox(保存修改,您已修改数据,是否保存?,Question!,YesNoCancel!)if updateORnot=1 then/保存if update(w_book.dw_1,true,false)=1 then/保存成功,提交修改w_book.dw_1.resetupdate()commit;elserollback;messagebox(错误!,保存失败)end ifclose(w_book)elseif updateORnot=2 then/不保存rollback;close(w_book) end ifend if4.6.2读者列表显示所有读者信息,并提供打印功能。

34、4.6.3读者查询按三种方式进行查询:图书证号,姓名,班级。通过变量p标识使用哪种查询方式:图书证号:p=1sle_1.setfocus()sle_1.enabled=truesle_2.enabled=falsesle_3.enabled=false姓名:p=2sle_2.setfocus()sle_2.enabled=truesle_1.enabled=falsesle_3.enabled=false班级:p=3sle_3.setfocus()sle_3.enabled=truesle_2.enabled=falsesle_1.enabled=false查找功能通过以下编码实现:choos

35、e case pcase 1abc=name_no+=+sle_1.text+case 2abc=name_name+=+sle_2.text+case 3abc=name_class+=+sle_3.text+end choosemessagebox(,abc)dw_1.setfilter(abc)filter(dw_1)if dw_1.retrieve()=0 then messagebox(提示,无此记录!)4.7. 用户管理用户管理包括系统用户管理和系统设置两个功能。4.7.1系统用户管理系统用户管理只能通过管理员权限操作。可以实现对系统用户,即管理员的增加,删除和修改等功能。增加:d

36、w_1.ScrollToRow(dw_1.InsertRow(0)dw_1.SetFocus()删除:deleterow(dw_1,dw_1.getrow()保存:if update(dw_1)=1 thendw_1.resetupdate() commit;messagebox(成功,数据已成功保存!)elserollback;messagebox(失败,数据保存失败!)end if关闭实现编码:int mcount,updateORnot /修改后没有保存的行数,是否修改mcount=w_book.dw_1.modifiedcount()if mcount=0 then/无未保存的修改cl

37、ose(w_book)elseif mcount0 thenupdateORnot=messagebox(保存修改,您已修改数据,是否保存?,Question!,YesNoCancel!)if updateORnot=1 then/保存if update(w_book.dw_1,true,false)=1 then/保存成功,提交修改w_book.dw_1.resetupdate()commit;elserollback;messagebox(错误!,保存失败)end ifclose(w_book)elseif updateORnot=2 then/不保存rollback;close(w_bo

38、ok) end ifend if4.7.2系统设置主要包括三个功能:开机登录窗口的设置,背景图选择,是否显示开机画面。Open()函数编码如下:char a,b,cselect start,bmp,flaginto :a,:b,:cfrom sz;choose case a /a为初始登录方式,对应start为0,1,2case 0 rb_3.checked=truecase 1 rb_1.checked=truecase 2 rb_2.checked=trueend choosechoose case b /背景选择,对应bmp 0,1,2,3case 0rb_4.checked=truec

39、ase 1rb_5.checked=truecase 2rb_6.checked=truecase 3rb_7.checked=trueend choosechoose case c /启动动画,对应flag 0,1case 0cbx_1.checked=falsecase 1 cbx_1.checked=trueend choosethis.X=(w_main.WorkSpaceWidth() - this.Width)/2this.Y=(w_main.WorkSpaceHeight() - w_main.mdi_1.MicroHelpHeight - this.Height)/2 50确定

40、实现编码:char a,b,c/p为初始登录方式if p=1 thenupdate szset start=1;end ifif p=2 thenupdate szset start=2;end ifif p=0 thenupdate szset start=0;end if/q为背景选择choose case qcase 0update szset bmp=0;case 1update szset bmp=1;case 2update szset bmp=2;case 3update szset bmp=3;end choose/v为开机动画if v=1 thenupdate szset flag=1;end ifif v=0 thenupdate szset flag=0;end ifselect start,bmp,flaginto :a,:b,:cfrom sz;messagebox(,系统设置成功,下次启动有效!)close(parent)

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

当前位置:首页 > 建筑/施工/环境 > 项目建议


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号