以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  取值问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=111432)

--  作者:实话实说
--  发布时间:2017/12/21 20:04:00
--  取值问题
以下代码问题在哪? 当修改产品代码或材料代码,即drs IsNot Nothing不成立时,应该
        e.DataRow("产品用料") = Nothing
        e.DataRow("材料") = Nothing
        e.DataRow("产品型号规格") = Nothing
但清空不了。

\'获取BOM表的产品用料|材料|产品型号规格
If e.DataCol.Name = "产品代码" Or e.DataCol.Name = "材料代码" Then
\'在BOM表中找出该产品
    Dim drs As List(Of DataRow) = DataTables("BOM").Select("产品代码 = " & "\'" & e.DataRow("产品代码") & "\' and 材料代码 = " & "\'" & e.DataRow("材料代码") & "\'" ) 
    If drs IsNot Nothing Then
        For Each dr As DataRow In drs
        If dr IsNot Nothing Then
            e.DataRow("产品用料") = dr("结构用料")
            e.DataRow("材料") = dr("材料")
            e.DataRow("产品型号规格") = dr("产品型号规格")
        End If
        Next        
    Else
        e.DataRow("产品用料") = Nothing
        e.DataRow("材料") = Nothing
        e.DataRow("产品型号规格") = Nothing
    End If
End If

--  作者:有点甜
--  发布时间:2017/12/21 23:45:00
--  

If drs IsNot Nothing Then

 

改成

 

If drs.count > 0 Then