Dim dt As DataTable = DataTables("职称评审成绩") Dim dt_d As DataTable = DataTables("加权计算") dt_d.DataRows.Clear For Each zy As String In dt.GetValues("专业组名称") Dim ls As List(Of String) = dt.GetValues("面试室", "专业组名称 = '" & zy & "'") Dim zy_sum As Double = 0 Dim lxs As List(Of String) = dt.GetValues("单位类型", "专业组名称 = '" & zy & "'") For Each s As String In ls Dim dr As DataRow = dt_d.AddNew dr("专业组名称") = zy dr("面试室") = s Dim ss_sum As Double = 0 For Each lx As String In lxs Dim sum As Double = dt.Compute("sum(原始成绩)", "专业组名称 = '" & zy & "' and 面试室 = '" & s & "' and 单位类型 = '" & lx & "'") Dim count As Double = dt.Compute("count(原始成绩)", "专业组名称 = '" & zy & "' and 面试室 = '" & s & "' and 单位类型 = '" & lx & "'") ss_sum += sum / count Next dr("面试室平均值") = ss_sum / lxs.count zy_sum += dr("面试室平均值") Next If ls.Count > 1 Then dt_d.ReplaceFor("加权平均值", zy_sum / ls.Count, "专业组名称 = '" & zy & "'") End If Next For Each dr As DataRow In dt_d.DataRows If dr("加权平均值") <> 0 AndAlso dr("面试室平均值") <> 0 Then dr("加权系数") = dr("加权平均值") / dr("面试室平均值") End If Next
|