If e.DataCol.Name = "结算金额" Then '如果内容发生变动的是品名列
If e.NewValue Is Nothing Then '如果新值是空白,也就是品名列的内容为空
e.DataRow("成本预算") = Nothing '那么清空此行单价列的内容
Else
Dim dr As DataRow '否则在产品表查找同名的产品行,将找到的行赋值给变量dr
dr("成本预算") = dr("结算金额") - dr("成本单价")
End If
End If
If e.DataCol.Name = "销售型号" Then '如果内容发生变动的是品名列
If e.NewValue Is Nothing Then '如果新值是空白,也就是品名列的内容为空
e.DataRow("吊牌单价") = Nothing '那么清空此行单价列的内容
e.DataRow("成本单价") = Nothing
Else
Dim dr As DataRow
'否则在产品表查找同名的产品行,将找到的行赋值给变量dr
dr = DataTables("基本资料").Find("[型号] = '" & e.NewValue & "'")
If dr IsNot Nothing Then '如果找到了同名的产品行,也就是dr不是Nothing
e.DataRow("吊牌单价") = dr("单价")
e.DataRow("成本单价") = dr("成本")
End If
End If
End If
Dim dr1 As DataRow = e.DataRow
Select Case e.DataCol.Name
Case "销售单价"
dr1("折扣扣率") = dr1("销售单价") / dr1("吊牌单价")
End Select
Select Case e.DataCol.Name
Case "销售公司", "销售型号"
Dim dr2 As DataRow = e.DataRow
Dim pr As DataRow
If dr2.IsNull("销售公司") OrElse dr2.IsNull("销售型号") Then
dr2("套餐折扣") = Nothing
Else
Dim filter As String
filter = "结算公司 = '" & dr2("销售公司") & "' And 型号 = '" & dr2("销售型号") & "'"
pr = DataTables("套餐").Find(filter)
If pr IsNot Nothing Then
dr2("套餐折扣") = pr("套餐折扣")
End If
End If
End Select
Dim dr4 As DataRow = e.DataRow
If dr4("结算类别") = ("代销") Then
dr4("结算金额") = dr4("吊牌单价") * dr4("套餐折扣")
ElseIf dr4("结算类别") = ("经销") Then
dr4("结算金额") = dr4("销售单价") * dr4("套餐折扣")
End If