以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  跨表应用代码报错  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=79682)

--  作者:jamhuton
--  发布时间:2016/1/7 11:14:00
--  跨表应用代码报错
错误信息:
.NET Framework 版本:2.0.50727.5485
Foxtable 版本:2015.12.22.1
错误所在事件:表,账单明细,DataColChanged
详细错误信息:
调用的目标发生了异常。
未将对象引用设置到对象的实例。


被引用表:
Select Case e.DataCol.Name
    Case "客户简称","到港日期","报关单号码","船名航次","提单号码","运输方式","箱量","贸易方式","件数","起运港","抵达港","重量","品名","月份"     
        Dim Filter As String = "[发票号码] = \'" & e.DataRow("发票号码") & "\'"
        Dim drs As List(Of DataRow) = DataTables("账单明细").Select(Filter)
        For Each dr As DataRow In drs
            dr(e.DataCol.Name) = e.NewValue
        Next
End Select

引用表:

If e.DataCol.Name = "发票号码" Then
    If e.NewValue Is Nothing Then
        e.DataRow("客户简称") = Nothing
        e.DataRow("到港日期") = Nothing
        e.DataRow("报关单号码") = Nothing
        e.DataRow("船名航次") = Nothing
        e.DataRow("提单号码") = Nothing
        e.DataRow("运输方式") = Nothing
        e.DataRow("箱量") = Nothing
        e.DataRow("贸易方式") = Nothing
        e.DataRow("件数") = Nothing
        e.DataRow("起运港") = Nothing
        e.DataRow("抵达港") = Nothing
        e.DataRow("重量") = Nothing
        e.DataRow("品名") = Nothing
        e.DataRow("月份") = Nothing
    Else
        Dim dr As DataRow
        dr = DataTables("进口业务进度表").Find("[发票号码] = \'" & e.NewValue & "\'")
        If dr IsNot Nothing
            e.DataRow("客户简称") = dr("客户简称")
            e.DataRow("到港日期") = dr("到港日期")
            e.DataRow("报关单号码") = dr("报关单号码")
            e.DataRow("船名航次") = dr("船名航次")
            e.DataRow("提单号码") = dr("提单号码")
            e.DataRow("运输方式") = dr("运输方式")
            e.DataRow("箱量") = dr("箱量")
            e.DataRow("贸易方式") = dr("贸易方式")
            e.DataRow("件数") = dr("件数")
            e.DataRow("起运港") = dr("起运港")
            e.DataRow("抵达港") = dr("抵达港")
            e.DataRow("重量") = dr("重量")
            e.DataRow("品名") = dr("品名")
            e.DataRow("月份") = dr("月份")
        End If
    End If
End If





--  作者:大红袍
--  发布时间:2016/1/7 11:22:00
--  

If e.NewValue Is Nothing Then

 

改成

 

If e.NewValue = Nothing Then

 

不行,就做个例子上来测试。


--  作者:jamhuton
--  发布时间:2016/1/7 12:33:00
--  
图片点击可在新窗口打开查看图片点击可在新窗口打开查看图片点击可在新窗口打开查看
做了个例子没问题
图片点击可在新窗口打开查看图片点击可在新窗口打开查看图片点击可在新窗口打开查看


--  作者:jamhuton
--  发布时间:2016/1/7 12:38:00
--  
If e.DataCol.Name = "发票号码" Then
    If e.NewValue Is Nothing Then
        e.DataRow("客户简称") = Nothing
        e.DataRow("到港日期") = Nothing
        e.DataRow("报关单号码") = Nothing
        e.DataRow("船名航次") = Nothing
        e.DataRow("提单号码") = Nothing
        e.DataRow("运输方式") = Nothing
        e.DataRow("箱量") = Nothing
        e.DataRow("贸易方式") = Nothing
        e.DataRow("件数") = Nothing
        e.DataRow("起运港") = Nothing
        e.DataRow("抵达港") = Nothing
        e.DataRow("重量") = Nothing
        e.DataRow("品名") = Nothing
        e.DataRow("月份") = Nothing
    Else
        Dim dr As DataRow
        dr = DataTables("进口业务进度表").Find("[发票号码] = \'" & e.NewValue & "\'")
        If dr IsNot Nothing
            e.DataRow("客户简称") = dr("客户简称")
            e.DataRow("到港日期") = dr("到港日期")
            e.DataRow("报关单号码") = dr("报关单号码")
            e.DataRow("船名航次") = dr("船名航次")
            e.DataRow("提单号码") = dr("提单号码")
            e.DataRow("运输方式") = dr("运输方式")
            e.DataRow("箱量") = dr("箱量")
            e.DataRow("贸易方式") = dr("贸易方式")
            e.DataRow("件数") = dr("件数")
            e.DataRow("起运港") = dr("起运港")
            e.DataRow("抵达港") = dr("抵达港")
            e.DataRow("重量") = dr("重量")
            e.DataRow("品名") = dr("品名")
            e.DataRow("月份") = dr("月份")
        End If
    End If
End If

If e.DataCol.Name = "发票号码" Then
    If e.NewValue Is Nothing Then
        e.DataRow("客户简称") = Nothing
        e.DataRow("到港日期") = Nothing
        e.DataRow("报关单号码") = Nothing
        e.DataRow("船名航次") = Nothing
        e.DataRow("提单号码") = Nothing
        e.DataRow("运输方式") = Nothing
        e.DataRow("箱量") = Nothing
        e.DataRow("贸易方式") = Nothing
        e.DataRow("件数") = Nothing
        e.DataRow("起运港") = Nothing
        e.DataRow("抵达港") = Nothing
        e.DataRow("重量") = Nothing
        e.DataRow("品名") = Nothing
        e.DataRow("月份") = Nothing
    Else
        Dim dr As DataRow
        dr = DataTables("进口业务登记").Find("[发票号码] = \'" & e.NewValue & "\'")
        If dr IsNot Nothing
            e.DataRow("客户简称") = dr("客户简称")
            e.DataRow("到港日期") = dr("到港日期")
            e.DataRow("报关单号码") = dr("报关单号码")
            e.DataRow("船名航次") = dr("船名航次")
            e.DataRow("提单号码") = dr("提单号码")
            e.DataRow("运输方式") = dr("运输方式")
            e.DataRow("箱量") = dr("箱量")
            e.DataRow("贸易方式") = dr("贸易方式")
            e.DataRow("件数") = dr("件数")
            e.DataRow("起运港") = dr("起运港")
            e.DataRow("抵达港") = dr("抵达港")
            e.DataRow("重量") = dr("重量")
            e.DataRow("品名") = dr("品名")
            e.DataRow("月份") = dr("月份")
        End If
    End If
End If


If e.DataCol.Name = "发票号码" Then
    If e.NewValue Is Nothing Then
        e.DataRow("制单费") = Nothing
        e.DataRow("垫付税金") = Nothing
        e.DataRow("商检费") = Nothing
        e.DataRow("商检费air") = Nothing
        e.DataRow("销毁费") = Nothing
        e.DataRow("换包装") = Nothing
        e.DataRow("换单费") = Nothing
        e.DataRow("仓储费") = Nothing
        e.DataRow("疏港费") = Nothing
        e.DataRow("超期费") = Nothing
        e.DataRow("污箱费") = Nothing
        e.DataRow("装卸费") = Nothing
        e.DataRow("查验费") = Nothing
    Else
        Dim dr As DataRow
        dr = DataTables("成本明细").Find("[发票号码] = \'" & e.NewValue & "\'")
        If dr IsNot Nothing
            e.DataRow("制单费") = dr("制单费")
            e.DataRow("垫付税金") = dr("垫付税金")
            e.DataRow("商检费") = dr("商检费")
            e.DataRow("商检费air") = dr("商检费air")
            e.DataRow("销毁费") = dr("销毁费")
            e.DataRow("换包装") = dr("换包装")
            e.DataRow("换单费") = dr("换单费")
            e.DataRow("仓储费") = dr("仓储费")
            e.DataRow("疏港费") = dr("疏港费")
            e.DataRow("超期费") = dr("超期费")
            e.DataRow("污箱费") = dr("污箱费")
            e.DataRow("装卸费") = dr("装卸费")
            e.DataRow("查验费") = dr("查验费")
        End If
    End If
End If




If e.DataCol.Name = "发票号码" Then
    If e.NewValue Is Nothing Then
        e.DataRow("海关查验") = Nothing
    Else
        Dim dr As DataRow
        dr = DataTables("进口业务进度表").Find("[发票号码] = \'" & e.NewValue & "\'")
        If dr("海关查验") = True
            e.DataRow("海关查验") = 500
        End If
    End If
End If

If e.DataCol.Name = "发票号码" Then
    If e.NewValue Is Nothing Then
        e.DataRow("商检查验") = Nothing
    Else
        Dim dr As DataRow
        dr = DataTables("进口业务进度表").Find("[发票号码] = \'" & e.NewValue & "\'")
        If dr("商检查验") = True
            e.DataRow("商检查验") = 500
        End If
    End If
End If



上面是这个表的datacolchanged里面的左右代码,请老师看看。

--  作者:jamhuton
--  发布时间:2016/1/7 12:38:00
--  
If e.DataCol.Name = "发票号码" Then
    If e.NewValue Is Nothing Then
        e.DataRow("加急") = Nothing
    Else
        Dim dr As DataRow
        dr = DataTables("进口业务进度表").Find("[发票号码] = \'" & e.NewValue & "\'")
        If dr("加急") = True
            e.DataRow("加急") = 200
        End If
    End If
End If


If e.DataCol.Name = "发票号码" Then
    If e.NewValue Is Nothing Then
        e.DataRow("海关查验") = Nothing
    Else
        Dim dr As DataRow
        dr = DataTables("进口业务登记").Find("[发票号码] = \'" & e.NewValue & "\'")
        If dr("海关查验") = True
            e.DataRow("海关查验") = 500
        End If
    End If
End If

If e.DataCol.Name = "发票号码" Then
    If e.NewValue Is Nothing Then
        e.DataRow("商检查验") = Nothing
    Else
        Dim dr As DataRow
        dr = DataTables("进口业务登记").Find("[发票号码] = \'" & e.NewValue & "\'")
        If dr("商检查验") = True
            e.DataRow("商检查验") = 500
        End If
    End If
End If

If e.DataCol.Name = "发票号码" Then
    If e.NewValue Is Nothing Then
        e.DataRow("加急") = Nothing
    Else
        Dim dr As DataRow
        dr = DataTables("进口业务登记").Find("[发票号码] = \'" & e.NewValue & "\'")
        If dr("加急") = True
            e.DataRow("加急") = 200
        End If
    End If
End If

还有这些


--  作者:jamhuton
--  发布时间:2016/1/7 14:14:00
--  



引用表:
If e.DataCol.Name = "发票号码" Then
    If e.NewValue Is Nothing Then
        e.DataRow("海关查验") = Nothing
    Else
        Dim dr As DataRow
        dr = DataTables("被引用").Find("[发票号码] = \'" & e.NewValue & "\'")
        If dr("海关查验") = True
            e.DataRow("海关查验") = 500
        End If
    End If
End If

If e.DataCol.Name = "发票号码" Then
    If e.NewValue Is Nothing Then
        e.DataRow("商检查验") = Nothing
    Else
        Dim dr As DataRow
        dr = DataTables("被引用").Find("[发票号码] = \'" & e.NewValue & "\'")
        If dr("商检查验") = True
            e.DataRow("商检查验") = 500
        End If
    End If
End If



If e.DataCol.Name = "发票号码" Then
    If e.NewValue Is Nothing Then
        e.DataRow("加急") = Nothing
    Else
        Dim dr As DataRow
        dr = DataTables("被引用").Find("[发票号码] = \'" & e.NewValue & "\'")
        If dr("加急") = True
            e.DataRow("加急") = 200
        End If
    End If
End If

被引用表:


Select Case e.DataCol.Name
    Case "加急"
        Dim Filter As String = "[发票号码] = \'" & e.DataRow("发票号码") & "\'"
        Dim drs As List(Of DataRow) = DataTables("引用").Select(Filter)
        For Each dr As DataRow In drs
            If e.NewValue = True
                dr(e.DataCol.Name) = 200
            Else
                dr(e.DataCol.Name) = e.NewValue
            End If
        Next
End Select

Select Case e.DataCol.Name
    Case "海关查验"
        Dim Filter As String = "[发票号码] = \'" & e.DataRow("发票号码") & "\'"
        Dim drs As List(Of DataRow) = DataTables("引用").Select(Filter)
        For Each dr As DataRow In drs
            If e.NewValue = True
                dr(e.DataCol.Name) = 500
            Else
                dr(e.DataCol.Name) = e.NewValue
            End If
        Next
End Select

Select Case e.DataCol.Name
    Case "商检查验"
        Dim Filter As String = "[发票号码] = \'" & e.DataRow("发票号码") & "\'"
        Dim drs As List(Of DataRow) = DataTables("引用").Select(Filter)
        For Each dr As DataRow In drs
            If e.NewValue = True
                dr(e.DataCol.Name) = 500
            Else
                dr(e.DataCol.Name) = e.NewValue
            End If
        Next
End Select
[此贴子已经被作者于2016/1/7 14:14:38编辑过]

--  作者:jamhuton
--  发布时间:2016/1/7 14:14:00
--  
调试下来是这些代码有问题
请老师看一下


--  作者:大红袍
--  发布时间:2016/1/7 14:30:00
--  

加判断

 

        Dim dr As DataRow

        dr = DataTables("进口业务进度表").Find("[发票号码] = \'" & e.NewValue & "\'")
        If dr IsNot Nothing AndAlso dr("海关查验") = True
            e.DataRow("海关查验") = 500
        End If

--  作者:jamhuton
--  发布时间:2016/1/7 14:31:00
--  
调试好了,问题解决了