Foxtable(狐表)用户栏目专家坐堂 → [求助] 表格式转换


  共有4413人关注过本帖树形打印复制链接

主题:[求助] 表格式转换

帅哥哟,离线,有人找我吗?
建筑人生
  1楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小狐 帖子:343 积分:3486 威望:0 精华:0 注册:2014/8/20 20:14:00
[求助] 表格式转换  发帖心情 Post By:2022/7/3 15:20:00 [显示全部帖子]


图片点击可在新窗口打开查看此主题相关图片如下: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格式,为什么有部分没有转换


 回到顶部