📄 frmbackbookinfo.frm
字号:
VERSION 5.00
Begin VB.Form frmbackbookinfo
Caption = "还书"
ClientHeight = 6870
ClientLeft = 60
ClientTop = 450
ClientWidth = 8250
LinkTopic = "Form1"
ScaleHeight = 6870
ScaleWidth = 8250
StartUpPosition = 2 '屏幕中心
Begin VB.Frame Frame4
Height = 975
Left = 1320
TabIndex = 14
Top = 5760
Width = 5655
Begin VB.CommandButton Command4
Caption = "取消"
Height = 495
Left = 3240
TabIndex = 16
Top = 240
Width = 1335
End
Begin VB.CommandButton Command3
Caption = "还书"
Height = 495
Left = 840
TabIndex = 15
Top = 240
Width = 1335
End
End
Begin VB.Frame Frame3
Caption = "书籍信息"
Height = 3375
Left = 120
TabIndex = 12
Top = 2280
Width = 7935
Begin VB.PictureBox DataGrid1
Height = 2895
Left = 240
ScaleHeight = 2835
ScaleWidth = 7395
TabIndex = 13
Top = 240
Width = 7455
End
End
Begin VB.Frame Frame2
Caption = "按书籍信息"
Height = 975
Left = 120
TabIndex = 6
Top = 1200
Width = 7935
Begin VB.ComboBox Combo4
Height = 300
Left = 4080
TabIndex = 9
Text = "选择图书名"
Top = 360
Width = 1815
End
Begin VB.ComboBox Combo3
Height = 300
Left = 960
TabIndex = 8
Text = "选择图书编号"
Top = 360
Width = 1815
End
Begin VB.CommandButton Command2
Caption = "查询"
Height = 375
Left = 6360
TabIndex = 7
Top = 360
Width = 1215
End
Begin VB.Label Label4
Caption = "图书编号"
Height = 375
Left = 120
TabIndex = 11
Top = 360
Width = 735
End
Begin VB.Label Label3
Caption = " 图书名"
Height = 375
Left = 3120
TabIndex = 10
Top = 360
Width = 855
End
End
Begin VB.Frame Frame1
Caption = "按读者信息"
Height = 975
Left = 120
TabIndex = 0
Top = 120
Width = 7935
Begin VB.CommandButton Command1
Caption = "查询"
Height = 375
Left = 6360
TabIndex = 5
Top = 360
Width = 1215
End
Begin VB.ComboBox Combo2
Height = 300
Left = 4080
TabIndex = 4
Text = "选择读者姓名"
Top = 360
Width = 1815
End
Begin VB.ComboBox Combo1
Height = 300
Left = 960
TabIndex = 2
Text = "选择读者编号"
Top = 360
Width = 1815
End
Begin VB.Label Label2
Caption = "读者姓名"
Height = 375
Left = 3120
TabIndex = 3
Top = 360
Width = 855
End
Begin VB.Label Label1
Caption = "读者编号"
Height = 375
Left = 120
TabIndex = 1
Top = 360
Width = 735
End
End
End
Attribute VB_Name = "frmbackbookinfo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Combo1_Click()
Combo2.ListIndex = Combo1.ListIndex
End Sub
Private Sub Combo2_Click()
Combo1.ListIndex = Combo2.ListIndex
End Sub
Private Sub Combo3_Click()
Combo4.ListIndex = Combo3.ListIndex
End Sub
Private Sub Combo4_Click()
Combo3.ListIndex = Combo4.ListIndex
End Sub
Private Sub Command1_Click()
Dim rs_reader As New ADODB.Recordset
Dim conn As New ADODB.Connection
Dim sql As String
findform = False
sql = "select * from 借阅信息 where 读者姓名 = '" & Combo2.Text & "'"
conn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\database.mdb"
rs_reader.CursorLocation = adUseClient
rs_reader.Open sql, conn, adOpenKeyset, adLockPessimistic
Set DataGrid1.DataSource = rs_reader
DataGrid1.AllowAddNew = False
DataGrid1.AllowUpdate = False
DataGrid1.AllowDelete = False
End Sub
Private Sub Command2_Click()
Dim rs_book As New ADODB.Recordset
Dim conn As New ADODB.Connection
Dim sql As String
findform = False
sql = "select * from 借阅信息 where 书籍编号 = '" & Combo3.Text & "'"
conn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\database.mdb"
rs_book.CursorLocation = adUseClient
rs_book.Open sql, conn, adOpenKeyset, adLockPessimistic
Set DataGrid1.DataSource = rs_book
DataGrid1.AllowAddNew = False
DataGrid1.AllowUpdate = False
DataGrid1.AllowDelete = False
End Sub
Private Sub Command3_Click()
Dim book_number As String
Dim reader_number As String
Dim answer As String
Dim rs_back As New ADODB.Recordset
Dim conn As New ADODB.Connection
Dim sql As String
conn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\database.mdb"
book_number = DataGrid1.Columns(3).CellValue(DataGrid1.Bookmark)
reader_number = DataGrid1.Columns(1).CellValue(DataGrid1.Bookmark)
answer = MsgBox("确定要还这本书吗?", vbYesNo, "")
If answer = vbYes Then
sql = "select * from 借阅信息 where 书籍编号 = '" & book_number & "'" '删除这本书在"借阅信息"中的记录
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_number & "'"
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_number & "'"
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
MsgBox "成功删除!", vbOKOnly + vbExclamation, ""
DataGrid1.AllowDelete = False
Else
Exit Sub
End If
If findform = True Then
Command1_Click
Else
Command2_Click
End If
End Sub
Private Sub Command4_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim rs_reader As New ADODB.Recordset
Dim conn As New ADODB.Connection
Dim rs_book As New ADODB.Recordset
Dim sql As String
sql = "select * from [读者信息]"
conn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\database.mdb"
rs_reader.CursorLocation = adUseClient
rs_reader.Open sql, conn, adOpenKeyset, adLockPessimistic
If Not rs_reader.EOF Then
Do While Not rs_reader.EOF
Combo1.AddItem rs_reader.Fields(1)
Combo2.AddItem rs_reader.Fields(0)
rs_reader.MoveNext
Loop
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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -