资源描述
源程序清单
1、文献名 login(login.frm)
功能阐明:整个系统旳登陆界面,需要输入顾客名和登陆密码才能进入到系统中,进行借阅等操作。
源代码:
Option Explicit
Dim cnt As Integer
Private Sub Command1_Click()
Dim sql As String
Dim rs_login As New ADODB.Recordset
If Trim(Combo1.Text) = "" Then
MsgBox "没有这个顾客", vbOKOnly + vbExclamation, ""
Combo1.SetFocus
Else
sql = "select * from 系统管理 where 顾客名='" & Combo1.Text & "'"
rs_login.Open sql, conn, adOpenKeyset, adLockPessimistic
If rs_login.EOF = True Then
MsgBox "没有这个顾客", vbOKOnly + vbExclamation, ""
Combo1.SetFocus
Else
If Trim(rs_login.Fields(1)) = Trim(txtpwd.Text) Then
userID = Combo1.Text
rs_login.Close
Unload Me
form1.Show
Else
MsgBox "密码不对旳", vbOKOnly + vbExclamation, ""
txtpwd.SetFocus
End If
End If
End If
cnt = cnt + 1
If cnt = 3 Then
Unload Me
End If
Exit Sub
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim connectionstring As String
connectionstring = "provider=Microsoft.Jet.oledb.4.0;" & _
"data source=book.mdb"
conn.Open connectionstring
cnt = 0
End Sub
Private Sub txtuser_Change()
End Sub
2、文献名 form1(form1.frm)
功能阐明:整个系统旳主界面,其中包括图书管理、读者管理、图书借阅管理、系统管理、有关,以及在这下面旳子菜单。
源代码:
Private Sub add_admin_Click()
frmadduser.Show
End Sub
Private Sub add_back_book_Click()
frmbackbookinfo.Show
End Sub
Private Sub add_book_info_Click()
frmaddbookinfo.Show
End Sub
Private Sub add_book_style_Click()
frmaddbookstyle.Show
End Sub
Private Sub add_lend_book_Click()
frmfindbook.Show
End Sub
Private Sub add_reader_info_Click()
frmaddreaderinfo.Show
End Sub
Private Sub add_reader_style_Click()
frmaddreaderstyle.Show
End Sub
Private Sub change_pwd_Click()
frmchangepwd.Show
End Sub
Private Sub del_book_info_Click()
frmmodifybookinfo.Show
End Sub
Private Sub del_book_style_Click()
frmmodifybookstyle.Show
End Sub
Private Sub del_reader_info_Click()
frmreaderinfo.Show
End Sub
Private Sub del_reader_style_Click()
frmmodifyreaderstyle.Show
End Sub
Private Sub exit_sys_Click()
End
End Sub
Private Sub find_book_info_Click()
frmfindbook.Show
End Sub
Private Sub find_lend_book_Click()
frmfindborrowinfo.Show
End Sub
Private Sub find_reader_info_Click()
frmfindreader.Show
End Sub
Private Sub Form_Load()
End Sub
Private Sub gly_Click()
Form2.Show
End Sub
Private Sub modify_book_info_Click()
frmmodifybookinfo.Show
End Sub
Private Sub modify_book_style_Click()
frmmodifybookstyle.Show
End Sub
Private Sub modify_reader_info_Click()
frmreaderinfo.Show
End Sub
Private Sub modify_reader_style_Click()
frmmodifyreaderstyle.Show
End Sub
3、文献名 frmaddbookstyle(frmbookstyle.frm)
功能阐明:用于添加图书类别信息。
源代码:
Option Explicit
Private Sub Command1_Click()
Dim rs_bookstyle As New ADODB.Recordset
Dim sql As String
If Trim(Text1.Text) = "" Then
MsgBox "图书种类不能为空", vbOKOnly + vbExclamation, ""
Text1.SetFocus
Exit Sub
End If
If Trim(Text2.Text) = "" Then
MsgBox "种类编号不能为空", vbOKOnly + vbExclamation, ""
Text2.SetFocus
Exit Sub
End If
sql = "select * from 图书类别 where 类别名称='" & Text1.Text & "'"
rs_bookstyle.Open sql, conn, adOpenKeyset, adLockPessimistic
If rs_bookstyle.EOF Then
rs_bookstyle.AddNew
rs_bookstyle.Fields(0) = Trim(Text1.Text)
rs_bookstyle.Fields(1) = Trim(Text2.Text)
rs_bookstyle.Update
MsgBox "添加图书类别成功!", vbOKOnly, ""
rs_bookstyle.Close
Else
MsgBox "读者类别反复!", vbOKOnly + vbExclamation, ""
Text1.SetFocus
Text1.Text = ""
rs_bookstyle.Close
Exit Sub
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
4、文献名 frmmodifybookstyle(code)
功能阐明:图书类别管理,可以修改和删除图书类别。
源代码:
Option Explicit
Dim rs_reader As New ADODB.Recordset
Private Sub cmdcancel_Click()
rs_reader.CancelUpdate
DataGrid1.Refresh
DataGrid1.AllowAddNew = False
DataGrid1.AllowUpdate = False
cmdmodify.Enabled = True
cmddel.Enabled = True
cmdcancel.Enabled = False
cmdupdate.Enabled = False
End Sub
Private Sub cmddel_Click()
Dim answer As String
On Error GoTo delerror
answer = MsgBox("确定要删除吗?", vbYesNo, "")
If answer = vbYes Then
DataGrid1.AllowDelete = True
rs_reader.Delete
rs_reader.Update
DataGrid1.Refresh
MsgBox "成功删除!", vbOKOnly + vbExclamation, ""
DataGrid1.AllowDelete = False
Else
Exit Sub
End If
delerror:
If Err.Number <> 0 Then
MsgBox Err.Description
End If
End Sub
Private Sub cmdmodify_Click()
Dim answer As String
On Error GoTo cmdmodify
cmddel.Enabled = False
cmdmodify.Enabled = False
cmdupdate.Enabled = True
cmdcancel.Enabled = True
DataGrid1.AllowUpdate = True
cmdmodify:
If Err.Number <> 0 Then
MsgBox Err.Description
End If
End Sub
Private Sub Command5_Click()
rs_reader.Update
DataGrid1.Refresh
End Sub
Private Sub cmdupdate_Click()
If Not IsNull(DataGrid1.Bookmark) Then
rs_reader.Update
End If
cmdmodify.Enabled = True
cmddel.Enabled = True
cmdcancel.Enabled = False
cmdupdate.Enabled = False
DataGrid1.AllowUpdate = False
MsgBox "保留成功!", vbOKOnly + vbExclamation, ""
End Sub
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim sql As String
On Error GoTo loaderror
sql = "select * from 图书类别"
rs_reader.CursorLocation = adUseClient
rs_reader.Open sql, conn, adOpenKeyset, adLockPessimistic '打开数据库
cmdupdate.Enabled = False
'设定datagrid控件属性
DataGrid1.AllowAddNew = False '不可增长
DataGrid1.AllowDelete = False '不可删除
DataGrid1.AllowUpdate = False
If userpow = "guest" Then '权限有关
Frame2.Enabled = False
End If
Set DataGrid1.DataSource = rs_reader
Exit Sub
loaderror:
MsgBox Err.Description
End Sub
5、文献名 frmaddbookinfo(frmaddbookinfo.frm)
功能阐明:添加图书信息,包括图书编号、书名、出版日期、入库日期、作者等信息。
源代码:
Option Explicit
Private Sub Command1_Click()
Dim rs_addbook As New ADODB.Recordset
Dim sql As String
If Trim(Combo1.Text) = "" Then
MsgBox "请选择图书种类", vbOKOnly + vbExclamation, ""
Combo1.SetFocus
Exit Sub
End If
If Trim(Text1.Text) = "" Then
MsgBox "图书编号不能为空", vbOKOnly + vbExclamation, ""
Text1.SetFocus
Exit Sub
End If
If Trim(Text2.Text) = "" Then
MsgBox "书名不能为空", vbOKOnly + vbExclamation, ""
Text2.SetFocus
Exit Sub
End If
If Not IsDate(Text5.Text) Then
MsgBox "请按照yyyy-mm-dd格式输入日期", vbOKOnly + vbExclamation, ""
Text5.SetFocus
Exit Sub
End If
If Not IsDate(Text6.Text) Then
MsgBox "请按照yyyy-mm-dd格式输入日期", vbOKOnly + vbExclamation, ""
Text6.SetFocus
Exit Sub
End If
sql = "select * from 书籍信息 where 书籍编号='" & Text1.Text & "'"
rs_addbook.Open sql, conn, adOpenKeyset, adLockPessimistic
If rs_addbook.EOF Then
rs_addbook.AddNew
rs_addbook.Fields(0) = Trim(Text1.Text)
rs_addbook.Fields(1) = Trim(Text2.Text)
rs_addbook.Fields(2) = Trim(Combo1.Text)
rs_addbook.Fields(3) = Trim(Text3.Text)
rs_addbook.Fields(4) = Trim(Text4.Text)
rs_addbook.Fields(5) = Trim(Text5.Text)
rs_addbook.Fields(6) = Trim(Text6.Text)
rs_addbook.Fields(7) = "否"
rs_addbook.Update
MsgBox "添加书籍信息成功!", vbOKOnly, ""
rs_addbook.Close
Else
MsgBox "图书编号反复!", vbOKOnly + vbExclamation, ""
Text1.SetFocus
Text1.Text = ""
rs_addbook.Close
Exit Sub
Private Sub Form_Load()
Dim rs_leibie As New ADODB.Recordset
Dim sql As String
sql = "select * from 图书类别"
rs_leibie.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_leibie.MoveFirst
Do While Not rs_leibie.EOF
Combo1.AddItem rs_leibie.Fields(0)
rs_leibie.MoveNext
Loop
rs_leibie.Close
End Sub
Private Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)
End Sub
6、文献名 frmfindbook(form)
功能阐明:查询图书信息,可以选择性旳输入图书旳编号、名称或者类别查询图书旳详细信息。
源代码:
Option Explicit
Dim panduan As String
Private Sub Command1_Click()
Dim rs_findbook As New ADODB.Recordset
Dim sql As String
If Check1.Value = vbChecked Then
sql = "书名='" & Trim(Text1.Text & " ") & "'"
End If
If Check2.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "类别='" & Trim(Combo1.Text & " ") & "'"
Else
sql = sql & "and 书名='" & Trim(Combo1.Text & " ") & "'"
End If
End If
If Check3.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "作者='" & Trim(Text2.Text & " ") & "'"
Else
sql = sql & "and 作者='" & Trim(Text2.Text & " ") & "'"
End If
End If
If Check4.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "出版社='" & Trim(Text3.Text & " ") & "'"
Else
sql = sql & "and 出版社='" & Trim(Text3.Text & " ") & "'"
End If
End If
If Check5.Value = vbChecked Then
If Trim(sql) = "" Then
sql = "书籍编号='" & Trim(Text4.Text & " ") & "'"
Else
sql = sql & "and 书籍编号='" & Trim(Text4.Text & " ") & "'"
End If
End If
If Trim(sql) = "" Then
MsgBox "请选择查询方式!", vbOKOnly + vbExclamation
Exit Sub
End If
sql = "select * from 书籍信息 where " & sql
rs_findbook.CursorLocation = adUseClient
rs_findbook.Open sql, conn, adOpenKeyset, adLockPessimistic
DataGrid1.AllowAddNew = False
DataGrid1.AllowDelete = False
DataGrid1.AllowUpdate = False
Set DataGrid1.DataSource = rs_findbook
'rs_findbook.Close
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command3_Click()
If Trim(book_num) = "" Then
MsgBox "请选择要借阅旳图书!", vbOKOnly + vbExclamation
Exit Sub
End If
If panduan = "是" Then
MsgBox "此书已被借出!", vbOKOnly + vbExclamation
Exit Sub
End If
frmborrowbook.Show
End Sub
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
book_num = DataGrid1.Columns(0).CellValue(DataGrid1.Bookmark)
panduan = DataGrid1.Columns(7).CellValue(DataGrid1.Bookmark)
End Sub
Private Sub Form_Load()
Dim rs_find As New ADODB.Recordset
Dim sql As String
sql = "select * from 图书类别"
rs_find.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_find.MoveFirst
If Not rs_find.EOF Then
Do While Not rs_find.EOF
Combo1.AddItem rs_find.Fields(0)
rs_find.MoveNext
Loop
Combo1.ListIndex = 0
End If
rs_find.Close
End Sub
7、文献名 frmaddreaderstyle(frmaddreaderstyle.frm)
功能阐明:添加读者旳类别。
源代码:
Option Explicit
Dim rs_readerstyle As New ADODB.Recordset
Private Sub Command1_Click()
Dim sql As String
If Trim(Text1.Text) = "" Then
MsgBox "读者种类不能为空", vbOKOnly + vbExclamation, ""
Text1.SetFocus
Exit Sub
End If
If Trim(Text2.Text) = "" Then
MsgBox "借书数量不能为空", vbOKOnly + vbExclamation, ""
Text2.SetFocus
Exit Sub
End If
If Trim(Text3.Text) = "" Then
MsgBox "借书期限不能为空", vbOKOnly + vbExclamation, ""
Text3.SetFocus
Exit Sub
End If
If Trim(Text4.Text) = "" Then
MsgBox "有限期限不能为空", vbOKOnly + vbExclamation, ""
Text4.SetFocus
Exit Sub
End If
sql = "select * from 读者类别 where 种类名称='" & Text1.Text & "'"
rs_readerstyle.Open sql, conn, adOpenKeyset, adLockPessimistic
If rs_readerstyle.EOF Then
rs_readerstyle.AddNew
rs_readerstyle.Fields(0) = Trim(Text1.Text)
rs_readerstyle.Fields(1) = CInt(Text2.Text)
rs_readerstyle.Fields(2) = CInt(Text3.Text)
rs_readerstyle.Fields(3) = CInt(Text4.Text)
rs_readerstyle.Update
MsgBox "添加读者类别成功!", vbOKOnly, ""
rs_readerstyle.Close
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Else
MsgBox "读者类别反复!", vbOKOnly + vbExclamation, ""
Text1.SetFocus
Text1.Text = ""
rs_readerstyle.Close
Exit Sub
End If
End Sub
8、文献名 frmmodifyreaderstyle(form)
功能阐明:读者类别管理,可以查询、删除、修改读者旳信息。
源代码:
Option Explicit
Dim rs_reader As New ADODB.Recordset
Private Sub cmdcancel_Click()
rs_reader.CancelUpdate
DataGrid1.Refresh
DataGrid1.AllowAddNew = False
DataGrid1.AllowUpdate = False
cmdmodify.Enabled = True
cmddel.Enabled = True
cmdcancel.Enabled = False
cmdupdate.Enabled = False
End Sub
Private Sub cmddel_Click()
Dim answer As String
On Error GoTo delerror
answer = MsgBox("确定要删除吗?", vbYesNo, "")
If answer = vbYes Then
DataGrid1.AllowDelete = True
rs_reader.Delete
rs_reader.Update
DataGrid1.Refresh
MsgBox "成功删除!", vbOKOnly + vbExclamation, ""
DataGrid1.AllowDelete = False
Else
Exit Sub
End If
delerror:
If Err.Number <> 0 Then
MsgBox Err.Description
End If
End Sub
Private Sub cmdmodify_Click()
Dim answer As String
On Error GoTo cmdmodify
cmddel.Enabled = False
cmdmodify.Enabled = False
cmdupdate.Enabled = True
cmdcancel.Enabled = True
DataGrid1.AllowUpdate = True
cmdmodify:
If Err.Number <> 0 Then
MsgBox Err.Description
End If
End Sub
Private Sub Command5_Click()
rs_reader.Update
DataGrid1.Refresh
End Sub
Private Sub cmdupdate_Click()
If Not IsNull(DataGrid1.Bookmark) Then
rs_reader.Update
End If
cmdmodify.Enabled = True
cmddel.Enabled = True
cmdcancel.Enabled = False
cmdupdate.Enabled = False
DataGrid1.AllowUpdate = False
MsgBox "保留成功!", vbOKOnly + vbExclamation, ""
End Sub
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim sql As String
On Error GoTo loaderror
sql = "select * from 读者类别"
rs_reader.CursorLocation = adUseClient
rs_reader.Open sql, conn, adOpenKeyset, adLockPessimistic '打开数据库
cmdupdate.Enabled = False
'设定datagrid控件属性
DataGrid1.AllowAddNew = False '不可增长
DataGrid1.AllowDelete = False '不可删除
DataGrid1.AllowUpdate = False
If userpow = "guest" Then '权限有关
Frame2.Enabled = False
End If
Set DataGrid1.DataSource = rs_reader
'cmdcancel.Enabled = False
Exit Sub
loaderror:
MsgBox Err.Description
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set DataGrid1.DataSource = Nothing
rs_reader.Close
End Sub
9、文献名frmaddreaderinfo(frmaddreaderinfo.frm)
功能阐明:添加读者信息,包括读者旳姓名、性别、读者类别、登记日期、 号码、工作单位、家庭地址等信息。
源代码:
Option Explicit
Dim rs_addreader As New ADODB.Recordset
Private Sub Command1_Click()
Dim sql As String
If Trim(Combo1.Text) = "" Then
MsgBox "请选择读者种类", vbOKOnly + vbExclamation, ""
Combo1.SetFocus
Exit Sub
End If
If Trim(Text1.Text) = "" Then
MsgBox "读者姓名不能为空", vbOKOnly + vbExclamation, ""
Text1.SetFocus
Exit Sub
End If
If Trim(Text2.Text) = "" Then
MsgBox "读者编号不能为空", vbOKOnly + vbExclamation, ""
Text2.SetFocus
Exit Sub
End If
sql = "select * from 读者信息 where 读者编号='" & Text2.Text & "'"
rs_addreader.Open sql, conn, adOpenKeyset, adLockPessimistic
If rs_addreader.EOF Then
rs_addreader.AddNew
rs_addreader.Fields(0) = Trim(Text1.Text)
rs_addreader.Fields(1) = Trim(Text2.Text)
rs_addreader.Fields(2) = Trim(Combo2.Text)
rs_addreader.Fields(3) = Trim(Combo1.Text)
rs_addreader.Fields(4) = Trim(Text3.Text)
rs_addreader.Fields(5) = Trim(Text4.Text)
rs_addreader.Fields(6) = Trim(Text5.Text)
rs_addreader.Fields(7) = CDate(Text6.Text)
rs_addreader.Update
MsgBox "添加读者信息
展开阅读全文