以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 汇总本月数 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=89890) |
||||
-- 作者:kaituozhe -- 发布时间:2016/8/31 18:00:00 -- 汇总本月数 For Each c As DataCol In e.DataTable.DataCols Dim Dowss As DataRow (of List) = e.DataTable.Select("摘要 = \'本月合计\'") next |
||||
-- 作者:有点蓝 -- 发布时间:2016/9/1 8:47:00 -- Dim Dowss As List(of DataRow) = e.DataTable.find("摘要 = \'本月合计\'") For Each dr As DataRow In Dowss Dim year As Integer = dr("日期").Year Dim month As Integer = dr("日期").Month Dim Date1 As Date = new Date(year,month,1) Dim Date2 As Date = new Date(year,month,Date.DaysInMonth(year,month)) For Each c As DataCol In e.DataTable.DataCols dr(c.name) = e.DataTable.Compute("sum(" & c.name & ")","日期 >= \'" & Date1 & "\' and 日期 <= \'" & Date2 & "\'") Next Next 这种直接用汇总或者分组统计好了 |
||||
-- 作者:kaituozhe -- 发布时间:2016/9/1 12:13:00 -- 此例子中有一个明细,想按月汇总,以下代码是那里出错了 If e.DataCol.Name = "摘要" AndAlso e.DataRow("摘要") = "本月合计" Then |
||||
-- 作者:kaituozhe -- 发布时间:2016/9/1 12:13:00 --
|
||||
-- 作者:kaituozhe -- 发布时间:2016/9/1 12:14:00 -- \'dr(c.name) = e.DataTable.Compute("sum(" & c.name & ")","日期 >= \'" & Date1 & "\' and 日期 <= \'" & Date2 & "\'and 摘要 <> \'本月合计\'")换成此句代码时,值就为了零了,不知道什么原因? |
||||
-- 作者:有点蓝 -- 发布时间:2016/9/1 14:26:00 -- If e.DataCol.Name = "摘要" AndAlso e.DataRow("摘要") = "本月合计" Then Dim Dowss As List(of DataRow) = e.DataTable.Select("摘要 = \'本月合计\'") For Each dr As DataRow In Dowss Dim year As Integer = dr("日期").Year Dim month As Integer = dr("日期").Month Dim Date1 As Date = new Date(year,month,1) Dim Date2 As Date = new Date(year,month,Date.DaysInMonth(year,month)) For Each c As DataCol In e.DataTable.DataCols If c.IsNumeric Then \'msgbox(Date1) \'msgbox(Date2) \'dr(c.name) = e.DataTable.Compute("sum(" & c.name & ")","日期 >= \'" & Date1 & "\' and 日期 <= \'" & Date2 & "\'and 摘要 <> \'本月合计\'") dr(c.name) = Nothing dr(c.name) = e.DataTable.Compute("sum(" & c.name & ")","日期 >= \'" & Date1 & "\' and 日期 <= \'" & Date2 & "\' ") End If Next Next End If
|
||||
-- 作者:kaituozhe -- 发布时间:2016/9/1 16:33:00 -- Select Case e.DataCol.Name 以上代码是流水账代码,黄水代码错误在那里,为什么求不出来值? |
||||
-- 作者:有点蓝 -- 发布时间:2016/9/1 16:53:00 -- 摘要 <> \'本月合计\'是会排除空值的,
|
||||
-- 作者:kaituozhe -- 发布时间:2016/9/1 20:18:00 -- 例子中的明细表,希望实现本年累计、本月合计及余额自动计算,里面怎么修改? |
||||
-- 作者:kaituozhe -- 发布时间:2016/9/1 20:18:00 --
|