以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]统计  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=86282)

--  作者:huhu
--  发布时间:2016/6/14 18:18:00
--  [求助]统计

我定义了一个控件cktj

Dim cktj As WinForm.Button = e.Form.Controls("Button1")

希望能对扫描配货明细表的各物料编码的数量求和统计,条件是收货单号为空。-----什么方法统计简单。

比如物料编码:1有2个;物料编码:2有3个

然后这个统计结果作为cktj.text.

 


图片点击可在新窗口打开查看此主题相关图片如下:统计.png
图片点击可在新窗口打开查看

--  作者:大红袍
--  发布时间:2016/6/15 0:29:00
--  

 不就是分组统计么?

 

 http://www.foxtable.com/help/topics/0677.htm

 


--  作者:huhu
--  发布时间:2016/6/15 10:43:00
--  

Dim cktj As WinForm.Button = e.Form.Controls("Button1")
                Dim b As New  GroupTableBuilder("统计表1",DataTables("扫描配货明细"))
                b.Filter = "收货单号 is null and 物料编码 > 0" \'仅统计客户为CS01的记录
                b.Groups.AddDef("物料编码") \'根据产品分组
                b.Totals.AddDef("数量") \'对数量进行统计
                b.Build \'生成统计表
                Dim str1 As String
                Dim lst2 As List(of DataRow) = DataTables("统计表1").datarows
                For Each mr As DataRow In lst2
                    str1 += "物料编码:" & mr("物料编码") & "--" & mr("数量") & ";"
                Next
                cktj.text = str1

 

这么写对吗?


--  作者:大红袍
--  发布时间:2016/6/15 10:47:00
--  
Dim str As String = ""
For Each bm As String In DataTables("扫描配货明细").GetValues("物料编码")
    Dim sum As Double = DataTables("扫描配货明细").Compute("sum(数量)", "物料编码 = \'" & bm & "\'")
    str &= "物料编码:" & bm & "--" & sum & ";"
Next
msgbox(str)

--  作者:huhu
--  发布时间:2016/6/15 11:51:00
--  
物料编码不能为空,物料编码 > 0----不对吗?
                Dim str1 As String = ""
                For Each wlbm As String In DataTables("扫描配货明细").GetValues("物料编码","状态 = \'生产结束扫描完成\' and 收货单号 is null and 物料编码 > 0")
                    Dim sum1 As Integer = DataTables("扫描配货明细").Compute("sum(数量)", "物料编码 = \'" & wlbm & "\'")
                    str1 &= "物料编码:" & wlbm & "--" & sum1 & ";"
                Next
                cktj.text = str1
                msgbox(str1 & vbcrlf & cktj.text)

--  作者:大红袍
--  发布时间:2016/6/15 11:52:00
--  

这个意思?

 

For Each wlbm As String In DataTables("扫描配货明细").GetValues("物料编码","状态 = \'生产结束扫描完成\' and 收货单号 is null and 物料编码 is not null")