收藏 分享(赏)

图书馆管理系统示范.doc

上传人:tkhy51908 文档编号:7114577 上传时间:2019-05-06 格式:DOC 页数:41 大小:1.86MB
下载 相关 举报
图书馆管理系统示范.doc_第1页
第1页 / 共41页
图书馆管理系统示范.doc_第2页
第2页 / 共41页
图书馆管理系统示范.doc_第3页
第3页 / 共41页
图书馆管理系统示范.doc_第4页
第4页 / 共41页
图书馆管理系统示范.doc_第5页
第5页 / 共41页
点击查看更多>>
资源描述

1、宿舍图书馆管理系统本系统采用 SQL Server 2000 作后台数据库,Visual Basic 6.0 作前台界面。一、 系统需求分析1、 需求分析2、 概念模型设计3、 逻辑结构设计二、 系统设计(系统总体设计,数据库设计)1、 系统界面及代码设计(1) 工程的结构该图书馆系统由 19个窗体,1 个标准模块(Module1.Bas) 和 1个设计器组成,如图所示:(2) 模块程序(Module1)模块的代码如下:Option ExplicitPublic cnn As ADODB.Connection 定义连接数据库对象Public cmd As ADODB.CommandPublic

2、 cmd1 As ADODB.Command 定义执行 sql语句对象Public rst As New ADODB.Recordset 定义打开表对象Public rst1 As New ADODB.RecordsetPublic rst2 As New ADODB.RecordsetPublic cnt As Integer 定义用户登录次数值(3) 连接数据库(Form1)“连接数据库”窗体的设计界面如下图:窗体中各控件的属性设置。其 caption属性与文本框的 text属性如表:“连接数据库”窗体控件属性Name属性 其他属性Label1(0) Caption=” 服务器”Label

3、1(1) Caption=” 数据库”Command1 Caption=”连接”Command2 Caption=” 返回”Form1 Caption=”连接数据库”Text1Text2“连接数据库”窗体的代码如下:Private Sub Command1_Click()If Text1.Text = “ ThenMsgBox “没有填写服务器“, vbOKOnly + vbExclamation, “Text1.SetFocusElseIf Text2.Text = “ ThenMsgBox “没有填写数据库“, vbOKOnly + vbExclamation, “Text2.SetFoc

4、usElsecnn = “Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=“ Data Source=“ & Text1.Text & “cnn.Open cnnUnload Melogin.ShowEnd IfEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()Set cnn = New ADODB.ConnectionEnd Sub(4) 登录(login)“登录”窗

5、体的设计界面如下图:窗体中各控件的属性设置。其 caption属性与文本框的 text属性如表: Name属性 其他属性Label1(0) Caption=” 用户名”Label1(1) Caption=” 密码”Command1 Caption=”确定”Command2 Caption=” 返回”login Caption=”连接数据库”Text1Text2 Passwordchar=”*”“登录”窗体的代码如下:Private Sub Command1_Click()If Text1.Text = “ Then 判断输入的用户名是否为空MsgBox “没有这个用户“, vbOKOnly +

6、 vbExclamation, “ElseIf rst.State = 1 Thenrst.CloseEnd Ifrst.Open “select * from 用户 where 用户名=“ & Text1.Text & “, cnn,adOpenKeyset, adLockPessimisticIf rst.EOF = True ThenMsgBox “没有这个用户“, vbOKOnly + vbExclamation, “rst.CloseText1.Text = “Text1.SetFocusElse 检验密码是否正确If Trim(rst.Fields(“密码“).Value) = T

7、rim(Text2.Text) Thenrst.CloseUnload Memenu.ShowElseMsgBox “密码不正确“, vbOKOnly + vbExclamation, “rst.CloseText2.Text = “Text2.SetFocusEnd IfEnd IfEnd Ifcnt = cnt + 1If cnt = 3 ThenUnload MeEnd IfExit SubEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()Set cmd = New ADODB.Comman

8、dcmd.ActiveConnection = cnncmd.CommandType = adCmdTextSet cmd1 = New ADODB.Commandcmd1.ActiveConnection = cnncmd1.CommandType = adCmdTextcnt = 0End Sub(5) 图书馆系统(menu)“图书馆系统”窗体的设计界面如下图:根据图书管理系统的功能,主窗体上设计有“用户系统” , “读者管理系统” ,“图书管理系统” , “借阅管理系统”及“登录退出系统”共 5个主菜单,主菜单中又包含菜单项和子菜单项,各级菜单的菜单级别及属性如下表: 标题 名称用户系统

9、 yh增加用户 addyh修改口令 xgyh删除用户 deyh读者管理系统 dzgl增加读者信息 adddz修改读者信息 xgdz删除读者信息 dedz查找读者信息 Indz图书管理系统 tsgl增加图书 addts修改图书 xgts删除图书 dets查询图书 cxts借阅管理系统 jy借书 zs还书 hs借阅情况 zqk登陆退出系统 退出切换用户 等完全退出 完全“图书馆系统”窗体的代码如下:Private Sub adddz_Click()Unload Meaddread.ShowEnd SubPrivate Sub addts_Click()Unload Meaddbooks.ShowE

10、nd SubPrivate Sub addyh_Click()Unload Meaddlogin.ShowEnd SubPrivate Sub cxts_Click()Unload Mesearchbook.ShowEnd SubPrivate Sub dedz_Click()Unload Medeleteread.ShowEnd SubPrivate Sub dets_Click()Unload Medeletebook.ShowEnd SubPrivate Sub deyh_Click()Unload Medeletelogin.ShowEnd SubPrivate Sub hs_Clic

11、k()Unload Mebackbook.ShowEnd SubPrivate Sub indz_Click()Unload Mesearchread.ShowEnd SubPrivate Sub xgdz_Click()Unload Meinsertread.ShowEnd SubPrivate Sub xgts_Click()Unload Meinsertbook.ShowEnd SubPrivate Sub xgyh_Click()Unload Meinsertlogin.ShowEnd SubPrivate Sub zqk_Click()Unload Mesearchborrow.Sh

12、owEnd SubPrivate Sub zs_Click()Unload Meborrowbook.ShowEnd SubPrivate Sub 等_Click()Unload Melogin.ShowEnd SubPrivate Sub 完全_Click()Unload MeEnd Sub(6) 增加用户(addlogin)“增加用户”窗体的设计界面如下图:窗体中各控件的属性设置。其 caption属性与文本框的 text属性如表: Name属性 其他属性Label1(0) Caption=” 用户名”Label1(1) Caption=” 密码”Label1(2) Caption=” 密

13、码确认”Command1 Caption=”确定”Command2 Caption=” 退出”addlogin Caption=”增加用户”Text1Text2 Passwordchar=”*”Text3 Passwordchar=”*”“增加用户”窗体的代码如下:Private Sub Command1_Click()If Text1.Text = “ ThenMsgBox “没有填写用户名!“, vbOKOnly + vbExclamation, “Text1.SetFocusElseIf Text2.Text = “ ThenMsgBox “没有填写密码!“, vbOKOnly + vb

14、Exclamation, “Text2.SetFocusElseIf Text3.Text = “ ThenMsgBox “没有填写确定密码!“, vbOKOnly + vbExclamation, “Text3.SetFocusElseIf Text2.Text = Text3.Text Thencmd.CommandText = “insert into 用户(用户名,密码) values(“ & Text1.Text & “,“ & Text2.Text & “)“MsgBox “添加用户信息成功!“, vbOKOnly, “cmd.ExecuteElseMsgBox “添加用户信息失败

15、!“, vbOKOnly + vbExclamation, “Text2.SetFocusEnd IfEnd SubPrivate Sub Command2_Click()Unload Memenu.ShowEnd Sub(7) 修改用户(insertlogin)“修改用户”窗体的设计界面如下图:窗体中各控件的属性设置。其 caption属性与文本框的 text属性如表: Name属性 其他属性Label1(0) Caption=” 用户名”Label1(1) Caption=”原密码”Label1(2) Caption=” 新密码”Label1(3) Caption=”密码确认”Comman

16、d1 Caption=”确定”Command2 Caption=” 返回”insertlogin Caption=”修改用户”Text1Text2 Passwordchar=”*”Text3 Passwordchar=”*”Text4 Passwordchar=”*”“修改用户”窗体的代码如下:Private Sub Command1_Click()Dim rst As New ADODB.RecordsetIf rst.State = 1 Thenrst.CloseEnd IfIf Text3.Text = “ ThenMsgBox “没有填写新密码!“, vbOKOnly + vbExcl

17、amation, “Text3.SetFocusElseIf Text4.Text = “ ThenMsgBox “没有填写新确定密码!“, vbOKOnly + vbExclamation, “Text4.SetFocusElserst.Open “select * from 用户 where 用户名=“ & Text1.Text & “, cnn, adOpenKeyset, adLockPessimisticIf rst.EOF = True ThenMsgBox “没有这个用户“, vbOKOnly + vbExclamation, “Else 检验密码是否正确If Trim(rst.

18、Fields(“密码“).Value) = Trim(Text2.Text) ThenIf Text3.Text = Text4.Text Thenrst.Closecmd.CommandText = “update 用户 set 密码=“ & Text3.Text & “ where 用户名=“ & Text1.Text & “and 密码=“ & Text2.Text & “cmd.ExecuteMsgBox “修改成功!“, vbOKOnly, “ElseMsgBox “用户新密码不正确!“, vbOKOnly + vbExclamation, “Text3.Text = “Text4.

19、Text = “Text3.SetFocusEnd IfElseMsgBox “用户密码不正确!“, vbOKOnly + vbExclamation, “Text2.Text = “Text2.SetFocusEnd IfEnd IfEnd IfEnd SubPrivate Sub Command2_Click()Unload Memenu.ShowEnd Sub(8) 删除用户(deletelogin)“删除用户”窗体的设计界面如下图:窗体中各控件的属性设置。其 caption属性与文本框的 text属性如表: Name属性 其他属性Label1(0) Caption=” 用户名”Labe

20、l1(1) Caption=” 密码”Command1 Caption=”确定”Command2 Caption=” 返回”deletelogin Caption=”删除用户”Text1Text2 Passwordchar=”*”“删除用户”窗体的代码如下:Private Sub Command1_Click()Dim rst As New ADODB.RecordsetIf rst.State = 1 Thenrst.CloseEnd IfIf Text1.Text = “ ThenMsgBox “没有填写用户名!“, vbOKOnly + vbExclamation, “Text1.Set

21、FocusElseIf Text2.Text = “ ThenMsgBox “没有填写密码!“, vbOKOnly + vbExclamation, “Text2.SetFocusElseIf Text1.Text “ Thenrst.Open “select * from 用户 where 用户名=“ & Text1.Text & “, cnn, adOpenKeyset, adLockPessimisticIf rst.EOF = True ThenMsgBox “没有这个用户“, vbOKOnly + vbExclamation, “rst.CloseText1.Text = “Text

22、1.SetFocusElse 检验密码是否正确If Trim(rst.Fields(“密码“).Value) = Trim(Text2.Text) Thenrst.Closecmd.CommandText = “delete from 用户 where 用户名=“ & Text1.Text & “Dim str2 As VbMsgBoxResultstr2 = MsgBox(“确定要删除? “, vbYesNo + vbInformation, “)If str2 = vbYes Thencmd.ExecuteMsgBox “删除成功!“, vbOKOnly, “Unload Memenu.S

23、howEnd IfElseMsgBox “要删除的用户密码不正确!“, vbOKOnly + vbExclamation, “Text2.Text = “Text2.SetFocusEnd IfEnd IfEnd IfEnd SubPrivate Sub Command2_Click()If rst.State = 1 Thenrst.CloseEnd IfUnload Memenu.ShowEnd Sub(9) 增加读者信息(addread)“增加读者信息”窗体的设计界面如下图:窗体中各控件的属性设置。其 caption属性与文本框的 text属性如表: Name属性 其他属性Label1(

24、0) Caption=” 读者编号”Label1(1) Caption=” 读者名称”Label1(2) Caption=”性别”Label1(3) Caption=”读者类别”Label1(4) Caption=”工作单位”Label1(5) Caption=”家庭住址”Label1(6) Caption=”联系电话”Command1 Caption=”确定”Command2 Caption=” 退出”addread Caption=”增加读者信息”Text1Text2Text3Text4Text5Frame1 Caption=” 输入要增加的读者信息”“增加读者信息”窗体的代码如下:Pri

25、vate Sub Command2_Click()If rst.State = 1 Thenrst.CloseEnd IfIf Text1.Text = “ ThenMsgBox “没有填写读者编号!“, vbOKOnly + vbExclamation, “Text1.SetFocusElserst.Open “select * from 读者基本信息 where 读者编号 =“ & Text1.Text & “, cnn, adOpenKeyset, adLockPessimisticIf Not rst.EOF = True ThenMsgBox “读者编号已存在!“, vbOKOnly

26、 + vbExclamation, “Text1.Text = “Text1.SetFocusElserst.Closecmd.CommandText = “insert into 读者基本信息(读者编号,读者名称,性别,读者类别,工作单位,家庭住址,联系电话) values(“ & Text1.Text & “,“ & Text2.Text & “,“ & Combo1.Text & “,“ & Combo2.Text & “,“ & Text3.Text & “,“ & Text4.Text & “,“ & Text5.Text & “)“MsgBox “添加读者基本信息信息成功!“, v

27、bOKOnly, “cmd.ExecuteUnload Memenu.ShowEnd IfEnd IfEnd SubPrivate Sub Command3_Click()Unload Memenu.ShowEnd SubPrivate Sub Form_Load()Combo2.AddItem “老师“Combo2.AddItem “学生“Combo2.AddItem “其他“Combo1.AddItem “男“Combo1.AddItem “女“End Sub(10) 修改读者信息“修改读者信息”窗体的设计界面如下图:窗体中各控件的属性设置。其 caption属性与文本框的 text属性如

28、表: Name属性 其他属性Label1(0) Caption=” 读者编号”Label1(1) Caption=” 读者名称”Label1(2) Caption=”性别”Label1(3) Caption=”读者类别”Label1(4) Caption=”工作单位”Label1(5) Caption=”家庭住址”Label1(6) Caption=”联系电话”Command1 Caption=”确定”Command2 Caption=” 修改”Command3 Caption=” 返回”addread Caption=”修改读者信息”Text1Text2Text3Text4Text5Fram

29、e1“修改读者信息”窗体的代码如下:If Text1.Text = “ ThenMsgBox “没有填写读者编号!“, vbOKOnly + vbExclamation, “ElseIf Text2.Text “ Thencmd.CommandText = “update 读者基本信息 set 性别=“ & Combo1.Text & “ where 读者编号=“ & Text1.Text & “cmd.ExecuteEnd IfIf Combo2.Text “ Thencmd.CommandText = “update 读者基本信息 set 工作单位=“ & Text3.Text & “ w

30、here 读者编号=“ & Text1.Text & “cmd.ExecuteEnd IfIf Text4.Text “ Thencmd.CommandText = “update 读者基本信息 set 联系电话=“ & Text5.Text & “ where 读者编号=“ & Text1.Text & “cmd.ExecuteEnd IfMsgBox “修改成功!“, vbOKOnly, “Unload Memenu.ShowEnd IfEnd SubPrivate Sub Command3_Click()If rst.State = 1 Thenrst.CloseEnd IfUnload

31、 Memenu.ShowEnd SubPrivate Sub Form_Load()Command2.Enabled = FalseCombo2.AddItem “老师“Combo2.AddItem “学生“Combo2.AddItem “其他“Combo1.AddItem “男“Combo1.AddItem “女“End Sub(11) 删除读者信息(deleteread)“删除读者信息”窗体的设计界面如下图:窗体中各控件的属性设置。其 caption属性与文本框的 text属性如表: Name属性 其他属性Label1(0) Caption=” 读者编号”Label1(1) Caption

32、=” 读者名称”Command1 Caption=”确定”Command2 Caption=” 返回”deleteread Caption=”删除读者信息”Text1Text2“删除读者信息”窗体的代码如下:Private Sub Command1_Click()If rst.State = 1 Thenrst.CloseEnd IfIf Text1.Text = “ ThenMsgBox “没有填写读者编号!“, vbOKOnly + vbExclamation, “Text1.SetFocusElseIf Text2.Text = “ ThenMsgBox “没有填写读者名称!“, vbO

33、KOnly + vbExclamation, “Text2.SetFocusElseIf Text1.Text “ Thenrst.Open “select * from 读者基本信息 where 读者编号=“ & Text1.Text & “, cnn, adOpenKeyset, adLockPessimisticIf rst.EOF = True ThenMsgBox “没有这个读者!“, vbOKOnly + vbExclamation, “rst.CloseText1.Text = “Text1.SetFocusElseIf Trim(rst.Fields(“读者名称“).Value

34、) = Trim(Text2.Text) Thenrst.Closecmd.CommandText = “delete from 读者基本信息 where 读者编号=“ & Text1.Text & “Dim str2 As VbMsgBoxResultstr2 = MsgBox(“确定要删除? “, vbYesNo + vbInformation, “)If str2 = vbYes Thencmd.ExecuteMsgBox “删除成功!“, vbOKOnly, “Unload Memenu.ShowEnd IfElseMsgBox “要删除的读者名称不正确“, vbOKOnly + vb

35、Exclamation, “rst.CloseText2.Text = “Text2.SetFocusEnd IfEnd IfEnd IfEnd SubPrivate Sub Command2_Click()If rst.State = 1 Thenrst.CloseEnd IfUnload Memenu.ShowEnd Sub(12) 查找读者信息 (searchread)“查找读者信息”窗体的设计界面如下图:窗体中各控件的属性设置。其 caption属性与文本框的 text属性如表: Name属性 其他属性Command2 Caption=”报表”Command3 Caption=” 退出

36、”searchread Caption=”查找读者信息”Command4 Caption=”第一行”Command5 Caption=”前一行”Command6 Caption=”后一行”Command7 Caption=”最后一行”Frame1 Caption=” 输入要查找的读者信息”“增加读者信息”窗体的代码如下:Private Sub Command2_Click()read.ShowEnd SubPrivate Sub Command3_Click()Unload Memenu.ShowEnd SubPrivate Sub Command4_Click()rst.MoveFirstE

37、nd SubPrivate Sub Command5_Click()If Not rst.BOF Thenrst.MovePreviousIf rst.BOF And rst.RecordCount 0 Thenrst.MoveFirstEnd IfEnd IfEnd SubPrivate Sub Command6_Click()If Not rst.EOF Thenrst.MoveNextIf rst.EOF And rst.RecordCount 0 Thenrst.MoveLastEnd IfEnd IfEnd SubPrivate Sub Command7_Click()rst.Mov

38、eLastEnd SubPrivate Sub Form_Load()Option1(1).Value = TrueCommand4.Enabled = FalseCommand5.Enabled = FalseCommand6.Enabled = FalseCommand7.Enabled = FalseCommand2.Enabled = FalseEnd SubPrivate Sub Image1_Click(Index As Integer)If rst.State = 1 Thenrst.CloseEnd IfIf DataE.rsread.State = 1 ThenDataE.r

39、sread.CloseEnd IfIf Option1(1).Value = True Thenrst.CursorLocation = adUseClientrst.Open “select * from 读者基本信息 where 读者编号=“ & Text1(1).Text & “, cnn, adOpenKeyset, adLockPessimisticIf rst.EOF = True ThenMsgBox “没有这个读者!“, vbOKOnly + vbExclamation, “ElseSet DataGrid1.DataSource = rstDataE.rsread.Open

40、rstCommand4.Enabled = TrueCommand5.Enabled = TrueCommand6.Enabled = TrueCommand7.Enabled = TrueCommand2.Enabled = TrueEnd IfElseIf Option3(1).Value = True Thenrst.CursorLocation = adUseClientrst.Open “select * from 读者基本信息“, cnn, adOpenKeyset, adLockPessimisticIf rst.EOF = True ThenMsgBox “没有读者!“, vb

41、OKOnly + vbExclamation, “ElseSet DataGrid1.DataSource = rstDataE.rsread.Open rstCommand4.Enabled = TrueCommand5.Enabled = TrueCommand6.Enabled = TrueCommand7.Enabled = TrueCommand2.Enabled = TrueEnd IfEnd IfEnd Sub(13) 增加图书(Addbook)“增加图书”窗体的设计界面如下图:窗体中各控件的属性设置。其 caption属性与文本框的 text属性如表: Name属性 其他属性L

42、abel1(0) Caption=” 图书编号”Label1(1) Caption=” 书名”Label1(3) Caption=”出版社”Label1(2) Caption=”类别”Label1(4) Caption=”出版日期”Label1(5) Caption=”作者”Label1(6) Caption=”内容摘要”Label1(7) Caption=”存放地点”Label1(8) Caption=”数量”Command1 Caption=”确定”Command2 Caption=” 退出”Addbook Caption=”增加图书信息”Text1Text2Text3Text4Text5

43、Text6Text7Text8Frame1 Caption=” 输入要增加的图书信息”“增加图书信息”窗体的代码如下:Private Sub Command2_Click()If rst.State = 1 Thenrst.CloseEnd IfIf Text1.Text = “ ThenMsgBox “没有填写图书编号!“, vbOKOnly + vbExclamation, “Text1.SetFocusElserst.Open “select * from 图书基本信息 where 图书编号=“ & Text1.Text & “, cnn, adOpenKeyset, adLockPes

44、simisticIf Not rst.EOF = True ThenMsgBox “图书编号已存在!“, vbOKOnly + vbExclamation, “Text1.Text = “Text1.SetFocusElserst.Closecmd.CommandText = “insert into 图书基本信息(图书编号,书名,类别,出版社,出版日期,作者,内容摘要,存放地点,数量) values(“ & Text1.Text & “,“ & Text2.Text & “,“ & Combo1.Text & “,“ & Text3.Text & “,“ & Text4.Text & “,“

45、 & Text5.Text & “,“ & Text6.Text & “,“ & Text7.Text & “,“ & Text8.Text & “)“cmd.ExecuteMsgBox “添加图书基本信息成功!“, vbOKOnly, “Unload Memenu.ShowEnd IfEnd IfEnd SubPrivate Sub Command3_Click()Unload Memenu.ShowEnd SubPrivate Sub Form_Load()Combo1.AddItem “文史“Combo1.AddItem “理工“Combo1.AddItem “英语“Combo1.Add

46、Item “计算机“End Sub(14) 修改图书(insertbook)“修改图书”窗体的设计界面如下图:窗体中各控件的属性设置。其 caption属性与文本框的 text属性如表: Name属性 其他属性Label1(0) Caption=” 图书编号”Label1(1) Caption=” 书名”Label1(3) Caption=”出版社”Label1(2) Caption=”类别”Label1(4) Caption=”出版日期”Label1(5) Caption=”作者”Label1(6) Caption=”内容摘要”Label1(7) Caption=”存放地点”Label1(8

47、) Caption=”数量”Command1 Caption=”确定”Command2 Caption=” 修改”Command3 Caption=”返回”Addbook Caption=”增加图书信息”Text1Text2Text3Text4Text5Text6Text7Text8Frame1 Caption=” 输入要增加的图书信息”“修改图书”窗体的代码如下:Private Sub Command1_Click()If Text1.Text = “ ThenMsgBox “没有填写图书编号!“, vbOKOnly + vbExclamation, “Text1.SetFocusElseI

48、f rst.State = 1 Thenrst.CloseEnd Ifrst.CursorLocation = adUseClientrst.Open “select * from 图书基本信息 where 图书编号=“ & Text1.Text & “, cnn, adOpenKeyset, adLockPessimisticIf rst.EOF = True ThenMsgBox “没有这本书!“, vbOKOnly + vbExclamation, “rst.CloseElseSet DataGrid1.DataSource = rstCommand2.Enabled = TrueEnd

49、 IfEnd IfEnd SubPrivate Sub Command2_Click()If Text1.Text = “ ThenMsgBox “没有填写图书编号!“, vbOKOnly + vbExclamation, “Text1.SetFocusElseIf Text8.Text “ Thencmd1.CommandText = “update 图书基本信息 set 书名=“ & Text2.Text & “ where 图书编号=“ & Text1.Text & “cmd1.ExecuteEnd IfIf Combo1.Text “ Thencmd1.CommandText = “update 图书基本信息 set 出版社=“ &

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

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报