📄 frmcustdel.frm
字号:
VERSION 5.00
Begin VB.Form frmCustDel
Caption = "客户信息 - [删除]"
ClientHeight = 3885
ClientLeft = 60
ClientTop = 345
ClientWidth = 3675
LinkTopic = "Form2"
LockControls = -1 'True
ScaleHeight = 3885
ScaleWidth = 3675
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton cmdCancel
Caption = "取消"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 2040
TabIndex = 4
Top = 2880
Width = 1215
End
Begin VB.CommandButton cmdDel
Caption = "删除"
Default = -1 'True
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 360
TabIndex = 3
Top = 2880
Width = 1215
End
Begin VB.TextBox txtCustName
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 350
Left = 1560
TabIndex = 0
Top = 600
Width = 1695
End
Begin VB.TextBox txtCustID
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 350
Left = 1560
TabIndex = 1
Top = 1320
Width = 1695
End
Begin VB.ComboBox Combo_CustType
Height = 300
ItemData = "frmCustDel.frx":0000
Left = 1560
List = "frmCustDel.frx":0002
Style = 2 'Dropdown List
TabIndex = 2
Top = 2010
Width = 1695
End
Begin VB.Label Label2
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "客户代码 C"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 435
TabIndex = 7
Top = 1395
Width = 1095
End
Begin VB.Label label1
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "客户名称"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 480
TabIndex = 6
Top = 660
Width = 975
End
Begin VB.Label Label3
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "客户类型"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 600
TabIndex = 5
Top = 2070
Width = 855
End
End
Attribute VB_Name = "frmCustDel"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdDel_Click()
Dim Rst As New ADODB.Recordset
Dim strSQL As String
Dim strCheck As String '查询条件语句
Dim varMSG
On Error GoTo ErrorExit
strCheck = "" '清除查询条件语句
If Me.txtCustName <> "" Then
strCheck = "CustName ='" & Me.txtCustName & "'"
End If
If Me.txtCustID <> "" Then '如果控件内容不为空,设置查询条件语句
If strCheck <> "" Then
strCheck = strCheck & " and "
End If
strCheck = strCheck & "CustID ='C" & Me.txtCustID & "'"
End If
If Me.Combo_CustType <> "" Then
If strCheck <> "" Then
strCheck = strCheck & " and "
End If
strCheck = strCheck & "CustType ='" & Me.Combo_CustType & "'"
End If
strSQL = "select * from tb_Customer " 'SQL语句
If strCheck <> "" Then
strSQL = strSQL & " WHERE " & strCheck
End If
Rst.Open strSQL, CnnDatabase, adOpenStatic, adLockOptimistic '一可修改的静态记录集
If Rst.RecordCount = 0 Then '查到的记录数 = 0
MsgBox "没有满足条件的要删除客户记录", vbExclamation, "删除中止-"
Exit Sub
End If
varMSG = MsgBox("满足以上删除条件的客户记录共有<" & Rst.RecordCount & ">条。" & _
Chr(10) & "是否确信要删除满足以上条件的所有客户记录?" & Chr(10) & _
"注意:此操作不可逆转!", vbYesNo)
If varMSG = vbYes Then
Rst.Delete '执行删除操作!
MsgBox "删除成功!", vbInformation, "操作结束-"
End If
Me.Combo_CustType.ListIndex = -1 '界面上的控件状态重置
Me.txtCustID = ""
Me.txtCustName = ""
Exit Sub
ErrorExit:
MsgBox Err.Description, vbCritical, Me.Caption
End Sub
Private Sub Form_Load()
With Combo_CustType '添加项目:客户类型
.Clear
.AddItem "正式客户"
.AddItem "试用客户"
.AddItem "潜在客户"
.AddItem "竞争对手"
.AddItem "代理商"
.AddItem "内部员工"
End With
Me.Combo_CustType.ListIndex = -1
Me.txtCustName = ""
Me.txtCustID = ""
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -