📄 bookadd.frm
字号:
VERSION 5.00
Begin VB.Form bookAdd
BackColor = &H00FFFFC0&
Caption = "添加产品信息"
ClientHeight = 5520
ClientLeft = 60
ClientTop = 345
ClientWidth = 5310
LinkTopic = "Form1"
LockControls = -1 'True
Picture = "bookAdd.frx":0000
ScaleHeight = 5520
ScaleWidth = 5310
StartUpPosition = 1 '所有者中心
Begin VB.TextBox bookOther
Height = 855
Left = 240
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 10
Top = 3720
Width = 4695
End
Begin VB.ComboBox bookTypename
Height = 300
Left = 1200
TabIndex = 9
Top = 1920
Width = 3615
End
Begin VB.CommandButton cancel
Caption = "返 回"
Height = 375
Left = 2880
TabIndex = 8
Top = 4920
Width = 1335
End
Begin VB.CommandButton addBkOK
Caption = "添 加"
Height = 375
Left = 960
TabIndex = 7
Top = 4920
Width = 1335
End
Begin VB.TextBox bookPrice
Height = 375
Left = 1200
TabIndex = 6
Top = 2640
Width = 3615
End
Begin VB.TextBox bookName
Height = 375
Left = 1200
TabIndex = 5
Top = 1080
Width = 3615
End
Begin VB.TextBox bookNo
Height = 375
Left = 1200
TabIndex = 4
Top = 240
Width = 3615
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "产品说明:"
Height = 255
Left = 240
TabIndex = 11
Top = 3360
Width = 975
End
Begin VB.Label Label13
BackColor = &H00FFFFC0&
BackStyle = 0 'Transparent
Caption = "产品价格:"
Height = 255
Left = 240
TabIndex = 3
Top = 2760
Width = 975
End
Begin VB.Label Label9
BackColor = &H00FFFFC0&
BackStyle = 0 'Transparent
Caption = "产品类型:"
Height = 255
Left = 240
TabIndex = 2
Top = 1920
Width = 975
End
Begin VB.Label Label4
BackColor = &H00FFFFC0&
BackStyle = 0 'Transparent
Caption = "产品名称:"
Height = 255
Left = 240
TabIndex = 1
Top = 1080
Width = 975
End
Begin VB.Label Label1
BackColor = &H00FFFFC0&
BackStyle = 0 'Transparent
Caption = "产品编号:"
Height = 255
Left = 240
TabIndex = 0
Top = 240
Width = 975
End
End
Attribute VB_Name = "bookAdd"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub addBkOK_Click()
Dim rs As New ADODB.Recordset
Dim sql As String
sql = "select * from books"
Dim sql2 As String
sql2 = "select * from books where bookNO ='" & bookNo.Text & "'"
If Trim(bookNo.Text) = "" Or _
Trim(bookName.Text) = "" Or _
Trim(bookTypename.Text) = "" Or _
Trim(bookPrice.Text) = "" Or Trim(bookOther) = "" Then
MsgBox "产品信息录入不能为空!", vbOKOnly
Else
Set rs = TransactSQL(sql2)
If rs.EOF = False Then
MsgBox "该编号产品已经存在,请核对!", vbOKOnly
rs.Close
Else
Set rs = TransactSQL(sql)
rs.AddNew '添加新纪录
rs.Fields(0) = Trim(bookNo.Text)
rs.Fields(1) = Trim(bookName.Text)
rs.Fields(2) = Trim(bookTypename.Text)
rs.Fields(3) = Trim(bookPrice.Text)
rs.Fields(4) = Trim(bookOther.Text)
rs.Update
MsgBox "添加成功!", vbOKOnly
rs.Close
End If
End If
End Sub
Private Sub cancel_Click()
Unload Me
End Sub
Private Sub Form_Load()
bookTypename.AddItem "电影", 0
bookTypename.AddItem "相声", 1
bookTypename.AddItem "小品", 2
bookTypename.AddItem "电视剧", 3
bookTypename.AddItem "专辑", 4
'操作选择
If ModifyBkFlag2 = True Then
'Dim rs As New ADODB.Recordset
Dim sql As String
sql = "select * from books where bookNO ='" & ModifyBkFlag1 & "'"
Set rs = TransactSQL(sql)
bookNo.Text = rs.Fields(0)
bookNo.Locked = True ' 使不可改动
bookName.Text = rs.Fields(1)
bookType.Text = rs.Fields(2)
bookPrice.Text = rs.Fields(3)
bookOther.Text = rs.Fields(4)
ModifyBkFlag2 = ModifyBkFlag2 Xor True
addBkOK.Enabled = False
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -