Rss & SiteMap
Foxtable(狐表) http://www.foxtable.com
Dim dr As DataRow = e.DataRow
Select Case e.DataCol.Name
Case "入库数量1","入库数量","单个克重"
If dr.IsNull("入库数量") OrElse dr.IsNull("单个克重") Then
dr("入库数量1") = Nothing
Else
dr("入库数量1") = dr("入库数量") * dr("单个克重")
End If
End Select
If e.DataCol.Name = "材料名" Then
Dim dr1 As DataRow = DataTables("入录资料").Find("原材料 = '" & e.NewValue & "'")
If dr1 IsNot Nothing
e.DataRow("材料代号")= dr1("代号")
e.DataRow("单位")= dr1("单位")
e.DataRow("规格")= dr1("规格")
e.DataRow("单个克重")= dr1("单个克重")
End If
End If
单个克重列默认值公式设为2
Dim dr As DataRow = e.DataRow
Select Case e.DataCol.Name
Case "入库数量1","入库数量","单个克重"
If dr.IsNull("入库数量") OrElse dr.IsNull("单个克重") Then
dr("入库数量1") = Nothing
Else
dr("入库数量1") = dr("入库数量") * dr("单个克重")
End If
End Select
If e.DataCol.Name = "材料名" Then
Dim dr1 As DataRow = DataTables("入录资料").Find("原材料 = " & "'" & e.DataRow("材料名") & "'" )
If dr1 IsNot Nothing
e.DataRow("材料代号")= dr1("代号")
e.DataRow("单位")= dr1("单位")
e.DataRow("规格")= dr1("规格")
e.DataRow("单个克重")= dr1("单个克重")
End If
End If
如果不是为了学习代码的话,入库数量列用表达式是最好的.
Dim dr As DataRow = e.DataRow
Select Case e.DataCol.Name
Case "入库数量1","入库数量","单个克重"
If dr.IsNull("入库数量") OrElse dr.IsNull("单个克重") Then
dr("入库数量1") = Nothing
Else
If e.DataCol.Name = "单个克重" Then
dr("入库数量1") = dr("入库数量") * dr("单个克重")
Else
dr("单个克重") = 2
dr("入库数量1") = dr("入库数量") * dr("单个克重")
End If
End If
End Select
If e.DataCol.Name = "材料名" Then
Dim dr1 As DataRow = DataTables("入录资料").Find("原材料 = '" & e.NewValue & "'")
If dr1 IsNot Nothing
e.DataRow("材料代号")= dr1("代号")
e.DataRow("单位")= dr1("单位")
e.DataRow("规格")= dr1("规格")
e.DataRow("单个克重")= dr1("单个克重")
End If
End If