Foxtable(狐表)用户栏目专家坐堂 → 递归函数计算物料成本的问题


  共有3614人关注过本帖树形打印复制链接

主题:递归函数计算物料成本的问题

帅哥哟,离线,有人找我吗?
able
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:69 积分:797 威望:0 精华:0 注册:2015/1/2 15:58:00
递归函数计算物料成本的问题  发帖心情 Post By:2015/3/4 11:35:00 [只看该作者]

以下代码是:内部函数
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 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("需求数量"))
    Next
    sum = sum*yl
    nd.Text &= "   成本:" & 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("需求数量"))
Next
tr.ResumeRedraw()

我想问一下:如何用同样的原理,将物料成本输出至数据表对应的行.

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2015/3/4 11:41:00 [只看该作者]

以下代码是:内部函数
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()
 


 回到顶部