此主题相关图片如下:01.png
此主题相关图片如下:02.png
此主题相关图片如下:03.png
此主题相关图片如下:04.png
Dim cmd1 As New SQLCommand
cmd1.C
cmd1.CommandText = "S ELECT DISTINCT 一级科目,二级科目,三级科目,四级科目,五级科目 From{汇总表}"
Dim dt1 As DataTable = cmd1.ExecuteReader()
Dim trv As WinForm.TreeView = e.Form.Controls("Tre_报表")
trv.BuildTree(dt1, "一级科目|二级科目|三级科目|四级科目|五级科目")
Dim X1, X2, X3, X4, X5 As Integer
Dim S1, S2, S3, S4, S5 As String
Dim dr As DataRow
With DataTables("主窗口_Tab_报表")
.StopRedraw
.DataRows.Clear
Dim s1s As List(Of String)
s1s = dt1.GetValues("一级科目")
If s1s.Count > 0 Then
For Each s1 In s1s
dr = DataTables("主窗口_Tab_报表").AddNew
X1 = X1 + 1
dr("序号") = x1
dr("科目名称") = s1
Dim s2s As List(Of String)
s2s = dt1.GetValues("二级科目", "[一级科目] = '" & S1 & "'")
If s2s.Count > 0 Then
For Each s2 In s2s
dr = DataTables("主窗口_Tab_报表").AddNew
X2 = X2 + 1
dr("序号") = X1 & "_" & x2
dr("科目名称") = s2
If X2 = s2s.Count Then '退出
X2 = 0
Exit For
End If
Dim s3s As List(Of String)
s3s = dt1.GetValues("三级科目", "[一级科目] = '" & S1 & "'and [二级科目] = '" & S2 & "'")
If s3s.Count > 0 Then
For Each s3 In s3s
dr = DataTables("主窗口_Tab_报表").AddNew
X3 = X3 + 1
dr("序号") = X1 & "_" & x2 & "_" & x3
dr("科目名称") = s3
If X3 = s3s.Count Then '退出
X3 = 0
Exit For
End If
Dim s4s As List(Of String)
s4s = dt1.GetValues("四级科目", "[一级科目]='" & S1 & "' and [二级科目]= '" & S2 & "' and [三级科目]= '" & s3 & "'")
If s4s.Count > 0 Then
For Each s4 In s4s
dr = DataTables("主窗口_Tab_报表").AddNew
X4 = X4 + 1
dr("序号") = X1 & "_" & x2 & "_" & x3 & "_" & x4
dr("科目名称") = s4
If X4 = s4s.Count Then '退出
X4 = 0
Exit For
End If
Dim s5s As List(Of String)
s5s = dt1.GetValues("五级科目", "[一级科目] ='" & S1 & "'and [二级科目] ='" & S2 & "'and [三级科目] ='" & s3 & "' and [四级科目] = '" & s4 & "'")
If s5s.Count > 0 Then
For Each s5 In s5s
dr = DataTables("主窗口_Tab_报表").AddNew
X5 = X5 + 1
dr("序号") = X1 & "_" & x2 & "_" & x3 & "_" & x4 & "_" & x5
dr("科目名称") = s5
If X5 = s5s.Count Then '退出
X5 = 0
Exit For
End If
Next
End If
Next
End If
Next
End If
Next
End If
Next
End If
.ResumeRedraw
End With
End Select
以上代码为表1转换表2格式,为什么有部分没有转换