Select Case e.DataCol.name
Case "物资部预算编号"
If e.DataRow.IsNull("物资部预算编号") Then
DataTables("管道成套项目采购明细表").DeleteFor("物资部预算编号='" & e.DataRow("物资部预算编号") & "'")
e.DataRow("材料到齐") = False
e.DataRow("复验合格") = False
e.DataRow("领料完成") = False
Else
If e.DataRow.GetChildRows("管道成套项目采购明细表").Count > 0
Dim cnt As Integer = DataTables("管道成套项目采购明细表").Compute("count(物资部预算编号)","物资部预算编号='" & e.NewValue & "' and (质保书状态=False or 理化检验结果=False)")
e.DataRow("复验合格") = (cnt=0)
cnt = DataTables("管道成套项目采购明细表").Compute("count(物资部预算编号)","物资部预算编号='" & e.NewValue & "' and (未到货数量 = 0 Or 未到货数量 Is null)")
e.DataRow("材料到齐") = (cnt=0)
cnt = DataTables("管道成套项目采购明细表").Compute("count(物资部预算编号)","物资部预算编号='" & e.NewValue & "' and (未领料数量 = 0 Or 未领料数量 Is null)")
e.DataRow("领料完成") = (cnt=0)
End If
If e.OldValue Is Nothing
Dim ndr As Row = Tables("管道成套项目采购明细表").AddNew
ndr("物资部预算编号") = e.DataRow("物资部预算编号")
ndr("销售合同编号") = e.DataRow("销售合同编号")
ndr("预算日期") = e.DataRow("预算日期")
ndr("项目名称") = e.DataRow("项目名称")
ndr("预算确认") = e.DataRow("预算确认")
ndr("编制人") = e.DataRow("编制人")
ndr.Move(0)
End If
End If
End Select