以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  动态列动态更新  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=81332)

--  作者:kaituozhe
--  发布时间:2016/2/24 21:31:00
--  动态列动态更新

Dim tb As DataTable = DataTables("会计科目")
If e.DataCol.name = "会计年度" And e.newvalue IsNot Nothing Then
    For Each c As DataCol In e.DataTable.DataCols
        If c.name <> "会计年度" AndAlso c.name <> "审核"  Then
msgbox(c.name)
            If tb.find("资产负债表 = \'" & c.name & "\'").Isnull("资产负债表包含科目") = True Then
msgbox(1)
                \'If c.name <> "会计年度" AndAlso c.name <> "审核" AndAlso c.name <> "应收款项" AndAlso c.name <> "应付款项" AndAlso c.name <> "固定资产原价" AndAlso c.name <> "未分配收益"  AndAlso c.name <> "货币资金" AndAlso c.name <> "存货"  Then
                e.DataRow(c.name) = DataTables("余额横表未审").Compute("sum(" & c.name & ")","会计年度 = \'" & e.DataRow("会计年度") & "\'")
           msgbox(2)    
            Else
                Dim lis As List(of String) =tb.find("科目名称 = \'" & c.name & "\'")("资产负债表包含科目")
                Dim sum As Double
                For Each li As String In lis
                    sum = sum + DataTables("余额横表未审").Compute("sum(" & li & ")","会计年度 = \'" & e.DataRow("会计年度") & "\'")
                Next
                e.DataRow(c.name) = sum
            End If
        End If
    Next
    e.DataRow("应收款项") = DataTables("余额横表未审").Compute("sum(应收款)","会计年度 = \'" & e.DataRow("会计年度") & "\'")
    e.DataRow("应付款项") = DataTables("余额横表未审").Compute("sum(应付款)","会计年度 = \'" & e.DataRow("会计年度") & "\'")
    e.DataRow("固定资产原价") = DataTables("余额横表未审").Compute("sum(固定资产)","会计年度 = \'" & e.DataRow("会计年度") & "\'")
    e.DataRow("未分配收益") = DataTables("余额横表未审").Compute("sum(本年收益)","会计年度 = \'" & e.DataRow("会计年度") & "\'")+DataTables("余额横表未审").Compute("sum(收益分配)","会计年度 = \'" & e.DataRow("会计年度") & "\'")
    e.DataRow("货币资金") = DataTables("余额横表未审").Compute("sum(库存现金)","会计年度 = \'" & e.DataRow("会计年度") & "\'")+DataTables("余额横表未审").Compute("sum(银行存款)","会计年度 = \'" & e.DataRow("会计年度") & "\'")+DataTables("余额横表未审").Compute("sum(授权支付用款额度)","会计年度 = \'" & e.DataRow("会计年度") & "\'")
   
End If

以上代码在黄色部分是提示错误,该怎么修改

.NET Framework 版本:2.0.50727.5485
Foxtable 版本:2015.12.22.1
错误所在事件:表,资产负债表未审,DataColChanged
详细错误信息:
调用的目标发生了异常。
未将对象引用设置到对象的实例。


--  作者:大红袍
--  发布时间:2016/2/24 22:28:00
--  

Dim fdr As DataRow = tb.find("资产负债表 = \'" & c.name & "\'")

If fdr IsNot Nothing AndAlso fdr.Isnull("资产负债表包含科目") Then


--  作者:kaituozhe
--  发布时间:2016/2/24 22:51:00
--  
还是不行
--  作者:大红袍
--  发布时间:2016/2/24 22:52:00
--  

不可能是2楼代码那里错。


--  作者:kaituozhe
--  发布时间:2016/2/25 0:12:00
--  

修改后还是提示如下

.NET Framework 版本:2.0.50727.5485
Foxtable 版本:2015.12.22.1
错误所在事件:表,资产负债表未审,DataColChanged
详细错误信息:
调用的目标发生了异常。
未将对象引用设置到对象的实例。


--  作者:kaituozhe
--  发布时间:2016/2/25 0:20:00
--  
Dim tb As DataTable = DataTables("会计科目")
If e.DataCol.name = "会计年度" And e.newvalue IsNot Nothing Then
    For Each c As DataCol In e.DataTable.DataCols
        If c.name <> "会计年度" AndAlso c.name <> "审核"  Then
            msgbox(c.name)
            \'Dim fdr As DataRow = tb.find("资产负债表 = \'" & c.name & "\'")
Dim fdr As DataRow = tb.find("资产负债表 = \'货币资金\'")
msgbox(1)
            If fdr IsNot Nothing AndAlso fdr.Isnull("资产负债表包含科目") = True Then
   msgbox(2)            
                \'If tb.find("资产负债表 = \'" & c.name & "\'").Isnull("资产负债表包含科目") = True Then
               
                \'If c.name <> "会计年度" AndAlso c.name <> "审核" AndAlso c.name <> "应收款项" AndAlso c.name <> "应付款项" AndAlso c.name <> "固定资产原价" AndAlso c.name <> "未分配收益"  AndAlso c.name <> "货币资金" AndAlso c.name <> "存货"  Then
                e.DataRow(c.name) = DataTables("余额横表未审").Compute("sum(" & c.name & ")","会计年度 = \'" & e.DataRow("会计年度") & "\'")
                msgbox(2)
            Else
                Dim lis As List(of String) =tb.find("科目名称 = \'" & c.name & "\'")("资产负债表包含科目")
                Dim sum As Double
                For Each li As String In lis
                    sum = sum + DataTables("余额横表未审").Compute("sum(" & li & ")","会计年度 = \'" & e.DataRow("会计年度") & "\'")
                Next
                e.DataRow(c.name) = sum
            End If
        End If
    Next
    e.DataRow("应收款项") = DataTables("余额横表未审").Compute("sum(应收款)","会计年度 = \'" & e.DataRow("会计年度") & "\'")
    e.DataRow("应付款项") = DataTables("余额横表未审").Compute("sum(应付款)","会计年度 = \'" & e.DataRow("会计年度") & "\'")
    e.DataRow("固定资产原价") = DataTables("余额横表未审").Compute("sum(固定资产)","会计年度 = \'" & e.DataRow("会计年度") & "\'")
    e.DataRow("未分配收益") = DataTables("余额横表未审").Compute("sum(本年收益)","会计年度 = \'" & e.DataRow("会计年度") & "\'")+DataTables("余额横表未审").Compute("sum(收益分配)","会计年度 = \'" & e.DataRow("会计年度") & "\'")
    e.DataRow("货币资金") = DataTables("余额横表未审").Compute("sum(库存现金)","会计年度 = \'" & e.DataRow("会计年度") & "\'")+DataTables("余额横表未审").Compute("sum(银行存款)","会计年度 = \'" & e.DataRow("会计年度") & "\'")+DataTables("余额横表未审").Compute("sum(授权支付用款额度)","会计年度 = \'" & e.DataRow("会计年度") & "\'")
   
End If

--  作者:Hyphen
--  发布时间:2016/2/25 8:27:00
--  
......
            Else
                Dim dr As DataRow = tb.find("科目名称 = \'" & c.name & "\'")
                If dr IsNot Nothing Then
                    Dim lis As List(of String) = dr("资产负债表包含科目")
                    Dim sum As Double
                    For Each li As String In lis
                        sum = sum + DataTables("余额横表未审").Compute("sum(" & li & ")","会计年度 = \'" & e.DataRow("会计年度") & "\'")
                    Next
                    e.DataRow(c.name) = sum
                End If
            End If
......

--  作者:kaituozhe
--  发布时间:2016/2/25 10:27:00
--  

Dim tb As DataTable = DataTables("会计科目")
If e.DataCol.name = "会计年度" And e.newvalue IsNot Nothing Then
    For Each c As DataCol In e.DataTable.DataCols
        If c.name <> "会计年度" AndAlso c.name <> "审核"  Then
            msgbox(c.name)
            \'Dim fdr As DataRow = tb.find("资产负债表 = \'" & c.name & "\'")

msgbox(1)
            If tb.find("资产负债表 = \'" & c.name & "\'")("表包含科目") Is Nothing Then
   msgbox(2)            
                \'If tb.find("资产负债表 = \'" & c.name & "\'").Isnull("资产负债表包含科目") = True Then
               
                \'If c.name <> "会计年度" AndAlso c.name <> "审核" AndAlso c.name <> "应收款项" AndAlso c.name <> "应付款项" AndAlso c.name <> "固定资产原价" AndAlso c.name <> "未分配收益"  AndAlso c.name <> "货币资金" AndAlso c.name <> "存货"  Then
                e.DataRow(c.name) = DataTables("余额横表未审").Compute("sum(" & c.name & ")","会计年度 = \'" & e.DataRow("会计年度") & "\'")
                msgbox(2)
            Else
                Dim lis As List(of String) =tb.find("科目名称 = \'" & c.name & "\'")("表包含科目")
                Dim sum As Double
                For Each li As String In lis
                    sum = sum + DataTables("余额横表未审").Compute("sum(" & li & ")","会计年度 = \'" & e.DataRow("会计年度") & "\'")
                Next
                e.DataRow(c.name) = sum
            End If
        End If
    Next
    e.DataRow("应收款项") = DataTables("余额横表未审").Compute("sum(应收款)","会计年度 = \'" & e.DataRow("会计年度") & "\'")
    e.DataRow("应付款项") = DataTables("余额横表未审").Compute("sum(应付款)","会计年度 = \'" & e.DataRow("会计年度") & "\'")
    e.DataRow("固定资产原价") = DataTables("余额横表未审").Compute("sum(固定资产)","会计年度 = \'" & e.DataRow("会计年度") & "\'")
    e.DataRow("未分配收益") = DataTables("余额横表未审").Compute("sum(本年收益)","会计年度 = \'" & e.DataRow("会计年度") & "\'")+DataTables("余额横表未审").Compute("sum(收益分配)","会计年度 = \'" & e.DataRow("会计年度") & "\'")
    e.DataRow("货币资金") = DataTables("余额横表未审").Compute("sum(库存现金)","会计年度 = \'" & e.DataRow("会计年度") & "\'")+DataTables("余额横表未审").Compute("sum(银行存款)","会计年度 = \'" & e.DataRow("会计年度") & "\'")+DataTables("余额横表未审").Compute("sum(授权支付用款额度)","会计年度 = \'" & e.DataRow("会计年度") & "\'")
   
End If

提示错误的是红色部分


--  作者:大红袍
--  发布时间:2016/2/25 10:39:00
--  
 无语,看楼上已经给你答案了啊,要判断是否找到对应的行啊
--  作者:kaituozhe
--  发布时间:2016/2/25 10:59:00
--  

.NET Framework 版本:2.0.50727.5485
Foxtable 版本:2015.12.22.1
错误所在事件:表,资产负债表未审,DataColChanged
详细错误信息:
调用的目标发生了异常。
无法将类型为“System.String”的对象强制转换为类型“System.Collections.Generic.List`1[System.String]”。

可能是以下代码的原因,资产负债表包含科目列包含的内容为  银行存款,库存现金,其他货币资金 怎么修改
  Dim lis As List(of String) = dr("资产负债表包含科目")