把ACCESS数据库转换成SQL数据库后高效流水账代码报错:此主题相关图片如下:屏幕截图 2021-12-25 194614.png
我从sql数据库中查看订单付款明细表中有_SortKey列
此主题相关图片如下:屏幕截图 2021-12-25 194738.png
订单付款明细表DataColChanged:
If Tables("订单付款明细表").Current IsNot Nothing Then
Dim r1 As Row = Tables("订单付款明细表").Current
Dim r As DataRow = DataTables("销售订单").find("订单号 = '" & r1("订单号") & "'")
If r IsNot Nothing Then
r1("订单总额") = r("GrandTotal")
r1("客户名称") = r("客户名称")
r1("客户电话") = r("客户电话")
End If
End If
Select Case e.DataCol.Name
Case "订单号","订单总额","付款金额"
Dim dr As DataRow
Dim mr As DataRow = e.DataRow
Dim drs As List(of DataRow)
dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [订单号] = '" & mr("订单号") & "'", "[_SortKey] Desc")
If dr Is Nothing Then
mr("未付金额") = mr("订单总额") - mr("付款金额")
dr = mr
End If
drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [订单号] = '" & dr("订单号") & "'", "[_SortKey]")
For i As Integer = 1 To drs.Count - 1
drs(i)("未付金额") = drs(i-1)("未付金额") - drs(i)("付款金额")
Next
If e.DataCol.Name = "订单号" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then
dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [订单号] = '" & e.OldValue & "'", "[_SortKey] Desc")
If dr Is Nothing Then
dr = e.DataTable.Find("[订单号] = '" & e.OldValue & "'", "[_SortKey]")
If dr IsNot Nothing Then
dr("未付金额") = dr("订单总额") - dr("付款金额")
End If
End If
If dr IsNot Nothing Then
drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [订单号] = '" & dr("订单号") & "'", "[_SortKey]")
For i As Integer = 1 To drs.Count - 1
drs(i)("未付金额") = drs(i-1)("未付金额") - drs(i)("付款金额")
Next
End If
End If
End Select
If e.DataCol.Name = "付款金额" Then
Dim pr As DataRow
pr = DataTables("销售订单").Find("订单号 = '" & e.DataRow("订单号") & "'")
If pr IsNot Nothing Then
pr("已付款")= pr("已付款") + e.NewValue - e.OldValue
End If
End If
订单出库明细表也有同样的流水账代码,没有报这个错。
[此贴子已经被作者于2021/12/26 2:36:31编辑过]