📄 frmtypes.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Begin VB.Form frmTypes
Caption = "客户类别设置"
ClientHeight = 4170
ClientLeft = 60
ClientTop = 390
ClientWidth = 5085
LinkTopic = "Form1"
ScaleHeight = 4170
ScaleWidth = 5085
StartUpPosition = 2 '屏幕中心
Begin MSAdodcLib.Adodc AdoType
Height = 330
Left = 3240
Top = 960
Visible = 0 'False
Width = 1635
_ExtentX = 2884
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.CommandButton Cmd_Modi
Caption = "修改"
Height = 435
Left = 3420
TabIndex = 5
Top = 1980
Width = 1275
End
Begin VB.CommandButton Cmd_Del
Caption = "删除"
Height = 435
Left = 3420
TabIndex = 4
Top = 2640
Width = 1275
End
Begin VB.CommandButton Cmd_Exit
Caption = "退出"
Height = 435
Left = 3420
TabIndex = 3
Top = 3300
Width = 1275
End
Begin VB.CommandButton Cmd_Add
Caption = "添加"
Height = 435
Left = 3420
TabIndex = 2
Top = 1380
Width = 1275
End
Begin VB.TextBox txtName
Height = 375
Left = 3180
TabIndex = 1
Top = 420
Width = 1755
End
Begin MSDataListLib.DataList DataList1
Height = 3420
Left = 240
TabIndex = 0
Top = 300
Width = 2595
_ExtentX = 4577
_ExtentY = 6033
_Version = 393216
End
End
Attribute VB_Name = "frmTypes"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private OriId As Long '类型编号
Private OriTypeName As String '原来的类型名称
'类型分类编号,1-客户类型;2-行业分类;3-职务类型;4-项目类型
Public nFlag As Integer
Private Sub Cmd_Add_Click()
'添加客户类型名称,先判断域是否为空
If Len(Trim(txtName)) = 0 Then
MsgBox ("请输入类型名称")
txtName.SetFocus
Exit Sub
End If
'判断数据库中是否已经存在此类型名称
If MyType.In_DB(Trim(txtName), nFlag) = True Then
MsgBox ("已经存在此类型名称")
txtName.SetFocus
Exit Sub
End If
'插入新记录
With MyType
.TypeName = Trim(txtName)
.Flag = nFlag
.Insert
MsgBox "添加成功"
txtName.Text = ""
End With
DataRefresh
End Sub
Private Sub Cmd_Del_Click()
If Len(Trim(DataList1.BoundText)) = 0 Then
MsgBox ("请选择记录")
Exit Sub
End If
' 确定删除
If MsgBox("是否确定要删除 ", vbYesNo, "请确认") = vbNo Then
Exit Sub
End If
' 删除类型
MyType.Delete (Val(DataList1.BoundText))
MsgBox "删除成功"
DataRefresh '刷新DataList1
txtName.Text = ""
End Sub
Private Sub Cmd_Exit_Click()
Unload Me
End Sub
Private Sub Cmd_Modi_Click()
'修改类型名称
If Len(Trim(DataList1.BoundText)) = 0 Then
MsgBox ("请选择记录")
Exit Sub
End If
'判断新的名称是否和原来的相同
If Trim(txtName) = OriTypeName Then
Exit Sub
End If
'判断新的名称是否已经存在
If MyType.In_DB(Trim(txtName), nTypeId) = True Then
MsgBox ("已经存在此类型名称")
txtName.SetFocus
Exit Sub
End If
'更新名称
MyType.TypeName = Trim(txtName)
MyType.Update (OriId)
MsgBox "修改成功"
DataRefresh '刷新类型列表
txtName.Text = ""
End Sub
Private Sub DataList1_Click()
'点击列表记录,将编号和名称放入变量和txtName域
If Len(Trim(DataList1.BoundText)) = 0 Then
MsgBox ("请选择记录")
Exit Sub
End If
OriId = Val(DataList1.BoundText) '记录编号
If MyType.GetInfo(OriId) = True Then '判断是否存在此记录信息
OriTypeName = Trim(MyType.TypeName) '将类型名称保存到变量中
txtName = Trim(MyType.TypeName) '文本框中显示类型名称
End If
End Sub
Private Sub Form_Load()
'刷新DataList1中的数据
DataRefresh
End Sub
Private Sub DataRefresh()
'设置连接字符串
AdoType.ConnectionString = Conn
'设置SQL语句
AdoType.RecordSource = "SELECT * FROM Types WHERE Flag=" + Trim(nFlag)
AdoType.Refresh
'设置数据源
Set DataList1.RowSource = AdoType
DataList1.ListField = "TypeName" '设置列表中显示字段
DataList1.BoundColumn = "Id" '设置列表绑定字段
DataList1.Refresh
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -