以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  求助:冲突如何识别  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=80422)

--  作者:卖糕的
--  发布时间:2016/1/22 14:26:00
--  求助:冲突如何识别

想根据商品编号规律来确定单捆数,一般是先判断壁厚,再判断外径,代码如下:

 

但是现在碰到一个异常是:如果壁厚两个有冲突,取最小的数据应该怎么修改代码

例如:商品编号:W61006000400CF  如果用壁厚判断,单捆数取5,如果用外径判断,单捆数取3

         实际要求是:3,请求解惑

 

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
            If dr("订单数量") <> Nothing And dr("单捆数") = Nothing Then   \'根据壁厚判断单捆数
                If mid(dr("商品编号"),9,4) >= 0900 Then
                    dr("单捆数") = 2
                ElseIf mid(dr("商品编号"),9,4) >= 0500 Then
                    dr("单捆数") = 3
                ElseIf mid(dr("商品编号"),9,4) >= 0300 Then
                    dr("单捆数") = 5
                End If
            End If

            If dr("订单数量") <> Nothing And dr("单捆数") = Nothing Then    \'根据外径判断单捆数
                If mid(dr("商品编号"),5,4) >= 0710 Then
                    dr("单捆数") = 2
                ElseIf mid(dr("商品编号"),5,4) >= 0590 Then
                    dr("单捆数") = 3
                ElseIf mid(dr("商品编号"),5,4) >= 0530 Then
                    dr("单捆数") = 4
                ElseIf mid(dr("商品编号"),5,4) >= 0430 Then
                    dr("单捆数") = 5
                ElseIf mid(dr("商品编号"),5,4) >= 0270 Then
                    dr("单捆数") = 6
                ElseIf mid(dr("商品编号"),5,4) >= 0190 Then
                    dr("单捆数") = 8
                ElseIf mid(dr("商品编号"),5,4) < 0190 Then
                    dr("单捆数") = 10
                End If
            End If
        End If
End Select


--  作者:卖糕的
--  发布时间:2016/1/22 14:42:00
--  
在线等。。。
--  作者:大红袍
--  发布时间:2016/1/22 14:44:00
--  

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

 


--  作者:卖糕的
--  发布时间:2016/1/22 14:48:00
--  
多谢老师,赶紧回去试试