以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  移动版汇总金额  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=114607)

--  作者:yifan3429
--  发布时间:2018/2/11 1:32:00
--  移动版汇总金额
Dim wb As New WeUI \'定义一个基于weui框架的网页生成器
Dim e As RequestEventArgs = args(0)
\'Dim u As String = e.cookies("name")
Dim s As String = e.cookies("部门")
\'Dim x As String = e.cookies("岗位")
\'For Each dr As DataRow In DataTables("财务流水").sqlSelect("[部门] = \'" & s & "\'","日期 Desc")
With wb.AddTable("","Table1")
    \'.MergeCols = 2 \'合并左边2列
    .Alternate = 3
    Dim nms() As String = {"经手人","编号","科目","摘要","收入","支出","日期" }
    .Head.AddRow(nms)
    For Each r As DataRow In DataTables("财务流水").sqlSelect("[部门] = \'" & s & "\'", "", "日期 Desc")
在表格的顶端生成数据汇总,汇总收入和支出 怎么编写代码呢
        With .Body.AddRow(r("经手人"),r("编号"),r("科目"),r("摘要"))
            .AddCell(Format(r("收入"),"#0.00"))
            .AddCell(Format(r("支出"),"#0.00"))
            .AddCell(Format(r("日期"),"MM月dd日"))
        End With
    Next
End With
e.WriteString(wb.Build)


搞不清了

Dim wb As New WeUI \'定义一个基于weui框架的网页生成器
Dim e As RequestEventArgs = args(0)
\'Dim u As String = e.cookies("name")
Dim s As String = e.cookies("部门")
\'Dim x As String = e.cookies("岗位")
\'For Each dr As DataRow In DataTables("财务流水").sqlSelect("[部门] = \'" & s & "\'","日期 Desc")
With wb.AddTable("","Table1")
    \'.MergeCols = 2 \'合并左边2列
    .Alternate = 3
    Dim nms() As String = {"经手人","编号","科目","摘要","收入","支出","日期" }
    .Head.AddRow(nms)
    Dim qty As Integer
    Dim amt As Double
    For i As Integer = 0 To dt.DataRows.count - 1
        Dim r As DataRow = dt.DataRows(i)
        If i > 0 Then
            Dim lr As DataRow = dt.DataRows(i-1)
            If r("科目") <> lr("科目") Then
                qty = dt.compute("sum(收入)","收入=\'" & lr("收入") & "\' )
                amt = dt.compute("sum(支出)","支出=\'" & lr("支出") & "\')
                With .Body.AddRow()
                    .Attribute = "style=\'background-color:#F0FFFF\'"
                    .AddCell("小计 " & lr("科目"),"colspan=\'3\'")
                    .AddCells(qty,"",amt,"")
                End With
                Next
                For Each r As DataRow In DataTables("财务流水").sqlSelect("[部门] = \'" & s & "\'", "", "日期 Desc")
                    With .Body.AddRow(r("经手人"),r("编号"),r("科目"),r("摘要"))
                        .AddCell(Format(r("收入"),"#0.00"))
                        .AddCell(Format(r("支出"),"#0.00"))
                        .AddCell(Format(r("日期"),"MM月dd日"))
                    End With
                Next
            End With
            e.WriteString(wb.Build)

--  作者:有点蓝
--  发布时间:2018/2/11 10:21:00
--  
.Head.AddRow(nms)
.body.AddRow("汇总","","","",DataTables("财务流水").compute("sum(收入)","[部门] = \'" & s & "\'"),DataTables("财务流水").compute("sum(支出)","[部门] = \'" & s & "\'"))
For Each r As DataRow In DataTables("财务流水").sqlSelect("[部门] = \'" & s & "\'", "", "日期 Desc")
    With .Body.AddRow(r("经手人"),r("编号"),r("科目"),r("摘要"))
        .AddCell(Format(r("收入"),"#0.00"))
        .AddCell(Format(r("支出"),"#0.00"))
        .AddCell(Format(r("日期"),"MM月dd日"))
    End With
Next
[此贴子已经被作者于2018/2/11 10:22:33编辑过]

--  作者:yifan3429
--  发布时间:2018/2/23 3:34:00
--  
.NET Framework 版本:2.0.50727.8762
Foxtable 版本:2017.12.31.1
错误所在事件:自定义函数财务流水
详细错误信息:
调用的目标发生了异常。
未将对象引用设置到对象的实例。
Dim wb As New WeUI \'定义一个基于weui框架的网页生成器
Dim e As RequestEventArgs = args(0)
Dim u As String = e.cookies("name")
With wb.AddTable("","Table1")
    .Alternate = 3
    Dim nms() As String = {"自编号","科目名称","摘要","收入","支出","日期" }
    .Head.AddRow(nms)
    .body.AddRow("汇总","","","",DataTables("财务流水").compute("sum(收入)","[经手人] = \'" & u & "\'"),DataTables("财务流水").compute("sum(支出)","[经手人] = \'" & u & "\'"))
     .body.AddRow("汇总","","","",DataTables("财务流水").compute("sum(收入)","[部门] = \'" & s & "\'"),DataTables("财务流水").compute("sum(支出)","[部门] = \'" & s & "\'"))
    For Each r As DataRow In DataTables("财务流水").sqlSelect("[经手人] = \'" & u & "\'", "", "日期 Desc")
        With .Body.AddRow(r("自编号"),r("科目名称"),r("摘要"))
            .AddCell(Format(r("收入"),"#0.00"))
            .AddCell(Format(r("支出"),"#0.00"))
            .AddCell(Format(r("日期"),"MM月dd日"))
        End With
    Next
End With
e.WriteString(wb.Build)
[此贴子已经被作者于2018/2/23 3:35:40编辑过]

--  作者:有点甜
--  发布时间:2018/2/23 9:01:00
--  

改成

 

dim sum1 as double = val(DataTables("财务流水").compute("sum(收入)","[部门] = \'" & s & "\'"))
dim sum2 as double = val(DataTables("财务流水").compute("sum(支出)","[部门] = \'" & s & "\'"))
.body.AddRow("汇总","","","",sum1,sum2)