以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  天统计  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=127582)

--  作者:yangwenghd
--  发布时间:2018/11/17 10:40:00
--  天统计

图片点击可在新窗口打开查看此主题相关图片如下:qq截图20181117103237.jpg
图片点击可在新窗口打开查看
老师 能帮忙看看这个填统计吗?在DateTimePicker1输入日期,然后把表a和表b对应月的天统计到表c
比如DateTimePicker1输入的是2018-10-xx,然后表c的统计时间列,输入2018年10月的1-31日,(就是DateTimePicker1月的每天,)然后表c的数据一和数据二的表a和表b的每天合计
昨天晚上我上次月统计的复制出来改,结果搞了一个晚上也没有搞出来,麻烦了,老师 ,感谢 感谢 
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:天统计.table



--  作者:y2287958
--  发布时间:2018/11/17 11:46:00
--  
DataTables("表C").DataRows.Clear
Dim DateTimePicker1 As WinForm.DateTimePicker = Forms("窗口1").Controls("DateTimePicker1")
Dim d1 As Date = new Date(DateTimePicker1.Value.Year,DateTimePicker1.Value.Month,1)
Dim d2 As Date = d1.AddMonths(1).AddDays(-1)
For i As Integer = 0 To d2.Day - 1
    Dim dr As DataRow = DataTables("表C").AddNew
    dr("统计时间") = d1.AddDays(i)
    dr("统计金额表一") = DataTables("表A").Compute("Sum(金额)","时间=#" & d1.AddDays(i) & "#")
    dr("统计金额表二") = DataTables("表B").Compute("Sum(变动金额)","变动日期=#" & d1.AddDays(i) & "#")
Next


--  作者:yangwenghd
--  发布时间:2018/11/17 15:01:00
--  
能在帮忙看看这个吗?感谢 感谢 就是没有得到数据的行都为0 感谢 感谢 
DataTables("日统计").DataRows.Clear
Dim DateTimePicker1 As WinForm.DateTimePicker = Forms("财务汇总窗口").Controls("DateTimePicker11")
Dim d1 As Date = new Date(DateTimePicker1.Value.Year,DateTimePicker1.Value.Month,1)
Dim d2 As Date = d1.AddMonths(1).AddDays(-1)
For i As Integer = 0 To d2.Day - 1
    Dim dr As DataRow = DataTables("日统计").AddNew
    dr("统计日期") = d1.AddDays(i)
    If dr IsNot Nothing Then
        dr("收_其它") = DataTables("其它收入").Compute("Sum(收入金额)","收入时间=#" & d1.AddDays(i) & "#")
    Else
        dr("收_其它") = 0
        dr("支_对公") = DataTables("支出账目").Compute("Sum(合计价格)","支出日期=#" & d1.AddDays(i) & "#")
    Else
        dr("支_对公") = 0
        dr("支_对私") = DataTables("支出明细").Compute("Sum(支出金额)","变动日期=#" & d1.AddDays(i) & "#")
    Else
        dr("支_对私") = 0
    Next
End If

--  作者:有点蓝
--  发布时间:2018/11/17 15:38:00
--  
DataTables("日统计").DataRows.Clear
Dim DateTimePicker1 As WinForm.DateTimePicker = Forms("财务汇总窗口").Controls("DateTimePicker11")
Dim d1 As Date = new Date(DateTimePicker1.Value.Year,DateTimePicker1.Value.Month,1)
Dim d2 As Date = d1.AddMonths(1).AddDays(-1)
For i As Integer = 0 To d2.Day - 1
    Dim dr As DataRow = DataTables("日统计").AddNew
    dr("统计日期") = d1.AddDays(i)
    dr("收_其它") = DataTables("其它收入").Compute("Sum(收入金额)","收入时间=#" & d1.AddDays(i) & "#")
    dr("支_对公") = DataTables("支出账目").Compute("Sum(合计价格)","支出日期=#" & d1.AddDays(i) & "#")
    dr("支_对私") = DataTables("支出明细").Compute("Sum(支出金额)","变动日期=#" & d1.AddDays(i) & "#")
Next

--  作者:yangwenghd
--  发布时间:2018/11/17 15:54:00
--  
谢谢 老师 ,空白的行还是空白呢,可以设置为没有得到数据的行都为零吗?感谢 感谢 
比如
  dr("统计日期") = d1.AddDays(i)
    If dr IsNot Nothing Then
        dr("收_其它") = DataTables("其它收入").Compute("Sum(收入金额)","收入时间=#" & d1.AddDays(i) & "#")
    Else
        dr("收_其它") = 0

在输入时间列 不是每天都有,如果没有时间的就默认为0 感谢 感谢 

--  作者:有点蓝
--  发布时间:2018/11/17 16:04:00
--  
For i As Integer = 0 To d2.Day - 1
    Dim dr As DataRow = DataTables("日统计").AddNew
    dr("统计日期") = d1.AddDays(i)
dim sum as double = DataTables("其它收入").Compute("Sum(收入金额)","收入时间=#" & d1.AddDays(i) & "#")
    dr("收_其它") = sum
sum = DataTables("支出账目").Compute("Sum(合计价格)","支出日期=#" & d1.AddDays(i) & "#")
    dr("支_对公") = sum 
sum = DataTables("支出明细").Compute("Sum(支出金额)","变动日期=#" & d1.AddDays(i) & "#")
    dr("支_对私") = sum
Next

--  作者:y2287958
--  发布时间:2018/11/17 16:10:00
--  
简单粗暴点
DataTables("日统计").DataRows.Clear
Dim DateTimePicker1 As WinForm.DateTimePicker = Forms("财务汇总窗口").Controls("DateTimePicker11")
Dim d1 As Date = new Date(DateTimePicker1.Value.Year,DateTimePicker1.Value.Month,1)
Dim d2 As Date = d1.AddMonths(1).AddDays(-1)
For i As Integer = 0 To d2.Day - 1
    Dim dr As DataRow = DataTables("日统计").AddNew
    dr("统计日期") = d1.AddDays(i)
    dr("收_其它") = DataTables("其它收入").Compute("Sum(收入金额)","收入时间=#" & d1.AddDays(i) & "#")
    dr("支_对公") = DataTables("支出账目").Compute("Sum(合计价格)","支出日期=#" & d1.AddDays(i) & "#")
    dr("支_对私") = DataTables("支出明细").Compute("Sum(支出金额)","变动日期=#" & d1.AddDays(i) & "#")
Next
DataTables("日统计").ReplaceFor("收_其它",0,"收_其它 is null")
DataTables("日统计").ReplaceFor("支_对公",0,"支_对公 is null")
DataTables("日统计").ReplaceFor("支_对私",0,"支_对私 is null")