📄 frmmanage.frm
字号:
End
Begin VB.TextBox txtUser
Height = 1035
Index = 2
Left = 1080
MaxLength = 60
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 3
Top = 960
Width = 5175
End
Begin VB.Label lblUser
Alignment = 1 'Right Justify
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "部门编号"
Height = 180
Index = 3
Left = 3360
TabIndex = 12
Top = 240
Width = 720
End
Begin VB.Label lblUser
Alignment = 1 'Right Justify
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "层次"
Height = 180
Index = 1
Left = 3720
TabIndex = 10
Top = 600
Width = 360
End
Begin VB.Label lblCboUser
Alignment = 1 'Right Justify
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "上层部门"
Height = 180
Left = 270
TabIndex = 9
Top = 600
Width = 720
End
Begin VB.Label lblUser
Alignment = 1 'Right Justify
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "隶属部门"
Height = 180
Index = 0
Left = 240
TabIndex = 8
Top = 240
Width = 720
End
Begin VB.Label lblUser
Alignment = 1 'Right Justify
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "部门职责"
Height = 180
Index = 2
Left = 240
TabIndex = 7
Top = 960
Width = 720
End
End
Begin MSComctlLib.TreeView tvwManage
Height = 5055
Left = 120
TabIndex = 11
Top = 420
Width = 3240
_ExtentX = 5715
_ExtentY = 8916
_Version = 393217
HideSelection = 0 'False
Indentation = 529
LabelEdit = 1
LineStyle = 1
Sorted = -1 'True
Style = 7
FullRowSelect = -1 'True
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin VB.Frame Frame2
Height = 400
Left = 120
TabIndex = 24
Top = 5400
Width = 3255
Begin VB.Label lblInfo
AutoSize = -1 'True
BackStyle = 0 'Transparent
ForeColor = &H00FF0000&
Height = 180
Left = 120
TabIndex = 25
Top = 165
Width = 90
End
End
End
Begin VB.Frame Frame1
Height = 600
Left = 60
TabIndex = 18
Top = 5880
Width = 9975
Begin VB.TextBox txtFind
Height = 300
Left = 2040
TabIndex = 21
Top = 200
Width = 4215
End
Begin VB.ComboBox cboFind
Height = 300
ItemData = "frmManage.frx":00BC
Left = 120
List = "frmManage.frx":00CF
Style = 2 'Dropdown List
TabIndex = 20
Top = 200
Width = 1815
End
Begin Manage.xpcmdButton cmdFind
Height = 345
Index = 1
Left = 7560
TabIndex = 19
Top = 180
Width = 1095
_extentx = 1931
_extenty = 609
font = "frmManage.frx":0101
caption = "全部"
forecolor = -2147483630
forehover = 0
End
Begin Manage.xpcmdButton cmdFind
Height = 345
Index = 0
Left = 6360
TabIndex = 22
Top = 180
Width = 1095
_extentx = 1931
_extenty = 609
font = "frmManage.frx":0125
caption = "查询"
forecolor = -2147483630
forehover = 0
End
Begin Manage.xpcmdButton cmdEnd
Cancel = -1 'True
Height = 345
Left = 8760
TabIndex = 23
Top = 180
Width = 1095
_extentx = 1931
_extenty = 609
font = "frmManage.frx":0149
caption = "关闭(&C)"
forecolor = -2147483630
End
End
End
Attribute VB_Name = "frmManage"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'7-13修正不能正确读取tvw列表的当前项
'7-14修正按钮的一些属性错误
Option Explicit
Dim adoEditLink As New ADODB.Recordset
Dim intSum() As Integer
Dim strUpManage As String
Dim strLevel As String
Dim strManage As String
Dim blnAddNew As Boolean
Dim strBM As String
Dim intManage As Integer
Private Sub ManageView()
Dim intTemp(1) As Integer
Dim strTempNode() As String
Dim strTempName() As String
On Error GoTo ErrHandle
tvwManage.Visible = False
With adoEditLink
If .State = adStateOpen Then .Close
tvwManage.Nodes.Clear
tvwManage.Nodes.Add , , "A", "部门结构", 1
intTemp(0) = 1 '记录层次
intTemp(1) = 1
nodLong(0) = 1
strTemp(0) = "C"
strTemp(1) = "A"
intManage = 0
.Open "select * from 隶属部门 order by 层次,部门编号,id", adoConn, adOpenDynamic, adLockPessimistic, adCmdText
If .EOF = False Then
.MoveLast
intManage = .RecordCount
.MoveFirst
lblinfo.Caption = "当前部门数量:" & intManage & "个."
ReDim strTempNode(intManage): ReDim strTempName(intManage)
intCount = 1
Do Until .EOF
If intTemp(0) <> .Fields("层次") Then
nodLong(0) = 1
strTemp(0) = strTemp(0) & "C"
strTemp(1) = strTemp(0) & (nodLong(0))
intTemp(0) = intTemp(0) + 1
End If
strTempNode(intTemp(1)) = strTemp(0) & nodLong(0)
strTempName(intTemp(1)) = .Fields("隶属部门")
For intCount = 1 To intTemp(1)
If .Fields("上层部门") = strTempName(intCount) Then
strTemp(2) = strTempNode(intCount)
Exit For
Else
strTemp(2) = strTemp(1)
End If
Next
tvwManage.Nodes.Add strTemp(2), tvwChild, strTemp(0) & nodLong(0), Trim(!隶属部门), intTemp(0) + 1
nodLong(0) = nodLong(0) + 1
intTemp(1) = intTemp(1) + 1
intCount = intCount + 1
.MoveNext
Loop
tvwManage.Nodes("C1").Selected = True
Else
lblinfo.Caption = "当前部门数量:0个."
End If
End With
tvwManage.Visible = True
Exit Sub
ErrHandle:
tvwManage.Visible = True
Call ErrMsg(Err.Number, Err.Description)
End Sub
Private Sub cboUser_Click()
If cboUser.ListIndex > 0 Then
txtUser(1).Text = intSum(cboUser.ListIndex) + 1
Else
txtUser(1).Text = 1
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -