📄 lendbookmanage.frm
字号:
VERSION 5.00
Begin VB.Form lendbookmanage
Caption = "借书窗体"
ClientHeight = 6630
ClientLeft = 60
ClientTop = 390
ClientWidth = 9735
LinkTopic = "Form2"
ScaleHeight = 6630
ScaleWidth = 9735
StartUpPosition = 3 '窗口缺省
Begin VB.ComboBox Combo2
Height = 300
Left = 3600
TabIndex = 7
Text = "选择姓名"
Top = 4320
Width = 1695
End
Begin VB.ComboBox Combo1
Height = 300
Left = 3600
TabIndex = 6
Text = "选择编号"
Top = 3720
Width = 1575
End
Begin VB.CommandButton Command2
Caption = "取消"
Height = 615
Left = 4440
TabIndex = 1
Top = 5040
Width = 1815
End
Begin VB.CommandButton Command1
Caption = "确定"
Height = 615
Left = 2040
TabIndex = 0
Top = 5040
Width = 1575
End
Begin VB.Label Label16
Caption = "读者类别"
Height = 495
Left = 1680
TabIndex = 19
Top = 4320
Width = 1575
End
Begin VB.Label Label15
Caption = "读者编号"
Height = 375
Left = 1680
TabIndex = 18
Top = 3720
Width = 1215
End
Begin VB.Label Label14
Caption = "Label14"
Height = 615
Left = 4320
TabIndex = 17
Top = 1920
Width = 1455
End
Begin VB.Label Label13
Caption = "Label13"
Height = 735
Left = 1680
TabIndex = 16
Top = 2760
Width = 1335
End
Begin VB.Label Label12
Caption = "Label12"
Height = 495
Left = 4320
TabIndex = 15
Top = 1200
Width = 1215
End
Begin VB.Label Label11
Caption = "Label11"
Height = 495
Left = 1440
TabIndex = 14
Top = 2160
Width = 1215
End
Begin VB.Label Label10
Caption = "Label10"
Height = 615
Left = 4200
TabIndex = 13
Top = 480
Width = 1575
End
Begin VB.Label Label9
Caption = "Label9"
Height = 615
Left = 1560
TabIndex = 12
Top = 1320
Width = 1095
End
Begin VB.Label Label8
Caption = "Label8"
Height = 615
Left = 1440
TabIndex = 11
Top = 600
Width = 1095
End
Begin VB.Label Label6
Caption = "出版日期"
Height = 615
Index = 1
Left = 480
TabIndex = 10
Top = 2880
Width = 1695
End
Begin VB.Label Label6
Caption = "登记日期"
Height = 495
Index = 0
Left = 3000
TabIndex = 9
Top = 2040
Width = 1455
End
Begin VB.Label Label4
Caption = "作者"
Height = 375
Index = 1
Left = 480
TabIndex = 8
Top = 2280
Width = 1215
End
Begin VB.Label Label5
Caption = "出版社"
Height = 735
Index = 0
Left = 3000
TabIndex = 5
Top = 1320
Width = 1815
End
Begin VB.Label Label2
Caption = "书名"
Height = 735
Index = 0
Left = 480
TabIndex = 4
Top = 1440
Width = 1815
End
Begin VB.Label Label3
Caption = "类别"
Height = 615
Index = 1
Left = 3120
TabIndex = 3
Top = 600
Width = 1575
End
Begin VB.Label Label1
Caption = "编号"
Height = 495
Left = 600
TabIndex = 2
Top = 720
Width = 1335
End
End
Attribute VB_Name = "lendbookmanage"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim leibie As String '该读者的类别
Dim qixian As String '该读者借书的期限
Dim shumu As Integer '该读者已借书数量
Dim maxnum As Integer '该读者借书数量的限制
Private Sub Combo1_Click()
Combo2.ListIndex = Combo1.ListIndex
End Sub
Private Sub Combo2_Click()
Combo1.ListIndex = Combo2.ListIndex
End Sub
Private Sub Command1_Click()
Dim rs_borrowbook As New ADODB.Recordset
Dim sql As String
Dim conn As New ADODB.Connection
conn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\database1.mdb"
sql = "select * from 读者信息表 where 读者编号='" & Combo1.Text & "'"
rs_borrowbook.Open sql, conn, adOpenKeyset, adLockPessimistic
leibie = rs_borrowbook.Fields(3)
shumu = rs_borrowbook.Fields(8)
rs_borrowbook.Close
sql = "select * from 读者类别表 where 种类名称='" & leibie & "'"
rs_borrowbook.Open sql, conn, adOpenKeyset, adLockPessimistic
qixian = rs_borrowbook.Fields(3)
maxnum = rs_borrowbook.Fields(2)
rs_borrowbook.Close
If shumu >= maxnum Then
MsgBox "该读者借书数额已满!", vbOKOnly + vbExclamation
Exit Sub
End If
sql = "select * from 借阅信息表"
rs_borrowbook.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_borrowbook.AddNew
rs_borrowbook.Fields(1) = Combo1.Text
rs_borrowbook.Fields(2) = Combo2.Text
rs_borrowbook.Fields(3) = Label8.Caption
rs_borrowbook.Fields(4) = Label9.Caption
rs_borrowbook.Fields(8) = rs_borrowbook.Fields(8) + 1
rs_borrowbook.Fields(5) = Date
rs_borrowbook.Fields(6) = Date + qixian
rs_borrowbook.Update
rs_borrowbook.Close
sql = "select * from 书籍信息表 where 图书编号='" & book_num & "'"
rs_borrowbook.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_borrowbook.Fields(7) = "是"
rs_borrowbook.Update
rs_borrowbook.Close
sql = "select * from 读者信息表 where 读者编号='" & Combo1.Text & "'"
rs_borrowbook.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_borrowbook.Update
rs_borrowbook.Close
MsgBox "本书借阅成功!", vbOKOnly + vbExclamation
Unload Me
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim rs_borrow As New ADODB.Recordset
Dim rs_reader As New ADODB.Recordset
Dim conn As New ADODB.Connection
Dim sql As String
Dim sqlreader As String
conn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\database1.mdb"
sql = "select * from 书籍信息表 where 图书编号='" & book_num & "'"
rs_borrow.Open sql, conn, adOpenKeyset, adLockPessimistic
Label8.Caption = rs_borrow.Fields(0)
Label9.Caption = rs_borrow.Fields(1)
Label10.Caption = rs_borrow.Fields(3)
Label11.Caption = rs_borrow.Fields(5)
Label12.Caption = rs_borrow.Fields(2)
Label13.Caption = rs_borrow.Fields(4)
Label14.Caption = rs_borrow.Fields(6)
sqlreader = "select * from 读者信息表"
rs_reader.Open sqlreader, 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
Else
MsgBox "请先登记读者!", vbOKOnly + vbExclamation
Exit Sub
End If
rs_borrow.Close
rs_reader.Close
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -