📄 borbook.frm
字号:
VERSION 5.00
Begin VB.Form borbook
Caption = "图书借阅"
ClientHeight = 5475
ClientLeft = 60
ClientTop = 345
ClientWidth = 6285
LinkTopic = "Form1"
ScaleHeight = 5475
ScaleWidth = 6285
StartUpPosition = 2 'CenterScreen
Begin VB.CommandButton cmdret
Caption = "返回"
BeginProperty Font
Name = "宋体"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 5280
TabIndex = 13
Top = 4680
Width = 855
End
Begin VB.Frame Frame3
Caption = "输入所借图书的编号"
BeginProperty Font
Name = "宋体"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1215
Left = 360
TabIndex = 10
Top = 3960
Width = 4695
Begin VB.CommandButton cmdok2
Caption = "确定"
BeginProperty Font
Name = "宋体"
Size = 9.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 3240
TabIndex = 12
Top = 480
Width = 735
End
Begin VB.TextBox txtbookid
Height = 495
Left = 480
TabIndex = 11
Top = 480
Width = 2295
End
End
Begin VB.Frame Frame2
Caption = "读者借书情况"
BeginProperty Font
Name = "宋体"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1575
Left = 360
TabIndex = 3
Top = 1920
Width = 4695
Begin VB.TextBox txtborcan
Height = 495
Left = 3360
TabIndex = 9
Top = 960
Width = 975
End
Begin VB.TextBox txtborall
Height = 495
Left = 1200
TabIndex = 7
Top = 960
Width = 975
End
Begin VB.TextBox txtreadername
Height = 495
Left = 1440
TabIndex = 6
Top = 240
Width = 1695
End
Begin VB.Label Label3
Alignment = 2 'Center
Caption = "可借书数"
BeginProperty Font
Name = "宋体"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2400
TabIndex = 8
Top = 1080
Width = 855
End
Begin VB.Label Label2
Caption = "借书总数"
BeginProperty Font
Name = "宋体"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 240
TabIndex = 5
Top = 1080
Width = 975
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "姓名"
BeginProperty Font
Name = "宋体"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 480
TabIndex = 4
Top = 360
Width = 975
End
End
Begin VB.Frame Frame1
Caption = "输入借书证号"
BeginProperty Font
Name = "宋体"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1095
Left = 360
TabIndex = 0
Top = 360
Width = 4695
Begin VB.CommandButton cmdok1
Caption = "确定"
BeginProperty Font
Name = "宋体"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 3240
TabIndex = 2
Top = 360
Width = 735
End
Begin VB.TextBox txtreaderid
Height = 495
Left = 480
TabIndex = 1
Top = 360
Width = 2295
End
End
End
Attribute VB_Name = "borbook"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public txtsql, msgtext As String
Public readerid As String
Public bookid As String
Public readername As String
Public rs As ADODB.Recordset
Public bs As ADODB.Recordset
Public bors As ADODB.Recordset
Public bookeds As ADODB.Recordset
Private Sub cmdok1_Click()
readerid = Trim(txtreaderid.Text)
If readerid = "" Then
MsgBox "借书证号不能为空,请输入!", vbOKOnly + vbExclamation, "警告"
Else
txtsql = "select * from readers where readerid='" & readerid & "'"
Set rs = ExecuteSQL(txtsql, msgtext)
If rs.EOF = True Then
MsgBox "该用户未登记,不能借书", vbOKOnly + vbExclamation, "警告"
Else
txtreadername.Text = rs.Fields("readername")
txtborall.Text = rs.Fields("booknum")
txtborcan.Text = rs.Fields("booknum") - rs.Fields("boralready")
txtreadername.Enabled = False
txtborall.Enabled = False
txtborcan.Enabled = False
If Val(Trim(txtborcan.Text)) > 0 Then
readername = rs.Fields("readername")
cmdok2.Enabled = True
Else
MsgBox "该读者已借满图书,不能再借", vbOKOnly + vbExclamation, "警告"
txtreaderid.Text = ""
txtreaderid.SetFocus
End If
End If
End If
End Sub
Private Sub cmdok2_Click()
If Val(Trim(txtborcan.Text)) = 0 Then
MsgBox "该读者已借满图书,不能再借", vbOKOnly + vbExclamation, "警告"
cmdok2.Enabled = False
Exit Sub
End If
bookid = Trim(txtbookid.Text)
If bookid = "" Then
MsgBox "图书编号不能为空,请输入!", vbOKOnly + vbExclamation, "警告"
txtbookid.SetFocus
Else
txtsql = "select * from books where bookid='" & bookid & "'"
Set bs = ExecuteSQL(txtsql, msgtext)
If bs.EOF = True Then
MsgBox "图书编号不正确,请重新输入!", vbOKOnly + vbExclamation, "警告"
txtbookid.Text = ""
txtbookid.SetFocus
Else
txtsql = "select * from borrowinfo where bookid='" & bookid & "'"
Set bors = ExecuteSQL(txtsql, msgtext)
If bs.Fields("borrow") = "y" Then
If bs.Fields("booked") = "y" And readerid = bors.Fields("readerid") Then
MsgBox "此书已被他人预约,不能续借!", vbOKOnly + vbExclamation, "警告"
Exit Sub
Else
MsgBox "此书还未归还!", vbOKOnly, "信息提示"
Exit Sub
End If
If bors.EOF = False Then
If bors.Fields("readerid") = readerid Then
If bors.Fields("borrowtimes") = 2 Then
MsgBox "已续借两次,不能再次续借!", vbOKOnly + vbExclamation, "警告"
Exit Sub
Else
bors.Fields("borrowtimes") = bors.Fields("borrowtimes") + 1
bors.Fields("borrowdate") = Date
bors.Fields("bookdays") = rs.Fields("bookdays") / 2
MsgBox "续借成功!", vbOKOnly, "友情提示"
bors.Update
End If
Else
MsgBox "该图书已经借出,不能再借!", vbOKOnly + vbExclamation, "警告"
txtbookid.Text = ""
txtbookid.SetFocus
End If
'Else
'MsgBox "该图书已经借出,不能再借!", vbOKOnly + vbExclamation, "警告"
'txtbookid.Text = ""
'txtbookid.SetFocus
End If
Else
If bs.Fields("booked") = "y" Then
txtsql = "select * from booked where bookid='" & bookid & "' order by bookdate asc"
Set bookeds = ExecuteSQL(txtsql, msgtext)
Do While bookeds.EOF = False
If (Date - bookeds.Fields("retdate")) < 5 Then
If bookeds.Fields("readerid") <> readerid Then
MsgBox "此书已被他人预约,不能外借!", vbOKOnly + vbExclamation, "警告"
Exit Sub
Else
bookeds.Delete
bookeds.Update
bookeds.MoveNext
If bookeds.EOF = True Then
bs.Fields("booked") = "n"
End If
Exit Do
End If
Else
bookeds.Delete
bookeds.Update
bookeds.MoveNext
End If
Loop
End If
bors.AddNew
bors.Fields("readerid") = readerid
bors.Fields("readername") = readername
bors.Fields("bookid") = bookid
bors.Fields("bookname") = bs.Fields("bookname")
bors.Fields("borrowdate") = Date
bors.Fields("borrowtimes") = bors.Fields("borrowtimes") + 1
bors.Fields("bookdays") = rs.Fields("bookdays")
bors.Update
bs.Fields("borrow") = "y"
bs.Update
rs.Fields("boralready") = rs.Fields("boralready") + 1
rs.Update
MsgBox "借书成功!", vbOKOnly, "借阅书籍"
txtborcan.Enabled = True
txtborcan.Text = rs.Fields("booknum") - rs.Fields("boralready")
txtborcan.Enabled = False
bors.Close
bs.Close
'rs.Close
End If
End If
End If
End Sub
Private Sub cmdret_Click()
Unload Me
End Sub
Private Sub Form_Load()
cmdok2.Enabled = False
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -