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
|