📄 frmtypeman.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 FrmTypeMan
Caption = "办公用品类别管理"
ClientHeight = 4470
ClientLeft = 60
ClientTop = 345
ClientWidth = 5760
LinkTopic = "Form1"
ScaleHeight = 4470
ScaleWidth = 5760
StartUpPosition = 2 '屏幕中心
Begin VB.TextBox txtName
Height = 330
Left = 4080
TabIndex = 8
Top = 480
Width = 1575
End
Begin MSAdodcLib.Adodc Adodc2
Height = 375
Left = 4200
Top = 3600
Visible = 0 'False
Width = 1335
_ExtentX = 2355
_ExtentY = 661
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 = "Adodc2"
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.OptionButton Option1
Caption = "二级分类名称"
Height = 255
Index = 1
Left = 2160
TabIndex = 7
Top = 120
Width = 1455
End
Begin VB.OptionButton Option1
Caption = "一级分类名称"
Height = 255
Index = 0
Left = 120
TabIndex = 6
Top = 120
Value = -1 'True
Width = 1455
End
Begin MSDataListLib.DataList DataList2
Height = 3840
Left = 2160
TabIndex = 5
Top = 480
Width = 1695
_ExtentX = 2990
_ExtentY = 6773
_Version = 393216
End
Begin MSDataListLib.DataList DataList1
Height = 3840
Left = 120
TabIndex = 4
Top = 480
Width = 1695
_ExtentX = 2990
_ExtentY = 6773
_Version = 393216
End
Begin MSAdodcLib.Adodc Adodc1
Height = 330
Left = 4080
Top = 3960
Visible = 0 'False
Width = 1455
_ExtentX = 2566
_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_Back
Caption = "返 回"
Height = 400
Left = 4200
TabIndex = 3
Top = 3120
Width = 1215
End
Begin VB.CommandButton Cmd_Modi
Caption = "修 改"
Height = 400
Left = 4200
TabIndex = 2
Top = 1760
Width = 1215
End
Begin VB.CommandButton Cmd_Del
Caption = "删 除"
Height = 400
Left = 4200
TabIndex = 1
Top = 2440
Width = 1215
End
Begin VB.CommandButton Cmd_Add
Caption = "添 加"
Height = 400
Left = 4200
TabIndex = 0
Top = 1080
Width = 1215
End
End
Attribute VB_Name = "FrmTypeMan"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public OriT1Name As String
Public OriT2Name As String
Private Sub Cmd_Add_Click()
If Len(Trim(txtName)) = 0 Then
MsgBox "请输入分类名称"
txtName.SetFocus
Exit Sub
End If
'判断当前选择按钮值
If Option1.Item(0).Value = True Then '选择一级分类
'判断一级分类名称是否已存在
If MyType.In_DB(Trim(txtName)) Then
MsgBox "分类名称已存在"
Exit Sub
Else
MyType.TypeName = Trim(txtName)
MyType.UpperId = 0
MyType.Insert
MsgBox "添加成功"
LoadTypes
txtName = ""
End If
Else '选择二级分类
'首先判断是否选择了一级分类名称
If DataList1.SelectedItem > 0 Then
'判断二级分类名称是否已存在
If MyType.In_DB(Trim(txtName)) Then
MsgBox "分类名称已存在"
Exit Sub
Else
MyType.TypeName = Trim(txtName)
MyType.UpperId = DataList1.BoundText()
MyType.Insert
MsgBox "添加成功"
LoadTypes
Set DataList2.RowSource = Nothing
DataList1.Enabled = True
DataList2.Enabled = False
txtName = ""
Option1.Item(0).Value = True
Option1.Item(1).Value = False
End If
Else
MsgBox "请选择上级分类"
Exit Sub
End If
End If
End Sub
Private Sub Cmd_Back_Click()
Unload Me
End Sub
Private Sub Cmd_Del_Click()
'判断当前选择按钮值
If Option1.Item(0).Value = True Then '选择一级分类
'判断是否选择了一级分类
If DataList1.SelectedItem > 0 Then
'如果此一级分类存在下级分类,则不允许删除
If MyType.HaveSon(DataList1.BoundText()) Then
MsgBox "存在二级分类,不能删除"
Exit Sub
Else
MyType.Delete (DataList1.BoundText())
MsgBox "删除成功"
LoadTypes
txtName = ""
End If
Else
MsgBox "请选择一级分类"
Exit Sub
End If
Else
'判断是否选择了二级分类
If DataList2.SelectedItem > 0 Then
'判断办公用品表中是否已经使用了此分类编号
If MyStore.HaveTId(DataList2.BoundText()) Then
MsgBox "办公用品表中存在此分类,不能删除"
Exit Sub
Else
MyType.Delete (DataList2.BoundText())
MsgBox "删除成功"
LoadTypes
Set DataList2.RowSource = Nothing
DataList1.Enabled = True
DataList2.Enabled = False
txtName = ""
Option1.Item(0).Value = True
Option1.Item(1).Value = False
End If
Else
MsgBox "请选择二级分类"
Exit Sub
End If
End If
End Sub
Private Sub Cmd_Modi_Click()
If Len(Trim(txtName)) = 0 Then
MsgBox "请输入分类名称"
txtName.SetFocus
Exit Sub
End If
'判断当前选择按钮值
If Option1.Item(0).Value = True Then '选择一级分类
'判断是否选择了一级分类
If DataList1.SelectedItem < 1 Then
MsgBox "请选择一级分类"
Exit Sub
End If
'判断是否修改了一级分类名称
If Trim(txtName) <> Trim(OriT1Name) Then
'判断新的一级分类名称是否存在
If MyType.In_DB(Trim(txtName)) Then
MsgBox "分类名称已存在"
Exit Sub
Else
MyType.TypeName = Trim(txtName)
MyType.Update (DataList1.BoundText())
MsgBox "修改成功"
LoadTypes
txtName = ""
End If
End If
Else '选择二级分类
'首先判断是否选择了二级分类名称
If DataList2.SelectedItem > 0 Then
'判断是否修改了一级分类名称
If Trim(txtName) = Trim(OriT2Name) Then
Exit Sub
End If
'判断新的二级分类名称是否存在
If MyType.In_DB(Trim(txtName)) Then
MsgBox "分类名称已存在"
Exit Sub
Else
MyType.TypeName = Trim(txtName)
MyType.Update (DataList2.BoundText())
MsgBox "修改成功"
LoadTypes
Set DataList2.RowSource = Nothing
DataList1.Enabled = True
DataList2.Enabled = False
txtName = ""
Option1.Item(0).Value = True
Option1.Item(1).Value = False
End If
Else
MsgBox "请选择二级分类"
Exit Sub
End If
End If
End Sub
Private Sub DataList1_Click()
'当选择一级分类名称时,将分类编号和名称赋给变量,同时将二级分类变量置为空,并装入二级分类名称
If DataList1.SelectedItem > 0 Then
OriT1Name = Trim(DataList1.Text)
txtName = OriT1Name
LoadTypes2
End If
End Sub
Private Sub DataList2_Click()
If DataList2.SelectedItem > 0 Then
OriT2Name = Trim(DataList2.Text)
txtName = OriT2Name
End If
End Sub
Private Sub Form_Load()
LoadTypes
DataList2.Enabled = False
End Sub
'装入一级分类名称
Private Sub LoadTypes()
Adodc1.ConnectionString = Conn
Adodc1.RecordSource = "Select * From Types Where UpperId=0 Order By TypeId"
Adodc1.Refresh
Set DataList1.RowSource = Adodc1
DataList1.ListField = "TypeName"
DataList1.BoundColumn = "TypeId"
End Sub
'根据一级分类编号 装入二级分类名称
Private Sub LoadTypes2()
Adodc2.ConnectionString = Conn
Adodc2.RecordSource = "Select * From Types Where UpperId=" + Trim(DataList1.BoundText()) + " Order By TypeId"
Adodc2.Refresh
Set DataList2.RowSource = Adodc2
DataList2.ListField = "TypeName"
DataList2.BoundColumn = "TypeId"
End Sub
'修改选项时,数据列表状态更改
Private Sub Option1_Click(Index As Integer)
If Index = 0 Then
DataList1.Enabled = True
DataList2.Enabled = False
Else
DataList1.Enabled = False
DataList2.Enabled = True
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -