📄 addproductdialog.frm
字号:
VERSION 5.00
Begin VB.Form AddProductDialog
BorderStyle = 3 'Fixed Dialog
Caption = "添加产品"
ClientHeight = 2175
ClientLeft = 2760
ClientTop = 3750
ClientWidth = 6030
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2175
ScaleWidth = 6030
ShowInTaskbar = 0 'False
StartUpPosition = 2 'CenterScreen
Begin VB.Frame Frame1
Caption = "产品信息"
Height = 1455
Left = 120
TabIndex = 2
Top = 120
Width = 5775
Begin VB.TextBox Text5
Height = 285
Left = 3840
TabIndex = 14
Top = 1080
Width = 1815
End
Begin VB.TextBox Text4
Height = 285
Left = 960
TabIndex = 12
Top = 1080
Width = 1815
End
Begin VB.TextBox Text3
Height = 285
Left = 3840
TabIndex = 10
Top = 720
Width = 1815
End
Begin VB.TextBox Text2
Height = 285
Left = 960
TabIndex = 8
Top = 720
Width = 1815
End
Begin VB.TextBox Text1
Height = 285
Left = 3840
TabIndex = 5
Top = 360
Width = 1815
End
Begin VB.Label Label7
AutoSize = -1 'True
Caption = "产品单价"
Height = 195
Left = 3000
TabIndex = 13
Top = 1080
Width = 720
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "库存量"
Height = 195
Left = 240
TabIndex = 11
Top = 1080
Width = 540
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "产品类型"
Height = 195
Left = 3000
TabIndex = 9
Top = 720
Width = 720
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "产品说明"
Height = 195
Left = 120
TabIndex = 7
Top = 720
Width = 720
End
Begin VB.Label Label2
BorderStyle = 1 'Fixed Single
Height = 255
Left = 960
TabIndex = 6
Top = 360
Width = 1815
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "产品名称"
Height = 195
Left = 3000
TabIndex = 4
Top = 360
Width = 720
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "产品编号"
Height = 195
Left = 120
TabIndex = 3
Top = 360
Width = 720
End
End
Begin VB.CommandButton CancelButton
Caption = "Cancel"
Height = 375
Left = 3480
TabIndex = 1
Top = 1680
Width = 1215
End
Begin VB.CommandButton OKButton
Caption = "OK"
Height = 375
Left = 1560
TabIndex = 0
Top = 1680
Width = 1215
End
End
Attribute VB_Name = "AddProductDialog"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim MyDB As Database
Dim MyRecord As Recordset
Dim TempStr As String
Private Sub CancelButton_Click()
Unload Me
End Sub
Private Sub Form_Load()
Set MyDB = OpenDatabase(VB.App.Path + "\MySampleDB.mdb", False, False)
Set MyRecord = MyDB.OpenRecordset("产品表")
MyRecord.Index = "PrimaryKey"
MyRecord.MoveLast
TempStr = MyRecord.Fields("ProductID")
TempStr = "P" & Format((Val(Right(TempStr, 5)) + 1), "0000#")
Label2.Caption = TempStr
End Sub
Private Sub Form_Unload(Cancel As Integer)
MyRecord.Close
MyDB.Close
End Sub
Private Sub OKButton_Click()
If Text1.Text = "" Then
MsgBox "请输入 产品名称 !"
Exit Sub
End If
If Text2.Text = "" Then
MsgBox "请输入 产品说明 !"
Exit Sub
End If
If Text3.Text = "" Then
MsgBox "请输入 产品类型 !"
Exit Sub
End If
If Text4.Text = "" Then
MsgBox "请输入 库存量 !"
Exit Sub
End If
If (Not IsNumeric(Text4.Text)) Or (Fix(Val(Text4.Text)) <> Val(Text4.Text)) Then
MsgBox "库存量 请输入整数 !"
Exit Sub
End If
If Text5.Text = "" Then
MsgBox "请输入 库存量 !"
Exit Sub
End If
If (Not IsNumeric(Text5.Text)) Then
MsgBox "库存量 请输入数字 !"
Exit Sub
End If
TempStr = "INSERT INTO 产品表 VALUES ('" & Label2.Caption & "','" & Text1.Text & _
"','" & Text2.Text & "','" & Text3.Text & "'," & Val(Text4.Text) & _
"," & Val(Text5.Text) & ")"
MyDB.Execute TempStr
MsgBox "成功添加产品" & Label2.Caption & "!"
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -