If e.DataCol.Name = "材料类型" Then If e.DataRow("材料类型") = "检具" Dim drm As DataRow drm = DataTables("检具表").Find("[物料名称]= '" & e.NewValue & "' And [规格型号]= '" & e.NewValue & "' ", "[_SortKey] Desc" ) If drm IsNot Nothing Then e.DataRow("现有库存数量") = drm("库存数量") End If ElseIf e.DataRow("材料类型") = "刀具" Dim drn As DataRow drn = DataTables("检具表").Find("[物料名称]= '" & e.NewValue & "' And [规格型号]= '" & e.NewValue & "' ", "[_SortKey] Desc" ) If drn IsNot Nothing Then e.DataRow("现有库存数量") = drn("库存数量") End If Else e.DataRow("材料类型") = "辅料" Dim drt As DataRow drt = DataTables("辅料表").Find("[物料名称]= '" & e.NewValue & "' And [规格型号]= '" & e.NewValue & "' ", "[_SortKey] Desc" ) If drt IsNot Nothing Then e.DataRow("现有库存数量") = drt("库存数量") End If End If End If