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