运费分摊我帮你做好了,下面代码加粗的部分,就是计算运费分摊的:
Dim dr1 As DataRow = e.DataRow
Dim dr2 As DataRow
If e.DataCol.Name = "驾驶员" Then
dr2 = DataTables("参数").Find("驾驶员 = " & "'" & dr1("驾驶员") & "'" )
If dr2 IsNot Nothing '如果找到, 则设置各列内容
dr1("车号")= dr2("车号")
dr1("车长")= dr2("车长")
End If
End If
Select Case e.DataCol.Name
Case "运输地点" ,"车号", "车长"
dr2 = DataTables("参数").Find("运输地点 = " & "'" & dr1("运输地点") & "' And 车长 = '" & dr1("车长") & "' And 车号 = '" & dr1("车号") & "'" )
If dr2 IsNot Nothing '如果找到, 则设置各列内容
dr1("运费")= dr2("运费")
End If
Case "出单日期","运费","处理总量"
Dim drs As List(of DataRow) = e.DataTable.Select("出单日期 = #" & dr1("出单日期") & "#")
Dim cnt As Integer = e.DataTable.Compute("sum(处理总量)", "出单日期 = #" & dr1("出单日期") & "#")
Dim val As Double = e.DataTable.Compute("sum(运费)", "出单日期 = #" & dr1("出单日期") & "#") /cnt
For Each dr As DataRow In drs
dr("运费分摊") = val * dr("处理总量")
Next
End Select
If e.DataCol.Name = "二次运输" Then
dr2 = DataTables("参数").Find("驾驶员 = " & "'" & dr1("二次运输") & "'" )
If dr2 IsNot Nothing '如果找到, 则设置各列内容
dr1("二次车号")= dr2("车号")
dr1("二次车长")= dr2("车长")
End If
End If
Select Case e.DataCol.Name
Case "运送地点" ,"二次车号", "二次车长"
dr2 = DataTables("参数").Find("运输地点 = " & "'" & dr1("运送地点") & "' And 车长 = '" & dr1("二次车长") & "' And 车号 = '" & dr1("二次车号") & "'" )
If dr2 IsNot Nothing '如果找到, 则设置各列内容
dr1("二次运费")= dr2("运费")
End If
End Select
Select Case e.DataCol.Name
Case "处理方式","品种1","规格1"
dr2 = DataTables("参数").Find("处理方式 = '" & dr1("处理方式") & "' And 产品名称 = '" & dr1("品种1") & "' And 产品规格 = '" & dr1("规格1") & "'")
If dr2 IsNot Nothing Then
dr1("单价1") = dr2("报价")
End If
End Select
Select Case e.DataCol.Name
Case "处理方式","品种2","规格2"
dr2 = DataTables("参数").Find("处理方式 = '" & dr1("处理方式") & "' And 产品名称 = '" & dr1("品种2") & "' And 产品规格 = '" & dr1("规格2") & "'")
If dr2 IsNot Nothing Then
dr1("单价2") = dr2("报价")
End If
End Select
Select Case e.DataCol.Name
Case "处理方式","品种3","规格3"
dr2 = DataTables("参数").Find("处理方式 = '" & dr1("处理方式") & "' And 产品名称 = '" & dr1("品种3") & "' And 产品规格 = '" & dr1("规格3") & "'")
If dr2 IsNot Nothing Then
dr1("单价3") = dr2("报价")
End If
End Select
Select Case e.DataCol.Name
Case "处理方式","品种4","规格4"
dr2 = DataTables("参数").Find("处理方式 = '" & dr1("处理方式") & "' And 产品名称 = '" & dr1("品种4") & "' And 产品规格 = '" & dr1("规格4") & "'")
If dr2 IsNot Nothing Then
dr1("单价4") = dr2("报价")
End If
End Select
Select Case e.DataCol.Name
Case "处理方式","品种5","规格5"
dr2 = DataTables("参数").Find("处理方式 = '" & dr1("处理方式") & "' And 产品名称 = '" & dr1("品种5") & "' And 产品规格 = '" & dr1("规格5") & "'")
If dr2 IsNot Nothing Then
dr1("单价5") = dr2("报价")
End If
End Select
Select Case e.DataCol.Name
Case "处理方式","品种6","规格6"
dr2 = DataTables("参数").Find("处理方式 = '" & dr1("处理方式") & "' And 产品名称 = '" & dr1("品种6") & "' And 产品规格 = '" & dr1("规格6") & "'")
If dr2 IsNot Nothing Then
dr1("单价6") = dr2("报价")
End If
End Select
Select Case e.DataCol.Name
Case "处理方式","品种7","规格7"
dr2 = DataTables("参数").Find("处理方式 = '" & dr1("处理方式") & "' And 产品名称 = '" & dr1("品种7") & "' And 产品规格 = '" & dr1("规格7") & "'")
If dr2 IsNot Nothing Then
dr1("单价7") = dr2("报价")
End If
End Select
Select Case e.DataCol.Name
Case "处理方式","品种8","规格8"
dr2 = DataTables("参数").Find("处理方式 = '" & dr1("处理方式") & "' And 产品名称 = '" & dr1("品种8") & "' And 产品规格 = '" & dr1("规格8") & "'")
If dr2 IsNot Nothing Then
dr1("单价8") = dr2("报价")
End If
End Select