源程序清单1、文件名 login(login.frm)功能说明:整个系统的登陆界面,需要输入用户名和登陆密码才能进入到系统中,进行借阅等操作。
源代码:Option ExplicitDim cnt As IntegerPrivate Sub Command1_Click()Dim sql As StringDim rs_login As New ADODB.RecordsetIf Trim(Combo1.Text) = "" ThenMsgBox "没有这个用户", vbOKOnly + vbExclamation, ""Combo1.SetFocusElsesql = "select * from 系统管理 where 用户名='" & Combo1.Text & "'" rs_login.Open sql, conn, adOpenKeyset, adLockPessimisticIf rs_login.EOF = True ThenMsgBox "没有这个用户", vbOKOnly + vbExclamation, ""Combo1.SetFocusElseIf Trim(rs_login.Fields(1)) = Trim(txtpwd.Text) ThenuserID = Combo1.Textrs_login.CloseUnload Meform1.ShowElseMsgBox "密码不正确", vbOKOnly + vbExclamation, ""txtpwd.SetFocusEnd IfEnd Ifcnt = cnt + 1If cnt = 3 ThenUnload MeEnd IfExit SubEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()Dim connectionstring As Stringconnectionstring = "provider=Microsoft.Jet.oledb.4.0;" & _"data source=book.mdb"conn.Open connectionstringcnt = 0End SubPrivate Sub txtuser_Change()End Sub2、文件名 form1(form1.frm)功能说明:整个系统的主界面,其中包括图书管理、读者管理、图书借阅管理、系统管理、关于,以及在这下面的子菜单。
源代码:Private Sub add_admin_Click()frmadduser.ShowEnd SubPrivate Sub add_back_book_Click()frmbackbookinfo.ShowPrivate Sub add_book_info_Click() frmaddbookinfo.ShowEnd SubPrivate Sub add_book_style_Click() frmaddbookstyle.ShowEnd SubPrivate Sub add_lend_book_Click() frmfindbook.ShowEnd SubPrivate Sub add_reader_info_Click() frmaddreaderinfo.ShowEnd SubPrivate Sub add_reader_style_Click() frmaddreaderstyle.ShowEnd SubPrivate Sub change_pwd_Click() frmchangepwd.ShowEnd SubPrivate Sub del_book_info_Click() frmmodifybookinfo.ShowEnd SubPrivate Sub del_book_style_Click() frmmodifybookstyle.ShowEnd SubPrivate Sub del_reader_info_Click() frmreaderinfo.ShowEnd SubPrivate Sub del_reader_style_Click()End SubPrivate Sub exit_sys_Click()EndEnd SubPrivate Sub find_book_info_Click() frmfindbook.ShowEnd SubPrivate Sub find_lend_book_Click() frmfindborrowinfo.ShowEnd SubPrivate Sub find_reader_info_Click() frmfindreader.ShowEnd SubPrivate Sub Form_Load()End SubPrivate Sub gly_Click()Form2.ShowEnd SubPrivate Sub modify_book_info_Click() frmmodifybookinfo.ShowEnd SubPrivate Sub modify_book_style_Click() frmmodifybookstyle.ShowEnd SubPrivate Sub modify_reader_info_Click() frmreaderinfo.ShowEnd SubPrivate Sub modify_reader_style_Click()End Sub3、文件名 frmaddbookstyle(frmbookstyle.frm)功能说明:用于添加图书类别信息。
源代码:Option ExplicitPrivate 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, adLockPessimisticIf 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 Sub4、文件名 frmmodifybookstyle(code)功能说明:图书类别管理,可以修改和删除图书类别。
源代码:Option 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("确定要删除吗?", vbYesNo, "")If answer = vbYes 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 Command5_Click()rs_reader.UpdateDataGrid1.RefreshEnd 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 Command1_Click()Unload MeEnd SubPrivate Sub Form_Load()Dim sql As StringOn Error GoTo loaderrorsql = "select * from 图书类别"rs_reader.CursorLocation = adUseClientrs_reader.Open sql, conn, adOpenKeyset, adLockPessimistic '打开数据库cmdupdate.Enabled = False'设定datagrid控件属性DataGrid1.AllowAddNew = False '不可增加DataGrid1.AllowDelete = False '不可删除DataGrid1.AllowUpdate = FalseIf userpow = "guest" Then '权限相关Frame2.Enabled = FalseEnd IfSet DataGrid1.DataSource = rs_readerExit Subloaderror:MsgBox Err.DescriptionEnd Sub5、文件名 frmaddbookinfo(frmaddbookinfo.frm)功能说明:添加图书信息,包括图书编号、书名、出版日期、入库日期、作者等信息。