如图
此主题相关图片如下:无标题.png
此主题相关图片如下:无题.png
代码如下
If e.DataCol.Name = "合同号" AndAlso e.DataRow("合同号") IsNot Nothing Then '如果列名是合同号且合同号非空,即发现新增合同
Dim cz As DataRow '在应收帐表中查找与所选合同号一致的行
cz= DataTables("表A").SQLFind("[单据号] = '" & e.DataRow("合同号") & "'")
If cz Is Nothing '没找到就登帐
Dim nma() As String = {"合同号","负责人","客户"} '合同数据来源列
Dim nmb() As String = {"单据号","负责人","客户"} '应收账表数据接收列
Dim t As Double = DataTables("表B").SQLCompute("sum(数量*单价)","合同号='" & e.NewValue & " ' ")
Dim dr As DataRow = DataTables("表A").AddNew
For i As Integer = 0 To nma.Length - 1
dr(nmb(i)) = e.DataRow(nma(i))
dr("借方")= t
Next
Else '否则提出警告并返回
MessageBox.Show("此合同已登帐!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Information)
Return
End If
End If
按理表A中借方应为表B中的金额,现在图中画圈的地方不对,请指教