这个应该比较完美了,不过也心淡,罢了
'''
If e.DataCol.Name = "付款单位" Then
Dim T As String
Dim mny,sum,sm As Double
Dim Da As DataTable = DataTables("总表")
if e.DataRow("金额") <=0 then
MessageBox.Show("请输入金额!", "提示")
Else
T = "[发货单位] = '" & e.NewValue & "' and [运费结算_结清] = False"
if Da.Find(T) isNot nothing then
sum = Da.Compute("Sum(运费结算_已收)",T)
sm= Da.Compute("Sum(运费结算_应收费)",T)
mny = e.DataRow("金额") +sum
if mny > sm then
MessageBox.Show("金额超出应付款项:" & (mny-sm) &"!", "提示")
end if
for each dr As DataRow in Da.select(T)
if mny <=0 then
exit for
else
if mny >= dr("运费结算_应收费")
dr("运费结算_已收") = dr("运费结算_应收费")
dr("运费结算_结清") = True
else
dr("运费结算_已收") = mny
end if
mny =mny- dr("运费结算_应收费")
end if
next
end if
end if
end if
[此贴子已经被作者于2008-12-20 22:53:49编辑过]