📄 borbook.frm
字号:
VERSION 5.00
Begin VB.Form borbook
Caption = "借书处理"
ClientHeight = 5055
ClientLeft = 60
ClientTop = 465
ClientWidth = 9270
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5055
ScaleWidth = 9270
StartUpPosition = 2 '屏幕中心
Begin VB.Frame Frame3
Caption = "输入所借图书的图书编号"
Height = 1215
Left = 480
TabIndex = 2
Top = 3480
Width = 8415
Begin VB.CommandButton cmd_back
Caption = "返回"
Height = 495
Left = 5880
TabIndex = 13
Top = 360
Width = 1455
End
Begin VB.CommandButton cmd_ok2
Caption = "确定"
Height = 495
Left = 3240
TabIndex = 12
Top = 360
Width = 1455
End
Begin VB.TextBox txtbno
Height = 375
Left = 480
MaxLength = 4
TabIndex = 11
Top = 480
Width = 2415
End
End
Begin VB.Frame Frame2
Caption = "读者借书情况"
Height = 1335
Left = 480
TabIndex = 1
Top = 1920
Width = 8415
Begin VB.TextBox txtcnum
Height = 375
Left = 6360
MaxLength = 9
TabIndex = 10
Top = 480
Width = 1695
End
Begin VB.TextBox txtsum
Height = 375
Left = 3840
MaxLength = 9
TabIndex = 8
Top = 480
Width = 975
End
Begin VB.TextBox txtname
Height = 375
Left = 960
MaxLength = 16
TabIndex = 6
Top = 480
Width = 1695
End
Begin VB.Label Label3
Caption = "可借书数"
Height = 375
Left = 5280
TabIndex = 9
Top = 600
Width = 1095
End
Begin VB.Label Label2
Caption = "借书总数"
Height = 375
Left = 3000
TabIndex = 7
Top = 600
Width = 1095
End
Begin VB.Label Label1
Caption = "姓名"
Height = 375
Left = 240
TabIndex = 5
Top = 600
Width = 1095
End
End
Begin VB.Frame Frame1
Caption = "输入借书证号"
Height = 1455
Left = 480
TabIndex = 0
Top = 240
Width = 8415
Begin VB.CommandButton cmd_ok1
Caption = "确定"
Height = 495
Left = 3840
TabIndex = 4
Top = 360
Width = 1335
End
Begin VB.TextBox txtrno
Height = 375
Left = 360
MaxLength = 4
TabIndex = 3
Top = 480
Width = 2655
End
End
End
Attribute VB_Name = "borbook"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public rno As String
Public bno As String
Public xm As String
Public rstseek As ADODB.Recordset
Public dw As String
Private Sub cmd_back_Click()
Unload Me
End Sub
Private Sub cmd_ok1_Click()
rno = Trim(txtrno.Text)
If rno = "" Then
MsgBox "借书证号不能为空,请输入!", vbOKOnly, "信息提示"
cmd_ok2.Enabled = False
Else
txtsql = "select * from reader where 借书证号='" + rno + "'"
Set rstseek = exesql(txtsql)
If rstseek.EOF = True Then
MsgBox "改读者没有登记,不能借书", vbOKOnly, "信息提示"
cmd_ok2.Enabled = False
Else
txtname.Text = rstseek.Fields("姓名")
txtsum.Text = str(rstseek.Fields("借书总数"))
txtcnum.Text = str(rstseek.Fields("借书总数") - rstseek.Fields("已借书数"))
If Val(Trim(txtcnum.Text)) > 0 Then
xm = rstseek.Fields("姓名")
dw = rstseek.Fields("单位")
cmd_ok2.Enabled = True
Else
MsgBox "已借满图书,不能再借", vbOKOnly, "信息提示"
cmd_ok2.Enabled = False
End If
End If
End If
End Sub
Private Sub cmd_ok2_Click()
If Val(Trim(txtcnum.Text)) = 0 Then
MsgBox "改读者已借满图书,不能再借!", vbOKOnly, "信息提示"
cmd_ok2.Enabled = False
Exit Sub
End If
bno = Trim(txtbno.Text)
If bno = "" Then
MsgBox "图书编号不能为空,请输入!", vbOKOnly, "信息提示"
Else
Dim rstfind As ADODB.Recordset
Dim rstadd As ADODB.Recordset
txtsql = "select * from book where 图书编号='" + bno + "'"
Set rstfind = exesql(txtsql)
If rstfind.EOF = True Then
MsgBox "图书编号不正确,请重新输入", vbOKOnly, "信息提示"
Else
If rstfind.Fields("借否") = "借" Then
MsgBox "改图书已借出,不能再借!", vbOKOnly, "信息提示"
Else
txtsql = "select * from borrow"
Set rstadd = exesql(txtsql)
rstadd.AddNew
rstadd.Fields("图书编号") = bno
rstadd.Fields("书名") = rstfind.Fields("书名")
rstadd.Fields("作者") = rstfind.Fields("作者")
rstadd.Fields("出版社") = rstfind.Fields("出版社")
rstadd.Fields("借书证号") = rno
rstadd.Fields("姓名") = xm
rstadd.Fields("单位") = dw
rstadd.Fields("借书日期") = Date
rstadd.Update
rstfind.Fields("借否") = "借"
rstfind.Update
rstseek.Fields("已借书数") = rstseek.Fields("已借书数") + 1
rstseek.Update
txtcnum.Text = str(rstseek.Fields("借书总数") - rstseek.Fields("已借书数"))
End If
End If
End If
End Sub
Private Sub Form_Load()
cmd_ok2.Enabled = False
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -