Dim dc As DataCol = e.DataCol
Dim dr As DataRow = e.DataRow
Select Case dc.Name
Case "商品编号" ,"单捆数"
If (dr("商品编号") Like "W*" Or dr("商品编号") Like "Y*") Then
Dim a As Integer = Nothing
Dim b As Integer = Nothing
If dr("订单数量") <> Nothing And dr("单捆数") = Nothing Then '根据壁厚判断单捆数
If mid(dr("商品编号"),9,4) >= 0900 Then
a = 2
ElseIf mid(dr("商品编号"),9,4) >= 0500 Then
a = 3
ElseIf mid(dr("商品编号"),9,4) >= 0300 Then
a = 5
End If
End If
If dr("订单数量") <> Nothing And dr("单捆数") = Nothing Then '根据外径判断单捆数
If mid(dr("商品编号"),5,4) >= 0710 Then
b = 2
ElseIf mid(dr("商品编号"),5,4) >= 0590 Then
b = 3
ElseIf mid(dr("商品编号"),5,4) >= 0530 Then
b = 4
ElseIf mid(dr("商品编号"),5,4) >= 0430 Then
b = 5
ElseIf mid(dr("商品编号"),5,4) >= 0270 Then
b = 6
ElseIf mid(dr("商品编号"),5,4) >= 0190 Then
b = 8
ElseIf mid(dr("商品编号"),5,4) < 0190 Then
b = 10
End If
End If
If a > 0 AndAlso b > 0 Then
a = iif(b<a, b, a)
ElseIf b > 0 Then
a = b
ElseIf a = 0 Then
a = Nothing
End If
dr("单捆数") = a
End If
End Select