Foxtable(狐表)用户栏目专家坐堂 → 运行效率太慢,求帮忙优化,提升效率


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

主题:运行效率太慢,求帮忙优化,提升效率

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


加好友 发短信
等级:超级版主 帖子:521 积分:4910 威望:0 精华:7 注册:2008/9/2 22:22:00
  发帖心情 Post By:2014/5/4 11:38:00 [显示全部帖子]

試試用分組統計及組合的方法,應該高效些

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


加好友 发短信
等级:超级版主 帖子:521 积分:4910 威望:0 精华:7 注册:2008/9/2 22:22:00
  发帖心情 Post By:2014/5/4 13:27:00 [显示全部帖子]

試試:窗口表改為查詢表

Dim  Filter,s1,s2,s3 ,flt1,ep1,ep2,ep3 As  String
Dim fdt1,fdt2,fdt3,fdt4,fdt5,fdt6,fdt7,fdt8,fdt9 As fxDataSource
Dim fxdts As fxDataSource() ={fdt1,fdt2,fdt3,fdt4,fdt5,fdt6,fdt7,fdt8,fdt9}
Dim nms1 As String() = {"编码","名称","颜色","尺码","年份","季节","零售价"}  '分組列
Dim nms2 As String() = {"编码","名称","颜色","尺码","年份","季节"}  '分組列
Dim nms() As String
Dim bd1 As  GroupTableBuilder
Dim t3 As Table = e.Form.Controls("库存报表").Table
Dim dt3,dt1,dt2 As DataTable
dt1=DataTables("出入库明细")
dt2=DataTables("库调明细表_主表")

s1 = "库房_调拨出库|库房_收货入库|库房_返货出库|店铺_调拨出库|店铺_调拨入库|店铺_零售出库|店铺_零退入库|店铺_库调|店铺_退货入库"      '統計標題
flt1= "业务单号首位 = 'D' and 收发类型= '调拨出库'@业务单号首位 = 'F' and 收发类型= '收货入库'@业务单号首位 = 'T' and 收发类型= '返货出库'@"   '條件組合
flt1+= "业务单号首位 = 'R' and 收发类型= '调拨出库'@业务单号首位 = 'R' and 收发类型= '调拨入库'@"
flt1+= "收发类型= '零售出库'@收发类型= '零退入库'@收发类型= '库调'@收发类型= '退货入库'"

ep1 = "IsNull([库房_收货入库],0) +IsNull([库房_返货出库],0)+IsNull([库房_调拨出库],0)+IsNull([店铺_退货入库],0)-Isnull([店铺_库调],0)"
ep2 = "IsNull([店铺_库调],0) +IsNull([店铺_调拨入库],0)+IsNull([店铺_调拨出库],0)+IsNull([店铺_零退入库],0)"
ep2+="-Isnull([店铺_零售出库],0)-Isnull([店铺_退货入库],0)"
ep3 = "IsNull([库房_合计],0) +IsNull([库房_合计],0)"

s3 ="品牌,门店,年份,季节,开始日期,截止日期"
For Each s2 In  s3.split(",")   
    With e.Form.Controls(s2)
        If .Value  IsNot  Nothing   Then
            If Filter > ""   Then
                Filter+ = " And "
            End  If
            If s2 = "开始日期" Then
                Filter+ =  "单据日期 >= #" & .Value &   "#"
            ElseIf s2 = "截止日期"  Then
                Filter+ =  "单据日期 <= #" & .Value &   "#"
            Else
                Filter+ =   s2 & " = '" & .Value &   "'"
            End  If
        End  If
    End   With 
Next



If   Filter >  "" Then
    Tables("出入库明细").Filter =  Filter
    
    For n1 As Integer = 0 To fxdts.Length-1
        If n1 > 6 Then
            dt3 = dt2
        Else
            dt3 = dt1
        End If
        bd1 = New GroupTableBuilder("报表",dt3)
        For Each s2 In nms1
            If dt3.DataCols.Contains(s2) Then
                bd1.Groups.AddDef(s2) '分组
            End If
        Next
        
        bd1.Totals.AddDef("数量",s1.split("|")(n1)) '对数量进行统计
        bd1.Filter = flt1.split("@")(n1) & " and " & Filter
        fxdts(n1) = bd1.BuildDataSource()
        nms = iif(n1 < 7,nms1,nms2)
        If  n1  > 0 Then  fxdts(0).Combine(nms,fxdts(n1),nms)
    Next
    
    
    t3.StopRedraw
    t3.DataSource = fxdts(0)
    With t3.DataTable.DataCols
        .Add("库房_合计", Gettype(Integer),ep1)
        .Add("店铺_合计", Gettype(Integer),ep2)
        .Add("店库_合计", Gettype(Integer),ep3)
    End With
    t3.ResumeRedraw
End If

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:进销存.rar


[此贴子已经被作者于2014-5-4 15:07:20编辑过]

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


加好友 发短信
等级:超级版主 帖子:521 积分:4910 威望:0 精华:7 注册:2008/9/2 22:22:00
  发帖心情 Post By:2014/5/6 22:28:00 [显示全部帖子]

优化一下:

Dim dt3 As DataTable
Dim bd1 As  GroupTableBuilder
Dim fxdts(8) As fxDataSource
Dim nms(),Ymds(),Bts() As String
Dim  Filter,s2,s3 ,flt1,ep1,ep2,ep3 As  String

Dim nms1 As String() = {"编码","名称","颜色","尺码","年份","季节","零售价"}  '分組列1
Dim nms2 As String() = {"编码","名称","颜色","尺码","年份","季节"}  '分組列2
Dim t3 As Table = e.Form.Controls("库存报表").Table

Ymds="D@F@T@R@R@@@@".split("@")
Bts= "库房_调拨出库@库房_收货入库@库房_返货出库@店铺_调拨出库@店铺_调拨入库@店铺_零售出库@店铺_零退入库@店铺_库调@店铺_退货入库".split("@")      '統計標題

ep1 = "IsNull([库房_收货入库],0) +IsNull([库房_返货出库],0)+IsNull([库房_调拨出库],0)+IsNull([店铺_退货入库],0)-Isnull([店铺_库调],0)"
ep2 = "IsNull([店铺_库调],0) +IsNull([店铺_调拨入库],0)+IsNull([店铺_调拨出库],0)+IsNull([店铺_零退入库],0)"
ep2+="-Isnull([店铺_零售出库],0)-Isnull([店铺_退货入库],0)"
ep3 = "IsNull([合计_库房],0) +IsNull([合计_店铺],0)"

s3 ="品牌,门店,年份,季节,开始日期,截止日期"
For Each s2 In  s3.split(",")
    With e.Form.Controls(s2)
        If .Value  IsNot  Nothing   Then
            If Filter > ""   Then
                Filter+ = " And "
            End  If
            If s2 = "开始日期" Then
                Filter+ =  "单据日期 >= #" & .Value &   "#"
            ElseIf s2 = "截止日期"  Then
                Filter+ =  "单据日期 <= #" & .Value &   "#"
            Else
                Filter+ =   s2 & " = '" & .Value &   "'"
            End  If
        End  If
    End   With
Next



If   Filter >  "" Then
    Tables("出入库明细").Filter =  Filter
    
    For n1 As Integer = 0 To 8
        If n1 > 6 Then
            dt3 = DataTables("库调明细表_主表")
        Else
            dt3 = DataTables("出入库明细")
        End If
        bd1 = New GroupTableBuilder("报表",dt3)
        For Each s2 In nms1
            If dt3.DataCols.Contains(s2) Then
                bd1.Groups.AddDef(s2) '分组
            End If
        Next
        
        bd1.Totals.AddDef("数量",Bts(n1)) '对数量进行统计
        flt1= "收发类型= '" &   Bts(n1).split("_")(1) & "'"
        If Ymds(n1) > "" Then
            flt1+= " And 业务单号首位 = '" &  Ymds(n1) & "'"
        End If
        
        bd1.Filter = flt1  & " and " & Filter
        fxdts(n1)  = bd1.BuildDataSource()
        nms = iif(n1 < 7,nms1,nms2)
        If  n1  > 0 Then  fxdts(0).Combine(nms,fxdts(n1),nms)
    Next
    
    
    t3.StopRedraw
    t3.DataSource = fxdts(0)
    With t3.DataTable.DataCols
        .Add("合计_库房", Gettype(Integer),ep1)
        .Add("合计_店铺", Gettype(Integer),ep2)
        .Add("合计_店库", Gettype(Integer),ep3)
    End With
    t3.AutoSizeCols
    t3.ResumeRedraw
End If
[此贴子已经被作者于2014-5-6 22:29:34编辑过]

 回到顶部