以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助] 帮忙看下这个递归怎么改  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=52681)

--  作者:jiskin
--  发布时间:2014/6/20 12:58:00
--  [求助] 帮忙看下这个递归怎么改
函数
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("物料名称"))
    Functions.Execute("AddChildren",cd,dt)
Next



窗口上由于这个结构的根是在另外一个表里的,所以就不知道如何添加进这个递归了,请帮忙看看
Dim r1 As Row = Tables("BOM管理_Table1").Current
Dim tr As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim nd As WinForm.TreeNode
tr.StopRedraw()
tr.Nodes.Clear
tr.Nodes.Add(r1("物料编号"),r1("物料名称")) 
For Each dr As DataRow In t.DataTable.datarows
        nd = tr.Nodes.Add(dr("子零件编号"),dr("物料名称"))
        Functions.Execute("AddChildren",nd,t.DataTable)
Next

--  作者:有点甜
--  发布时间:2014/6/20 14:12:00
--  

 不明白说什么,是不是这样?

 

Dim r1 As Row = Tables("BOM管理_Table1").Current
Dim tr As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim nd As WinForm.TreeNode
tr.StopRedraw()
tr.Nodes.Clear
For Each dr As DataRow In t.DataTable.Select("[父零件编号] = \'" & r1("物料编号") & "\'")
    nd = tr.Nodes.Add(dr("子零件编号"),dr("物料名称"))
    Functions.Execute("AddChildren",nd,t.DataTable)
Next


--  作者:jiskin
--  发布时间:2014/6/20 14:19:00
--  
以下是引用有点甜在2014-6-20 14:12:00的发言:

 不明白说什么,是不是这样?

 

Dim r1 As Row = Tables("BOM管理_Table1").Current
Dim tr As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim nd As WinForm.TreeNode
tr.StopRedraw()
tr.Nodes.Clear
For Each dr As DataRow In t.DataTable.Select("[父零件编号] = \'" & r1("物料编号") & "\'")
    nd = tr.Nodes.Add(dr("子零件编号"),dr("物料名称"))
    Functions.Execute("AddChildren",nd,t.DataTable)
Next

 

 

不是的,窗口中的代码 按帮助中应该是这样的

Dim tr As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim nd As WinForm.TreeNode
tr.StopRedraw()
tr.Nodes.Clear
\'tr.Nodes.Add("全部")
For Each dr As DataRow In dt.datarows
    If dr.IsNull("父零件编号") Then
        nd = tr.Nodes.Add(dr("子零件编号"),dr("物料名称"))
        Functions.Execute("AddChildren",nd,dt)
    End If
Next

 

但是 这个BOM结构的根物料 不在这个BOM结构的表中,而是在另外一张表中

所以我不知道该如何去调用

 


--  作者:jiskin
--  发布时间:2014/6/20 14:21:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:qq截图20140620142040.png
图片点击可在新窗口打开查看

--  作者:有点甜
--  发布时间:2014/6/20 14:25:00
--  

 不明白你的意思,请上传例子。

 

Dim r1 As Row = Tables("BOM管理_Table1").Current
Dim tr As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim nd As WinForm.TreeNode
tr.StopRedraw()
tr.Nodes.Clear

Dim fdr As DataRow = DataTables("另一个表").Find("xxxxx")

For Each dr As DataRow In t.DataTable.Select("[父零件编号] = \'" & fdr("物料编号") & "\'")
    nd = tr.Nodes.Add(dr("子零件编号"),dr("物料名称"))
    Functions.Execute("AddChildren",nd,t.DataTable)
Next


--  作者:jiskin
--  发布时间:2014/6/20 14:38:00
--  
以下是引用有点甜在2014-6-20 14:25:00的发言:

 不明白你的意思,请上传例子。

 

Dim r1 As Row = Tables("BOM管理_Table1").Current
Dim tr As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim nd As WinForm.TreeNode
tr.StopRedraw()
tr.Nodes.Clear

Dim fdr As DataRow = DataTables("另一个表").Find("xxxxx")

For Each dr As DataRow In t.DataTable.Select("[父零件编号] = \'" & fdr("物料编号") & "\'")
    nd = tr.Nodes.Add(dr("子零件编号"),dr("物料名称"))
    Functions.Execute("AddChildren",nd,t.DataTable)
Next

 

例子:

 

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目4.table


--  作者:有点甜
--  发布时间:2014/6/20 14:42:00
--  

这样?

 

Dim t As Table = Tables("表B")
Dim r1 As Row = Tables("表A").Current
Dim tr As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim nd As WinForm.TreeNode
tr.StopRedraw()
tr.Nodes.Clear
Dim d As WinForm.TreeNode = tr.Nodes.Add(r1("物料编号"),r1("物料名称"))
For Each dr As DataRow In t.DataTable.Select("[父零件编号] = \'" & r1("物料编号") & "\'")
    nd = d.Nodes.Add(dr("子零件编号"),dr("物料名称"))
    Functions.Execute("AddChildren",nd,t.DataTable)
Next


--  作者:jiskin
--  发布时间:2014/6/20 14:53:00
--  
以下是引用有点甜在2014-6-20 14:42:00的发言:

这样?

 

Dim t As Table = Tables("表B")
Dim r1 As Row = Tables("表A").Current
Dim tr As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim nd As WinForm.TreeNode
tr.StopRedraw()
tr.Nodes.Clear
Dim d As WinForm.TreeNode = tr.Nodes.Add(r1("物料编号"),r1("物料名称"))
For Each dr As DataRow In t.DataTable.Select("[父零件编号] = \'" & r1("物料编号") & "\'")
    nd = d.Nodes.Add(dr("子零件编号"),dr("物料名称"))
    Functions.Execute("AddChildren",nd,t.DataTable)
Next

 

good