For i As Integer = 1 To 8
If i Mod 2 = 1 Then
Dim drs As List (of DataRow) = DataTables("BOM用量計算暫存二").Select("","主件路徑")
If drs IsNot Nothing Then
For Each dr As DataRow In drs
For Each BOM As DataRow In DataTables("BOMUsage").Select("[主件品號] = '" & dr("品號") & "' And [元件狀態] = '有效'")
Dim Item_Code As String = BOM("元件品號")
If Item_Code.StartsWith("B") Or Item_Code.StartsWith("C") Then
Dim radd As Row = Tables("BOM用量計算暫存一").AddNew
radd("品號") = BOM("元件品號")
radd("數量") = BOM("單位用量") * dr("數量")
radd("主件路徑") = dr("主件路徑") & "." & BOM("主件品號")
Else
Dim radd As Row = Tables("BOM材料暫存明細").AddNew
radd("品號") = BOM("元件品號")
radd("數量") = BOM("單位用量") * dr("數量")
radd("主件路徑") = dr("主件路徑")
End If
Next
Next
DataTables("BOM用量計算暫存二").DataRows.Clear
End If
End If
If i Mod 2 = 0 Then
Dim drs As List (of DataRow) = DataTables("BOM用量計算暫存一").Select("","主件路徑")
If drs IsNot Nothing Then
For Each dr As DataRow In drs
For Each BOM As DataRow In DataTables("BOMUsage").Select("[主件品號] = '" & dr("品號") & "' And [元件狀態] = '有效'")
Dim Item_Code As String = BOM("元件品號")
If Item_Code.StartsWith("B") Or Item_Code.StartsWith("C") Then
Dim radd As Row = Tables("BOM用量計算暫存二").AddNew
radd("品號") = BOM("元件品號")
radd("數量") = BOM("單位用量") * dr("數量")
radd("主件路徑") = dr("主件路徑") & "." & BOM("主件品號")
Else
Dim radd As Row = Tables("BOM材料暫存明細").AddNew
radd("品號") = BOM("元件品號")
radd("數量") = BOM("單位用量") * dr("數量")
radd("主件路徑") = dr("主件路徑")
End If
Next
Next
DataTables("BOM用量計算暫存一").DataRows.Clear
End If
End If
Next