以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]BOM展开增加上阶料号和层级  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=114010)

--  作者:ymjr2011
--  发布时间:2018/1/26 15:29:00
--  [求助]BOM展开增加上阶料号和层级

图片点击可在新窗口打开查看此主题相关图片如下:微信截图_20180126152341.png
图片点击可在新窗口打开查看
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:test3_201801261523.zip



--  作者:有点甜
--  发布时间:2018/1/26 15:54: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)
Dim idx = 0
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("层级") = idx

        ndr("用量") = dr("用量")
        ndr("需求量") = dr("用量") * txt2
        \'Functions.Execute("sum",dr, txt2)
    Next
    idx += 1
    drs = dt.SQLSelect("主物料 in (\'" & String.Join("\',\'",lst.ToArray) & "\')")
Loop

--  作者:ymjr2011
--  发布时间:2018/1/26 16:17:00
--  
谢谢,不过好像需求量算的不对吧?当前物料的需求量应该等于上阶的需求量*当前行的用量
--  作者:有点甜
--  发布时间:2018/1/26 16:30: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)
Dim idx = 0
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
        fdr = DataTables("表c").Find("物料编码 = \'" & dr("主物料") & "\'")
        If fdr Is Nothing Then
            ndr("需求量") = dr("用量") * txt2
        Else
            ndr("需求量") = dr("用量") * fdr("需求量")
           
        End If
        ndr("上级编码") = dr("主物料")
        ndr("层级") = idx
        ndr("用量") = dr("用量")
        \'Functions.Execute("sum",dr, txt2)
    Next
    idx += 1
    drs = dt.SQLSelect("主物料 in (\'" & String.Join("\',\'",lst.ToArray) & "\')")
Loop