源程序1.主窗体Private Sub add_back_Click() frmbackbookinfo.ShowEnd SubPrivate Sub add_binf_Click() frmaddbookinfo.ShowEnd SubPrivate Sub add_book_style_Click() frmaddbookstyle.ShowEnd SubPrivate Sub add_manager_Click() frmadduser.ShowEnd SubPrivate Sub add_rinf_Click() frmaddreaderinfo.ShowEnd SubPrivate Sub add_rstyle_Click() frmaddreaderstyle.ShowEnd SubPrivate Sub change_binf_Click() frmmodifybookinfo.ShowEnd SubPrivate Sub change_book_style_Click() frmmodifybookstyle.ShowEnd SubPrivate Sub delete_binf_Click() frmmodifybookinfo.ShowEnd SubPrivate Sub delete_book_style_Click() frmmodifybookstyle.ShowEnd SubPrivate Sub delete_rstyle_Click() frmmodifyreaderstyle.ShowEnd SubPrivate Sub exit_Click()EndEnd SubPrivate Sub find_binf_Click() frmfindbook.ShowEnd SubPrivate Sub find_lend_Click() frmfindborrowinfo.ShowEnd SubPrivate Sub find_rinf_Click()frmfindreader.ShowEnd SubPrivate Sub password_Click()frmchangepwd.ShowEnd Sub2.LoginOption ExplicitPrivate Sub cmdOK_Click()Dim strUserName As StringDim strPassword As StringDim strTargetAsp As StringDim conn As ADODB.ConnectionDim rsLogin As ADODB.RecordsetDim strSQL As StringIf Trim(txtUserName.Text) = "" ThenMsgBox "“用户名”不能为空!"Exit SubElsestrUserName = Trim(txtUserName.Text)End IfIf Trim(txtPassword.Text) = "" ThenMsgBox "“口令”不能为空!"Exit SubElsestrPassword = Trim(txtPassword.Text)End If'检查口令、用户身份Set conn = New ADODB.Connectionconn.Provider = "Microsoft.jet.OLEDB.4.0"conn.ConnectionString = "D:\图书管理系统\book.mdb"conn.OpenstrUserName = Replace(strUserName, "'", "“")strSQL = "select*from 系统管理where 用户名='" & strUserName & "'and 密码='" & strPassword & "'"Set rsLogin = conn.Execute(strSQL)If rsLogin.EOF Or rsLogin.BOF ThenMsgBox "用户名或口令错误,请检查!"txtPassword.SelStart = 0txtPassword.SelLength = Len(txtPassword.Text)txtPassword.SetFocusElseSelect Case rsLogin("权限")Case "领导"strTargetAsp = "LeadersMain.asp"Case "主任"strTargetAsp = "ZhuRenMain.asp"Case "秘书"strTargetAsp = "MishuMain.asp"Case "图书管理员"strTargetAsp = "TuShuManagerMain.asp"Case ElsestrTargetAsp = "OtherMain.asp"End SelectSaveSetting "JGYOA", "Login", "UserName", strUserNameHyperlink.NavigateTo "HTTP://" & "/oa/" & strTargetAspEnd If'释放变量Set rsLogin = NothingSet conn = NothingEnd Sub3.frmaddbookinfoPrivate Sub Command1_Click()Dim rs_addbook As New ADODB.RecordsetDim sql As StringIf Trim(Combo1.Text) = " " ThenMsgBox "请选择图书种类", vbOKOnly + vbExclamation, ""Combo1.SetFocusExit SubEnd IfIf Trim(Text1.Text) = " " ThenMsgBox "图书编号不能为空", vbOKOnly + vbExclamation, ""Text1.SetFocusExit SubEnd IfIf Trim(Text2.Text) = " " ThenMsgBox "书名不能为空", vbOKOnly + vbExclamation, ""Text2.SetFocusExit SubEnd IfIf Not IsDate(Text5.Text) ThenMsgBox "请按照yyy-mm-dd格式输入日期", vbOKOnly + vbExclamation, ""Text5.SetFocusExit SubEnd IfIf Not IsDate(Text6.Text) ThenMsgBox "请按照yyy-mm-dd格式输入日期", vbOKOnly + vbExclamation, ""Text6.SetFocusExit SubEnd Ifsql = "select * from 书籍信息where 书籍编号='" & Text1.Text & "'" rs_addbook.Open sql, conn, adOpenKeyset, adLockPessimisticIf rs_addbook.EOF Thenrs_addbook.AddNewrs_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.UpdateMsgBox "添加图书信息成功!", vbOKOnly, ""rs_addbook.CloseElseMsgBox "图书编号重复!", vbOKOnly + vbExclamation, ""Text1.SetFocusText1.Text = ""rs_addbook.CloseExit SubEnd IfEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()Dim rs_leibie As New ADODB.RecordsetDim sql As Stringsql = "select * from 图书类别"rs_leibie.Open sql, conn, adOpenKeyset, adLockPessimisticrs_leibie.MoveFirstDo While Not rs_leibie.EOFCombo1.AddItem rs_leibie.Fields(0)rs_leibie.MoveNextLooprs_leibie.CloseEnd Sub4.frmaddbookstylePrivate Sub Command1_Click()Dim rs_bookstyle As New ADODB.RecordsetDim sql As StringIf Trim(Text1.Text) = "" ThenMsgBox "图书种类不能为空", vbOKOnly + vbExclamation, ""Text1.SetFocusExit SubEnd IfIf Trim(Text2.Text) = "" ThenMsgBox "种类编号不能为空", vbOKOnly + vbExclamation, ""Text2.SetFocusExit SubEnd Ifsql = " select * from 图书类别where 类别名称='" & Text1.Text & "'" rs_bookstyle.Open sql, conn, adOpenKeyset, adLockOptimisticIf rs_bookstyle.EOF Thenrs_bookstyle.AddNewrs_bookstyle.Fields(0) = Trim(Text1.Text)rs_bookstyle.Fields(1) = Trim(Text2.Text)rs_bookstyle.UpdateMsgBox "添加图书类别成功!", vbOKOnly, ""rs_bookstyle.CloseElseMsgBox "读者类别重复!", vbOKOnly + vbExclamation, ""Text1.SetFocusText1.Text = " "rs_bookstyle.CloseExit SubEnd IfEnd SubPrivate Sub Command2_Click()Unload MeEnd Sub5.frmaddreaderinfoOption ExplicitDim rs_addreader As New ADODB.RecordsetPrivate Sub Command1_Click()Dim sql As StringIf Trim(Combo1.Text) = "" ThenMsgBox "请选择读者种类", vbOKOnly + vbExclamation, ""Combo1.SetFocusExit SubEnd IfIf Trim(Text2.Text) = "" ThenMsgBox "读者姓名不能为空", vbOKOnly + vbExclamation, ""Text1.SetFocusExit SubEnd IfIf Trim(Text3.Text) = "" ThenMsgBox "读者编号不能为空", vbOKOnly + vbExclamation, ""Text2.SetFocusExit SubEnd Ifsql = "select * from 读者信息where 读者编号='" & Text2.Text & "'" rs_addreader.Open sql, conn, adOpenKeyset, adLockPessimisticIf rs_addreader.EOF Thenrs_addreader.AddNewrs_addreader.Fields(0) = Trim(Text2.Text)rs_addreader.Fields(1) = Trim(Text3.Text)rs_addreader.Fields(2) = Trim(Combo2.Text)rs_addreader.Fields(3) = Trim(Combo1.Text)rs_addreader.Fields(4) = Trim(Text5.Text)rs_addreader.Fields(5) = Trim(Text6.Text)rs_addreader.Fields(6) = Trim(Text4.Text)rs_addreader.Fields(7) = CDate(Text1.Text)rs_addreader.UpdateMsgBox "添加读者信息成功!", vbOKOnly, ""rs_addreader.CloseElseMsgBox "读者编号重复!", vbOKOnly + vbExclamation, ""Text1.SetFocusText1.Text = ""rs_addreader.CloseExit SubEnd IfEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()Combo2.AddItem "男"Combo2.AddItem "女"Dim rs_leibie As New ADODB.RecordsetDim sql As Stringsql = "select * from 读者类别"rs_leibie.Open sql, conn, adOpenKeyset, adLockPessimisticrs_leibie.MoveFirstDo While Not rs_leibie.EOFCombo1.AddItem rs_leibie.Fields(0)rs_leibie.MoveNextLooprs_leibie.CloseEnd Sub6.frmaddreaderstyleOption ExplicitDim rs_readerstyle As New ADODB.RecordsetPrivate Sub Command1_Click()Dim sql As StringIf Trim(Text1.Text) = "" ThenMsgBox "读者种类不能为空!", vbOKOnly + vbExclamation, ""Text1.SetFocusExit SubEnd IfIf Trim(Text2.Text) = "" ThenMsgBox "借书数量不能为空!", vbOKOnly + vbExclamation, ""Text2.SetFocusExit SubEnd IfIf Trim(Text3.Text) = "" ThenMsgBox "借书期限不能为空!", vbOKOnly + vbExclamation, ""Text3.SetFocusExit SubEnd IfIf Trim(Text4.Text) = "" ThenMsgBox "有限期限不能为空!", vbOKOnly + vbExclamation, ""Text4.SetFocusExit SubEnd Ifsql = "select*from 读者类别where 种类名称='" & Text1.Text & "'" rs_readerstyle.Open sql, conn, adOpenKeyset, adLockPessimisticIf rs_readerstyle.EOF Thenrs_readerstyle.AddNewrs_readerstyle.Fields(0) = Trim(Text1.Text)rs_readerstyle.Fields(1) = Trim(Text2.Text)rs_readerstyle.Fields(2) = Trim(Text3.Text)rs_readerstyle.Fields(3) = Trim(Text4.Text)rs_readerstyle.UpdateMsgBox "添加读者类别成功!", vbOKOnly, ""rs_readerstyle.CloseElseMsgBox "读者类别重复!", vbOKOnly + vbExclamation, ""Text1.SetFocusText1.Text = ""rs_readerstyle.CloseExit SubEnd IfEnd SubPrivate Sub Command2_Click()Unload MeEnd Sub7.frmadduserPrivate Sub Command1_Click()Dim sql As StringDim rs_add As New ADODB.RecordsetIf Trim(Text1.Text) = "" ThenMsgBox "用户名不能为空", vbOKOnly + vbExclamation, ""Exit SubText1.SetFocusElsesql = "select * from 系统管理"rs_add.Open sql, conn, adOpenKeyset, adLockPessimisticWhile (rs_add.EOF = False)If Trim(rs_add.Fields(0)) = Trim(Text1.Text) ThenMsgBox "已有这个用户", vbOKOnly + vbExclamation, ""Text1.SetFocusText1.Text = ""Text2.Text = ""Text3.Text = ""Combo1.Text = ""Exit SubElsers_add.MoveNextEnd IfWendIf Trim(Text2.Text) <> Trim(Text3.Text) ThenMsgBox "两次密码不一致", vbOKOnly + vbExclamation, ""Text2.SetFocusText2.Text = ""Text3.Text = ""Exit SubElseIf Trim(Combo1.Text) <> "system" And Trim(Combo1.Text) <> "guest" Then MsgBox "请选择正确的用户权限", vbOKOnly + vbExclamation, ""Combo1.SetFocusCombo1.Text = ""Exit SubElsers_add.AddNewrs_add.Fields(0) = Text1.Textrs_add.Fields(1) = Text2.Textrs_add.Updaters_add.CloseMsgBox "添加用户成功", vbOKOnly + vbExclamation, ""Unload MeEnd IfEnd IfEnd IfEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()Combo1.AddItem "system"Combo1.AddItem "guest"End Sub8.frmbackbookinfoPrivate Sub Combo1_Click()Combo2.ListIndex = Combo1.ListIndexEnd SubPrivate Sub Combo2_Click()Combo1.ListIndex = Combo2.ListIndexEnd SubPrivate Sub Combo3_Click()Combo4.ListIndex = Combo3.ListIndexEnd SubPrivate Sub Combo4_Click()Combo3.ListIndex = Combo4.ListIndexEnd SubPrivate Sub Command1_Click()Dim book_num As StringDim reader_num As StringDim answer As StringDim rs_back As New ADODB.RecordsetDim sql As StringOn Error GoTo delerrorbook_num = DataGrid1.Columns(3).CellV alue(DataGrid1.Bookmark) reader_num = DataGrid1.Columns(1).CellV alue(DataGrid1.Bookmark) answer = MsgBox("确定要还这本书吗?", vbY esNo, "")If answer = vbY es Thensql = "select * from 借阅信息where 书籍编号='" & book_num & "'"rs_back.CursorLocation = adUseClientrs_back.Open sql, conn, adOpenKeyset, adLockPessimisticrs_back.Deleters_back.Updaters_back.Closesql = "select * from 书籍信息where 书籍编号='" & book_num & "'"rs_back.CursorLocation = adUseClientrs_back.Open sql, conn, adOpenKeyset, adLockPessimisticrs_back.Fields(7) = "否"rs_back.Updaters_back.Closesql = "select * from 读者信息where 读者编号='" & reader_num & "'"rs_back.CursorLocation = adUseClientrs_back.Open sql, conn, adOpenKeyset, adLockPessimisticrs_back.Fields(8) = rs_back.Fields(8) - 1rs_back.Updaters_back.CloseIf findform = True ThenCommand1_ClickElseCommand2_ClickEnd IfMsgBox "成功删除!", vbOKOnly + vbExclamation, ""DataGrid1.AllowDelete = FalseElseExit SubEnd Ifdelerror:If Err.Number <> 0 ThenMsgBox Err.DescriptionEnd IfEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Command3_Click()Dim rs_reader As New ADODB.RecordsetDim sql As Stringfindform = Turesql = "select*from 借阅信息where 读者姓名='" & Combo2.Text & "'" rs_reader.CursorLocation = adUseClientrs_reader.Open sql, conn, adOpenKeyset, adLockPessimisticSet DataGrid1.DataSource = rs_readerDataGrid1.AllowAddNew = FalseDataGrid1.AllowDelete = FalseDataGrid1.AllowUpdate = FalseEnd SubPrivate Sub Command4_Click()Dim rs_book As New ADODB.RecordsetDim sql As Stringfindform = Falsesql = "select * from 借阅信息where 书籍编号='" & Combo3.Text & "'" rs_book.CursorLocation = adUseClientrs_book.Open sql, conn, adOpenKeyset, adLockPessimisticSet DataGrid1.DataSource = rs_bookDataGrid1.AllowAddNew = FalseDataGrid1.AllowDelete = FalseDataGrid1.AllowUpdate = FalseEnd SubPrivate Sub Form_Load()Dim rs_reader As New ADODB.RecordsetDim rs_book As New ADODB.RecordsetDim sql As Stringsql = "select * from 读者信息"rs_reader.CursorLocation = adUseClientrs_reader.Open sql, conn, adOpenKeyset, adLockPessimisticIf Not rs_reader.EOF ThenDo While Not rs_reader.EOFCombo1.AddItem rs_reader.Fields(1)Combo2.AddItem rs_reader.Fields(0)rs_reader.MoveNextLoopEnd Ifrs_reader.Closesql = "select * from 借阅信息"rs_book.CursorLocation = adUseClientrs_book.Open sql, conn, adOpenKeyset, adLockPessimisticIf Not rs_book.EOF ThenDo While Not rs_book.EOFCombo3.AddItem rs_book.Fields(3)Combo4.AddItem rs_book.Fields(4)rs_book.MoveNextLoopEnd Ifrs_book.CloseEnd Sub9.frmborrowbookOption ExplicitDim leibie As StringDim qixian As IntegerDim shumu As IntegerDim maxnum As IntegerPrivate Sub Combo1_Change()Combo2.ListIndex = Combo1.ListIndexEnd SubPrivate Sub Combo2_Change()Combo1.ListIndex = Combo2.ListIndexEnd SubPrivate Sub Command1_Click()Dim rs_borrowbook As New ADODB.RecordsetDim sql As Stringsql = "select * from读者信息where读者编号='" & Combo1.Text & "" rs_borrowbook.Open sql, conn.adOpenKeyset, adLockPessimisticleibie = rs_borrowbook.Fields(3)shumu = rs_borrowbook.Fields(8)rs_borrowbook.Closesql = "select * from读者类别where种类名称='" & leibie & ""rs_borrowbook.Open sql, conn.adOpenKeyset, adLockPessimistic qixian = rs_borrowbook.Fields(2)maxnum = rs_borrowbook.Fields(1)rs_borrowbook.CloseIf shumu >= maxnum ThenMsgBox "该读者借书数额已满!", vbOKOnly + vbExclamation Exit SubEnd Ifsql = "select * from借阅信息"rs_borrowbook.Open sql, conn.adOpenKeyset, adLockPessimisticrs_borrowbook.AddNewrs_borrowbook.Fields(1) = Combo1.Textrs_borrowbook.Fields(2) = Combo2.Textrs_borrowbook.Fields(3) = Label8.Captionrs_borrowbook.Fields(4) = Label9.Captionrs_borrowbook.Fields(5) = Daters_borrowbook.Fields(6) = DateAdd("Ww", qixian, Date)rs_borrowbook.Updaters_borrowbook.Closesql = "select * from书籍信息where书籍编号='" & book_num & ""rs_borrowbook.Open sql, conn.adOpenKeyset, adLockPessimisticrs_borrowbook.Fields(7) = "是"rs_borrowbook.Updaters_borrowbook.Closesql = "select * from读者信息where读者编号='" & Combo1.Text & "" rs_borrowbook.Open sql, conn.adOpenKeyset, adLockPessimisticrs_borrowbook.Fields(8) = rs_borrowbook.Fields(8) + 1rs_borrowbook.Updaters_borrowbook.CloseMsgBox "本书借阅成功!", vbOKOnly + vbExclamationUnload MeEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()Dim rs_borrow As New ADODB.RecordsetDim rs_reader As New ADODB.RecordsetDim sql As Stringsql = "select * from 书籍信息where 书籍编号= '" & book_num & "'" rs_borrow.Open sql, conn, adOpenKeyset, adLockPessimisticLabel8.Caption = rs_borrow.Fields(0)Label9.Caption = rs_borrow.Fields(1)Label10.Caption = rs_borrow.Fields(2)Label11.Caption = rs_borrow.Fields(3)Label12.Caption = rs_borrow.Fields(4)Label13.Caption = rs_borrow.Fields(5)Label14.Caption = rs_borrow.Fields(6)sql = "select * from 读者信息"rs_reader.Open sql, conn, adOpenKeyset, adLockPessimisticIf Not rs_reader.EOF ThenDo While Not rs_reader.EOFCombo1.AddItem rs_reader.Fields(1)Combo2.AddItem rs_reader.Fields(0)rs_reader.MoveNextLoopElseMsgBox "请先登记读者", vbOKOnly + vbExclamationExit SubEnd Ifrs_borrow.Closers_reader.CloseEnd Sub10.frmchangepwdPrivate Sub Command1_Click()Dim rs_chang As New ADODB.RecordsetDim sql As StringIf Trim(Text1.Text) <> Trim(Text2.Text) ThenMsgBox "密码不一致", vbOKOnly + vbExclamation, ""Text2.SetFocusText1.Text = ""Text2.Text = ""Elsesql = "select*from 系统管理where 用户名='" & userID & "'"rs_chang.Open sql, conn, adOpenKeyset, adLockPessimisticrs_chang.Fields(1) = Text1.Textrs_chang.Updaters_chang.CloseMsgBox "密码修改成功", vbOKOnly + vbExclamation, ""Unload MeEnd IfEnd SubPrivate Sub Command2_Click()Unload MeEnd Sub11.frmfindbookOption ExplicitDim panduan As StringPrivate Sub Command1_Click()Dim rs_findbook As New ADODB.RecordsetDim sql As StringIf Check1.V alue = vbChecked Thensql = "书名='" & Trim(Text1.Text & "") & "'"End IfIf Check2.V alue = vbChecked ThenIf Trim(sql) = "" Thensql = "类别='" & Trim(Combo1.Text & "") & "'"Elsesql = sql & "and 书名='" & Trim(Combo1.Text & "") & "'"End IfEnd IfIf Check3.V alue = vbChecked ThenIf Trim(sql) = "" Thensql = "作者='" & Trim(Text2.Text & "") & "'"Elsesql = sql & "and 作者='" & Trim(Text2.Text & "") & "'"End IfEnd IfIf Check4.V alue = vbChecked ThenIf Trim(sql) = "" Thensql = "出版社='" & Trim(Text3.Text & "") & "'"Elsesql = sql & "and 出版社='" & Trim(Text3.Text & "") & "'"End IfEnd IfIf Check5.V alue = vbChecked ThenIf Trim(sql) = "" Thensql = "书籍编号='" & Trim(Text4.Text & "") & "'"Elsesql = sql & "and 书籍编号='" & Trim(Text4.Text & "") & "'"End IfEnd IfIf Trim(sql) = "" ThenMsgBox "请选择查询方式!", vbOKOnly + vbExclamationExit SubEnd Ifsql = "select * from 书籍信息where " & sqlrs_findbook.CursorLocation = adUseClientrs_findbook.Open sql, conn, adOpenKeyset, adLockPessimisticDataGrid1.AllowAddNew = FalseDataGrid1.AllowDelete = FalseDataGrid1.AllowUpdate = FalseSet DataGrid1.DataSource = rs_findbookEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Command3_Click()If Trim(book_num) = "" ThenMsgBox "请选择要借阅的图书!", vbOKOnly + vbExclamationExit SubEnd IfIf panduan = "是" ThenMsgBox "此书已被借出!", vbOKOnly + vbExclamationExit SubEnd Iffrmborrowbook.ShowEnd SubPrivate Sub DataGrid1_RowColChange(LastRow As V ariant, ByV al LastCol As Integer) book_num = DataGrid1.Columns(0).CellV alue(DataGrid1.Bookmark)panduan = DataGrid1.Columns(7).CellV alue(DataGrid1.Bookmark)End SubPrivate Sub Form_Load()Dim rs_find As New ADODB.RecordsetDim sql As Stringsql = "select * from 图书类别"rs_find.Open sql, conn, adOpenKeyset, adLockPessimisticrs_find.MoveFirstIf Not rs_find.EOF ThenDo While Not rs_find.EOFCombo1.AddItem rs_find.Fields(0)rs_find.MoveNextLoopCombo1.ListIndex = 0End Ifrs_find.CloseEnd Sub12.frmfindborrowinfoPrivate Sub Command1_Click()Dim sql As StringDim rs_find As New ADODB.RecordsetIf Option1.V alue = True Thensql = "select * from 书籍信息where 是否被借出='是'"End IfIf Option2.V alue = True Thensql = "select * from 书籍信息where 是否被借出='否'"End IfIf Option3.V alue = True Thensql = "select * from 书籍信息where 读者姓名='" & Text1.Text & "'" End Ifrs_find.CursorLocation = adUseClientrs_find.Open sql, conn, adOpenKeyset, adLockPessimisticDataGrid1.AllowAddNew = FalseDataGrid1.AllowDelete = FalseDataGrid1.AllowUpdate = FalseSet DataGrid1.DataSource = rs_findEnd SubPrivate Sub Command2_Click()Unload MeEnd Sub13.frmfindreaderOption ExplicitPrivate Sub Command1_Click()Dim rs_findreader As New ADODB.RecordsetDim sql As StringIf Check1.V alue = vbChecked Thensql = "读者编号='" & Trim(Text1.Text & "") & "'"End IfIf Check2.V alue = vbChecked ThenIf Trim(sql) = "" Thensql = "读者姓名='" & Trim(Text2.Text & "") & "'"Elsesql = sql & "and读者姓名='" & Trim(Text2.Text & "") & "'" End IfEnd IfIf Check3.V alue = vbChecked ThenIf Trim(sql) = "" Thensql = "读者类别='" & Trim(Combo1.Text & "") & "'"Elsesql = sql & "and读者类别='" & Trim(Combo1.Text & "") & "'" End IfEnd Ifsql = "select * from 读者信息where " & sqlrs_findreader.CursorLocation = adUseClientrs_findreader.Open sql, conn, adOpenKeyset, adLockPessimistic DataGrid1.AllowAddNew = FalseDataGrid1.AllowDelete = FalseDataGrid1.AllowUpdate = FalseSet DataGrid1.DataSource = rs_findreader'rs_findreader.CloseEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()Dim rs_find As New ADODB.RecordsetDim sql As Stringsql = "select * from 读者类别"rs_find.Open sql, conn, adOpenKeyset, adLockPessimisticIf Not rs_find.EOF ThenDo While Not rs_find.EOFCombo1.AddItem rs_find.Fields(0)rs_find.MoveNextLoopCombo1.ListIndex = 0End Ifrs_find.CloseEnd Sub14.frmmodifybookinfoOption ExplicitDim rs_book As New ADODB.RecordsetPrivate Sub cmdcancel_Click()rs_book.CancelUpdateDataGrid1.AllowAddNew = FalseDataGrid1.AllowUpdate = Falsecmdmodify.Enabled = Truecmddel.Enabled = Falsecmdcancel.Enabled = Falsecmdupdate.Enabled = FalseEnd SubPrivate Sub cmddel_Click()Dim answer As StringOn Error GoTo delerroranswer = MsgBox("确定要删除吗?", vbY esNo, "")If answer = vbY es ThenDataGrid1.AllowDelete = Truers_book.Deleters_book.UpdateDataGrid1.RefreshMsgBox "成功删除!", vbOKOnly + vbExclamation, "" DataGrid1.AllowDelete = FalseElseExit SubEnd Ifdelerror:If Err.Number <> 0 ThenMsgBox Err.DescriptionEnd IfEnd SubPrivate Sub cmdmodify_Click()Dim answer As StringOn Error GoTo cmdmodifycmddel.Enabled = Falsecmdmodify.Enabled = Falsecmdupdate.Enabled = Truecmdcancel.Enabled = TrueDataGrid1.AllowUpdate = Truecmdmodify:If Err.Number <> 0 ThenMsgBox Err.DescriptionEnd IfEnd SubPrivate Sub cmdupdate_Click()If Not IsNull(DataGrid1.Bookmark) Thenrs_book.UpdateEnd Ifcmdmodify.Enabled = Truecmddel.Enabled = Truecmdcancel.Enabled = Falsecmdupdate.Enabled = FalseDataGrid1.AllowUpdate = FalseMsgBox "修改成功!", vbOKOnly + vbExclamation, "" End SubPrivate Sub Form_Load()Dim sql As StringOn Error GoTo loaderrorsql = "select * from 书籍信息"rs_book.CursorLocation = adUseClientrs_book.Open sql, conn, adOpenKeyset, adLockPessimistic cmdupdate.Enabled = FalseDataGrid1.AllowAddNew = FalseDataGrid1.AllowDelete = FalseDataGrid1.AllowUpdate = FalseIf userpow = "guest" ThenFrame2.Enabled = FalseEnd IfSet DataGrid1.DataSource = rs_bookExit Subloaderror:MsgBox Err.DescriptionEnd SubPrivate Sub Form_Unload(Cancel As Integer)Set DataGrid1.DataSource = Nothingrs_book.CloseEnd Sub15.frmmodifybookstyleOption ExplicitDim rs_reader As New ADODB.RecordsetPrivate Sub cmdcancel_Click()rs_reader.CancelUpdateDataGrid1.AllowAddNew = FalseDataGrid1.AllowUpdate = Falsecmdmodify.Enabled = Truecmddel.Enabled = Truecmdcancel.Enabled = Falsecmdupdate.Enabled = FalseEnd SubPrivate Sub cmddel_Click()Dim answer As StringOn Error GoTo delerroranswer = MsgBox("确定要删除吗?", vbY esNo, "")If answer = vbY es ThenDataGrid1.AllowDelete = Truers_reader.Deleters_reader.UpdateDataGrid1.RefreshMsgBox "成功删除!", vbOKOnly + vbExclamation, ""DataGrid1.AllowDelete = FalseElseExit SubEnd Ifdelerror:If Err.Number <> 0 ThenMsgBox Err.DescriptionEnd IfEnd SubPrivate Sub cmdmodify_Click()Dim answer As StringOn Error GoTo cmdmodifycmddel.Enabled = Falsecmdmodify.Enabled = Falsecmdupdate.Enabled = Truecmdcancel.Enabled = TrueDataGrid1.AllowUpdate = Truecmdmodify:If Err.Number <> 0 ThenMsgBox Err.DescriptionEnd IfEnd SubPrivate Sub cmdupdate_Click()If Not IsNull(DataGrid1.Bookmark) Thenrs_reader.UpdateEnd Ifcmdmodify.Enabled = Truecmddel.Enabled = Truecmdcancel.Enabled = Falsecmdupdate.Enabled = FalseDataGrid1.AllowUpdate = FalseMsgBox "修改成功!", vbOKOnly + vbExclamation, ""End SubPrivate Sub Form_Load()Dim sql As StringOn Error GoTo loaderrorsql = "select * from 图书类别"rs_reader.CursorLocation = adUseClientrs_reader.Open sql, conn, adOpenKeyset, adLockPessimisticcmdupdate.Enabled = False '窗体刚刚加载时,"取消"按钮应设置为不可用,即将其Enabled属性设为False'设定DataGrid控件属性DataGrid1.AllowAddNew = FalseDataGrid1.AllowDelete = FalseDataGrid1.AllowUpdate = FalseIf userpow = "guest" ThenFrame2.Enabled = FalseEnd If'添加错误处理语句Set DataGrid1.DataSource = rs_reader '使用DataGrid控件来显示图书类型数据表中的数据信息Exit Subloaderror:MsgBox Err.DesctiptionEnd SubPrivate Sub Form_Unload(Cancel As Integer)Set DataGrid1.DataSource = Nothingrs_reader.CloseEnd Sub16.frmmodifyreaderstyleOption ExplicitDim rs_reader As New ADODB.RecordsetPrivate Sub cmdcancel_Click()rs_reader.CancelUpdateDataGrid1.RefreshDataGrid1.AllowAddNew = FalseDataGrid1.AllowUpdate = Falsecmdmodify.Enabled = Truecmddel.Enabled = Truecmdcancel.Enabled = Falsecmdupdate.Enabled = FalseEnd SubPrivate Sub cmddel_Click()Dim answer As StringOn Error GoTo delerroranswer = MsgBox("确定要删除吗?", vbY esNo, "")If answer = vbY es ThenDataGrid1.AllowDelete = Truers_reader.Deleters_reader.UpdateDataGrid1.RefreshMsgBox "成功删除!", vbOKOnly + vbExclamation, ""DataGrid1.AllowDelete = FalseElseExit Sub。