|
If e.DataCol.Name = "客戶" OrElse e.DataCol.Name = "商品名稱" Then '如果內(nèi)容發(fā)生變動的是品名列
If e.DataRow.isnull("客戶") OrElse e.DataRow.isnull("商品名稱") Then '如果新值是空白,也就是品名列的內(nèi)容為空
e.DataRow("單價") = Nothing '那么清空此行單價列的內(nèi)容
Else
Dim dr As DataRow
'否則在產(chǎn)品表查找同名的產(chǎn)品行,將找到的行賦值給變量dr
dr = DataTables("客戶").Find("[客戶名稱] = '" & e.DataRow("客戶") & "'")
If dr IsNot Nothing Then '如果找到了同名的產(chǎn)品行,也就是dr不是Nothing
Dim dr2 As DataRow = DataTables("商品").Find("[商品名稱] = '" & e.DataRow("商品名稱") & "'")
If dr2 IsNot Nothing Then
e.DataRow("單價") = dr2(dr("售價級別"))
End If
End If
End If
End If
If e.DataCol.Name = "商品名稱" Then
If e.DataRow.isnull("商品名稱") Then
e.DataRow("單價") = Nothing
Else
Dim dr2 As DataRow = DataTables("商品").Find("[商品名稱] = '" & e.DataRow("商品名稱") & "'")
If dr2 IsNot Nothing Then
e.DataRow("規(guī)格") = dr2("規(guī)格")
End If
End If
End If
以上是我在別的軟件的VB代碼,能否幫忙轉(zhuǎn)成ACCESS用的? |
|