姓 名: 学 号: 专 业: 班 级: 组 号: 指导教师:
数学系
1.
需求分析说明书 ........................................................................................................................ 3 1.1. 数据库分析 ................................................................................................................. 3 1.2. 系统功能分析 ................................................................................................................... 3 E-R模型设计 ............................................................................................................................. 3 数据库设计 ................................................................................................................................ 4 系统功能实现 ............................................................................................................................ 5
4.1.连接数据库 ................................................................................................................ 5 4.2.用户登录界面 ............................................................................................................ 6 4.3.系统主界面 ................................................................................................................ 8 4.4.借还图书 .................................................................................................................... 9 4.4.1. 借阅图书 .................................................................................................................. 9 4.4.2.当前借阅 ............................................................................................................... 11 4.4.3.归还处理 ............................................................................................................... 12 4.5.书库操作 .................................................................................................................. 14 4.5.1.书库管理 ............................................................................................................... 14 4.5.2.书库列表 ............................................................................................................... 15 4.5.3.查找图书 ............................................................................................................... 16 4.6. 读者操作 ................................................................................................................... 17 4.6.1.读者管理 ............................................................................................................... 17 4.6.2.读者列表 ............................................................................................................... 19 4.6.3.读者查询 ............................................................................................................... 19 4.7. 用户管理 ................................................................................................................... 20 4.7.1.系统用户管理 ....................................................................................................... 20 4.7.2.系统设置 ............................................................................................................... 22
2.
3. 4.
课程设计题目:图书馆管理系统
1. 需求分析说明书
1.1. 数据库分析
通过对图书馆管理系统功能的分析和实际调查情况,所设计的图书馆管理系统包括以下数据库信息:
(1)管理员基本信息:管理员ID、密码。
(2)图书信息:包括图书ID、图书名称、作者、单价、借书人、以及借出标记。
(3)借书信息:借书人、所借的的书名。
(4)读者信息:包括读者编号、读者姓名、班级、以及所借书籍。 (5)系统设置:启动动画、背景图片、开机登录窗口初始。
1.2. 系统功能分析
本系统功能模块取决于登陆者的身份,若以管理员身份登录,拥有以下功能: (1) 书库管理:包括新书登记、图书信息查询、修改图书信息等功能。 (2) 读者管理:其提供办理借阅证、借阅证信息查询、修改借阅证等功能。 (3) 系统管理:包括添加账号、修改密码和退出系统等功能。 若以读者身份登录本系统,拥有以下功能:
(1) 借书功能:查询想要借的书本,然后即可借阅。 (2) 借阅查询:查询已借书本。 (3) 还书功能:归还所借书籍。
2. E-R模型设计
3. 数据库设计
BookPK Book_IDBook_NameWriterPressPriceInLibrary_DataTotal_AmoutNow_AmountPK ProofProof_IDNameSexBirth_TimeAddressID_NumberTel_NumberNow_Borrow_AmountBorrowPKFK2FK1 BorrowIDProof_IDBook_IDBorrow_DatePKFK2FK1 PuniPuni_IDProof_IDBook_IDBorrow_DateReturn_Date
基本表的设计如下: (1) 管理员基本信息表
管理员基本信息表(users)包含了图书馆管理员的基本信息,其结构如表1所示。
表1 管理员基本信息表
字 段 名 称 name_name Name_pass 数 据 类 型 VARCHAR2(50) VARCHAR2(50) 可 否 为 空 约 束 条 件 说 明 NOT NULL NOT NULL 主键 无 姓名 密码 (2) 图书信息表 图书信息表(Book)包含了图书馆所有图书的基本信息,用来方便读者查询和借阅,其结构如表2所示。
表2:图书信息表 字 段 名 称 Book_no Book_Name Book_jg Book_zname Book_jname Flag 数 据 类 型 VARCHAR(50) VARCHAR(50) VARCHAR(50) VARCHAR(50) VARCHAR(50) VARCHAR(50) 可 否 为 空 约 束 条 件 说 明 NOT NULL NOT NULL 无 无 无 无 主键 无 无 无 无 无 书籍号码 书名 书籍价格 作者 借书人 借出标记 (3) 读者信息表
读者信息表(readname)包含了所有读者的借阅卡信息,用来方便读者借阅和管理员,其结构如表3所示。
表3:读者信息表
字 段 名 称 Name_no Name_name Name_class Name_book 数 据 类 型 VARCHAR(50) VARCHAR(50) VARCHAR(50) VARCHAR(50) 可 否 为 空 约 束 条 件 说 明 NOT NULL NOT NULL NOT NULL NOT NULL 主键 无 无 无 读者号码 姓名 班级 所借书籍 (4) 借书信息表 借书信息表(namebook)包含了每个读者所借书籍信息(最多五本),其结构如表4所示。
表4:借书信息表
字 段 名 称 Name Book1 Book2 Book3 Book4 Book5 数 据 类 型 VARCHAR(50) VARCHAR(50) VARCHAR(50) VARCHAR(50) VARCHAR(50) VARCHAR(50) 可 否 为 空 约 束 条 件 无 无 无 无 无 无 无 无 无 无 无 无 说 明 借书人姓名 书本1 书本2 书本3 书本4 书本5 (5) 系统初始表 系统初始表(sz)包含了启动程序的初始设置值,其结构表如表5所示。
表5 罚单信息表
字 段 名 称 Start Bmp Flag
数 据 类 型 VARCHAR(50) VARCHAR(50) VARCHAR(50) 可 否 为 空 约 束 条 件 无 无 无 无 无 无 说 明 登录窗口选择 背景图片选择 开机动画标记 4. 系统功能实现
4.1.连接数据库
该系统是通过PowerBuilder和SQL server2000共同制作完成的。由SQLserver设计完数据库book后,将book添加到ODBC数据源中。在PowerBuilder中database中的ODBC中新建book_profile,连接数据源book,即完成了PowerBuilder和数据库的连接。并通过以下代码实现数据源的连接: SQLCA.DBMS = \"ODBC\" SQLCA.AutoCommit = False
SQLCA.DBParm = \"ConnectString='DSN=book;UID=zhuzi;PWD=123'\" connect using sqlca;
if sqlca.sqlcode<>0 then
messagebox(\"错误\数据库连接错误,请检查后重试!\ return end if
open(w_splash)
4.2.用户登录界面
本系统包括两个登陆界面:管理员登陆界面和读者登陆界面。
管理员登陆后可以实现书库管理,读者管理,与系统管理,界面如下:
完成代码如下: string id,getname,ff time d_date d_date=now() ff=string(d_date)
id=trim(sle_no.text)
getname=trim(sle_name.text)
if id=\"\" or id='' then
MessageBox(\"系统提示\请输入读者证号!\") return end if
//密码不能为空
if getname=\"\" or getname='' then
MessageBox(\"系统提示\请输入姓名!\") return end if
//读者登陆
select name_no,name_name into :ls_no,:ls_name from readname
where name_no=:id;
if sqlca.sqlcode<>0 then messagebox(\"系统提示\无此读者!\") sle_no.text=\"\" sle_name.text=\"\"
sle_no.setfocus() return end if
if getname<>trim(ls_name) then messagebox(\"警告\姓名错误!\") sle_name.text=\"\" sle_name.setfocus() return end if
messagebox('Welcome!','欢迎你的到来,'+ls_name+'!'+'现在是:'+ff) m_main.m_1.m_2.enabled=true
m_main.m_1.m_还书处理.enabled=true m_main.m_1.m_当前借阅.enabled=true
m_main.m_书库操作.m_书库管理.enabled=false m_main.m_读者操作.m_读者管理.enabled=false
m_main.m_用户管理.m_系统用户管理.enabled=false w_main.title='图书馆管理系统---当前读者: '+ls_name name=ls_name close(w_ptlogin)
读者登陆界面:读者登录后可以实现借阅图书,借书查询,还书功能。
string id,getpassword id=trim(sle_name.text)
getpassword=trim(sle_pw.text) if id=\"\" or id='' then
MessageBox(\"系统提示\请输入用户名!\") return end if
//密码不能为空
if getpassword=\"\" or getpassword='' then
MessageBox(\"系统提示\请输入密码!\") return end if
//管理员登陆
select name_name,name_pass
into :ls_name,:ls_pass from users
where name_name=:id;
if sqlca.sqlcode<>0 then messagebox(\"系统提示\无此管理员!\") sle_pw.text=\"\" sle_name.text=\"\" sle_name.setfocus() return end if
if getpassword<>trim(ls_pass) then messagebox(\"警告\口令错误!\") sle_pw.text=\"\" sle_pw.setfocus() return end if
//进入管理员管理界面
messagebox('系统登入成功','欢迎你的到来,'+ls_name+'!') m_main.m_1.m_2.enabled=false
m_main.m_1.m_当前借阅.enabled=false m_main.m_1.m_还书处理.enabled=false
m_main.m_书库操作.m_书库管理.enabled=true m_main.m_读者操作.m_读者管理.enabled=true
m_main.m_用户管理.m_系统用户管理.enabled=true
w_main.title='图书馆管理系统---当前管理员: '+ls_name close(w_gjlogin)
4.3.系统主界面
系统主界面包括如下功能:
(1) 系统处理:系统初始化,读者登录,管理员登陆,退出。 (2) 借还图书:借阅图书,当前借阅,还书处理。 (3) 书库操作:书库管理,书库列表,查找图书。 (4) 读者操作:读者管理,读者列表,读者查询。 (5) 用户管理:系统用户管理,系统设置。 (6) 帮助:关于,帮助文件。
系统初始化后,相当于当前登录到系统中的用户既不是管理员也不是读者, 所以只能实现查看图书以及查询读者的功能。初始化通过以下代码实现: m_main.m_书库操作.m_书库管理.enabled=false m_main.m_读者操作.m_读者管理.enabled=false
m_main.m_用户管理.m_系统用户管理.enabled=false m_main.m_1.m_2.enabled=false
m_main.m_1.m_当前借阅.enabled=false
m_main.m_1.m_还书处理.enabled=false w_main.title='图书馆管理系统' name='0'
messagebox('提示','系统初始化成功!')。其它功能以下详细介绍。
4.4.借还图书
借还图书包括借阅图书,当前借阅,归还处理三个模块。
4.4.1. 借阅图书
上图为借阅图书截图,该模块可以实现以下功能:首先在输入栏中输入想要借的书籍,点击查询即可获得,然后点击“借出”即可借阅。一个读者最多可借五本书。
其中,查询书籍的代码是通过书名查询的,实现代码如下: string lookforcondition
lookforcondition='book_name'+'='+\"'\"+sle_1.text+\"'\" dw_1.setfilter(lookforcondition) filter(dw_1)
if dw_1.retrieve()=0 then messagebox('提示','图书馆没有此书!')。 借书功能通过以下代码实现: string a,a1,a2,a3,a4,a5 int b=0 integer c=0
a=trim(sle_1.text) //a为要借的书
select book1,book2,book3,book4,book5 into :a1,:a2,:a3,:a4,:a5 from namebook
where name=:name; //a1,a2,a3,a4,a5为已经借的书
if a1<>'' then c=c+1 if a2<>'' then c=c+1 if a3<>'' then c=c+1 if a4<>'' then c=c+1 if a5<>'' then c=c+1
if c=5 then
messagebox('','您所借的书不能超过五本!') b=1 goto aa
elseif a=a1 or a=a2 or a=a3 or a=a4 or a=a5 then messagebox('','您已经借了这本书!') b=1 goto aa end if
choose case c case 0
update namebook set book1=:a
where name=:name; update book
set book_jname=:name 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=: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_jname=:name where book_name=:a; update book set flag='已借出' where book_name=:a; end choose aa:
if b=0 then messagebox('成功','借书成功!') dw_1.retrieve() return
4.4.2.当前借阅
当前借阅模块显示当前读者所借的书籍:
姓名栏中即为当前登录的读者姓名,其余栏中为读者所借的书籍,该对话框的open()函数编码如下:
string lookforcondition
this.X=(w_main.WorkSpaceWidth() - this.Width)/2
this.Y=(w_main.WorkSpaceHeight() - w_main.mdi_1.MicroHelpHeight - this.Height)/2 - 50
dw_1.settransobject(sqlca)
lookforcondition='name'+'='+\"'\"+ls_name+\"'\" //name即为读者的name name=lsname
dw_1.setfilter(lookforcondition) //过滤dw_1 filter(dw_1) dw_1.retrieve()
该段代码实现数据窗口中显现的为当前读者的借书信息。
4.4.3.归还处理
勾选想要归还的书名,点击确认还这些书即可完成归还功能: string a
if cbx_1.checked=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 if
if cbx_2.checked=true then
a=dw_1.getitemstring(dw_1.getrow(),'book2') update namebook set 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 if
if 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_name=:a; update book set flag='未借出' where book_name=:a; end if
if 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 if
if cbx_5.checked=true 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 if
if cbx_1.checked=true or cbx_2.checked=true or cbx_3.checked=true or cbx_4.checked=true or cbx_5.checked=true then
messagebox('提示','成功!') else
messagebox('提示','您还没有还书!') end if
close(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 then
dw_1.resetupdate() commit;
messagebox('成功','数据已成功保存!') else
rollback;
messagebox('失败','数据保存失败!') end if
退出实现编码:
int mcount,updateORnot //修改后没有保存的行数,是否修改 mcount=w_book.dw_1.modifiedcount() if mcount=0 then
//无未保存的修改 close(w_book) elseif mcount>0 then
updateORnot=messagebox(\"保存修改\您已修改数据,存?\
if updateORnot=1 then //保存
if update(w_book.dw_1,true,false)=1 then //保存成功,提交修改 w_book.dw_1.resetupdate() commit; else rollback; messagebox(\"错误!\保存失败\") end if
close(w_book)
elseif updateORnot=2 then //不保存 rollback;
close(w_book) end if end if
4.5.2.书库列表
书库列表模块实现显示书库中所有图书的信息,截图如下:
是否保
4.5.3.查找图书
该模块实现搜索图书的功能,有四种搜错方式:按书号,按书名,按价格,按作者。
按书号通过以下编码实现: string lookforcondition
lookforcondition='book_no'+'='+\"'\"+sle_1.text+\"'\" dw_1.setfilter(lookforcondition)
filter(dw_1)
if dw_1.retrieve()=0 then messagebox('提示','图书馆没有此书!') 按书名通过以下编码实现: string lookforcondition
lookforcondition='book_name'+'='+\"'\"+sle_3.text+\"'\" dw_1.setfilter(lookforcondition) filter(dw_1)
if dw_1.retrieve()=0 then messagebox('提示','图书馆没有此书!') 按价格通过如下实现: string lookforcondition
lookforcondition='book_jg'+ddplb_1.text+sle_4.text dw_1.setfilter(lookforcondition) filter(dw_1)
if dw_1.retrieve()=0 then messagebox('提示','图书馆没有此书!') 按作者:
string lookforcondition
lookforcondition='book_zname'+'='+\"'\"+sle_5.text+\"'\" dw_1.setfilter(lookforcondition) filter(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 f
dw_1.scrolltorow(dw_1.rowcount())
f=dw_1.getitemstring(dw_1.getrow(),'name_name') insert namebook(name) values (:f);
if update(dw_1)=1 then dw_1.resetupdate() commit;
messagebox('成功','数据已成功保存!') else
rollback;
messagebox('失败','数据保存失败!') end if
退出编码实现如下:
int mcount,updateORnot //修改后没有保存的行数,是否修改 mcount=w_book.dw_1.modifiedcount() if mcount=0 then
//无未保存的修改 close(w_book) elseif mcount>0 then
updateORnot=messagebox(\"保存修改\您已修改数据,存?\
if updateORnot=1 then //保存
if update(w_book.dw_1,true,false)=1 then //保存成功,提交修改 w_book.dw_1.resetupdate() commit; else rollback; messagebox(\"错误!\保存失败\") end if
close(w_book)
elseif updateORnot=2 then //不保存 rollback;
close(w_book) end if end if
是否保4.6.2.读者列表
显示所有读者信息,并提供打印功能。
4.6.3.读者查询
按三种方式进行查询:图书证号,姓名,班级。 通过变量p标识使用哪种查询方式: 图书证号:p=1 sle_1.setfocus() sle_1.enabled=true sle_2.enabled=false sle_3.enabled=false 姓名:p=2 sle_2.setfocus()
sle_2.enabled=true sle_1.enabled=false sle_3.enabled=false 班级:p=3 sle_3.setfocus() sle_3.enabled=true sle_2.enabled=false sle_1.enabled=false
查找功能通过以下编码实现: choose case p case 1 abc='name_no'+'='+\"'\"+sle_1.text+\"'\" case 2 abc='name_name'+'='+\"'\"+sle_2.text+\"'\" case 3 abc='name_class'+'='+\"'\"+sle_3.text+\"'\" end choose
messagebox('',abc) dw_1.setfilter(abc) filter(dw_1)
if dw_1.retrieve()=0 then messagebox('提示','无此记录!')
4.7. 用户管理
用户管理包括系统用户管理和系统设置两个功能。
4.7.1.系统用户管理
系统用户管理只能通过管理员权限操作。可以实现对系统用户,即管理员的增加,删除和修改等功能。
增加:
dw_1.ScrollToRow(dw_1.InsertRow(0)) dw_1.SetFocus()
删除:deleterow(dw_1,dw_1.getrow()) 保存:
if update(dw_1)=1 then dw_1.resetupdate() commit;
messagebox('成功','数据已成功保存!') else
rollback;
messagebox('失败','数据保存失败!') end if
关闭实现编码:
int mcount,updateORnot //修改后没有保存的行数,是否修改 mcount=w_book.dw_1.modifiedcount() if mcount=0 then
//无未保存的修改 close(w_book) elseif mcount>0 then
updateORnot=messagebox(\"保存修改\您已修改数据,存?\
if updateORnot=1 then //保存
if update(w_book.dw_1,true,false)=1 then //保存成功,提交修改 w_book.dw_1.resetupdate() commit; else rollback; messagebox(\"错误!\保存失败\") end if
close(w_book)
elseif updateORnot=2 then //不保存 rollback;
close(w_book) end if end if
是否保4.7.2.系统设置
主要包括三个功能:开机登录窗口的设置,背景图选择,是否显示开机画面。 Open()函数编码如下: char a,b,c
select start,bmp,flag into :a,:b,:c from sz;
choose case a //a为初始登录方式,对应start为0,1,2 case '0' rb_3.checked=true case '1' rb_1.checked=true case '2' rb_2.checked=true end choose
choose case b //背景选择,对应bmp 0,1,2,3 case '0' rb_4.checked=true case '1' rb_5.checked=true case '2' rb_6.checked=true case '3' rb_7.checked=true end choose
choose case c //启动动画,对应flag 0,1 case '0' cbx_1.checked=false case '1' cbx_1.checked=true end choose
this.X=(w_main.WorkSpaceWidth() - this.Width)/2
this.Y=(w_main.WorkSpaceHeight() - w_main.mdi_1.MicroHelpHeight this.Height)/2 – 50
确定实现编码: char a,b,c
//p为初始登录方式 if p='1' then
- update sz set start='1'; end if
if p='2' then update sz set start='2'; end if
if p='0' then update sz set start='0'; end if
//q为背景选择 choose case q case '0'
update sz set bmp='0'; case '1'
update sz set bmp='1'; case '2'
update sz set bmp='2'; case '3'
update sz set bmp='3'; end choose //v为开机动画 if v='1' then update sz set flag='1'; end if
if v='0' then update sz set flag='0'; end if
select start,bmp,flag into :a,:b,:c from sz;
messagebox('','系统设置成功,下次启动有效!') close(parent)
因篇幅问题不能全部显示,请点此查看更多更全内容