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


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

主题:统计转移

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


加好友 发短信
等级:二尾狐 帖子:573 积分:2961 威望:0 精华:0 注册:2016/10/27 14:33:00
  发帖心情 Post By:2016/11/3 12:05:00 [显示全部帖子]

Dim dt_tj As DataTable = DataTables("统计")
Dim dt_dd As DataTable = DataTables("订单")
Dim dt_zc As DataTable = DataTables("支出")

dt_tj.DataRows.Clear
Dim minDD As Date = dt_dd.compute("min(日期)")
Dim minZC As Date = dt_zc.compute("min(日期)")
Dim maxDD As Date = dt_dd.compute("max(日期)")
Dim maxZC As Date = dt_zc.compute("max(日期)")

Dim minDate As Date = iif(minDD<minZC, minDD, minZC)
Dim maxDate As Date = iif(maxDD>maxZC, maxDD, maxZC)

For i As Integer = minDate.Year To maxDate.Year
    For j As Integer = 1 To 12
        Dim ndr As DataRow = dt_tj.AddNew
        Dim d As Date = new Date(i, j, 1)
        Dim filter As String = "日期 >= #" & d & "# and 日期 < #" & d.AddMonths(1) & "#"
        ndr("年份") = i
        ndr("月份") = j
        ndr("订单_数量") = dt_dd.compute("sum(数量)", filter)
        ndr("订单_价格") = dt_dd.compute("sum(价格)", filter)
        Dim fdr As DataRow = dt_dd.Find(filter, "日期 desc")
        If fdr IsNot Nothing Then
            ndr("订单_预留价格") = fdr("预留价格")
        Else
            ndr("订单_预留价格") = 0
        End If
        ndr("支出_数量") = dt_zc.compute("sum(次数)", filter)
        ndr("支出_单价") = dt_zc.compute("sum(单价)", filter)
        fdr = dt_zc.Find(filter, "日期 desc")
        If fdr IsNot Nothing Then
            ndr("支出_预留单价") = fdr("预留单价")
        Else
            ndr("支出_预留单价") = 0
        End If
    Next
Next


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


加好友 发短信
等级:二尾狐 帖子:573 积分:2961 威望:0 精华:0 注册:2016/10/27 14:33:00
  发帖心情 Post By:2016/11/3 12:25:00 [显示全部帖子]

Dim dt_tj As DataTable = DataTables("统计")
Dim dt_dd As DataTable = DataTables("订单")
Dim dt_zc As DataTable = DataTables("支出")

dt_tj.DataRows.Clear
Dim minDD As Date = dt_dd.compute("min(日期)")
Dim minZC As Date = dt_zc.compute("min(日期)")
Dim maxDD As Date = dt_dd.compute("max(日期)")
Dim maxZC As Date = dt_zc.compute("max(日期)")

Dim minDate As Date = iif(minDD<minZC, minDD, minZC)
Dim maxDate As Date = iif(maxDD>maxZC, maxDD, maxZC)

For i As Integer = minDate.Year To maxDate.Year
    For j As Integer = 1 To 12
        Dim ndr As DataRow = dt_tj.AddNew
        Dim d As Date = new Date(i, j, 1)
        Dim filter As String = "日期 >= #" & d & "# and 日期 < #" & d.AddMonths(1) & "#"
        ndr("年份") = i
        ndr("月份") = j
        ndr("订单_数量") = val(dt_dd.compute("sum(数量)", filter))
        ndr("订单_价格") = val(dt_dd.compute("sum(价格)", filter))
        Dim fdr As DataRow = dt_dd.Find(filter, "日期 desc")
        If fdr IsNot Nothing Then
            ndr("订单_预留价格") = fdr("预留价格")
        Else
            ndr("订单_预留价格") = 0
        End If
        ndr("支出_数量") = val(dt_zc.compute("sum(次数)", filter))
        ndr("支出_单价") = val(dt_zc.compute("sum(单价)", filter))
        fdr = dt_zc.Find(filter, "日期 desc")
        If fdr IsNot Nothing Then
            ndr("支出_预留单价") = fdr("预留单价")
        Else
            ndr("支出_预留单价") = 0
        End If
    Next
Next


 回到顶部