以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  多列重复  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=120194)

--  作者:outcat
--  发布时间:2018/6/9 10:43:00
--  多列重复

Select Case e.DataCol.name
    Case "商品名称","规格型号"
        Dim spmc As String
        Dim ggxh As String
        If e.DataCol.Name= "商品名称" Then
            spmc = e.NewValue
            ggxh = e.DataRow("规格型号")
        Else
            ggxh = e.NewValue
            spmc = e.DataRow("商品名称")
        End If
        If spmc >= "" AndAlso ggxh  >= "" Then
            Dim dr As DataRow = e.DataRow
            If e.DataTable.Find("商品名称 = \'" & spmc & "\' And 规格型号 = \'" & ggxh & "\'") IsNot Nothing Then
                MessageBox.Show("已经存在相同商品名称和规格型号的商品!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
                e.Cancel = True
            End If
        End If
End Select

老师,我这段代码当商品没有输入规格型号的时候,可以再输入同样的商品名没有规格型号,也就是可以保存同样的没有输入规格型号的商品,这个应该怎么再设置一下呢,我试着写了,都不能成功,请指点一下


--  作者:有点蓝
--  发布时间:2018/6/9 11:50:00
--  
……
If spmc >= "" AndAlso ggxh  >= "" Then
    Dim dr As DataRow = e.DataRow
    If e.DataTable.Find("商品名称 = \'" & spmc & "\' And 规格型号 = \'" & ggxh & "\'") IsNot Nothing Then
        MessageBox.Show("已经存在相同商品名称和规格型号的商品!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        e.Cancel = True
    End If
ElseIf ggxh = ""
    Dim dr As DataRow = e.DataRow
    If e.DataTable.Find("商品名称 = \'" & spmc & "\'") IsNot Nothing Then
        MessageBox.Show("已经存在相同商品名称的商品!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        e.Cancel = True
    End If
    
End If
……