Foxtable(狐表)用户栏目专家坐堂 → [求助] 防止重复记录


  共有2501人关注过本帖树形打印复制链接

主题:[求助] 防止重复记录

美女呀,离线,留言给我吧!
susanhe
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小狐 帖子:312 积分:2477 威望:0 精华:0 注册:2018/11/22 20:30:00
[求助] 防止重复记录  发帖心情 Post By:2019/8/30 23:16:00 [只看该作者]

 

 

你好,以下代码中可不可以帮忙加一个条件,如果表PrintHistory已经存在相同的PartNo,就不再新增该记录。谢谢。

 

 

Dim t1 As Table = Tables("生产任务单")
Dim nmb() As String = {"生产任务单号","产品名称","数量","PrintTime"}
Dim nma() As String = {"生产任务单号","PartNo","Qty","PrintTime"}

For r As Integer = t1.TopPosition To t1.BottomPosition
    Dim dr As Row = Tables("PrintHistory").AddNew
    For i As Integer = 0 To nma.Length - 1
        dr(nma(i)) = t1.rows(r)(nmb(i))
    Next
Next


 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110574 积分:562760 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/8/31 8:01:00 [只看该作者]

Dim t1 As Table = Tables("生产任务单")
Dim nmb() As String = {"生产任务单号","产品名称","数量","PrintTime"}
Dim nma() As String = {"生产任务单号","PartNo","Qty","PrintTime"}
For r As Integer = t1.TopPosition To t1.BottomPosition
    Dim r1 As Row = t1.rows(r)
    Dim dr As DataRow = DataTables("PrintHistory").Find("PartNo='" & r1("PartNo") & "'")
    If dr Is Nothing Then
        dr = DataTables("PrintHistory").AddNew
        For i As Integer = 0 To nma.Length - 1
            dr(nma(i)) = r1(nmb(i))
        Next
    End If
Next

 回到顶部