'非关联表之间的数据同步(884)
Select Case e.DataCol.name
Case "材料名称"
Dim dr As DataRow = DataTables("区队材料领用表").Find("材料名称 = '" & e.OldValue & "'")
If dr Is Nothing Then
dr = DataTables("区队材料领用表").AddNew()
dr("领用区队") = e.DataRow("领用区队")
dr("材料名称") = e.DataRow("材料名称")
dr("规格型号") = e.DataRow("规格型号")
dr("数量") = e.DataRow("数量")
dr("领用时间") = e.DataRow("领用时间")
dr("使用地点") = e.DataRow("使用地点")
Else
dr("材料名称") = e.DataRow("材料名称")
End If
Case "规格型号","数量","单位"
Dim dr As DataRow = DataTables("区队材料领用表").Find("材料名称 = '" & e.DataRow("材料名称") & "'")
If dr IsNot Nothing Then
dr(e.DataCol.Name) = e.DataRow(e.DataCol.Name)
End If
End Select
'从材料信息表中提取输入材料的单价
Select Case e.DataCol.Name
Case "材料名称","规格型号"
Dim dr As DataRow = e.DataRow
Dim pr As DataRow
If dr.IsNull("材料名称") OrElse dr.IsNull("规格型号") Then
dr("单价") = Nothing
dr("单位") = Nothing
Else
Dim filter As String
filter = "材料名称 = '" & dr("材料名称") & "' And 规格型号 = '" & dr("规格型号") & "'"
pr = DataTables("材料信息表").Find(filter)
If pr IsNot Nothing Then
dr("单价") = pr("单价")
dr("单位") = pr("单位")
End If
End If
End Select