Foxtable(狐表)用户栏目专家坐堂 → [求助]如何修改加权计算代码?


  共有3036人关注过本帖树形打印复制链接

主题:[求助]如何修改加权计算代码?

帅哥哟,离线,有人找我吗?
大红袍
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/1/26 0:24:00 [显示全部帖子]

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

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/1/26 23:18:00 [显示全部帖子]

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

 回到顶部