📄 frmtypes.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmTypes
BorderStyle = 1 'Fixed Single
Caption = "商品分类编码"
ClientHeight = 5055
ClientLeft = 45
ClientTop = 435
ClientWidth = 6990
Icon = "frmTypes.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 5055
ScaleWidth = 6990
Begin MSComctlLib.ImageList ilt
Left = 3150
Top = 2730
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 16
ImageHeight = 16
MaskColor = 12632256
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 2
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmTypes.frx":1042
Key = ""
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmTypes.frx":2094
Key = ""
EndProperty
EndProperty
End
Begin MSComctlLib.TreeView tvw
Height = 4875
Left = 60
TabIndex = 12
Top = 90
Width = 2685
_ExtentX = 4736
_ExtentY = 8599
_Version = 393217
HideSelection = 0 'False
Indentation = 353
LabelEdit = 1
LineStyle = 1
Style = 7
ImageList = "ilt"
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin Manage.xpcmdbutton cmdExit
Height = 465
Left = 5190
TabIndex = 11
Top = 4140
Width = 1275
_ExtentX = 2249
_ExtentY = 820
Caption = "退 出"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin Manage.xpcmdbutton cmdDel
Height = 465
Left = 3420
TabIndex = 10
Top = 4140
Width = 1275
_ExtentX = 2249
_ExtentY = 820
Caption = "删 除"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin Manage.xpcmdbutton cmdSave
Height = 465
Left = 5160
TabIndex = 9
Top = 3360
Width = 1275
_ExtentX = 2249
_ExtentY = 820
Caption = "保 存"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin Manage.xpcmdbutton cmdAdd
Height = 465
Left = 3420
TabIndex = 8
Top = 3360
Width = 1275
_ExtentX = 2249
_ExtentY = 820
Caption = "添 加"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin VB.TextBox txtName
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 4230
TabIndex = 5
Top = 1920
Width = 2295
End
Begin VB.TextBox txtID
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 4230
MaxLength = 2
TabIndex = 4
Top = 1420
Width = 2265
End
Begin VB.Line Line4
BorderColor = &H00FFFFFF&
BorderWidth = 2
X1 = 6900
X2 = 6900
Y1 = 120
Y2 = 4950
End
Begin VB.Line Line3
BorderColor = &H00FFFFFF&
BorderWidth = 2
X1 = 2820
X2 = 6900
Y1 = 4950
Y2 = 4950
End
Begin VB.Line Line2
BorderColor = &H00808080&
X1 = 2820
X2 = 2820
Y1 = 90
Y2 = 4920
End
Begin VB.Line Line1
BorderColor = &H00808080&
X1 = 2820
X2 = 6900
Y1 = 90
Y2 = 90
End
Begin VB.Label lblName
BorderStyle = 1 'Fixed Single
Height = 345
Left = 4230
TabIndex = 7
Top = 930
Width = 2265
End
Begin VB.Label lblID
BorderStyle = 1 'Fixed Single
Height = 375
Left = 4230
TabIndex = 6
Top = 450
Width = 2265
End
Begin VB.Label Label4
Caption = "类别名称"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 3210
TabIndex = 3
Top = 2010
Width = 840
End
Begin VB.Label Label3
Caption = "类别编码"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 3210
TabIndex = 2
Top = 1500
Width = 840
End
Begin VB.Label Label2
Caption = "上级名称"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 3180
TabIndex = 1
Top = 990
Width = 840
End
Begin VB.Label Label1
Caption = "上级编码"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 3180
TabIndex = 0
Top = 480
Width = 840
End
End
Attribute VB_Name = "frmTypes"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub cmdAdd_Click()
If tvw.SelectedItem Is Nothing Then Exit Sub
If Not tvw.SelectedItem.Parent Is Nothing Then
If tvw.SelectedItem.Parent.Index <> 1 Then Exit Sub
End If
tvw.Enabled = False
cmdSave.Enabled = True
cmdDel.Enabled = False
cmdAdd.Enabled = False
cmdExit.Caption = "取 消"
txtID.Text = ""
txtName.Text = ""
txtID.Locked = False
txtName.Locked = False
If tvw.SelectedItem.Index = 1 Then
lblID.Caption = "": lblName.Caption = ""
Else
lblID.Caption = Right(tvw.SelectedItem.Key, 2)
lblName.Caption = tvw.SelectedItem.Text
End If
txtID.SetFocus
End Sub
Private Sub cmdDel_Click()
Dim Cmd As ADODB.Command
Dim SQL As String
Dim KeyID As String
If tvw.SelectedItem Is Nothing Then Exit Sub
If tvw.SelectedItem.Children > 0 Then Exit Sub
If tvw.SelectedItem.Index = 1 Then Exit Sub
KeyID = Mid(tvw.SelectedItem.Key, 2)
SQL = "delete from yaopin_types where id='" & KeyID & "'"
Set Cmd = New ADODB.Command
Cmd.ActiveConnection = Conn
Cmd.CommandText = SQL
Cmd.CommandType = adCmdText
Cmd.Execute
tvw.Nodes.Remove tvw.SelectedItem.Index
lblID.Caption = ""
lblName.Caption = ""
txtID.Text = ""
txtName.Text = ""
End Sub
Private Sub cmdExit_Click()
If cmdExit.Caption = "取 消" Then
cmdExit.Caption = "退 出"
cmdAdd.Enabled = True
cmdDel.Enabled = True
tvw.Enabled = True
txtID.Text = ""
txtName.Text = ""
txtID.Locked = True
txtName.Locked = True
Else
Unload Me
End If
End Sub
Private Sub cmdSave_Click()
Dim Cmd As ADODB.Command
Dim Rst As ADODB.Recordset
Dim Nod As Node
Dim SQL As String
Dim KeyString As String
Dim KeyID As String
If lblID.Caption = "" Then
KeyString = "n" & Format(txtID.Text, "00")
KeyID = Format(txtID.Text, "00")
Else
KeyString = "s" & Format(txtID.Text, "00")
KeyID = lblID.Caption & Format(txtID.Text, "00")
End If
Set Rst = New ADODB.Recordset
Rst.CursorLocation = adUseClient
SQL = "select * from yaopin_types where id='" & KeyID & "'"
Rst.CursorLocation = adUseClient
Rst.Open SQL, Conn, adOpenStatic, adLockReadOnly, adCmdText
If Not Rst.EOF Then MsgBox "编码有重复!": Exit Sub
Set Rst = Nothing
Set Nod = tvw.Nodes.Add(tvw.SelectedItem.Index, tvwChild, KeyString, txtName.Text & "(" & txtID.Text & ")", 1)
SQL = "insert into yaopin_types values('" & lblID.Caption & Format(txtID.Text, "00") & "','" & txtName.Text & "')"
Set Cmd = New ADODB.Command
Cmd.ActiveConnection = Conn
Cmd.CommandText = SQL
Cmd.CommandType = adCmdText
Cmd.Execute
Set Cmd = Nothing
Nod.EnsureVisible
Call cmdExit_Click
End Sub
Private Sub Form_Load()
Dim Rst As ADODB.Recordset
Dim CRst As ADODB.Recordset
Dim SQL As String
Dim I As Integer
Dim J As Integer
Dim Pid As Integer
Dim Nod As Node
cmdSave.Enabled = False
txtID.Locked = True
txtName.Locked = True
tvw.Nodes.Add , , , "所有类别", 1
Pid = tvw.Nodes(1).Index
Set tvw.ImageList = ilt
Set Rst = New ADODB.Recordset
Rst.CursorLocation = adUseClient
SQL = "select * from yaopin_types where len(id)=2 order by id desc"
Rst.Open SQL, Conn, adOpenStatic, adLockReadOnly, adCmdText
If Rst.EOF Then Exit Sub
For I = 1 To Rst.RecordCount
Set Nod = tvw.Nodes.Add
Nod.Text = Rst.Fields("name") & "(" & Rst.Fields("id") & ")"
Nod.Key = "n" & Rst.Fields("id").Value
Nod.Image = 1
Set Nod.Parent = tvw.Nodes(1)
Set CRst = New ADODB.Recordset
CRst.CursorLocation = adUseClient
SQL = "select * from yaopin_types where id like '" & Rst.Fields("id") & "%' and len(id)=4 order by id"
CRst.Open SQL, Conn, adOpenStatic, adLockReadOnly, adCmdText
If CRst.EOF Then GoTo move1
For J = 1 To CRst.RecordCount
tvw.Nodes.Add Nod.Index, tvwChild, "s" & CRst.Fields("id"), CRst.Fields("name") & "(" & CRst.Fields("id") & ")", 1
CRst.MoveNext
Next
move1:
CRst.Close
Set CRst = Nothing
Rst.MoveNext
Next
Rst.Close
Set Rst = Nothing
End Sub
Private Sub tvw_NodeClick(ByVal Node As MSComctlLib.Node)
Dim KeyID As String
If Node.Index = 1 Then Exit Sub
If Node.Parent.Index = 1 Then
lblID.Caption = ""
lblName.Caption = ""
Else
lblID.Caption = Mid(Node.Parent.Key, 2)
lblName.Caption = Node.Parent.Text
End If
KeyID = Node.Key
If Len(KeyID) = 3 Then
txtID.Text = Mid(KeyID, 2)
Else
txtID.Text = Mid(KeyID, 4)
End If
txtName.Text = Node.Text
End Sub
Private Sub txtID_KeyPress(KeyAscii As Integer)
If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 Then KeyAscii = 0
End Sub
Private Sub txtName_KeyPress(KeyAscii As Integer)
If KeyAscii = 38 Then KeyAscii = 0
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -