If Forms("订单录入").Opened Then
Dim yfzf As String '运费支付方式
yfzf = Forms("订单录入").Controls("ComboBox1").value
Dim dz As String = forms("订单录入").controls("TextBox5").text '地域
Dim yf As Single '运费
Dim dr As DataRow
Dim dr1 As DataRow = e.DataRow
Dim dr2 As DataRow
Select Case yfzf
Case "到付"
If e.DataCol.Name = "数量" Then '如果是数量列的内容变动
dr2 = DataTables("单价").Find("商品ID ='" & dr1("商品ID") & "'")
If dr2 IsNot Nothing Then
dr1("运费单价") = 0
dr1("合价") = dr1("数量") * dr1("单价")
dr1("成本") = dr1("数量") * dr2("代理单价")
dr1("结算合价") = dr1("数量") * dr2("进货单价")
end if
End If
Case "免邮"
If e.DataCol.Name = "数量" Then '如果是数量列的内容变动
dr2 = DataTables("单价").Find("商品ID ='" & dr1("商品ID") & "'")
If dz IsNot Nothing Then
dr = DataTables("地域及运费").Find("市县 ='" & dz & "'")
dr1("运费单价") = dr("运费")
End If
dr1("合价") = dr1("数量") * dr1("单价") - dr1("数量") * dr1("运费单价")
dr1("成本") = dr1("数量") * dr2("代理单价") - dr1("数量") * dr1("运费单价")
dr1("结算合价") = dr1("数量") * dr2("进货单价") + dr1("数量") * dr1("运费单价")
End If
Case "寄付"
If e.DataCol.Name = "数量" Then '如果是数量列的内容变动
dr2 = DataTables("单价").Find("商品ID ='" & dr1("商品ID") & "'")
if dr2 isNot Nothing then
If dz IsNot Nothing Then
dr = DataTables("地域及运费").Find("市县 ='" & dz & "'")
dr1("运费单价") = dr("运费")
End If
dr1("合价") = dr1("数量") * dr1("单价") + dr1("数量") * dr1("运费单价")
dr1("成本") = dr1("数量") * dr2("代理单价") + dr1("数量") * dr1("运费单价")
dr1("结算合价") = dr1("数量") * dr2("进货单价") + dr1("数量") * dr1("运费单价")
end if
End If
End Select
End If