以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  如何防止出现相同采购单号和采购单行号的行  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=136256)

--  作者:edisontsui
--  发布时间:2019/6/10 13:40:00
--  如何防止出现相同采购单号和采购单行号的行
Select Case e.DataCol.name
    Case "采购单号"
        If e.NewValue > "" AndAlso e.DataRow.IsNull("采购单行号") = False
            Dim dr As DataRow = e.DataRow
            If e.DataTable.Find("采购单号 = \'" & e.NewValue & "\' And 采购单行号 =" & dr("采购单行号")) IsNot Nothing Then
                MessageBox.Show("已经存在相同采购单号和采购单行号的行!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
                e.Cancel = True
            End If
        End If
    Case "采购单行号"
        If  e.NewValue > "" AndAlso e.DataRow.IsNull("采购单号") = False
            Dim dr As DataRow = e.DataRow
            If e.DataTable.Find("采购单行号 = \'" & e.NewValue & "\' And 采购单号 =" & dr("采购单号")) IsNot Nothing Then
                MessageBox.Show("已经存在相同采购单号和采购单行号的行!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
                e.Cancel = True
            End If
        End If
End Select

上面代号的目的是为了防止出现相同采购单号和采购单行号的行。但是执行Case "采购单行号"时会出现警告:
.NET Framework 版本:2.0.50727.8806
Foxtable 版本:2017.10.16.1
错误所在事件:表,采购单,DataColChanging
详细错误信息:
调用的目标发生了异常。
未找到列 [BSPOE024]。

请教是什么问题。谢谢。
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目4.rar



--  作者:有点甜
--  发布时间:2019/6/10 14:47:00
--  
Select Case e.DataCol.name
    Case "采购单号"
        If e.NewValue > "" AndAlso e.DataRow.IsNull("采购单行号") = False
            Dim dr As DataRow = e.DataRow
            If e.DataTable.Find("采购单号 = \'" & e.NewValue & "\' And 采购单行号 = \'" & dr("采购单行号") & "\'") IsNot Nothing Then
                MessageBox.Show("已经存在相同采购单号和采购单行号的行!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
                e.Cancel = True
            End If
        End If
    Case "采购单行号"
        If  e.NewValue > "" AndAlso e.DataRow.IsNull("采购单号") = False
            Dim dr As DataRow = e.DataRow
            If e.DataTable.Find("采购单行号 = \'" & e.NewValue & "\' And 采购单号 = \'" & dr("采购单号") & "\'") IsNot Nothing Then
                MessageBox.Show("已经存在相同采购单号和采购单行号的行!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
                e.Cancel = True
            End If
        End If
End Select