以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [公告]关于BOM的展开  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=105808)

--  作者:狐作非为
--  发布时间:2017/8/26 14:25:00
--  [公告]关于BOM的展开
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:test3.foxdb


当前物料清单是已经加载好的,但是在实际应用中,物料清单默认是不加载的。在调用BOM时才加载 。如果要对附件中的产品101展开BOM,那么会先加载物料清单,但这时仅仅只会加载当前主件为101的物料,而下级物料会缺失,请指导下

--  作者:有点蓝
--  发布时间:2017/8/26 15:12:00
--  
Dim dt As DataTable = DataTables("物料清单")
DataTables("表c").DataRows.Clear
Dim txt1 = e.Form.Controls("textbox1").text
Dim txt2 = val(e.Form.Controls("textbox2").text)
Dim filter As String
If txt1 > "" Then
    filter = "主物料 = \'" & txt1 & "\'"
Else
    filter = "主物料 is null"
End If
Dim drs As List(of DataRow) =dt.SQLSelect(filter)
Dim lst As new List(of String)
Do While drs.Count > 0
    lst.Clear
    For Each dr As DataRow In drs
        Dim bh As String = dr("子物料")
        Dim ndr As DataRow = DataTables("表c").AddNew
        ndr("物料编码") = bh
        lst.Add(bh)
        Dim fdr As DataRow = DataTables("产品表").Find("物料编码 = \'" & bh & "\'")
        If fdr IsNot Nothing Then
            ndr("物料名称") = fdr("物料名称")
        End If
        ndr("用量") = dr("用量")
        ndr("需求量") = dr("用量") * txt2
        \'Functions.Execute("sum",dr, txt2)
    Next
    drs = dt.SQLSelect("主物料 in (\'" & String.Join("\',\'",lst.ToArray) & "\')")
Loop