📄 book_s_add.frm
字号:
VERSION 5.00
Begin VB.Form book_s_add
Caption = "图书类别"
ClientHeight = 2970
ClientLeft = 60
ClientTop = 465
ClientWidth = 4950
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2970
ScaleWidth = 4950
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "取消"
Height = 495
Left = 2400
TabIndex = 5
Top = 1800
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "确定"
Height = 495
Left = 720
TabIndex = 4
Top = 1800
Width = 1095
End
Begin VB.TextBox Text2
Height = 375
Left = 1920
TabIndex = 3
Top = 960
Width = 1575
End
Begin VB.TextBox Text1
Height = 375
Left = 1920
TabIndex = 2
Top = 360
Width = 1575
End
Begin VB.Label Label2
Caption = "图书编号:"
Height = 375
Left = 720
TabIndex = 1
Top = 960
Width = 1335
End
Begin VB.Label Label1
Caption = "类别名称:"
Height = 375
Left = 720
TabIndex = 0
Top = 480
Width = 1215
End
End
Attribute VB_Name = "book_s_add"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim rs_book As New ADODB.Recordset
Dim sql As String
If Trim(Text1.Text) = "" Then
MsgBox "图书类别不能为空", vbOKOnly + vbExclamation, ""
Text1.SetFocus
Exit Sub
End If
If Trim(Text2.Text) = "" Then
MsgBox "图书编号不能为空", vbOKOnly + vbExclamation, ""
Text2.SetFocus
Exit Sub
End If
sql = "select * from 图书类别 where 类别名称='" & Text1.Text & "'"
rs_book.Open sql, conn, adOpenKeyset, adLockPessimistic
If (rs_book.EOF = True) Then
rs_book.AddNew
rs_book.Fields(0) = Text1.Text
rs_book.Fields(1) = Text2.Text
rs_book.Update
MsgBox "图书类别添加成功", vbOKOnly + vbExclamation, ""
rs_book.Close
Unload Me
Else
MsgBox "图书类别名称重复", vbOKOnly + vbExclamation, ""
Text1.SetFocus
Text1.Text = ""
rs_book.Close
Exit Sub
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -