If e.DataCol.name = "系统拆分" OrElse e.DataCol.name = "供货批次" Then
If e.DataRow("系统拆分") = True Then
If e.DataRow("供货批次") <> Nothing Then
e.DataTable.DeleteFor("订单分批次号 like '" & e.DataRow("订单编号") & "%' and 订单分批次号 <> '" & e.DataRow("订单编号") & "-01'")
Dim n1 As Double = e.DataRow("产品数量") / e.DataRow("供货批次")
Dim n2 As Double = (e.DataRow("大订单截止日期") - e.DataRow("大订单开始日期")).TotalDays / e.DataRow("供货批次")
e.DataRow("订单分批次号") = e.DataRow("订单编号") & "-01"
e.DataRow("检验日期") = e.DataRow("大订单开始日期").adddays(n2)
e.DataRow("分批次数量") = n1
For i As Integer = 2 To e.DataRow("供货批次")
Dim ndr As DataRow = e.DataTable.addnew
ndr("订单分批次号") = e.DataRow("订单编号") & format(i, "-00")
ndr("检验日期") = e.DataRow("大订单开始日期").adddays(n2*i)
ndr("分批次数量") = n1
Next
End If
ElseIf e.DataCol.name = "供货批次" Then
e.DataTable.DeleteFor("订单分批次号 like '" & e.DataRow("订单编号") & "%' and 订单分批次号 <> '" & e.DataRow("订单编号") & "-01'")
Dim n1 As Double = e.DataRow("产品数量") / e.DataRow("供货批次")
Dim n2 As Double = (e.DataRow("大订单截止日期") - e.DataRow("大订单开始日期")).TotalDays / e.DataRow("供货批次")
e.DataRow("订单分批次号") = e.DataRow("订单编号") & "-01"
e.DataRow("检验日期") = e.DataRow("大订单开始日期").adddays(n2)
e.DataRow("分批次数量") = n1
For i As Integer = 2 To e.DataRow("供货批次")
Dim ndr As DataRow = e.DataTable.addnew
ndr("订单分批次号") = e.DataRow("订单编号") & format(i, "-00")
ndr("检验日期") = e.DataRow("大订单开始日期").adddays(n2*i)
ndr("分批次数量") = n1
Next
ElseIf e.DataCol.name = "系统拆分" AndAlso e.oldvalue = True Then
e.DataTable.DeleteFor("订单分批次号 like '" & e.DataRow("订单编号") & "%' and 订单分批次号 <> '" & e.DataRow("订单编号") & "-01'")
End If
End If
If e.DataCol.name = "分批时间" Then
Dim i = e.DataRow("订单分批次号").lastindexof("-")
e.DataRow("检验日期") = Nothing
If i >= 0 Then
Dim id = e.DataRow("订单分批次号").SubString(0, i)
Dim drs = e.DataTable.Select("订单分批次号 like '" & id & "%'", "订单分批次号")
Dim count = 0
For Each dr As DataRow In drs
count += val(dr("分批时间"))
dr("检验日期") = (drs(0)("大订单开始日期")).adddays(count)
If dr("检验日期") > drs(0)("大订单截止日期") Then
msgbox("检验日期超过了")
End If
Next
End If
End If