📄 addcustomerdialog.frm
字号:
VERSION 5.00
Begin VB.Form AddCustomerDialog
BorderStyle = 3 'Fixed Dialog
Caption = "添加客户"
ClientHeight = 3930
ClientLeft = 2760
ClientTop = 3750
ClientWidth = 6030
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3930
ScaleWidth = 6030
ShowInTaskbar = 0 'False
StartUpPosition = 2 'CenterScreen
Begin VB.Frame Frame1
Caption = "客户信息"
Height = 3255
Left = 120
TabIndex = 2
Top = 120
Width = 5775
Begin VB.TextBox Text7
Height = 1215
Left = 960
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 17
Top = 1920
Width = 4695
End
Begin VB.TextBox Text6
Height = 285
Left = 3840
TabIndex = 16
Top = 1560
Width = 1815
End
Begin VB.TextBox Text5
Height = 285
Left = 960
TabIndex = 14
Top = 1560
Width = 1815
End
Begin VB.TextBox Text4
Height = 285
Left = 3840
TabIndex = 12
Top = 1200
Width = 1815
End
Begin VB.TextBox Text3
Height = 285
Left = 960
TabIndex = 10
Top = 1200
Width = 1815
End
Begin VB.TextBox Text2
Height = 285
Left = 3840
TabIndex = 8
Top = 840
Width = 1815
End
Begin VB.TextBox Text1
Height = 285
Left = 960
TabIndex = 6
Top = 840
Width = 1815
End
Begin VB.Label Label9
AutoSize = -1 'True
Caption = "备注"
Height = 195
Left = 360
TabIndex = 18
Top = 2400
Width = 360
End
Begin VB.Label Label8
AutoSize = -1 'True
Caption = "传真号码"
Height = 195
Left = 3000
TabIndex = 15
Top = 1560
Width = 720
End
Begin VB.Label Label7
AutoSize = -1 'True
Caption = "邮政编码"
Height = 195
Left = 120
TabIndex = 13
Top = 1560
Width = 720
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "单位地址"
Height = 195
Left = 3000
TabIndex = 11
Top = 1200
Width = 720
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "联系电话"
Height = 195
Left = 120
TabIndex = 9
Top = 1200
Width = 720
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "联系人"
Height = 195
Left = 3120
TabIndex = 7
Top = 840
Width = 540
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "单位名称"
Height = 195
Left = 120
TabIndex = 5
Top = 840
Width = 720
End
Begin VB.Label Label2
BorderStyle = 1 'Fixed Single
Height = 255
Left = 960
TabIndex = 4
Top = 360
Width = 1815
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 = 3600
TabIndex = 1
Top = 3480
Width = 1215
End
Begin VB.CommandButton OKButton
Caption = "OK"
Height = 375
Left = 1320
TabIndex = 0
Top = 3480
Width = 1215
End
End
Attribute VB_Name = "AddCustomerDialog"
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("CustomerID")
TempStr = "C" & 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 Text5.Text = "" Then
MsgBox "请输入 邮政编码 !"
Exit Sub
End If
If Text6.Text = "" Then
MsgBox "请输入 传真号码 !"
Exit Sub
End If
TempStr = "INSERT INTO 客户表 VALUES ('" & Label2.Caption & "','" & Text1.Text & _
"','" & Text2.Text & "','" & Text3.Text & "','" & Text4.Text & _
"','" & Text5.Text & "','" & Text6.Text & "','" & Text7.Text & "')"
MyDB.Execute TempStr
MsgBox "成功添加客户" & Label2.Caption & "!"
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -