以下代码是:内部函数
Dim nd As WinForm.TreeNode = args(0)
Dim dt As DataTable = args(1)
Dim je As Double = args(2)
Dim yl As Double = args(3)
Dim cdr As DataRow = args(4)
Dim drs As List(of DataRow)
drs = dt.Select("[父键] = '" & nd.name & "'")
If drs.Count = 0 Then
nd.Text &= " 成本:" & je
Return je
Else
Dim sum As Double = 0
For Each dr As DataRow In drs
Dim cd As Winform.TreeNode = nd.Nodes.Add(dr("键"),dr("物料名称"))
sum += Functions.Execute("bom",cd,dt,dr("金额"),dr("需求数量"),dr)
Next
sum = sum*yl
nd.Text &= " 成本:" & sum
cdr("成本") = sum
Return sum
End If
以下代码是在目录树:用来返回物料成本
Dim tr As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim nd As WinForm.TreeNode
Dim dt As DataTable = DataTables("表A")
tr.StopRedraw()
tr.Nodes.Clear
tr.Nodes.Add("全部")
For Each dr As DataRow In dt.Select("父键 is null")
nd = tr.Nodes.Add(dr("键"),dr("物料名称"))
Functions.Execute("bom",nd,dt,0,dr("需求数量"),dr)
Next
tr.ResumeRedraw()