For Each dr As DataRow In dt.datarows
If dr("所属母件") = dbtx Then
nd = tr.Nodes.Add(dr("物料编码"),dr("物料名称"))
Dim r As Row = Tables("产品").AddNew()
r("物料编码") = dr("物料编码")
r("物料名称") = dr("物料名称")
Functions.Execute("AddChildren",nd,dt)
End If
Next
内部函数
Dim nd As WinForm.TreeNode = args(0)
Dim dt As DataTable = args(1)
Dim drs As List(of DataRow)
drs = dt.Select("[所属母件] = '" & nd.name & "'")
For Each dr As DataRow In drs
Dim cd As Winform.TreeNode = nd.Nodes.Add(dr("物料编码"),dr("物料名称"))
Dim s As String = dr("物料编码")
Dim cr As DataRow = DataTables("产品").Find("物料编码 = '" & s & "'")
If cr IsNot Nothing Then
cr("用量") = cr("用量") + dr("用量")
Else
Dim r As Row = Tables("产品").AddNew()
r("物料编码") = dr("物料编码")
r("物料名称") = dr("物料名称")
r("用量") = dr("用量")
End If
Functions.Execute("AddChildren",cd,dt)
Next