If DataTables("凭证明细").HasChanges Or DataTables("凭证").HasChanges Then
'msgbox(0)
Dim Result As DialogResult
Result =MessageBox.Show("[凭证明细]或[凭证]数据已经修改,是否保存?","提示",MessageBoxButtons.YesNoCancel)
If Result = DialogResult.Yes Then
Dim r As Row = Tables("凭证").Current
SystemReady = False
If r IsNot Nothing Then
'If r.IsNull("附件张数") Then
'MessageBox.Show("附件张数不允许为空!")
'e.Cancel = True
'End If
If r.Isnull("日期") Or r.Isnull("凭证类别") Then
MessageBox.Show("日期或凭证类别不允许为空!")
e.Cancel = True
ElseIf r("借方金额") <> r("贷方金额") Then
MessageBox.Show("借贷不平衡!")
e.Cancel = True
ElseIf Tables("凭证.凭证明细").Rows(0)("借方金额") = 0 Then
MessageBox.Show("请录入借贷金额!")
e.Cancel = True
End If
For Each dr As Row In Tables("凭证.凭证明细").Rows
If dr.IsNull("摘要") And dr.IsNull("科目代码") Then
If dr.IsNull("借方金额") And dr.IsNull("贷方金额") Then
Tables("凭证.凭证明细").Current.Delete
Else
MessageBox.show("请输入摘要及会计科目!")
e.Cancel = True
Return
End If
ElseIf dr.IsNull("借方金额") And dr.IsNull("贷方金额") Then
MessageBox.show("请输入完整会计科目及借贷金额!")
e.Cancel = True
Return
End If
'Next
'For Each dr As DataRow In r.DataRow.GetChildRows("凭证明细")
Dim str() As String = {"员工核算","客户核算","项目核算","合同核算","供应商核算"}
Dim str1() As String = {"员工编号","客户编号","项目编号","合同编号","供应商编号"}
Dim dr1 As DataRow = DataTables("会计科目").SQLFind("[科目代码] = '" & dr("科目代码") & "'")
If dr1 IsNot Nothing Then
For i As Integer = 0 To str.Length -1
If dr1.IsNull(str(i)) = False AndAlso dr.IsNull(str1(i)) Then
MessageBox.show("请输入[" & str1(i) & " ]!")
e.Cancel = True
Return
End If
Next
End If
Next
SystemReady = True
Tables("凭证").save
Tables("凭证明细").save
'End If
End If
ElseIf Result = DialogResult.Cancel Then
' Return
e.Cancel = True
Else
Tables("凭证").DataTable.RejectChanges
Tables("凭证明细").DataTable.RejectChanges
Tables("凭证").save
Tables("凭证明细").save
End If
End If