VB图书管理系统毕业论文 第16页
Private Sub Command1_Click()
Dim rs_reader As New ADODB.Recordset
Dim sql As String
findform = True
sql = "select * from 借阅信息 where 读者姓名='" & Combo2.Text & "'"
rs_reader.CursorLocation = adUseClient
rs_reader.Open sql, conn, adOpenKeyset, adLockPessimistic
Set DataGrid1.DataSource = rs_reader
DataGrid1.AllowAddNew = False
DataGrid1.AllowDelete = False
DataGrid1.AllowUpdate = False
End Sub
Private Sub Command2_Click()
Dim rs_book As New ADODB.Recordset
Dim sql As String
findform = False
sql = "select * from 借阅信息 where 书籍编号='" & Combo3.Text & "'"
rs_book.CursorLocation = adUseClient
rs_book.Open sql, conn, adOpenKeyset, adLockPessimistic
Set DataGrid1.DataSource = rs_book
DataGrid1.AllowAddNew = False
DataGrid1.AllowDelete = False
DataGrid1.AllowUpdate = False
End Sub
Private Sub Command3_Click()
Dim book_num As String
Dim reader_num As String
Dim answer As String
Dim rs_back As New ADODB.Recordset
Dim sql As String
On Error GoTo delerror
book_num = DataGrid1.Columns(3).CellValue(DataGrid1.Bookmark)
reader_num = DataGrid1.Columns(1).CellValue(DataGrid1.Bookmark)
answer = MsgBox("确定要还这本书吗?", vbYesNo, "")
If answer = vbYes Then
sql = "select * from 借阅信息 where 书籍编号='" & book_num & "'"
rs_back.CursorLocation = adUseClient
rs_back.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_back.Delete
rs_back.Update
rs_back.Close
sql = "select * from 书籍信息 where 书籍编号='" & book_num & "'"
rs_back.CursorLocation = adUseClient
rs_back.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_back.Fields(7) = "否"
rs_back.Update
rs_back.Close
sql = "select * from 读者信息 where 读者编号='" & reader_num & "'"
rs_back.CursorLocation = adUseClient
rs_back.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_back.Fields(8) = rs_back.Fields(8) - 1
rs_back.Update
rs_back.Close
If findform = True Then
Command1_Click
Else
Command2_Click
End If
MsgBox "成功删除!", vbOKOnly + vbExclamation, ""
DataGrid1.AllowDelete = False
Else
Exit Sub
End If
delerror:
If Err.Number <> 0 Then
MsgBox Err.Description
End If
rs_reader.Close
sql = "select * from 借阅信息"
rs_book.CursorLocation = adUseClient
rs_book.Open sql, conn, adOpenKeyset, adLockPessimistic
If Not rs_book.EOF Then
Do While Not rs_book.EOF
Combo3.AddItem rs_book.Fields(3)
Combo4.AddItem rs_book.Fields(4)
rs_book.MoveNext
Loop
End If
rs_book.Close
End Sub
<< 上一页 [11] [12] [13] [14] [15] [16]
VB图书管理系统毕业论文 第16页下载如图片无法显示或论文不完整,请联系qq752018766