For Each dr As DataRow In DataTables("库存消耗").DataRows Dim fdr As DataRow = DataTables("排程").DataRows(0) Dim flag As Boolean = False Dim sum As Double = 0 For Each dc As DataCol In fdr.DataTable.DataCols If flag Then For i As Integer = 1 To fdr.DataTable.DataRows.Count-1 Dim cdr As DataRow = fdr.DataTable.DataRows(i) sum += val(dr(cdr("第一列"))) * val(cdr(dc.name)) Next If sum >= dr("库存") dr("预计消耗日期") = fdr(dc.name) Exit For End If Else If fdr(dc) = dr("库存统计日期") Then flag = True End If End If Next Next
|