以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  输入校验  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=59234)

--  作者:newsun2k
--  发布时间:2014/10/31 10:07:00
--  输入校验
我定义一个类,并加入以下代码,校验一行是否全为空值
Public Function checkNullRow(table1 As DataTable, r1 As DataRow) As Boolean
checkNullRow = True
    For Each c1 As DataCol In Table1.dataCols
        If r1.IsNull(c1.Name) Then
        Else
            checkNullRow = False
            Return True
        End If
    Next
checkNullRow = True
End Function

然后,在表的beforesavedatarow的事件中,加入
Dim dr As DataRow = e.DataRow
Dim cI As new checkInput

If cI.checkNullRow(e.DataTable,e.DataRow) Then   \'空行
    dr.Delete
    Return
End If

但是,并没有想我设想的工作。
如果我加入两个新行,一行中有数据,一行无数据,保存时,两行均被删除。何解?

--  作者:有点甜
--  发布时间:2014/10/31 10:11:00
--  
Public Function checkNullRow(table1 As DataTable, r1 As DataRow) As Boolean
    For Each c1 As DataCol In Table1.dataCols
        If r1.IsNull(c1.Name) Then
            Return True
        End If
    Next
    Return False
End Function

--  作者:newsun2k
--  发布时间:2014/10/31 10:51:00
--  
明白了,谢谢。
另外,如果我连续在主表中增加多行,正常输入情况下,每一行在子表应该对应增加一行。
1、利用syscmd.project.save保存时,先保存主表?还是子表?这个顺序可否设置?
2、在beforesavedatarow事件中,对每个主表中保存的当前行,如何校验对应子表中是否已经增加了一行?