图书馆管理系统示范.doc_第1页
图书馆管理系统示范.doc_第2页
图书馆管理系统示范.doc_第3页
图书馆管理系统示范.doc_第4页
图书馆管理系统示范.doc_第5页
已阅读5页,还剩36页未读 继续免费阅读

下载本文档

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

文档简介

宿舍图书馆管理系统本系统采用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 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=” 服务器”Label1(1)Caption=” 数据库”Command1Caption=”连接”Command2Caption=” 返回”Form1Caption=”连接数据库”Text1Text2“连接数据库”窗体的代码如下:Private Sub Command1_Click()If Text1.Text = Then MsgBox 没有填写服务器, vbOKOnly + vbExclamation, Text1.SetFocusElseIf Text2.Text = Then MsgBox 没有填写数据库, vbOKOnly + vbExclamation, Text2.SetFocusElsecnn = Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog= & Text2.Text & ;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) “登录”窗体的设计界面如下图:窗体中各控件的属性设置。其caption属性与文本框的text属性如表: Name属性其他属性Label1(0)Caption=” 用户名”Label1(1)Caption=” 密码”Command1Caption=”确定”Command2Caption=” 返回”loginCaption=”连接数据库”Text1Text2Passwordchar=”*”“登录”窗体的代码如下: Private Sub Command1_Click()If Text1.Text = Then 判断输入的用户名是否为空 MsgBox 没有这个用户, vbOKOnly + vbExclamation, ElseIf rst.State = 1 Thenrst.CloseEnd If rst.Open select * from 用户 where 用户名= & Text1.Text & , cnn,adOpenKeyset, adLockPessimistic If rst.EOF = True Then MsgBox 没有这个用户, vbOKOnly + vbExclamation, rst.Close Text1.Text = Text1.SetFocus Else 检验密码是否正确 If Trim(rst.Fields(密码).Value) = Trim(Text2.Text) Then rst.Close Unload Me menu.Show Else MsgBox 密码不正确, vbOKOnly + vbExclamation, rst.Close Text2.Text = Text2.SetFocus End If End IfEnd Ifcnt = cnt + 1If cnt = 3 Then Unload MeEnd IfExit SubEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()Set cmd = New ADODB.Commandcmd.ActiveConnection = cnncmd.CommandType = adCmdTextSet cmd1 = New ADODB.Commandcmd1.ActiveConnection = cnncmd1.CommandType = adCmdTextcnt = 0End Sub(5) 图书馆系统(menu) “图书馆系统”窗体的设计界面如下图:根据图书管理系统的功能,主窗体上设计有“用户系统”,“读者管理系统”,“图书管理系统”,“借阅管理系统”及“登录退出系统”共5个主菜单,主菜单中又包含菜单项和子菜单项,各级菜单的菜单级别及属性如下表: 标题名称用户系统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.ShowEnd 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_Click()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.ShowEnd 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=” 密码确认”Command1Caption=”确定”Command2Caption=” 退出”addloginCaption=”增加用户”Text1Text2Passwordchar=”*”Text3Passwordchar=”*” “增加用户”窗体的代码如下:Private Sub Command1_Click()If Text1.Text = Then MsgBox 没有填写用户名!, vbOKOnly + vbExclamation, Text1.SetFocusElseIf Text2.Text = Then MsgBox 没有填写密码!, vbOKOnly + vbExclamation, Text2.SetFocusElseIf Text3.Text = Then MsgBox 没有填写确定密码!, vbOKOnly + vbExclamation, Text3.SetFocusElseIf Text2.Text = Text3.Text Then cmd.CommandText = insert into 用户(用户名,密码) values( & Text1.Text & , & Text2.Text & ) MsgBox 添加用户信息成功!, vbOKOnly, cmd.ExecuteElse MsgBox 添加用户信息失败!, 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=”密码确认”Command1Caption=”确定”Command2Caption=” 返回”insertloginCaption=”修改用户”Text1Text2Passwordchar=”*”Text3Passwordchar=”*”Text4Passwordchar=”*”“修改用户”窗体的代码如下:Private Sub Command1_Click()Dim rst As New ADODB.RecordsetIf rst.State = 1 Then rst.CloseEnd IfIf Text3.Text = Then MsgBox 没有填写新密码!, vbOKOnly + vbExclamation, Text3.SetFocusElseIf Text4.Text = Then MsgBox 没有填写新确定密码!, vbOKOnly + vbExclamation, Text4.SetFocusElse rst.Open select * from 用户 where 用户名= & Text1.Text & , cnn, adOpenKeyset, adLockPessimistic If rst.EOF = True Then MsgBox 没有这个用户, vbOKOnly + vbExclamation, Else 检验密码是否正确 If Trim(rst.Fields(密码).Value) = Trim(Text2.Text) Then If Text3.Text = Text4.Text Then rst.Close cmd.CommandText = update 用户 set 密码= & Text3.Text & where 用户名= & Text1.Text & and 密码= & Text2.Text & cmd.Execute MsgBox 修改成功!, vbOKOnly, Else MsgBox 用户新密码不正确!, vbOKOnly + vbExclamation, Text3.Text = Text4.Text = Text3.SetFocus End If Else MsgBox 用户密码不正确!, vbOKOnly + vbExclamation, Text2.Text = Text2.SetFocus End If End IfEnd IfEnd SubPrivate Sub Command2_Click()Unload Memenu.ShowEnd Sub(8) 删除用户(deletelogin)“删除用户”窗体的设计界面如下图: 窗体中各控件的属性设置。其caption属性与文本框的text属性如表: Name属性其他属性Label1(0)Caption=” 用户名”Label1(1)Caption=” 密码”Command1Caption=”确定”Command2Caption=” 返回”deleteloginCaption=”删除用户”Text1Text2Passwordchar=”*”“删除用户”窗体的代码如下: Private Sub Command1_Click()Dim rst As New ADODB.RecordsetIf rst.State = 1 Then rst.CloseEnd IfIf Text1.Text = Then MsgBox 没有填写用户名!, vbOKOnly + vbExclamation, Text1.SetFocusElseIf Text2.Text = Then MsgBox 没有填写密码!, vbOKOnly + vbExclamation, Text2.SetFocusElseIf Text1.Text And Text2.Text Then rst.Open select * from 用户 where 用户名= & Text1.Text & , cnn, adOpenKeyset, adLockPessimistic If rst.EOF = True Then MsgBox 没有这个用户, vbOKOnly + vbExclamation, rst.Close Text1.Text = Text1.SetFocus Else 检验密码是否正确 If Trim(rst.Fields(密码).Value) = Trim(Text2.Text) Then rst.Close cmd.CommandText = delete from 用户 where 用户名= & Text1.Text & Dim str2 As VbMsgBoxResult str2 = MsgBox(确定要删除? , vbYesNo + vbInformation, ) If str2 = vbYes Then cmd.Execute MsgBox 删除成功!, vbOKOnly, Unload Me menu.Show End If Else MsgBox 要删除的用户密码不正确!, vbOKOnly + vbExclamation, Text2.Text = Text2.SetFocus End If End IfEnd IfEnd SubPrivate Sub Command2_Click()If rst.State = 1 Thenrst.CloseEnd IfUnload Memenu.ShowEnd Sub(9) 增加读者信息(addread)“增加读者信息”窗体的设计界面如下图:窗体中各控件的属性设置。其caption属性与文本框的text属性如表: Name属性其他属性Label1(0)Caption=” 读者编号”Label1(1)Caption=” 读者名称”Label1(2)Caption=”性别”Label1(3)Caption=”读者类别”Label1(4)Caption=”工作单位”Label1(5)Caption=”家庭住址”Label1(6)Caption=”联系电话”Command1Caption=”确定”Command2Caption=” 退出”addreadCaption=”增加读者信息”Text1Text2Text3Text4Text5Frame1Caption=” 输入要增加的读者信息”“增加读者信息”窗体的代码如下: Private Sub Command2_Click()If rst.State = 1 Then rst.CloseEnd IfIf Text1.Text = Then MsgBox 没有填写读者编号!, vbOKOnly + vbExclamation, Text1.SetFocusElse rst.Open select * from 读者基本信息 where 读者编号= & Text1.Text & , cnn, adOpenKeyset, adLockPessimistic If Not rst.EOF = True Then MsgBox 读者编号已存在!, vbOKOnly + vbExclamation, Text1.Text = Text1.SetFocus Else rst.Close cmd.CommandText = insert into 读者基本信息(读者编号,读者名称,性别,读者类别,工作单位,家庭住址,联系电话) values( & Text1.Text & , & Text2.Text & , & Combo1.Text & , & Combo2.Text & , & Text3.Text & , & Text4.Text & , & Text5.Text & ) MsgBox 添加读者基本信息信息成功!, vbOKOnly, cmd.Execute Unload Me menu.Show End 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属性如表: Name属性其他属性Label1(0)Caption=” 读者编号”Label1(1)Caption=” 读者名称”Label1(2)Caption=”性别”Label1(3)Caption=”读者类别”Label1(4)Caption=”工作单位”Label1(5)Caption=”家庭住址”Label1(6)Caption=”联系电话”Command1Caption=”确定”Command2Caption=” 修改”Command3Caption=” 返回”addreadCaption=”修改读者信息”Text1Text2Text3Text4Text5Frame1“修改读者信息”窗体的代码如下: If Text1.Text = Then MsgBox 没有填写读者编号!, vbOKOnly + vbExclamation, Else If Text2.Text Then cmd.CommandText = update 读者基本信息 set 读者名称= & Text2.Text & where 读者编号= & Text1.Text & cmd.Execute End If If Combo1.Text Then cmd.CommandText = update 读者基本信息 set 性别= & Combo1.Text & where 读者编号= & Text1.Text & cmd.Execute End If If Combo2.Text Then cmd.CommandText = update 读者基本信息 set 读者类别= & Combo2.Text & where 读者编号= & Text1.Text & cmd.Execute End If If Text3.Text Then cmd.CommandText = update 读者基本信息 set 工作单位= & Text3.Text & where 读者编号= & Text1.Text & cmd.Execute End If If Text4.Text Then cmd.CommandText = update 读者基本信息 set 家庭住址= & Text4.Text & where 读者编号= & Text1.Text & cmd.Execute End If If Text5.Text Then cmd.CommandText = update 读者基本信息 set 联系电话= & Text5.Text & where 读者编号= & Text1.Text & cmd.Execute End If MsgBox 修改成功!, vbOKOnly, Unload Me menu.ShowEnd IfEnd SubPrivate Sub Command3_Click()If rst.State = 1 Thenrst.CloseEnd IfUnload 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=” 读者名称”Command1Caption=”确定”Command2Caption=” 返回”deletereadCaption=”删除读者信息”Text1Text2“删除读者信息”窗体的代码如下:Private Sub Command1_Click()If rst.State = 1 Then rst.CloseEnd IfIf Text1.Text = Then MsgBox 没有填写读者编号!, vbOKOnly + vbExclamation, Text1.SetFocusElseIf Text2.Text = Then MsgBox 没有填写读者名称!, vbOKOnly + vbExclamation, Text2.SetFocusElseIf Text1.Text And Text2.Text Thenrst.Open select * from 读者基本信息 where 读者编号= & Text1.Text & , cnn, adOpenKeyset, adLockPessimistic If rst.EOF = True Then MsgBox 没有这个读者!, vbOKOnly + vbExclamation, rst.Close Text1.Text = Text1.SetFocus Else If Trim(rst.Fields(读者名称).Value) = Trim(Text2.Text) Then rst.Close cmd.CommandText = delete from 读者基本信息 where 读者编号= & Text1.Text & Dim str2 As VbMsgBoxResult str2 = MsgBox(确定要删除? , vbYesNo + vbInformation, ) If str2 = vbYes Then cmd.Execute MsgBox 删除成功!, vbOKOnly, Unload Me menu.Show End If Else MsgBox 要删除的读者名称不正确, vbOKOnly + vbExclamation, rst.Close Text2.Text = Text2.SetFocus End If End IfEnd IfEnd SubPrivate Sub Command2_Click()If rst.State = 1 Then rst.CloseEnd IfUnload Memenu.ShowEnd Sub(12) 查找读者信息 (searchread)“查找读者信息”窗体的设计界面如下图:窗体中各控件的属性设置。其caption属性与文本框的text属性如表: Name属性其他属性Command2Caption=”报表”Command3Caption=” 退出”searchreadCaption=”查找读者信息”Command4Caption=”第一行”Command5Caption=”前一行”Command6Caption=”后一行”Command7Caption=”最后一行”Frame1Caption=” 输入要查找的读者信息”“增加读者信息”窗体的代码如下:Private Sub Command2_Click()read.ShowEnd SubPrivate Sub Command3_Click()Unload Memenu.ShowEnd SubPrivate Sub Command4_Click()rst.MoveFirstEnd SubPrivate Sub Command5_Click()If Not rst.BOF Then rst.MovePrevious If rst.BOF And rst.RecordCount 0 Then rst.MoveFirst End IfEnd IfEnd SubPrivate Sub Command6_Click() If Not rst.EOF Then rst.MoveNext If rst.EOF And rst.RecordCount 0 Then rst.MoveLast End IfEnd IfEnd SubPrivate Sub Command7_Click()rst.MoveLastEnd 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 Then rst.Close End If If DataE.rsread.State = 1 Then DataE.rsread.Close End If If Option1(1).Value = True Then rst.CursorLocation = adUseClient rst.Open select * from 读者基本信息 where 读者编号= & Text1(1).Text & , cnn, adOpenKeyset, adLockPessimistic If rst.EOF = True Then MsgBox 没有这个读者!, vbOKOnly + vbExclamation, Else Set DataGrid1.DataSource = rst DataE.rsread.Open rst Command4.Enabled = True Command5.Enabled = True Command6.Enabled = True Command7.Enabled = True Command2.Enabled = True End If ElseIf Option3(1).Value = True Then rst.CursorLocation = adUseClient rst.Open select * from 读者基本信息, cnn, adOpenKeyset, adLockPessimistic If rst.EOF = True Then MsgBox 没有读者!, vbOKOnly + vbExclamation, Else Set DataGrid1.DataSource = rst DataE.rsread.Open rst Command4.Enabled = True Command5.Enabled = True Command6.Enabled = True Command7.Enabled = True Command2.Enabled = True End If End IfEnd Sub(13) 增加图书(Addbook)“增加图书”窗体的设计界面如下图:窗体中各控件的属性设置。其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)Caption=”数量”Command1Caption=”确定”Command2Caption=” 退出”AddbookCaption=”增加图书信息”Text1Text2Text3Text4Text5Text6Text7Text8Frame1Caption=” 输入要增加的图书信息”“增加图书信息”窗体的代码如下:Private Sub Command2_Click()If rst.State = 1 Thenrst.CloseEnd IfIf Text1.Text = Then MsgBox 没有填写图书编号!, vbOKOnly + vbExclamation, Text1.SetFocusElserst.Open select * from 图书基本信息 where 图书编号= & Text1.Text & , cnn, adOpenKeyset, adLockPessimistic If Not rst.EOF = True Then MsgBox 图书编号已存在!, vbOKOnly + vbExclamation, Text1.Text = Text1.SetFocus Else rst.Close cmd.CommandText = insert into 图书基本信息(图书编号,书名,类别,出版社,出版日期,作者,内容摘要,存放地点,数量) values( & Text1.Text & , & Text2.Text & , & Combo1.Text & , & Text3.Text & , & Text4.Text & , & Text5.Text & , & Text6.Text & , & Text7.Text & , & Text8.Text & ) cmd.Execute MsgBox 添加图书基本信息成功!, vbOKOnly, Unload Me menu.Show End IfEnd IfEnd SubPrivate Sub Command3_Click()Unload Memenu.ShowEnd SubPrivate Sub Form_Load()Combo1.AddItem 文史Combo1.AddItem 理工Combo1.AddItem 英语Combo1.AddItem 计算机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)Caption=”数量”Command1Caption=”确定”Command2Caption=” 修改”Command3Caption=”返回”Addb

温馨提示

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

评论

0/150

提交评论