Select Case e.DataCol.Name
Case "料号","是否需要加工"
If e.DataRow.IsNull("料号") OrElse e.DataRow.IsNull("是否需要加工") Then
e.DataRow("外部单价") = Nothing
'e.DataRow("型号") = Nothing
'e.DataRow("规格") = Nothing
'e.DataRow("单价") = Nothing
Else
Dim dr As DataRow
If e.DataRow("是否需要加工") = "需要加工"
dr = DataTables("来料记录").Find("[料号] = '" & e.DataRow("料号") & "'","素材单价 desc")
If dr IsNot Nothing
e.DataRow("素材单价") = dr("素材单价")
e.DataRow("综合单价") = dr("素材单价") + dr("加工单价")
End If
Else
dr = DataTables("来料记录").Find("[料号] = '" & e.DataRow("料号") & "'","外部单价 desc")
If dr IsNot Nothing
e.DataRow("外部单价") = dr("外部单价")
e.DataRow("综合单价") = IIF(dr("外部单价") > dr("内部单价"),dr("外部单价") ,dr("内部单价"))
End If
End If
End If
End Select