📄 addbook.frm
字号:
VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form addbook
BorderStyle = 1 'Fixed Single
Caption = "添加图书信息"
ClientHeight = 3960
ClientLeft = 3780
ClientTop = 3750
ClientWidth = 7305
Icon = "addbook.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
ScaleHeight = 3960
ScaleWidth = 7305
Begin VB.CommandButton Command2
Caption = "关闭(&C)"
Height = 375
Left = 5400
TabIndex = 18
Top = 3480
Width = 1695
End
Begin VB.CommandButton Command1
Caption = "添加(&A)"
Height = 375
Left = 3600
TabIndex = 17
Top = 3480
Width = 1695
End
Begin VB.Frame Frame1
Caption = "书籍信息"
Height = 3255
Left = 120
TabIndex = 0
Top = 120
Width = 7095
Begin MSComCtl2.DTPicker DTPicker1
Height = 375
Left = 4680
TabIndex = 16
Top = 2160
Width = 2175
_ExtentX = 3836
_ExtentY = 661
_Version = 393216
CalendarBackColor= 12648447
CalendarTitleBackColor= -2147483645
Format = 48955392
CurrentDate = 39064
End
Begin VB.TextBox Text6
BackColor = &H00C0FFFF&
Height = 375
Left = 1200
TabIndex = 14
Top = 2160
Width = 2175
End
Begin VB.TextBox Text5
BackColor = &H00C0FFFF&
Height = 375
Left = 4680
TabIndex = 12
Top = 1560
Width = 2175
End
Begin VB.TextBox Text4
BackColor = &H00C0FFFF&
Height = 375
Left = 1200
TabIndex = 10
Top = 1560
Width = 2175
End
Begin VB.TextBox Text3
BackColor = &H00C0FFFF&
Height = 375
Left = 4680
TabIndex = 8
Top = 960
Width = 2175
End
Begin VB.ComboBox Combo1
BackColor = &H00C0FFFF&
Height = 300
Left = 1200
TabIndex = 6
Top = 960
Width = 2175
End
Begin VB.TextBox Text2
BackColor = &H00C0FFFF&
Height = 375
Left = 4680
TabIndex = 4
Top = 360
Width = 2175
End
Begin VB.TextBox Text1
BackColor = &H00C0FFFF&
Height = 375
Left = 1200
TabIndex = 2
Top = 360
Width = 2175
End
Begin VB.Label Label8
Caption = "登记日期"
Height = 255
Left = 3720
TabIndex = 15
Top = 2280
Width = 855
End
Begin VB.Label Label7
Caption = "书籍页码"
Height = 255
Left = 240
TabIndex = 13
Top = 2280
Width = 855
End
Begin VB.Label Label6
Caption = "书籍价格"
Height = 255
Left = 3720
TabIndex = 11
Top = 1680
Width = 975
End
Begin VB.Label Label5
Caption = "作者姓名"
Height = 255
Left = 240
TabIndex = 9
Top = 1680
Width = 855
End
Begin VB.Label Label4
Caption = "出 版 社"
Height = 255
Left = 3720
TabIndex = 7
Top = 1080
Width = 855
End
Begin VB.Label Label3
Caption = "类别代码"
Height = 375
Left = 240
TabIndex = 5
Top = 1080
Width = 855
End
Begin VB.Label Label2
Caption = "书籍名称"
Height = 255
Left = 3720
TabIndex = 3
Top = 480
Width = 855
End
Begin VB.Label Label1
Caption = "书籍编号"
Height = 375
Left = 240
TabIndex = 1
Top = 480
Width = 855
End
End
End
Attribute VB_Name = "addbook"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command1_Click()
If Text1.Text = "" Then
MsgBox "书籍编号不能为空!", vbInformation + vbOKOnly, "警告"
Text1.SetFocus
Exit Sub
End If
If Text2.Text = "" Then
MsgBox "书籍名称不能为空!", vbInformation + vbOKOnly, "警告"
Text2.SetFocus
Exit Sub
End If
If Combo1.Text = "" Then
MsgBox "类别代码不能为空!", vbInformation + vbOKOnly, "警告"
Combo1.SetFocus
Exit Sub
End If
If Text3.Text = "" Then
MsgBox "出版社不能为空!", vbInformation + vbOKOnly, "警告"
Text3.SetFocus
Exit Sub
End If
If Text4.Text = "" Then
MsgBox "作者姓名不能为空!", vbInformation + vbOKOnly, "警告"
Text4.SetFocus
Exit Sub
End If
If Text5.Text = "" Then
MsgBox "书籍价格不能为空!", vbInformation + vbOKOnly, "警告"
Text5.SetFocus
Exit Sub
End If
If Text6.Text = "" Then
MsgBox "书籍页码不能为空!", vbInformation + vbOKOnly, "警告"
Text6.SetFocus
Exit Sub
End If
Set g_rs = g_db.OpenRecordset("select * from bookinfo", dbOpenDynaset)
If g_rs.RecordCount > 0 Then
g_rs.MoveFirst
Do While Not g_rs.EOF
If g_rs!书籍编号 = Text1.Text Then
MsgBox "对不起,该书籍编号已经存在,请重新输入!", vbInformation + vbOKOnly, "警告"
Set g_rs = Nothing
Exit Sub
End If
g_rs.MoveNext
Loop
End If
g_rs.AddNew
g_rs!书籍编号 = Text1.Text
g_rs!书籍名称 = Text2.Text
g_rs!类别代码 = Mid(Combo1.Text, 1, 1)
g_rs!出版社 = Text3.Text
g_rs!作者姓名 = Text4.Text
g_rs!书籍价格 = Text5.Text
g_rs!书籍页码 = Text6.Text
g_rs!登记日期 = DTPicker1.Value
g_rs!是否借出 = False
g_rs.Update
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Set g_rs = Nothing
MsgBox "书籍信息已成功添加!", vbInformation + vbOKOnly, "信息"
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
dbl
DTPicker1.Value = Date
Set g_rs = g_db.OpenRecordset("booktype", dbOpenTable)
Combo1.Clear
If g_rs.RecordCount > 0 Then
g_rs.MoveFirst
Do While Not g_rs.EOF
Combo1.AddItem g_rs!类别代码 + "-" + g_rs!书籍类别
g_rs.MoveNext
Loop
Set g_rs = Nothing
Else
MsgBox "请先设置书籍类别代码!", vbInformation + vbOKOnly, "警告"
setbooktype.Show
Unload Me
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -