If e.DataCol.Name = "产品编号" Then
If e.NewValue = Nothing Then
e.DataRow("产品名称") = Nothing
e.DataRow("规格型号") = Nothing
e.DataRow("分类") = Nothing
e.DataRow("单位") = Nothing
e.DataRow("产地") = Nothing
e.DataRow("注册证号") = Nothing
e.DataRow("单价元") = Nothing
e.DataRow("入库批号") = Nothing
e.DataRow("有效期") = Nothing
Else
Dim dr As DataRow
dr = DataTables("入库明细").Find("[产品编号] = '" & e.NewValue & "'")
If dr IsNot Nothing
e.DataRow("产品名称")= dr("产品名称")
e.DataRow("规格型号") = dr("规格型号")
e.DataRow("单位") = dr("单位")
e.DataRow("分类") = dr("分类")
e.DataRow("产地") = dr("产地")
e.DataRow("注册证号") = dr("注册证号")
e.DataRow("单价元") = dr("单价元")
e.DataRow("入库批号") = Nothing
e.DataRow("有效期") = Nothing
End If
End If
End If
Select Case e.DataCol.Name
Case "入库批号"
if e.newValue <> Nothing AndAlso e.newvalue.Length >= 8 then
Dim s As String = CStr(e.NewValue)
Dim d As Date =new Date(s.SubString(0,4),s.SubString(4,2),s.SubString(6,2))
d = d.AddYears(1).AddDays(-1)
e.DataRow("有效期") = Format(d,"yyyyMMdd")
end if
End Select
If e.DataCol.Name = "单价元" OrElse e.DataCol.Name = "数量" Then
e.DataRow("金额元") = e.DataRow("单价元") * e.DataRow("数量")
End If