📄 frmuser.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmUser
Appearance = 0 'Flat
BackColor = &H80000005&
BorderStyle = 0 'None
Caption = "用户信息"
ClientHeight = 3825
ClientLeft = 0
ClientTop = 0
ClientWidth = 3345
LinkTopic = "Form1"
ScaleHeight = 3825
ScaleWidth = 3345
ShowInTaskbar = 0 'False
StartUpPosition = 1 '所有者中心
Begin VB.Frame frabk
Appearance = 0 'Flat
BackColor = &H00E0E0E0&
ForeColor = &H80000008&
Height = 3885
Left = 0
TabIndex = 0
Top = -90
Width = 3345
Begin MSComctlLib.TreeView treeviewUser
Height = 3120
Left = 0
TabIndex = 3
Top = 270
Width = 3345
_ExtentX = 5900
_ExtentY = 5503
_Version = 393217
LabelEdit = 1
LineStyle = 1
Style = 6
Checkboxes = -1 'True
HotTracking = -1 'True
BorderStyle = 1
Appearance = 0
End
Begin VB.CommandButton cmdYes
BackColor = &H80000009&
Caption = "确定"
Height = 330
Left = 675
Style = 1 'Graphical
TabIndex = 2
Top = 3465
Width = 870
End
Begin VB.CommandButton cmdNo
Appearance = 0 'Flat
BackColor = &H80000009&
Caption = "取消"
Height = 330
Left = 1710
Style = 1 'Graphical
TabIndex = 1
Top = 3465
Width = 870
End
End
End
Attribute VB_Name = "frmUser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private mvarUserName As String
Public Property Let SetUserName(ByVal vData As String)
mvarUserName = vData
End Property
Private Sub cmdNo_Click()
Unload Me
End Sub
Private Sub cmdYes_Click()
Dim i As Integer
Dim tmpCount
Dim strUserName_C, strUserName As String
strUserName_C = "": strUserName = ""
tmpCount = 0
With treeviewUser
For i = 1 To .Nodes.count
If .Nodes(i).Checked = True Then
If .Nodes(i).Key = "R" Then
ElseIf .Nodes(i).Parent.Key = "R" Then
Else
strUserName_C = strUserName_C & .Nodes(i).Text & ","
strUserName = strUserName & .Nodes(i).Key & ","
tmpCount = tmpCount + 1
End If
End If
Next i
If strUserName_C <> "" Then
strUserName_C = Left(strUserName_C, Len(strUserName_C) - 1)
End If
If strUserName <> "" Then
strUserName = Left(strUserName, Len(strUserName) - 1)
End If
End With
With frmNode
If Trim$(.txtNum) = "" Or .txtNum = 0 Then
.txtNum = tmpCount
End If
.txtMan = strUserName_C
.txtManKey = strUserName
End With
Unload Me
End Sub
Private Sub Form_Load()
Dim RS As New ADODB.Recordset
Dim strSQL As String
Dim i As Integer
Dim nodX As Node
Dim tmpStr As String
Set RS = g_AllUserRs.Clone(adLockReadOnly)
If RS.EOF Then Exit Sub
i = 1
treeviewUser.Nodes.Add , , "R", "全体人员"
treeviewUser.Nodes(1).Expanded = True
Do Until RS.EOF
If i = 1 Then
treeviewUser.Nodes.Add "R", tvwChild, RS.Fields("deparment_c"), RS.Fields("deparment_c")
tmpStr = RS.Fields("deparment_c")
Set nodX = treeviewUser.Nodes.Add(tmpStr, tvwChild, RS.Fields("username"), RS.Fields("username_c"))
If CheckExist(RS.Fields("username")) Then
nodX.Checked = True
End If
ElseIf tmpStr = RS.Fields("deparment_c") Then
Set nodX = treeviewUser.Nodes.Add(tmpStr, tvwChild, RS.Fields("username"), RS.Fields("username_c"))
If CheckExist(RS.Fields("username")) Then
nodX.Checked = True
End If
Else
treeviewUser.Nodes.Add "R", tvwChild, RS.Fields("deparment_c"), RS.Fields("deparment_c")
tmpStr = RS.Fields("deparment_c")
Set nodX = treeviewUser.Nodes.Add(tmpStr, tvwChild, RS.Fields("username"), RS.Fields("username_c"))
If CheckExist(RS.Fields("username")) Then
nodX.Checked = True
End If
End If
RS.MoveNext: i = i + 1
Loop
RS.Close
Set RS = Nothing
End Sub
Private Sub Form_Unload(Cancel As Integer)
frmNode.Enabled = True
End Sub
Private Sub treeviewUser_NodeCheck(ByVal Node As MSComctlLib.Node)
Dim i As Integer
Dim Nodex As Node
If Node.Key = "R" Then
If Node.Checked = True Then
For i = 1 To treeviewUser.Nodes.count
treeviewUser.Nodes(i).Checked = True
Next i
Else
For i = 1 To treeviewUser.Nodes.count
treeviewUser.Nodes(i).Checked = False
Next i
End If
Exit Sub
End If
If Node.Checked = True Then
If Node.Parent.Key = "R" Then
Set Nodex = Node.Child
Nodex.Checked = True
For i = 2 To Node.Children
Set Nodex = Nodex.Next
Nodex.Checked = True
Next i
End If
Else
If Node.Parent.Key = "R" Then
Set Nodex = Node.Child
Nodex.Checked = False
For i = 2 To Node.Children
Set Nodex = Nodex.Next
Nodex.Checked = False
Next i
End If
End If
End Sub
Private Function CheckExist(vData As String) As Boolean
Dim tmpStr() As String
Dim i, count As Integer
CheckExist = False
tmpStr = Split(mvarUserName, ",")
count = UBound(tmpStr)
For i = 0 To count
If vData = tmpStr(i) Then
CheckExist = True
Exit Function
End If
Next i
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -