Select Case e.DataCol.Name Case "欠交数量" If e.DataRow ("欠交数量") = 0 And e.DataRow.IsNull ("实际交货数量") = False Then Dim nma() As String = {"计划编号","车号","入库单号"} 'A表数据来源列 Dim nmb() As String = {"计划编号","车号","入库单号"} 'B表数据接收列 Dim drr As DataRow = DataTables("合同明细").AddNew For i As Integer = 0 To nma.Length - 1 drr(nmb(i)) = e.DataRow(nma(i)) Next End If End Select 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 Dim drr As DataRow = DataTables("订单").find("计划编号='" & mr("计划编号") & "'") mr("欠交数量") = drr("计划数量") - 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 Dim drr As DataRow = DataTables("订单").find("计划编号='" & mr("计划编号") & "'") dr("欠交数量") = drr("计划数量") - dr("实际交货数量") End If End If If dr IsNot Nothing Then drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [计划编号] = '" & dr("计划编号") & "'", "[_SortKey]") Dim drr As DataRow = DataTables("订单").find("计划编号='" & dr("计划编号") & "'") If drr IsNot Nothing Then drs(0)("欠交数量")= drr("计划数量") End If For i As Integer = 1 To drs.Count - 1 drs(i)("欠交数量") = drs(i-1)("欠交数量") - drs(i)("实际交货数量") Next End If End If End Select
|