Foxtable(狐表)用户栏目专家坐堂 → [求助] 横向显示后面数据


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

主题:[求助] 横向显示后面数据

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/7/11 12:35:00 [显示全部帖子]

参考代码,细节自行调整

 

Dim dt1 As DataTable = DataTables("MRP报表")
Dim dtb As New DataTableBuilder("mrp统计表")
dtb.AddDef("成品代码", Gettype(String), 16)
dtb.AddDef("成品名称及规格", Gettype(String), 16)
Dim lbs As List(of String) = dt1.GetValues("子料类别")
For Each lb As String In lbs
    Dim dms As List(of String) = dt1.getvalues("成品代码", "子料类别 = '" & lb & "'")
    Dim max As Integer = 0
    For Each dm As String In dms
        Dim count As Integer = dt1.Compute("count(_Identify)", "成品代码 = '" & dm & "' and 子料类别 = '" & lb & "'")
        If count > max Then max = count
    Next
    For i As Integer = 1 To max
        Dim name As String = lb & "_" & lb & i
        dtb.AddDef(name & "_子料代码", Gettype(String))
        dtb.AddDef(name & "_子料名称", Gettype(String))
        dtb.AddDef(name & "_库存", Gettype(String))
        dtb.AddDef(name & "_在途采购", Gettype(String))
    Next
Next
dtb.Build()
Dim dt2 As Table = Tables("mrp统计表")
For Each dm As String() In dt1.GetValues("成品代码|成品名称及规格")
    Dim nr As Row = dt2.AddNew
    nr("成品代码") = dm(0)
    nr("成品名称及规格") = dm(1)
Next
MainTable= dt2

 

http://www.foxtable.com/webhelp/scr/2394.htm

 


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/7/17 10:58:00 [显示全部帖子]

没看懂你要统计的东西,截图说明要统计什么。

 

Dim dt1 As DataTable = DataTables("MRP报表")
Dim dtb As New DataTableBuilder("mrp统计表")
dtb.AddDef("成品代码", Gettype(String), 16)
dtb.AddDef("成品名称及规格", Gettype(String), 16)
dtb.AddDef("可配套数量", Gettype(String))
dtb.AddDef("同类子料个数", Gettype(String))
Dim lbs As List(of String) = dt1.GetValues("子料类别")
For Each lb As String In lbs
    dtb.AddDef(lb & "_子料代码", Gettype(String))
    dtb.AddDef(lb & "_子料名称", Gettype(String))
    dtb.AddDef(lb & "_库存", Gettype(String))
    dtb.AddDef(lb & "_在途采购", Gettype(String))
Next
dtb.Build()
Dim dt2 As Table = Tables("mrp统计表")
For Each dm As String() In dt1.GetValues("成品代码|成品名称及规格")
    Dim nr As Row = dt2.AddNew
    nr("成品代码") = dm(0)
    nr("成品名称及规格") = dm(1)
    Dim min As Double = 99999
    For Each lbei As String In dt1.GetValues("子料类别","成品代码='" & dm(0) & "' And 成品名称及规格='" & dm(1) & "'")
        Dim dr As DataRow = dt1.Find("成品代码='" & dm(0) & "' And 成品名称及规格='" & dm(1) & "' and 子料类别='" & lbei & "'","子料库存数量")
        If dr IsNot Nothing
            nr(lbei  & "_子料代码") = dr("子料代码")
            nr(lbei  & "_子料名称") = dr("子料名称及规格")
            nr(lbei  & "_库存") = dr("子料库存数量")
            nr(lbei  & "_在途采购") = dr("子料在途采购")
            If min > dr("子料库存数量") Then
                min = dr("子料库存数量")
            End If
        End If
    Next
    nr("可配套数量") = min
Next
MainTable= dt2


 回到顶部