以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  求教BIN  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=42813)

--  作者:czy66ds
--  发布时间:2013/11/22 17:18:00
--  求教BIN

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:按款号分尺码组合汇总库存数量.rar

问题写在项目界面里,请帮忙。

因为在这个项目中你帮过我,故直接向你求助。

谢谢。


--  作者:Bin
--  发布时间:2013/11/22 17:23:00
--  
我选择7月1-7月31一样有找不到列的错误提示
另外,选择那个范围会出现你所说的问题呢?

--  作者:有点甜
--  发布时间:2013/11/22 20:08:00
--  
 根据错误提示改了一下,看看是否满足。

\'------设置时段统计--------
Dim sd As WinForm.DateTimePicker
Dim ed As WinForm.DateTimePicker
sd = e.Form.Controls("起始日期")
ed = e.Form.Controls("终止日期")
If sd.Value Is Nothing OrElse ed.Value Is Nothing Then
    MessageBox.Show("请输入起始日期和终止日期!","提示", MessageBoxButtons.OK ,MessageBoxIcon.Information)
    e.Cancel = True
End If
output.Show(sd.Value)
output.Show(ed.Value)

Dim f As String
f = "日期 >= #" & sd.Value & "# And 日期 < #" & ed.Value.AddDays(1) & "#"
MessageBox.Show(F)

Dim g1 As New CrossTableBuilder("结存统计", DataTables("上月结存"))
Dim f1 As fxDataSource
g1.HGroups.AddDef("款号")
g1.VGroups.AddDef("尺码")
g1.Totals.AddDef("数量", "结存_数量")
g1.FromServer = True
g1.Filter=f
g1.Build()
\'MainTable = Tables("结存统计")
f1 =g1.BuildDataSource()

Dim g2 As New CrossTableBuilder("入库统计", DataTables("本月入库"))
Dim f2 As fxDataSource
g2.HGroups.AddDef("款号")
g2.VGroups.AddDef("尺码")
g2.Totals.AddDef("数量", "入库_数量")
g2.FromServer = True
g2.Filter=f
g2.Build()
\'MainTable = Tables("入库统计")
f2 =g2.BuildDataSource()

Dim g3 As New CrossTableBuilder("出库统计", DataTables("本月出库"))
Dim f3 As fxDataSource
g3.HGroups.AddDef("款号")
g3.VGroups.AddDef("尺码")
g3.Totals.AddDef("数量", "出库_数量")
g3.FromServer = True
g3.Filter=f
g3.Build()
\'MainTable = Tables("出库统计")
f3 =g3.BuildDataSource()

Dim g4 As New CrossTableBuilder("销售统计", DataTables("本月销售"))
Dim f4 As fxDataSource
g4.HGroups.AddDef("款号")
g4.VGroups.AddDef("尺码")
g4.Totals.AddDef("数量", "销售_数量")
g4.FromServer = True
g4.Filter=f
g4.Build()
\'MainTable = Tables("销售统计")
f4 =g4.BuildDataSource()

f1.Combine("款号",f2,"款号") \'将入库统计数据组合到结存统计数据
f1.Combine("款号",f3,"款号") \'将出库统计数据组合到结存统计数据
f1.Combine("款号",f4,"款号") \'将销售统计数据组合到结存统计数据

Tables("统计窗口_Table1").DataSource = f1 \'将统计结果绑定到Table
Dim s As String
For i As Integer=1 To Tables("统计窗口_Table1").Cols.count-1
    s= s & "IsNull([" & Tables("统计窗口_Table1").Cols(i).name & "],0) +"
Next

MessageBox.show(s)
With DataTables("统计窗口_Table1").DataCols  \'用表达式列计算库存数据
    
    .Add("库存_总量",Gettype(Integer), s.trim("+"))
    Dim str As String = ""
    If .Contains("数量_1") Then
        str += "IsNull([数量_1],0)+"
    End If
    If .Contains("数量_11") Then
        str += "IsNull([数量_11],0)+"
    End If
    If .Contains("数量_12") Then
        str += "IsNull([数量_12],0)+"
    End If
    If .Contains("数量_13") Then
        str += "IsNull([数量_13],0) +"
    End If
    .Add("库存_L",Gettype(Integer), str.Trim("+"))
    If .Contains("数量_2") Then
        str += "IsNull([数量_2],0)+"
    End If
    If .Contains("数量_21") Then
        str += "IsNull([数量_21],0)+"
    End If
    If .Contains("数量_22") Then
        str += "IsNull([数量_22],0)+"
    End If
    If .Contains("数量_23") Then
        str += "IsNull([数量_23],0) +"
    End If
    
    .Add("库存_M",Gettype(Integer), str.Trim("+"))
    If .Contains("数量_3") Then
        str += "IsNull([数量_3],0)+"
    End If
    If .Contains("数量_31") Then
        str += "IsNull([数量_31],0)+"
    End If
    If .Contains("数量_32") Then
        str += "IsNull([数量_32],0)+"
    End If
    If .Contains("数量_33") Then
        str += "IsNull([数量_33],0) +"
    End If
    .Add("库存_S",Gettype(Integer), str.Trim("+"))
    If .Contains("数量_4") Then
        str += "IsNull([数量_4],0)+"
    End If
    If .Contains("数量_41") Then
        str += "IsNull([数量_41],0)+"
    End If
    If .Contains("数量_42") Then
        str += "IsNull([数量_42],0)+"
    End If
    If .Contains("数量_43") Then
        str += "IsNull([数量_43],0) +"
    End If
    .Add("库存_XL",Gettype(Integer), str.Trim("+"))
End With
\'Tables("统计窗口_Table1").SysStyles("Alternate").BackColor = Color.pink
Tables("统计窗口_Table1").SetColVisibleWidth("款号|100|库存_S|60|库存_M|60|库存_L|60|库存_XL|60|库存_总量|70")

--  作者:czy66ds
--  发布时间:2013/11/22 22:21:00
--  
测试通过了,实在是高哇!
关键是这个貌似不起眼的.Contains!
前提是是否存在”数量_x”,然后才是[数量_x]是否有内容。
有了这个思路我再改一下就可以成功了。
看起来选择狐表开发版是对的,不但工具好,而且高手如林,热心助人。
进一步想想,做此类问题,得先判断最多能有多少个[数量_x],然后再手工去一个一个写代码,能否再提高一步,概括生华,形成一个简化的通用的代码块呢?_这是我的自言自语。

在别人的帮助下,调通了带码,愿望变成了现实,那种愉悦的心情,怎么说也不过分。继续努力吧_这又是自言自语。
再一次向BIN、有点甜等高手们致谢,高手们,晚安!

[此贴子已经被作者于2013-11-22 22:32:39编辑过]