Foxtable(狐表)用户栏目专家坐堂 → [求助]核实表存在的重复内容


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

主题:[求助]核实表存在的重复内容

帅哥哟,离线,有人找我吗?
cbt
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:569 积分:4210 威望:0 精华:0 注册:2015/5/13 8:32:00
  发帖心情 Post By:2017/6/13 17:23:00 [显示全部帖子]

DataColChanging

If e.DataCol.Name = "工作站"  Or e.DataCol.Name = "职务"  Then
    If e.DataRow.IsNull("工作站") AndAlso e.DataRow.IsNull("职务") Then Return
    Dim fl As String = IIF(e.DataCol.Name = "工作站","工作站='" & e.NewValue & "' and 职务='" & e.DataRow("职务") & "'","工作站='" & e.DataRow("工作站") & "' and 职务='" & e.NewValue  & "'")
    If e.DataTable.Find(fl) IsNot Nothing  Then
        e.Cancel = True
        MessageBox.Show("工作站 和 职务 不能重复!")
    End If
End If

[此贴子已经被作者于2017/6/13 17:30:37编辑过]

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


加好友 发短信
等级:二尾狐 帖子:569 积分:4210 威望:0 精华:0 注册:2015/5/13 8:32:00
  发帖心情 Post By:2017/6/13 18:32:00 [显示全部帖子]

 加多一个判断不就行了。。。
If e.DataCol.Name = "工作站"  Or e.DataCol.Name = "职务"  Then
    If e.DataRow.IsNull("工作站") AndAlso e.DataRow.IsNull("职务") Then Return
    Dim fl As String = IIF(e.DataCol.Name = "工作站","工作站='" & e.NewValue & "' and 职务='" & e.DataRow("职务") & "'","工作站='" & e.DataRow("工作站") & "' and 职务='" & e.NewValue  & "'")
    Dim dr As DataRow = e.DataTable.Find(fl)
    If dr IsNot Nothing AndAlso dr("职务")= "工作站站长" Then
        e.Cancel = True
        MessageBox.Show("工作站 和 职务 不能重复!")
    End If
End If

[此贴子已经被作者于2017/6/13 18:55:57编辑过]

 回到顶部