📄 frmborrowenter.frm
字号:
VERSION 5.00
Begin VB.Form frmborrowenter
BorderStyle = 3 'Fixed Dialog
Caption = "借阅登记"
ClientHeight = 3345
ClientLeft = 3480
ClientTop = 3180
ClientWidth = 6330
Icon = "frmborrowenter.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 3345
ScaleWidth = 6330
ShowInTaskbar = 0 'False
Begin VB.TextBox Txtreturntime
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Left = 1200
TabIndex = 11
Top = 2520
Width = 1695
End
Begin VB.CommandButton Cmdclose
Caption = "关闭"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 5040
TabIndex = 10
Top = 2880
Width = 975
End
Begin VB.CommandButton Cmdsave
Caption = "保存"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 3720
TabIndex = 9
Top = 2880
Width = 975
End
Begin VB.TextBox Txtborrowtime
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Left = 1200
Locked = -1 'True
TabIndex = 8
Top = 1920
Width = 1695
End
Begin VB.TextBox Txtbookname
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Left = 1200
Locked = -1 'True
TabIndex = 7
Top = 1320
Width = 3495
End
Begin VB.TextBox Txtbookindex
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Left = 1200
TabIndex = 6
Top = 720
Width = 1695
End
Begin VB.TextBox Txtreaderindex
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Left = 1200
TabIndex = 5
Top = 120
Width = 1695
End
Begin VB.Label Lblreturntime
AutoSize = -1 'True
Caption = "返还时间"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 240
TabIndex = 4
Top = 2640
Width = 840
End
Begin VB.Label Lblborrowtime
AutoSize = -1 'True
Caption = "借阅时间"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 240
TabIndex = 3
Top = 2040
Width = 840
End
Begin VB.Label Lblbookname
AutoSize = -1 'True
Caption = "图书名称"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 240
TabIndex = 2
Top = 1440
Width = 840
End
Begin VB.Label Lblbookindex
AutoSize = -1 'True
Caption = "图书编号"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 240
TabIndex = 1
Top = 840
Width = 840
End
Begin VB.Label Lblreaderindex
AutoSize = -1 'True
Caption = "读者编号"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 240
TabIndex = 0
Top = 240
Width = 840
End
End
Attribute VB_Name = "Frmborrowenter"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Cmdclose_Click()
Unload Me
End Sub
Private Sub Cmdsave_Click()
Dim x As Integer
Dim strInsertSQL As String
'判断输入的数据是否完整
If (Trim(Txtreaderindex.Text) = Empty) _
Or (Trim(Txtbookindex.Text) = Empty) Then
MsgBox "请输入读者编号和图书编号...", vbInformation + vbOKOnly, "借阅资料不完整"
' 弹出消息框,判断输入的数据是否准确,如果准确向数据库中倒入数据
ElseIf MsgBox("读者编号:" & Trim(Txtreaderindex.Text) & vbCrLf & _
"图书编号:" & Trim(Txtbookindex.Text) & vbCrLf & _
"图书名称:" & Trim(Txtbookname.Text) & vbCrLf & _
"借阅时间:" & Trim(Txtborrowtime.Text) & vbCrLf & _
"返还时间:" & Trim(Txtreturntime.Text) _
, vbOKCancel + vbInformation, "图书资料确认") = vbOK Then
If g_DBRct.State = adStateOpen Then
g_DBRct.Close
End If
g_DBRct.Open "BorrowMessage", g_DBCon, adOpenDynamic, adLockOptimistic
g_DBRct.AddNew
g_DBRct!readerindex = Trim(Txtreaderindex.Text)
g_DBRct!bookindex = Trim(Txtbookindex.Text)
g_DBRct!borrowtime = Trim(Txtborrowtime.Text)
g_DBRct!returntime = Trim(Txtreturntime.Text)
g_DBRct.Update
'向借阅表中插入数据
g_DBCon.Execute ("update readermessage set borrowbookdegree=borrowbookdegree+1 where readerindex='" & Trim(Txtreaderindex.Text) & "'")
'更新读者表中借阅次数
g_DBCon.Execute ("update bookmessage set borrowdegree=borrowdegree+1 where bookindex='" & Trim(Txtbookindex.Text) & "'")
'更新图书表中借阅次数
If g_DBRct.State = adStateOpen Then
g_DBRct.Close
End If
g_DBRct.Open "BookMessage", g_DBCon, adOpenDynamic, adLockOptimistic
x = g_DBRct!numbers
If x = 1 Then
g_DBCon.Execute ("update bookmessage set states=0 where bookindex='" & Trim(Txtbookindex.Text) & "'")
'更新图书表中图书的状态(在库或借出)
Else
g_DBCon.Execute ("update bookmessage set numbers=numbers-1 where bookindex='" & Trim(Txtbookindex.Text) & "'")
'将图书表中图书的数量减一
End If
MsgBox "借阅资料已保存...", vbInformation + vbOKOnly, "保存成功"
Txtreaderindex.Text = Empty
Txtbookindex.Text = Empty
Txtbookname.Text = Empty
End If
End Sub
Private Sub Form_Load()
'窗体加载时,借阅时间和返还时间自动生成
Txtborrowtime.Text = Date
Txtreturntime.Text = DateAdd("d", 3, CDate(Txtborrowtime.Text))
End Sub
Private Sub Txtbookindex_click()
Cmdsave.Enabled = True
If g_DBRct.State = adStateOpen Then
g_DBRct.Close
End If
'判断读者编号是否存在
g_DBRct.Filter = "readerindex='" & Trim(Txtreaderindex.Text) & "'"
g_DBRct.Open "select readerindex from readermessage", g_DBCon, adOpenDynamic, adLockOptimistic
If g_DBRct.BOF = True And g_DBRct.EOF = True Then
MsgBox "读者编号不存在!", vbCritical + vbYesNo, "错误读者编号"
Txtreaderindex.Text = ""
Else
If g_DBRct.State = adStateOpen Then
g_DBRct.Close
End If
g_DBRct.Open "select * from borrowmessage where readerindex='" & Trim(Txtreaderindex.Text) & "'", g_DBCon, adOpenDynamic, adLockOptimistic
If g_DBRct.EOF And g_DBRct.BOF Then
MsgBox "这是该读者第一次借书!"
Else
If g_DBRct.State = adStateOpen Then
g_DBRct.Close
Set g_DBRct = Nothing
End If
g_DBRct.Open "select states from borrowmessage where states=0 and readerindex='" & Trim(Txtreaderindex.Text) & "'", g_DBCon, adOpenStatic
'判断读者所借的书是否超过五本
If g_DBRct.RecordCount > 4 Then
MsgBox "所借图书已超过五本,不允许在借了?", vbCritical + vbOKOnly, "不许借书"
End If
End If
End If
End Sub
Private Sub Txtbookname_click()
Dim x As Integer
Dim st As String
If g_DBRct.State = adStateOpen Then
g_DBRct.Close
End If
'判断图书编号是否存在
g_DBRct.Filter = "bookindex='" & Trim(Txtbookindex.Text) & "'"
g_DBRct.Open "select bookindex,bookname,numbers,states from bookmessage", g_DBCon, adOpenDynamic, adLockOptimistic
If g_DBRct.BOF = True And g_DBRct.EOF = True Then
MsgBox "图书编号不存在!", vbCritical + vbYesNo, "错误图书编号"
Txtbookindex.Text = ""
'判断图书是否在库
ElseIf g_DBRct!states = 0 Then
MsgBox "该图书已被借光,请重新选择一本书", vbInformation + vbOKOnly, "库存为空"
Txtbookindex.Text = ""
Txtbookname.Text = ""
Cmdsave.Enabled = False
Else
Txtbookname.Text = g_DBRct!bookname
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -