以文本方式查看主题

-  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=127117)

--  作者:edisontsui
--  发布时间:2018/11/6 10:07:00
--  离开某数据表时提出警告
当要离开某个数据表(比如:采购单总表)时,如果某数据列(比如:供应商代号)还有空格没有输入数据,那么系统就会提出警告并且暂时不准离开该数据表(比如:采购单总表)。这个代码该怎么写?谢谢。
--  作者:有点甜
--  发布时间:2018/11/6 10:15:00
--  

参考

 

http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=126976&skin=0

 


--  作者:edisontsui
--  发布时间:2018/11/6 11:39:00
--  
谢谢。
--  作者:edisontsui
--  发布时间:2018/11/6 16:53:00
--  
If e.OldTableName = "出入库" Then
    Dim a As Row = Tables("出入库").Current
    If a.IsNull("物料编号") OrElse a.Isnull("出入库单号") OrElse e.DataCol("出入库数量") = 0 Then
        Dim Result As DialogResult
        Result = MessageBox.Show("出入库填写不完整,是否要离开此表?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        If Result = DialogResult.Yes Then
            a.delete
        Else
            e.cancel = True
        End If
    Else
        a.save
    End If
End If

我将以上代码放入 maintablechanging 时,出现警告:datacol 不是 maintablechangingeventargs的成员。请问要怎么修改?谢谢。

--  作者:edisontsui
--  发布时间:2018/11/6 17:18:00
--  
我将 e.DataCol 改成 a 就不会出现警告了。
--  作者:有点甜
--  发布时间:2018/11/7 9:38:00
--  

如果要判断所有行,改成这样

 

If e.OldTableName = "出入库" Then
    Dim fdr As DataRow = DataTables("出入库").find("物料编号 is null or 出入库单号 is null or 出入库数量 is null")
    If fdr IsNot Nothing Then
        msgbox("不能离开")
        e.cancel = True
    End If
End If


--  作者:edisontsui
--  发布时间:2018/12/12 14:23:00
--  
If e.OldTableName = "接头巴任务单" Then
    Dim a As Row = Tables("接头巴任务单").Current
    If a.IsNull("制造产品号") 
        Dim Result As DialogResult
        Result = MessageBox.Show("接头巴任务单填写不完整,是否要离开此表?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        If Result = DialogResult.Yes Then
            a.delete
        Else
            e.cancel = True
        End If
    Else
        a.save
    End If
End If


要离开当前表而执行如上代码,如果选择“Yes”确定离开时,每次只能删除一行数据。能否帮我改一下,只要确定离开该表,那么就将所有符合条件(制造产品号为空)的行都一次性删除掉呢?

--  作者:有点甜
--  发布时间:2018/12/12 14:39:00
--  
If e.OldTableName = "接头巴任务单" Then
    Dim a As DataRow = DataTables("接头巴任务单").Find("制造产品号 is null")
    If a IsNot Nothing Then
        Dim Result As DialogResult
        Result = MessageBox.Show("接头巴任务单填写不完整,是否要离开此表?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        If Result = DialogResult.Yes Then
            DataTables("接头巴任务单").deletefor("制造产品号 is null")
        Else
            e.cancel = True
        End If
    Else
        a.save
    End If
End If

--  作者:edisontsui
--  发布时间:2018/12/13 14:36:00
--  
使用以上代码,在离开数据表时会出现如下警告,为什么?

.NET Framework 版本:2.0.50727.8793
Foxtable 版本:2017.3.18.1
错误所在事件:项目,MainTableChanging
详细错误信息:
未将对象引用设置到对象的实例。

--  作者:有点甜
--  发布时间:2018/12/13 15:34:00
--  
If e.OldTableName = "接头巴任务单" Then
    Dim a As DataRow = DataTables("接头巴任务单").Find("制造产品号 is null")
    If a IsNot Nothing Then
        Dim Result As DialogResult
        Result = MessageBox.Show("接头巴任务单填写不完整,是否要离开此表?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        If Result = DialogResult.Yes Then
            DataTables("接头巴任务单").deletefor("制造产品号 is null")
        Else
            e.cancel = True
        End If
    Else
        DataTables("接头巴任务单").save
    End If
End If