以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  datacolchanged报错  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=130901)

--  作者:lfz123
--  发布时间:2019/2/11 11:40:00
--  datacolchanged报错
报错提示: 麻烦老师帮我看下! 其他功能都已经实现,就是会有这个报错,但不影响结果

图片点击可在新窗口打开查看此主题相关图片如下:错误提示.png
图片点击可在新窗口打开查看

我在凭证明细的DataColChanged事件中写了如下代码:

If e.DataCol.name = "科目代码" Then

    If e.DataRow.IsNull("科目代码") Then

        e.DataRow("会计科目_一级科目") = ""

        e.DataRow("会计科目_明细科目") = ""

    Else

        Dim str As String = e.DataRow("科目代码")

        If str.Length = 4 Then

            Dim dr As DataRow = DataTables("会计科目").find("科目代码 = \'"& e.datarow("科目代码") & "\'")

            e.DataRow("会计科目_一级科目") = dr("科目名称")

            e.DataRow("会计科目_明细科目") = ""

        Else

            Dim str1 As String = str.SubString(0,4)

            Dim dr1 As DataRow = DataTables("会计科目").find("科目代码 = \'"& str1 & "\'")

            e.DataRow("会计科目_一级科目") = dr1("科目名称")

            Dim dr2 As DataRow = DataTables("会计科目").find("科目代码 = \'"& str & "\'")

            e.DataRow("会计科目_明细科目") = dr2("科目名称")

        End If

    End If

End If


在窗口的按钮中写了如下代码:

Dim t As Table =  Tables("凭证.凭证明细")

t.AddNew(2)

t.Rows(0)("科目代码") = "1211001"

t.Rows(1)("科目代码") = "217100101"

Dim str As String = Forms("凭证录入").Controls("lb凭证ID").text

Dim dt As DataTable = Tables("进项票_table1").DataTable

For Each id As String In dt.GetValues("科目代码","凭证ID = \'"& str & "\'")

    Dim r As Row = Tables("凭证.凭证明细").AddNew()

    r("科目代码") = id

    r("贷方金额") = dt.Compute("sum(发票金额)","科目代码= \'"& id & "\'and 凭证ID = \'"& str & "\'")

    Dim dr As DataRow = dt.find("科目代码= \'"& id & "\'and 凭证ID = \'"& str & "\'")

    r("摘要") = dr("销方名称").Substring(0,6) & "购:" & dr("发票摘要")

Next


t.Rows(0)("借方金额") = dt.Compute("sum(金额)","凭证ID = \'"& str & "\'")

t.Rows(1)("借方金额") = dt.Compute("sum(税额)","凭证ID = \'"& str & "\'")


Dim s As String = dt.GetComboListString("发票摘要","凭证ID = \'"& str & "\'")

s = s.Replace("|"," ")

t.Rows(0)("摘要") = "购:" & s 

t.Rows(1)("摘要") = "进项税:" & s


--  作者:有点甜
--  发布时间:2019/2/11 11:51:00
--  
If e.DataCol.name = "科目代码" Then    
    If e.DataRow.IsNull("科目代码") Then
       
        e.DataRow("会计科目_一级科目") = ""
       
        e.DataRow("会计科目_明细科目") = ""
       
    Else
       
        Dim str As String = e.DataRow("科目代码")
       
        If str.Length = 4 Then
           
            Dim dr As DataRow = DataTables("会计科目").find("科目代码 = \'"& e.datarow("科目代码") & "\'")
            If dr IsNot Nothing Then
                e.DataRow("会计科目_一级科目") = dr("科目名称")
            End If
            e.DataRow("会计科目_明细科目") = ""
           
        Else
           
            Dim str1 As String = str.SubString(0,4)
           
            Dim dr1 As DataRow = DataTables("会计科目").find("科目代码 = \'"& str1 & "\'")
            If dr1 IsNot Nothing Then
                e.DataRow("会计科目_一级科目") = dr1("科目名称")
            End If
            Dim dr2 As DataRow = DataTables("会计科目").find("科目代码 = \'"& str & "\'")
            If dr2 IsNot Nothing Then
                e.DataRow("会计科目_明细科目") = dr2("科目名称")
            End If
        End If        
    End If   
End If

--  作者:lfz123
--  发布时间:2019/2/11 12:22:00
--  
知道了,知道了,老师视频里面也讲过,好像有find,都需要做这个条件判断,我忘记了