📄 form3.frm
字号:
VERSION 5.00
Begin VB.Form tianjiatushuxinxi
Caption = "添加图书信息"
ClientHeight = 4725
ClientLeft = 60
ClientTop = 345
ClientWidth = 7515
Icon = "Form3.frx":0000
LinkTopic = "Form3"
Picture = "Form3.frx":1E72
ScaleHeight = 4725
ScaleWidth = 7515
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox Text1
Height = 375
Left = 3360
TabIndex = 6
Top = 600
Width = 1335
End
Begin VB.Frame Frame1
Height = 3495
Left = 1440
TabIndex = 0
Top = 120
Width = 5535
Begin VB.CommandButton Command3
Caption = "清空数据"
Height = 495
Left = 4080
TabIndex = 13
Top = 2520
Width = 1095
End
Begin VB.ComboBox Combo1
Height = 300
Left = 1920
TabIndex = 12
Top = 1680
Width = 1335
End
Begin VB.CommandButton Command2
Caption = "关闭窗口"
Height = 495
Left = 4080
TabIndex = 11
Top = 1680
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "确定"
Height = 495
Left = 4080
TabIndex = 10
Top = 840
Width = 1095
End
Begin VB.TextBox Text4
Height = 375
Left = 1920
TabIndex = 9
Top = 2760
Width = 1335
End
Begin VB.TextBox Text3
Height = 390
Left = 1920
TabIndex = 8
Top = 2160
Width = 1335
End
Begin VB.TextBox Text2
Height = 375
Left = 1920
TabIndex = 7
Top = 1080
Width = 1335
End
Begin VB.Label Label5
Caption = "出版社 "
Height = 375
Left = 840
TabIndex = 5
Top = 2760
Width = 855
End
Begin VB.Label Label4
Caption = "作者 "
Height = 375
Left = 840
TabIndex = 4
Top = 2280
Width = 735
End
Begin VB.Label Label3
Caption = "类别 "
Height = 495
Left = 840
TabIndex = 3
Top = 1680
Width = 855
End
Begin VB.Label Label2
Caption = "书名 "
Height = 495
Left = 840
TabIndex = 2
Top = 1080
Width = 735
End
Begin VB.Label Label1
Caption = "图书编号"
Height = 495
Left = 840
TabIndex = 1
Top = 600
Width = 975
End
End
End
Attribute VB_Name = "tianjiatushuxinxi"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command3_Click()
Text1.Text = Empty
Text2.Text = Empty
Text3.Text = Empty
Text4.Text = Empty
Combo1.Text = Empty
End Sub
Private Sub Form_Load()
'conn.Open "provider=microsoft.jet.oledb.4.0;" & "data source=" & App.Path & "\db1.mdb"
Dim rs_leibie As New adodb.Recordset
Dim sql As String
sql = "select * from bookstypes"
rs_leibie.Open sql, conn, adOpenKeyset, adLockPessimistic
rs_leibie.MoveFirst
Do While Not rs_leibie.EOF
Combo1.AddItem rs_leibie.Fields(1)
rs_leibie.MoveNext
Loop
rs_leibie.Close
End Sub
Private Sub Command1_Click()
Dim rs_addbook As New adodb.Recordset
Dim sql As String
If Trim(Combo1.Text) = "" Then
MsgBox "请选择图书种类", vbOKOnly + vbExclamation, ""
Combo1.SetFocus
Exit Sub
End If
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
If Trim(Text3.Text) = "" Then
MsgBox "作者不能为空", vbOKOnly + vbExclamation, ""
Text3.SetFocus
Exit Sub
End If
If Trim(Text4.Text) = "" Then
MsgBox "出版社不能为空", vbOKOnly + vbExclamation, ""
Text4.SetFocus
Exit Sub
End If
sql = "select * from books where bookid='" & Text1.Text & "'"
rs_addbook.Open sql, conn, adOpenKeyset, adLockPessimistic
If rs_addbook.EOF Then
rs_addbook.AddNew
rs_addbook.Fields(0) = Trim(Text1.Text)
rs_addbook.Fields(1) = Trim(Text2.Text)
rs_addbook.Fields(2) = Trim(Combo1.Text)
rs_addbook.Fields(5) = Trim(Text3.Text)
rs_addbook.Fields(3) = Trim(Text4.Text)
rs_addbook.Fields(4) = Trim("未借")
rs_addbook.Update
MsgBox "添加书籍信息成功!", vbOKOnly, ""
rs_addbook.Close
Else
MsgBox "图书编号重复!", vbOKOnly + vbExclamation, ""
Text1.SetFocus
Text1.Text = ""
rs_addbook.Close
Exit Sub
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -