Foxtable(狐表)用户栏目专家坐堂 → 统计问题


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

主题:统计问题

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


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

参考代码

 


Dim dt As DataTable = DataTables("产成品收付存")
dt.DataRows.Clear
Dim dt1 As DataTable = DataTables("开piao明细")
Dim d1 As Date = new Date(Date.Today.year, Date.Today.Month,1)
Dim d2 As Date = d1.AddMonths(1)
For Each ary() As String In dt1.GetValues("型号|规格|单位")
    Dim ndr As DataRow = dt.AddNew
    ndr("型号") = ary(0)
    ndr("规格") = ary(1)
    ndr("单位") = ary(2)
    Dim filter As String = "型号 = '" & ary(0) & "' and 规格 = '" & ary(1) & "' and 单位 = '" & ary(2) & "'"
    filter = filter.Replace("*", "[*]")
    output.show(filter & " and 开piao日期 < #" & d1 & "#")
    Dim psum_sl As Double = dt1.Compute("sum(数量)", filter & " and 开piao日期 < #" & d1 & "#")
    Dim sum_sl_in As Double = dt1.Compute("sum(数量)", filter & " and 开piao日期 >= #" & d1 & "# and 开piao日期 < #" & d2 & "# and 数量 >= 0")
    Dim sum_sl_out As Double = dt1.Compute("sum(数量)", filter & " and 开piao日期 >= #" & d1 & "# and 开piao日期 < #" & d2 & "# and 数量 <= 0")
    ndr("上月结存_数量") = psum_sl
    ndr("本月收进_数量") = sum_sl_in
    ndr("本月付出_数量") = sum_sl_out
Next

 


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


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

代码我测试没问题,如果选日期,修改红色代码即可

 

Dim dt As DataTable = DataTables("产成品收付存")
dt.DataRows.Clear
Dim dt1 As DataTable = DataTables("开piao明细")
Dim d1 As Date = new Date(Date.Today.year, Date.Today.Month,1)
Dim d2 As Date = d1.AddMonths(1
)
For Each ary() As String In dt1.GetValues("型号|规格|单位")
    Dim ndr As DataRow = dt.AddNew
    ndr("型号") = ary(0)
    ndr("规格") = ary(1)
    ndr("单位") = ary(2)
    Dim filter As String = "型号 = '" & ary(0) & "' and 规格 = '" & ary(1) & "' and 单位 = '" & ary(2) & "'"
    filter = filter.Replace("*", "[*]")
    output.show(filter & " and 开piao日期 < #" & d1 & "#")
    Dim psum_sl As Double = dt1.Compute("sum(数量)", filter & " and 开piao日期 < #" & d1 & "#")
    Dim sum_sl_in As Double = dt1.Compute("sum(数量)", filter & " and 开piao日期 >= #" & d1 & "# and 开piao日期 < #" & d2 & "# and 数量 >= 0")
    Dim sum_sl_out As Double = dt1.Compute("sum(数量)", filter & " and 开piao日期 >= #" & d1 & "# and 开piao日期 < #" & d2 & "# and 数量 <= 0")
    ndr("上月结存_数量") = psum_sl
    ndr("本月收进_数量") = sum_sl_in
    ndr("本月付出_数量") = sum_sl_out
Next


 回到顶部