以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  数据重复添加  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=48092)

--  作者:lxhmax
--  发布时间:2014/3/22 22:33:00
--  数据重复添加
请问下各位老师:
目前的状况是,我每按一次按钮 检测项目 都会添加一次,按多次就一直重复添加
请问要怎样才能按多次按钮时不重复添加 检测项目 
   对于每个样品编号都只有一个唯一的检测项目

Dim tbl As Table = Tables("委托协议书.样品信息")
Dim jcxm As String = tbl.current("检测项目")=DataTables("检测流程流转记录表").GetComboListString("检测项目","样品编号=\'" & tbl.current("样品编号") & "\'","_SortKey").Replace("|",",")
Dim s As String = Tables("委托协议书.样品信息").current("检测项目")
Dim s1 As String = Tables("委托协议书.样品信息").current("样品编号")
If s <> "" And s1 <> "" Then
    Dim Values() As String = s.split(",")
    For i As Integer = 0 To Values.Length - 1
        Dim Arys As List(Of String())
        Arys = DataTables("项目管理").GetUniqueValues("检测项目 = \'" & Values(i) & "\'", "检测依据","项目代码")
        For Each Ary As String() In Arys
            Dim r As Row = Tables("委托协议书.样品信息.检测流程流转记录表").AddNew()
            r("样品编号") = s1
            r("检测项目") = Values(i)
            r("检测依据") = Ary(0)
            r("项目代码") = Ary(1)
        Next
    Next
End If

--  作者:有点酸
--  发布时间:2014/3/23 9:57:00
--  
Dim tbl As Table = Tables("委托协议书.样品信息")
Dim jcxm As String = tbl.current("检测项目")=DataTables("检测流程流转记录表").GetComboListString("检测项目","样品编号=\'" & tbl.current("样品编号") & "\'","_SortKey").Replace("|",",")
Dim s As String = Tables("委托协议书.样品信息").current("检测项目")
Dim s1 As String = Tables("委托协议书.样品信息").current("样品编号")
For Each r1 As Row in Tables("委托协议书.样品信息.检测流程流转记录表").Rows
    if r1("样品编号") = s1 Then
           Messagebox.show("不要重复增加")
           Return
    End if
next
If s <> "" And s1 <> "" Then
    Dim Values() As String = s.split(",")
    For i As Integer = 0 To Values.Length - 1
        Dim Arys As List(Of String())
        Arys = DataTables("项目管理").GetUniqueValues("检测项目 = \'" & Values(i) & "\'", "检测依据","项目代码")
        For Each Ary As String() In Arys
            Dim r As Row = Tables("委托协议书.样品信息.检测流程流转记录表").AddNew()
            r("样品编号") = s1
            r("检测项目") = Values(i)
            r("检测依据") = Ary(0)
            r("项目代码") = Ary(1)
        Next
    Next
End If