1、主窗体及代码Private Sub chkQuery_Click()If chkQuery.Value = 1 ThentxtQueryBookID.Enabled = TrueElsetxtQueryBookID.Enabled = FalseEnd IfEnd SubPrivate Sub cmdLendBook_Click()If txtReaderID.Text “0“ Then 判断是否已经借满Set g_rs = g_db.OpenRecordset(“lentInfo“, dbOpenTable)With g_rs.AddNew.Fields(“读者编号 “) = txtRead
2、erID.Text.Fields(“书籍编号 “) = txtBookID.Text.Fields(“借书日期 “) = dtpLendDate.Value.UpdateEnd WithSet g_rs = Nothing更新 bookInfo表,设置该书是 否借出属性为“借出“g_strSql = “select * from bookInfo where 书籍编号=“ Data Source=“ Persist Security Info=False“Adodc1.CursorLocation = adUseClientAdodc1.CommandType = adCmdTextAdodc
3、1.RecordSource = strDataSourceAdodc1.RefreshIf blnRenew = False Then 如果是正常借书进行如下操作Set dtgrdLendBook.DataSource = Adodc1dtgrdLendBook.Refresh显示一共借 了多少书lblLendCount.Caption = “所借图书:“ + CStr(Adodc1.Recordset.RecordCount)显示还能够 借多少书g_strSql = “select * from basicSet“Set g_rs = g_db.OpenRecordset(g_strSql
4、)intCount = g_rs!借出册数 - Adodc1.Recordset.RecordCountlblRemain.Caption = CStr(intCount)ElseSet dtgrdLendBookRenew.DataSource = Adodc1dtgrdLendBookRenew.RefreshEnd IfEnd FunctionPrivate Sub txtReaderIDRenew_KeyPress(KeyAscii As Integer)判断用户按下回车键并 且是否输入 读者编号If KeyAscii = “13“ And txtReaderIDRenew.Text
5、“ Then根据输入的 读者编号,查找读者姓 名g_strSql = “select * from readerInfo where 读者编号=“ & txtReaderIDRenew.Text & “Set g_rs = g_db.OpenRecordset(g_strSql) 进行数据库 的查询判断是否找 到If Not g_rs.EOF ThentxtReaderNameRenew.Text = g_rs!读者姓名InitDataGrid (True) 初始化 DataGrid 控件信息cmdOK.Enabled = TrueElseMsgBox “没有该读者信息!“, vbOKOnly, “提示“txtReaderNameRenew.Text = “cmdOK.Enabled = FalseEnd IfSet g_rs = NothingElseIf KeyAscii = “13“ And txtReaderIDRenew.Text = “ ThenMsgBox “请先输入读者编号“, vbOKOnly, “提示“cmdOK.Enabled = FalseEnd IfEnd Sub