📄 addbook.frm
字号:
VERSION 5.00
Begin VB.Form addbook
Caption = "添加图书"
ClientHeight = 5100
ClientLeft = 3360
ClientTop = 1710
ClientWidth = 8115
Icon = "addbook.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5100
ScaleWidth = 8115
Begin VB.CommandButton Command2
Caption = "关 闭"
Height = 615
Left = 4710
TabIndex = 13
Top = 4320
Width = 2055
End
Begin VB.CommandButton Command1
Caption = "保 存"
Height = 615
Left = 1350
TabIndex = 12
Top = 4320
Width = 2055
End
Begin VB.Frame Frame1
Caption = "添加图书:"
Height = 3975
Left = 120
TabIndex = 0
Top = 120
Width = 7815
Begin VB.ComboBox Combo2
Height = 300
Left = 5040
TabIndex = 10
Top = 2160
Width = 2055
End
Begin VB.ComboBox Combo1
Height = 300
Left = 5040
TabIndex = 8
Top = 1080
Width = 2055
End
Begin VB.TextBox Text9
BeginProperty DataFormat
Type = 1
Format = """¥""#,##0.00"
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 2
EndProperty
Height = 270
Left = 5040
TabIndex = 11
Top = 2760
Width = 2055
End
Begin VB.TextBox Text8
BeginProperty DataFormat
Type = 1
Format = "0"
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 1
EndProperty
Height = 270
Left = 5040
TabIndex = 9
Top = 1664
Width = 2055
End
Begin VB.TextBox Text7
BeginProperty DataFormat
Type = 1
Format = "0"
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 1
EndProperty
Height = 270
Left = 5040
TabIndex = 7
Top = 560
Width = 2055
End
Begin VB.TextBox Text6
BeginProperty DataFormat
Type = 1
Format = "yyyy-M-d"
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 3
EndProperty
Height = 270
Left = 1680
TabIndex = 6
Top = 3320
Width = 2055
End
Begin VB.TextBox Text5
Height = 270
Left = 1680
TabIndex = 5
Top = 2768
Width = 2055
End
Begin VB.TextBox Text4
Height = 270
Left = 1680
TabIndex = 4
Top = 2216
Width = 2055
End
Begin VB.TextBox Text3
Height = 270
Left = 1680
TabIndex = 3
Top = 1664
Width = 2055
End
Begin VB.TextBox Text2
Height = 270
Left = 1680
TabIndex = 2
Top = 1112
Width = 2055
End
Begin VB.TextBox Text1
Height = 270
Left = 1680
TabIndex = 1
Top = 560
Width = 2055
End
Begin VB.Label Label11
AutoSize = -1 'True
Caption = "图书价格:"
Height = 180
Left = 4080
TabIndex = 24
Top = 2805
Width = 900
End
Begin VB.Label Label10
AutoSize = -1 'True
Caption = "存放位置:"
Height = 180
Left = 4080
TabIndex = 23
Top = 2250
Width = 900
End
Begin VB.Label Label9
AutoSize = -1 'True
Caption = "现存数量:"
Height = 180
Left = 4080
TabIndex = 22
Top = 1710
Width = 900
End
Begin VB.Label Label8
AutoSize = -1 'True
Caption = "类 别:"
Height = 180
Left = 4080
TabIndex = 21
Top = 1155
Width = 900
End
Begin VB.Label Label7
AutoSize = -1 'True
Caption = "页 数:"
Height = 180
Left = 4080
TabIndex = 20
Top = 600
Width = 900
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "出版时间:"
Height = 180
Left = 600
TabIndex = 19
Top = 3360
Width = 900
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "出 版 社:"
Height = 180
Left = 600
TabIndex = 18
Top = 2808
Width = 900
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "作 者:"
Height = 180
Left = 600
TabIndex = 17
Top = 2256
Width = 900
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "书 名:"
Height = 180
Left = 600
TabIndex = 16
Top = 1704
Width = 900
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "条 形 码:"
Height = 180
Left = 600
TabIndex = 15
Top = 1152
Width = 900
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "图书编号:"
Height = 180
Left = 600
TabIndex = 14
Top = 600
Width = 900
End
End
End
Attribute VB_Name = "addbook"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim addbookcn As New ADODB.Connection
Dim addbookrsuser As New ADODB.Recordset
Dim addbookrsuser1 As New ADODB.Recordset
Dim addbookrsuser2 As New ADODB.Recordset
Private Sub Command1_Click()
If IsDate(Text6.Text) Then
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Or Text5.Text = "" Or Text6.Text = "" Or Text7.Text = "" Or Text8.Text = "" Or Text9.Text = "" Or Combo1.Text = "" Or Combo2.Text = "" Then
nul = MsgBox("每一项都必须填写!", vbOKOnly + vbExclamation, "错误:")
Else
addbookrsuser.AddNew
addbookrsuser("图书编号") = Text1.Text
addbookrsuser("条形码") = Text2.Text
addbookrsuser("书名") = Text3.Text
addbookrsuser("作者") = Text4.Text
addbookrsuser("出版社") = Text5.Text
addbookrsuser("出版时间") = Text6.Text
addbookrsuser("页数") = Text7.Text
addbookrsuser("类别") = Combo1.Text
addbookrsuser("现存数量") = Text8.Text
addbookrsuser("存放位置") = Combo2.Text
addbookrsuser("图书价格") = Text9.Text
addbookrsuser("入馆时间") = Date
addduzhersuser.UpdateBatch adAffectAllChapters
nul = MsgBox("记录添加成功!", vbOKOnly + vbInformation, "揭示:")
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
End If
Else
nul = MsgBox("日期格式不对!(正确格式:yyyy-mm-dd)", vbOKOnly + vbExclamation, "错误:")
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
main.Show
main.Enabled = True
End Sub
Private Sub Form_Load()
Set addbookcn = New Connection
addbookcn.ConnectionString = "provider=Microsoft.Jet.OLEDB.3.51;data source=book.mdb;"
addbookcn.CursorLocation = adUseClient
addbookcn.Open
Set addbookrsuser = New Recordset
addbookrsuser.CursorLocation = adUseClient
addbookrsuser.Open "Select * from book", addbookcn, adOpenDynamic, adLockOptimistic
Set addbookrsuser1 = New Recordset
addbookrsuser1.CursorLocation = adUseClient
addbookrsuser1.Open "Select * from 图书类别", addbookcn, adOpenDynamic, adLockOptimistic
For i = 0 To addbookrsuser1.RecordCount
Combo1.AddItem addbookrsuser1(0)
addbookrsuser1.MoveNext
If addbookrsuser1.EOF = True Then
addbookrsuser1.MoveLast
Combo1.ListIndex = 0
Exit For
End If
Next i
Set addbookrsuser1 = New Recordset
addbookrsuser1.CursorLocation = adUseClient
addbookrsuser1.Open "Select * from 存放位置", addbookcn, adOpenDynamic, adLockOptimistic
For j = 0 To addbookrsuser1.RecordCount
Combo2.AddItem addbookrsuser1(0)
addbookrsuser1.MoveNext
If addbookrsuser1.EOF = True Then
addbookrsuser1.MoveLast
Combo2.ListIndex = 0
Exit For
End If
Next j
End Sub
Private Sub Text1_GotFocus()
Text1.BackColor = &HFFC0C0
End Sub
Private Sub Text1_LostFocus()
Text1.BackColor = &H80000014
End Sub
Private Sub Text2_GotFocus()
Text2.BackColor = &HFFC0C0
End Sub
Private Sub Text2_LostFocus()
Text2.BackColor = &H80000014
End Sub
Private Sub Text3_GotFocus()
Text3.BackColor = &HFFC0C0
End Sub
Private Sub Text3_LostFocus()
Text3.BackColor = &H80000014
End Sub
Private Sub Text4_GotFocus()
Text4.BackColor = &HFFC0C0
End Sub
Private Sub Text4_LostFocus()
Text4.BackColor = &H80000014
End Sub
Private Sub Text5_GotFocus()
Text5.BackColor = &HFFC0C0
End Sub
Private Sub Text5_LostFocus()
Text5.BackColor = &H80000014
End Sub
Private Sub Text6_GotFocus()
Text6.BackColor = &HFFC0C0
End Sub
Private Sub Text6_LostFocus()
Text6.BackColor = &H80000014
End Sub
Private Sub Text7_GotFocus()
Text7.BackColor = &HFFC0C0
End Sub
Private Sub Text7_LostFocus()
Text7.BackColor = &H80000014
End Sub
Private Sub Text8_GotFocus()
Text8.BackColor = &HFFC0C0
End Sub
Private Sub Text8_LostFocus()
Text8.BackColor = &H80000014
End Sub
Private Sub Text9_GotFocus()
Text9.BackColor = &HFFC0C0
End Sub
Private Sub Text9_LostFocus()
Text9.BackColor = &H80000014
End Sub
Private Sub combo1_GotFocus()
Combo1.BackColor = &HFFC0C0
End Sub
Private Sub combo1_LostFocus()
Combo1.BackColor = &H80000014
End Sub
Private Sub combo2_GotFocus()
Combo2.BackColor = &HFFC0C0
End Sub
Private Sub combo2_LostFocus()
Combo2.BackColor = &H80000014
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -