MS
This commit is contained in:
336
app/DD-Record-Organiser/ClassNodeNavigation.vb
Normal file
336
app/DD-Record-Organiser/ClassNodeNavigation.vb
Normal file
@@ -0,0 +1,336 @@
|
||||
Public Class ClassNodeNavigation
|
||||
Public Shared Function CreateTreeViewNodes(DT_TREEVIEW_PER_CONTROLS As DataTable, TREEVIEW_IMAGELIST As ImageList)
|
||||
Try
|
||||
' Rootnode erstellen und taggen
|
||||
If DT_TREEVIEW_PER_CONTROLS.Rows.Count > 1 Then
|
||||
' Presuming the DataTable has a column named ENTITY_ID and TYPE_NODE.
|
||||
Dim expression As String
|
||||
expression = "TYPE_NODE = 0"
|
||||
Dim foundRowsLevel0() As DataRow
|
||||
' Use the Select method to find all rows matching the filter.
|
||||
foundRowsLevel0 = DT_TREEVIEW_PER_CONTROLS.Select(expression, "NODE_CAPTION")
|
||||
Dim i As Integer
|
||||
Dim NODE_CONFIG_ID
|
||||
Dim LEVEL0_NODE As TreeNode
|
||||
|
||||
' For each row create a Node
|
||||
For i = 0 To foundRowsLevel0.GetUpperBound(0)
|
||||
Dim ID = foundRowsLevel0(i)("GUID")
|
||||
Dim LevelEntity = foundRowsLevel0(i)("ENTITY_ID")
|
||||
Dim controlID = foundRowsLevel0(i)("CONTROL_ID")
|
||||
Dim nodetext = foundRowsLevel0(i)("NODE_CAPTION")
|
||||
Dim Type_node = foundRowsLevel0(i)("TYPE_NODE")
|
||||
Dim RECORD_ID = foundRowsLevel0(i)("RECORD_ID")
|
||||
NODE_CONFIG_ID = foundRowsLevel0(i)("NODE_CONFIG_ID")
|
||||
|
||||
LEVEL0_NODE = New TreeNode(nodetext)
|
||||
If Not IsDBNull(RECORD_ID) Then
|
||||
LEVEL0_NODE.Tag = LevelEntity & " - CONTROL-ID" & controlID.ToString & "#" & ID & "#RECORD-ID" & RECORD_ID.ToString
|
||||
Else
|
||||
LEVEL0_NODE.Tag = LevelEntity & " - CONTROL-ID" & controlID.ToString & "#" & ID
|
||||
End If
|
||||
|
||||
Dim index As Integer = 0
|
||||
For Each img As String In TREEVIEW_IMAGELIST.Images.Keys
|
||||
If img = NODE_CONFIG_ID & "#" & LevelEntity Then
|
||||
Exit For
|
||||
End If
|
||||
index += 1
|
||||
Next
|
||||
LEVEL0_NODE.ImageIndex = index
|
||||
LEVEL0_NODE.SelectedImageIndex = index
|
||||
|
||||
'### LEVEL 1 laden #######
|
||||
Dim expressionLevel1 As String
|
||||
expressionLevel1 = "PARENT_GUID = " & ID 'TYPE_NODE = 1 AND Einschränkung auf Type 2 und Parent_Guid
|
||||
Dim foundRowsLevel1() As DataRow
|
||||
foundRowsLevel1 = DT_TREEVIEW_PER_CONTROLS.Select(expressionLevel1, "NODE_CAPTION")
|
||||
Dim j As Integer
|
||||
For j = 0 To foundRowsLevel1.GetUpperBound(0)
|
||||
Dim ID1 = foundRowsLevel1(j)("GUID")
|
||||
Dim LevelEntity1 = foundRowsLevel1(j)("ENTITY_ID")
|
||||
Dim controlID1 = foundRowsLevel1(j)("CONTROL_ID")
|
||||
Dim nodetext1 = foundRowsLevel1(j)("NODE_CAPTION")
|
||||
Dim Type_node1 = foundRowsLevel1(j)("TYPE_NODE")
|
||||
RECORD_ID = foundRowsLevel1(j)("RECORD_ID")
|
||||
NODE_CONFIG_ID = foundRowsLevel1(j)("NODE_CONFIG_ID")
|
||||
' Node erstellen..
|
||||
Dim LEVEL1_NODE As TreeNode
|
||||
LEVEL1_NODE = New TreeNode(nodetext1)
|
||||
If Not IsDBNull(RECORD_ID) Then
|
||||
LEVEL1_NODE.Tag = LevelEntity1 & "-CONTROL-ID" & controlID1.ToString & "#" & ID1 & "#RECORD-ID" & RECORD_ID.ToString
|
||||
Else
|
||||
LEVEL1_NODE.Tag = LevelEntity1 & "-CONTROL-ID" & controlID1.ToString & "#" & ID1
|
||||
End If
|
||||
|
||||
index = 0
|
||||
For Each img As String In TREEVIEW_IMAGELIST.Images.Keys
|
||||
If img = NODE_CONFIG_ID & "#" & LevelEntity1 Then
|
||||
Exit For
|
||||
End If
|
||||
index += 1
|
||||
Next
|
||||
LEVEL1_NODE.ImageIndex = index
|
||||
LEVEL1_NODE.SelectedImageIndex = index
|
||||
' ..und einfügen
|
||||
LEVEL0_NODE.Nodes.Add(LEVEL1_NODE)
|
||||
'### LEVEL 2 laden #######
|
||||
Dim expressionLevel2 As String
|
||||
expressionLevel2 = "PARENT_GUID = " & ID1 'TYPE_NODE = 2 AND Einschränkung auf Type und Parent_Guid
|
||||
Dim foundRowsLevel2() As DataRow
|
||||
foundRowsLevel2 = DT_TREEVIEW_PER_CONTROLS.Select(expressionLevel2, "NODE_CAPTION")
|
||||
Dim k As Integer
|
||||
For k = 0 To foundRowsLevel2.GetUpperBound(0)
|
||||
Dim ID2 = foundRowsLevel2(k)("GUID")
|
||||
Dim LevelEntity2 = foundRowsLevel2(k)("ENTITY_ID")
|
||||
Dim controlID2 = foundRowsLevel2(k)("CONTROL_ID")
|
||||
Dim nodetext2 = foundRowsLevel2(k)("NODE_CAPTION")
|
||||
RECORD_ID = foundRowsLevel2(k)("RECORD_ID")
|
||||
NODE_CONFIG_ID = foundRowsLevel2(k)("NODE_CONFIG_ID")
|
||||
' Node erstellen..
|
||||
Dim LEVEL2_NODE As TreeNode
|
||||
LEVEL2_NODE = New TreeNode(nodetext2)
|
||||
If Not IsDBNull(RECORD_ID) Then
|
||||
LEVEL2_NODE.Tag = LevelEntity2 & "-CONTROL-ID" & controlID2.ToString & "#" & ID2 & "#RECORD-ID" & RECORD_ID.ToString
|
||||
Else
|
||||
LEVEL2_NODE.Tag = LevelEntity2 & "-CONTROL-ID" & controlID2.ToString & "#" & ID2
|
||||
End If
|
||||
|
||||
index = 0
|
||||
For Each img As String In TREEVIEW_IMAGELIST.Images.Keys
|
||||
If img = NODE_CONFIG_ID & "#" & LevelEntity2 Then
|
||||
Exit For
|
||||
End If
|
||||
index += 1
|
||||
Next
|
||||
LEVEL2_NODE.ImageIndex = index
|
||||
LEVEL2_NODE.SelectedImageIndex = index
|
||||
' ..und einfügen
|
||||
LEVEL1_NODE.Nodes.Add(LEVEL2_NODE)
|
||||
'### LEVEL 3 laden #######
|
||||
Dim expressionLevel3 As String
|
||||
expressionLevel3 = "PARENT_GUID = " & ID2 'TYPE_NODE = 3 AND Einschränkung auf Type und Parent_Guid
|
||||
Dim foundRowsLevel3() As DataRow
|
||||
foundRowsLevel3 = DT_TREEVIEW_PER_CONTROLS.Select(expressionLevel3, "NODE_CAPTION")
|
||||
Dim l As Integer
|
||||
For l = 0 To foundRowsLevel3.GetUpperBound(0)
|
||||
Dim ID3 = foundRowsLevel3(l)("GUID")
|
||||
Dim LevelEntity3 = foundRowsLevel3(l)("ENTITY_ID")
|
||||
Dim controlID3 = foundRowsLevel3(l)("CONTROL_ID")
|
||||
Dim nodetext3 = foundRowsLevel3(l)("NODE_CAPTION")
|
||||
RECORD_ID = foundRowsLevel3(l)("RECORD_ID")
|
||||
NODE_CONFIG_ID = foundRowsLevel3(l)("NODE_CONFIG_ID")
|
||||
' Node erstellen..
|
||||
Dim LEVEL3_NODE As TreeNode
|
||||
LEVEL3_NODE = New TreeNode(nodetext3)
|
||||
If Not IsDBNull(RECORD_ID) Then
|
||||
LEVEL3_NODE.Tag = LevelEntity3 & "-CONTROL-ID" & controlID3.ToString & "#" & ID3 & "#RECORD-ID" & RECORD_ID.ToString
|
||||
Else
|
||||
LEVEL3_NODE.Tag = LevelEntity3 & "-CONTROL-ID" & controlID3.ToString & "#" & ID3
|
||||
End If
|
||||
|
||||
index = 0
|
||||
For Each img As String In TREEVIEW_IMAGELIST.Images.Keys
|
||||
If img = NODE_CONFIG_ID & "#" & LevelEntity3 Then
|
||||
Exit For
|
||||
End If
|
||||
index += 1
|
||||
Next
|
||||
LEVEL3_NODE.ImageIndex = index
|
||||
LEVEL3_NODE.SelectedImageIndex = index
|
||||
' ..und einfügen
|
||||
LEVEL2_NODE.Nodes.Add(LEVEL3_NODE)
|
||||
'### LEVEL 4 laden #######
|
||||
Dim expressionLevel4 As String
|
||||
expressionLevel4 = "PARENT_GUID = " & ID3 'TYPE_NODE = 4 AND Einschränkung auf Type und Parent_Guid
|
||||
Dim foundRowsLevel4() As DataRow
|
||||
foundRowsLevel4 = DT_TREEVIEW_PER_CONTROLS.Select(expressionLevel4, "NODE_CAPTION")
|
||||
Dim m As Integer
|
||||
For m = 0 To foundRowsLevel4.GetUpperBound(0)
|
||||
Dim ID5 = foundRowsLevel4(m)("GUID")
|
||||
Dim LevelEntity5 = foundRowsLevel4(m)("ENTITY_ID")
|
||||
Dim controlID5 = foundRowsLevel4(m)("CONTROL_ID")
|
||||
Dim nodetext5 = foundRowsLevel4(m)("NODE_CAPTION")
|
||||
RECORD_ID = foundRowsLevel4(m)("RECORD_ID")
|
||||
NODE_CONFIG_ID = foundRowsLevel4(m)("NODE_CONFIG_ID")
|
||||
' Node erstellen..
|
||||
Dim LEVEL4_NODE As TreeNode
|
||||
LEVEL4_NODE = New TreeNode(nodetext5)
|
||||
If Not IsDBNull(RECORD_ID) Then
|
||||
LEVEL4_NODE.Tag = LevelEntity5 & "-CONTROL-ID" & controlID5.ToString & "#" & ID5 & "#RECORD-ID" & RECORD_ID.ToString
|
||||
Else
|
||||
LEVEL4_NODE.Tag = LevelEntity5 & "-CONTROL-ID" & controlID5.ToString & "#" & ID5
|
||||
End If
|
||||
|
||||
index = 0
|
||||
For Each img As String In TREEVIEW_IMAGELIST.Images.Keys
|
||||
If img = NODE_CONFIG_ID & "#" & LevelEntity5 Then
|
||||
Exit For
|
||||
End If
|
||||
index += 1
|
||||
Next
|
||||
LEVEL4_NODE.ImageIndex = index
|
||||
LEVEL4_NODE.SelectedImageIndex = index
|
||||
' ..und einfügen
|
||||
LEVEL3_NODE.Nodes.Add(LEVEL4_NODE)
|
||||
'### LEVEL 5 laden #######
|
||||
Dim expressionLevel5 As String
|
||||
Dim sortExp As String = "NODE_CONFIG_ID, NODE_CAPTION"
|
||||
expressionLevel5 = "PARENT_GUID = " & ID5 'TYPE_NODE = 5 AND Einschränkung auf Type und Parent_Guid
|
||||
Dim foundRowsLevel5() As DataRow
|
||||
foundRowsLevel5 = DT_TREEVIEW_PER_CONTROLS.Select(expressionLevel5, sortExp)
|
||||
Dim n As Integer
|
||||
If ID5 = 1146 Then
|
||||
Console.WriteLine("Aha")
|
||||
End If
|
||||
For n = 0 To foundRowsLevel5.GetUpperBound(0)
|
||||
Dim ID6 = foundRowsLevel5(n)("GUID")
|
||||
Dim LevelEntity6 = foundRowsLevel5(n)("ENTITY_ID")
|
||||
Dim controlID6 = foundRowsLevel5(n)("CONTROL_ID")
|
||||
Dim nodetext6 = foundRowsLevel5(n)("NODE_CAPTION")
|
||||
RECORD_ID = foundRowsLevel5(n)("RECORD_ID")
|
||||
NODE_CONFIG_ID = foundRowsLevel5(n)("NODE_CONFIG_ID")
|
||||
' Node erstellen..
|
||||
Dim LEVEL5_NODE As TreeNode
|
||||
LEVEL5_NODE = New TreeNode(nodetext6)
|
||||
If Not IsDBNull(RECORD_ID) Then
|
||||
LEVEL5_NODE.Tag = LevelEntity6 & "-CONTROL-ID" & controlID6.ToString & "#" & ID6 & "#RECORD-ID" & RECORD_ID.ToString
|
||||
Else
|
||||
LEVEL5_NODE.Tag = LevelEntity6 & "-CONTROL-ID" & controlID6.ToString & "#" & ID6
|
||||
End If
|
||||
|
||||
index = 0
|
||||
For Each img As String In TREEVIEW_IMAGELIST.Images.Keys
|
||||
If img = NODE_CONFIG_ID & "#" & LevelEntity6 Then
|
||||
Exit For
|
||||
End If
|
||||
index += 1
|
||||
Next
|
||||
LEVEL5_NODE.ImageIndex = index
|
||||
LEVEL5_NODE.SelectedImageIndex = index
|
||||
' ..und einfügen
|
||||
LEVEL4_NODE.Nodes.Add(LEVEL5_NODE)
|
||||
'### LEVEL 5 laden #######
|
||||
Dim expressionLevel6 As String
|
||||
expressionLevel6 = "PARENT_GUID = " & ID6 'TYPE_NODE = 6 AND Einschränkung auf Type und Parent_Guid
|
||||
Dim foundRowsLevel6() As DataRow
|
||||
foundRowsLevel6 = DT_TREEVIEW_PER_CONTROLS.Select(expressionLevel6, sortExp)
|
||||
If ID6 = 1146 Then
|
||||
Console.WriteLine("Aha")
|
||||
End If
|
||||
Dim o As Integer
|
||||
For o = 0 To foundRowsLevel6.GetUpperBound(0)
|
||||
Dim ID7 = foundRowsLevel6(o)("GUID")
|
||||
Dim LevelEntity7 = foundRowsLevel6(o)("ENTITY_ID")
|
||||
Dim controlID7 = foundRowsLevel6(o)("CONTROL_ID")
|
||||
Dim nodetext7 = foundRowsLevel6(o)("NODE_CAPTION")
|
||||
RECORD_ID = foundRowsLevel6(o)("RECORD_ID")
|
||||
NODE_CONFIG_ID = foundRowsLevel6(o)("NODE_CONFIG_ID")
|
||||
' Node erstellen..
|
||||
Dim LEVEL6_NODE As TreeNode
|
||||
LEVEL6_NODE = New TreeNode(nodetext7)
|
||||
If Not IsDBNull(RECORD_ID) Then
|
||||
LEVEL6_NODE.Tag = LevelEntity7 & "-CONTROL-ID" & controlID7.ToString & "#" & ID7 & "#RECORD-ID" & RECORD_ID.ToString
|
||||
Else
|
||||
LEVEL6_NODE.Tag = LevelEntity7 & "-CONTROL-ID" & controlID7.ToString & "#" & ID7
|
||||
End If
|
||||
|
||||
index = 0
|
||||
For Each img As String In TREEVIEW_IMAGELIST.Images.Keys
|
||||
If img = NODE_CONFIG_ID & "#" & LevelEntity7 Then
|
||||
Exit For
|
||||
End If
|
||||
index += 1
|
||||
Next
|
||||
LEVEL6_NODE.ImageIndex = index
|
||||
LEVEL6_NODE.SelectedImageIndex = index
|
||||
' ..und einfügen
|
||||
LEVEL5_NODE.Nodes.Add(LEVEL6_NODE)
|
||||
'### LEVEL 7 laden #######
|
||||
Dim expressionLevel7 As String
|
||||
expressionLevel7 = "PARENT_GUID = " & ID7 'TYPE_NODE = 7 AND Einschränkung auf Type und Parent_Guid
|
||||
Dim foundRowsLevel7() As DataRow
|
||||
foundRowsLevel7 = DT_TREEVIEW_PER_CONTROLS.Select(expressionLevel7, sortExp)
|
||||
Dim p As Integer
|
||||
For p = 0 To foundRowsLevel7.GetUpperBound(0)
|
||||
Dim ID8 = foundRowsLevel7(p)("GUID")
|
||||
Dim LevelEntity8 = foundRowsLevel7(p)("ENTITY_ID")
|
||||
Dim controlID8 = foundRowsLevel7(p)("CONTROL_ID")
|
||||
Dim nodetext8 = foundRowsLevel7(p)("NODE_CAPTION")
|
||||
RECORD_ID = foundRowsLevel7(p)("RECORD_ID")
|
||||
NODE_CONFIG_ID = foundRowsLevel7(p)("NODE_CONFIG_ID")
|
||||
' Node erstellen..
|
||||
Dim LEVEL7_NODE As TreeNode
|
||||
LEVEL7_NODE = New TreeNode(nodetext8)
|
||||
If Not IsDBNull(RECORD_ID) Then
|
||||
LEVEL7_NODE.Tag = LevelEntity8 & "-CONTROL-ID" & controlID8.ToString & "#" & ID8 & "#RECORD-ID" & RECORD_ID.ToString
|
||||
Else
|
||||
LEVEL7_NODE.Tag = LevelEntity8 & "-CONTROL-ID" & controlID8.ToString & "#" & ID8
|
||||
End If
|
||||
|
||||
index = 0
|
||||
For Each img As String In TREEVIEW_IMAGELIST.Images.Keys
|
||||
If img = NODE_CONFIG_ID & "#" & LevelEntity8 Then
|
||||
Exit For
|
||||
End If
|
||||
index += 1
|
||||
Next
|
||||
LEVEL7_NODE.ImageIndex = index
|
||||
LEVEL7_NODE.SelectedImageIndex = index
|
||||
' ..und einfügen
|
||||
LEVEL6_NODE.Nodes.Add(LEVEL7_NODE)
|
||||
'### LEVEL 7 laden #######
|
||||
Dim expressionLevel8 As String
|
||||
expressionLevel8 = "PARENT_GUID = " & ID8 'TYPE_NODE = 7 AND Einschränkung auf Type und Parent_Guid
|
||||
Dim foundRowsLevel8() As DataRow
|
||||
foundRowsLevel8 = DT_TREEVIEW_PER_CONTROLS.Select(expressionLevel8, sortExp)
|
||||
Dim q As Integer
|
||||
For q = 0 To foundRowsLevel8.GetUpperBound(0)
|
||||
Dim ID9 = foundRowsLevel8(q)("GUID")
|
||||
Dim LevelEntity9 = foundRowsLevel8(q)("ENTITY_ID")
|
||||
Dim controlID9 = foundRowsLevel8(q)("CONTROL_ID")
|
||||
Dim nodetext9 = foundRowsLevel8(q)("NODE_CAPTION")
|
||||
RECORD_ID = foundRowsLevel8(q)("RECORD_ID")
|
||||
NODE_CONFIG_ID = foundRowsLevel8(q)("NODE_CONFIG_ID")
|
||||
' Node erstellen..
|
||||
Dim LEVEL8_NODE As TreeNode
|
||||
LEVEL8_NODE = New TreeNode(nodetext9)
|
||||
If Not IsDBNull(RECORD_ID) Then
|
||||
LEVEL8_NODE.Tag = LevelEntity9 & "-CONTROL-ID" & controlID9.ToString & "#" & ID9 & "#RECORD-ID" & RECORD_ID.ToString
|
||||
Else
|
||||
LEVEL8_NODE.Tag = LevelEntity9 & "-CONTROL-ID" & controlID9.ToString & "#" & ID9
|
||||
End If
|
||||
|
||||
index = 0
|
||||
For Each img As String In TREEVIEW_IMAGELIST.Images.Keys
|
||||
If img = NODE_CONFIG_ID & "#" & LevelEntity9 Then
|
||||
Exit For
|
||||
End If
|
||||
index += 1
|
||||
Next
|
||||
LEVEL8_NODE.ImageIndex = index
|
||||
LEVEL8_NODE.SelectedImageIndex = index
|
||||
' ..und einfügen
|
||||
LEVEL7_NODE.Nodes.Add(LEVEL8_NODE)
|
||||
'### LEVEL 8 laden #######
|
||||
Next ' Level 7 Ende
|
||||
Next ' Level 7 Ende
|
||||
Next ' Level 6 Ende
|
||||
Next ' Level 5 Ende
|
||||
Next 'Level 4 Ende
|
||||
Next 'Level 3 Ende
|
||||
Next ' Level 2 Ende
|
||||
Next 'Level 1 Ende
|
||||
Next
|
||||
Return LEVEL0_NODE
|
||||
Else
|
||||
MsgBox("Check the Control Navigation Option or inform Digital Data!", MsgBoxStyle.Critical)
|
||||
Return Nothing
|
||||
End If
|
||||
Catch ex As Exception
|
||||
ClassLogger.Add(">> Unexpected Error in CreateTreeViewNodes (NodeNavigation): " & ex.Message, True)
|
||||
MsgBox("Error in CreateTreeViewNodes (NodeNavigation):" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
End Class
|
||||
Reference in New Issue
Block a user