📄 frmbrwnextedit.frm
字号:
VERSION 5.00
Begin VB.Form frmBrwNextEdit
BackColor = &H00C0C0C0&
Caption = "借阅编辑步骤二"
ClientHeight = 6630
ClientLeft = 5025
ClientTop = 3015
ClientWidth = 8160
LinkTopic = "Form1"
ScaleHeight = 6630
ScaleWidth = 8160
Begin VB.CommandButton cmdCancel
Caption = "取消(&C)"
Height = 615
Left = 5040
TabIndex = 3
Top = 5760
Width = 1335
End
Begin VB.CommandButton cmdOk
Caption = "生成信息(&G)"
Height = 615
Left = 3120
TabIndex = 2
Top = 5760
Width = 1335
End
Begin VB.Frame Frame2
BackColor = &H00C0C0C0&
Caption = "步骤二:填写图书信息"
Height = 2535
Left = 480
TabIndex = 1
Top = 2880
Width = 7095
Begin VB.TextBox txtTypeName
Height = 495
Left = 4800
TabIndex = 23
Top = 1680
Width = 2055
End
Begin VB.TextBox txtPrice
Height = 495
Left = 1320
TabIndex = 22
Top = 1680
Width = 2175
End
Begin VB.TextBox txtPublisher
Height = 495
Left = 4800
TabIndex = 21
Top = 960
Width = 1935
End
Begin VB.TextBox txtAuthor
Height = 495
Left = 1320
TabIndex = 20
Top = 960
Width = 2175
End
Begin VB.TextBox txtBName
Height = 495
Left = 4800
TabIndex = 19
Top = 240
Width = 1935
End
Begin VB.TextBox txtBNo
Height = 495
Left = 1320
TabIndex = 12
Top = 240
Width = 2175
End
Begin VB.Label Label10
BackStyle = 0 'Transparent
Caption = "所属类别"
Height = 375
Left = 3960
TabIndex = 18
Top = 1800
Width = 735
End
Begin VB.Label Label9
BackStyle = 0 'Transparent
Caption = "价格"
Height = 495
Left = 240
TabIndex = 17
Top = 1680
Width = 855
End
Begin VB.Label Label8
BackStyle = 0 'Transparent
Caption = "出版社"
Height = 375
Left = 3960
TabIndex = 16
Top = 1080
Width = 735
End
Begin VB.Label Label7
BackStyle = 0 'Transparent
Caption = "图书作者"
Height = 375
Left = 240
TabIndex = 15
Top = 960
Width = 855
End
Begin VB.Label Label6
BackStyle = 0 'Transparent
Caption = "图书名称"
Height = 375
Left = 3960
TabIndex = 14
Top = 360
Width = 975
End
Begin VB.Label Label5
BackStyle = 0 'Transparent
Caption = "图书编号"
Height = 375
Left = 240
TabIndex = 13
Top = 360
Width = 975
End
End
Begin VB.Frame Frame1
BackColor = &H00C0C0C0&
Caption = "借阅信息"
Height = 2055
Left = 480
TabIndex = 0
Top = 360
Width = 7095
Begin VB.TextBox txtReturnDate
Height = 495
Left = 4920
TabIndex = 11
Top = 1200
Width = 1815
End
Begin VB.TextBox txtBorrowDate
Height = 495
Left = 1440
TabIndex = 10
Top = 1200
Width = 2175
End
Begin VB.TextBox txtReader
Height = 495
Left = 4920
TabIndex = 9
Top = 360
Width = 1815
End
Begin VB.TextBox txtCNo
Height = 495
Left = 1440
TabIndex = 8
Top = 360
Width = 2175
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
Caption = "应归还日期"
Height = 495
Left = 3840
TabIndex = 7
Top = 1320
Width = 975
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "借阅日期"
Height = 615
Left = 240
TabIndex = 6
Top = 1200
Width = 1335
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "姓名"
Height = 495
Left = 3960
TabIndex = 5
Top = 480
Width = 735
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "借阅证号"
Height = 495
Left = 240
TabIndex = 4
Top = 360
Width = 1095
End
End
End
Attribute VB_Name = "frmBrwNextEdit"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rs As ADODB.Recordset
Dim SQLStr As String
' 返回按钮
Private Sub cmdCancel_Click()
Unload Me
End Sub
'生成信息/确定按钮
Private Sub cmdOk_Click()
'生成信息
If Left(cmdOk.Caption, 4) = "生成信息" Then
'判断框的有效性
If Trim(txtBNo.Text) = "" Then
MsgBox "输入的图书编号为空", vbInformation, "生成信息"
txtBNo.SetFocus
Exit Sub
End If
'判断是否存在此图书编号
SQLStr = "select * from BookInfo where BookNo='" + Trim(txtBNo) + "'"
Set rs = SQLQuery(SQLStr)
If rs.EOF Then
MsgBox "无此借阅证号,请输入正确的图书编号", vbInformation, "生成信息"
txtBNo.SetFocus
txtBNo.SelStart = 0
txtBNo.SelLength = Len(txtBNo.Text)
Exit Sub
End If
'确认此借阅证号为正确的
If MsgBox("是否借阅此编号的图书?" + vbCrLf + "生成其他信息后,图书编号将不能被修改", vbQuestion + vbYesNo + vbDefaultButton1, "询问") = vbNo Then
Exit Sub
End If
'对控件属性进行修改
txtBNo.Enabled = False
txtBName.Text = Trim(rs.Fields("BookName"))
txtAuthor.Text = Trim(rs.Fields("Author"))
txtPublisher.Text = Trim(rs.Fields("Publisher"))
txtPrice.Text = Trim(Str(rs.Fields("Price")))
Dim rst As ADODB.Recordset
SQLStr = "select * from BookType where TypeID=" + Trim(rs.Fields("TypeID"))
Set rst = SQLQuery(SQLStr)
txtTypeName.Text = Trim(rst.Fields("typename"))
cmdOk.Caption = "确定(&O)"
'当"生成信息"后,"生成信息"按钮的Caption属性修改为"确定",以下是"确定"代码
Else
'判断此书籍是否已经被借出
SQLStr = "select * from BorrowInfo where BookNo='" + Trim(txtBNo) + "'"
Set rs = SQLQuery(SQLStr)
If Not rs.EOF Then
'如果没查询到此图书编号,表明没有借出此书
'如果查询到此图书编号,表明已经借出此书
MsgBox "此书已经借出,借书操作失败", vbInformation, "生成信息"
Unload Me
Exit Sub
End If
SQLStr = "insert into BorrowInfo(CardNo,BookNo,BorrowDate,ReturnDate,BorrowState) values('" + Trim(txtCNo) + "','" + Trim(txtBNo) + "','" + Format(txtBorrowDate, "yyyy-mm-dd") + "','" + Format(txtReturnDate, "yyyy-mm-dd") + "'," + Trim(Str(0)) + ")"
SQLExt SQLStr '执行insert 语句
MsgBox "借阅成功", vbInformation, "借阅信息"
Unload Me '关闭窗口
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -