以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  修改代码  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=81609)

--  作者:发财
--  发布时间:2016/3/2 9:18:00
--  修改代码
Dim n As Integer = DataTables("凭证").Compute("Max(凭证ID)") 
Dim r As Row = Tables("凭证").Current(n)
If r IsNot Nothing Then
    If r.IsNull("附件张数") Then
        MessageBox.Show("附件张数不允许为空!")
        e.Cancel = True
    End If
    If r("借方金额") <> r("贷方金额") Then
        MessageBox.Show("借贷不平衡!")
        e.Cancel = True
    End If
    If Tables("凭证.凭证明细").Rows(0)("借方金额") = "" Then
        MessageBox.Show("请录入借贷金额!")
        e.Cancel = True
    End If
End If
代码第一、二句应如何改?

--  作者:发财
--  发布时间:2016/3/2 9:30:00
--  
Dim cr As Row = Tables("凭证").current
If cr("凭证ID") < DataTables("凭证").Compute("Max(凭证ID)") Then
    With Tables("凭证")
        .Position = .Rows.Count - 1
    End With
End If
Dim r As Row = Tables("凭证").Current()
If r IsNot Nothing Then
    If r.IsNull("附件张数") Then
        MessageBox.Show("附件张数不允许为空!")
        e.Cancel = True
    End If
    If r("借方金额") <> r("贷方金额") Then
        MessageBox.Show("借贷不平衡!")
        e.Cancel = True
    End If
    If Tables("凭证.凭证明细").Rows(0)("借方金额") = "" Then
        MessageBox.Show("请录入借贷金额!")
        e.Cancel = True
    End If
End If
这样改,感觉太多余了吧?


--  作者:大红袍
--  发布时间:2016/3/2 10:18:00
--  

这个意思?

 

 
Dim r As Row = Tables("凭证").Rows(Tables("凭证").Rows.Count - 1)