以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]检查后台数据的代码求助  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=150267)

--  作者:huangfanzi
--  发布时间:2020/5/25 16:00:00
--  [求助]检查后台数据的代码求助
有以下表:

图片点击可在新窗口打开查看此主题相关图片如下:qq截图20200525155239.jpg
图片点击可在新窗口打开查看

在全局DataColChanging中有以个代码:
\'复核后禁止去审核
If e.DataTable.Datacols.Contains("审核") AndAlso e.DataTable.Datacols.Contains("复核人") Then
    If e.DataCol.Name = "审核" AndAlso e.NewValue = False Then
        If e.DataRow("复核人") <> Nothing Then
            e.Cancel = True
            MessageBox.Show("此记录已经复核,取消复核后才能去审核","提示!",MessageBoxButtons.OK,MessageBoxIcon.Information)
        End If
    End If
End If

现在有个漏洞,在用户A打开此表时,用户B还没有复核第3条记录,此时用户B在另一个专用复核的窗口中复核了此条记录并把复核人写入了数据库,由于用户A的表上复核人还是空的,因此他还是能去掉复核,请问这种情况应该如何处理,谢谢!



--  作者:linyunu1
--  发布时间:2020/5/25 16:09:00
--  
http://www.foxtable.com/webhelp/topics/3007.htm
--  作者:有点蓝
--  发布时间:2020/5/25 16:26:00
--  
试试

If e.DataTable.Datacols.Contains("审核") AndAlso e.DataTable.Datacols.Contains("复核人") Then
    If e.DataCol.Name = "审核" AndAlso e.NewValue = False Then
        Dim nu As Boolean = e.DataRow.isnull("复核人")
        If nu
            Dim dr As DataRow = e.DataTable.sqlfind("[_Identify]=" & e.DataRow("_Identify")) Then
            If dr IsNot Nothing AndAlso dr.IsNull("复核人") = False Then
                nu = False
            End If
        End If
        If nu = False
            e.Cancel = True
            MessageBox.Show("此记录已经复核,取消复核后才能去审核","提示!",MessageBoxButtons.OK,MessageBoxIcon.Information)
        End If
    End If
End If