Foxtable(狐表)用户栏目专家坐堂 → [原创]这样的统计能实现吗?


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

主题:[原创]这样的统计能实现吗?

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


加好友 发短信
等级:八尾狐 帖子:1812 积分:12999 威望:0 精华:14 注册:2008/10/11 18:07:00
  发帖心情 Post By:2012/9/13 13:29:00 [显示全部帖子]

Dim r1 As Row
Dim n1,n2  As Integer
Dim cp1,ht1,fl1,fl2 As String
Dim Cps,Hts As List(Of String)
Dim dt1 As DataTable =DataTables("欠货明细表")
fl1 ="欠货数量 <> 0"

Cps = dt1.GetUniqueValues(fl1,"产品型号")
For Each cp1  In Cps
    fl2 ="产品型号='" & cp1 & "'And " & fl1
    hts =dt1.GetUniqueValues(fl2,"合同编号")
    
    If hts.Count > n2 Then
        n2 =hts.Count
    End If
Next
Dim dtb As New DataTableBuilder("统计")
dtb.AddDef("产品型号", Gettype(String), 32)
dtb.AddDef("欠货数量", Gettype(Integer))
For n1  = 1 To  n2
    dtb.AddDef("H" & n1 , Gettype(String), 32)
    dtb.AddDef("Q" & n1 , Gettype(Integer))
Next
dtb.Build()

Tables("统计").StopRedraw
For Each cp1  In Cps
    fl2 ="产品型号='" & cp1 & "'And " & fl1
    hts =dt1.GetUniqueValues(fl2,"合同编号")
    r1 =Tables("统计").AddNew
    r1("产品型号") =cp1
    r1("欠货数量") =dt1.Compute("sum(欠货数量)",fl2)
    For n1 = 0 To  hts.count-1
        r1("H" & n1+1) =hts(n1)
        r1("Q" & n1+1) =dt1.Compute("sum(欠货数量)",fl2 & " And 合同编号 ='" & hts(n1) & "'")
    Next
Next
With DataTables("统计")    
    For n1  = 1 To  n2
        .DataCols("H" & n1).Caption = "欠货明细_合同编号"
        .DataCols("Q" & n1).Caption = "欠货明细_欠货数量"     
    Next
    .BuildHeader()
End With

Tables("统计").ResumeRedraw
MainTable= Tables("统计")
[此贴子已经被作者于2012-9-13 14:14:27编辑过]

 回到顶部