Foxtable(狐表)用户栏目专家坐堂 → [求助]1.排名错误:无法找到 2.填充对应班级的教师姓名


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

主题:[求助]1.排名错误:无法找到 2.填充对应班级的教师姓名

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/6/19 11:30:00 [显示全部帖子]

1、

 

Dim f As New Filler
f.SourceTable = DataTables("成绩加载表")
f.SourceCols = "考试性质,考试年月,学校,班级,姓名,科类,考号,语文,数学,英语,物理,化学,生物,政治,历史,地理"
f.DataTable = DataTables("成绩排名")
f.DataCols = "考试性质,考试年月,学校,班级,姓名,科类,考号,语文,数学,英语,物理,化学,生物,政治,历史,地理"
f.ExcludeExistValue = True
f.ExcludeNullValue = True
f.Fill

 Dim pm As List(Of String()) = DataTables("成绩排名").getvalues("考试年月|班级","")
'获取考试年月和班级为名单

Dim pmc As Integer
Dim ColNames() As String = {"语文","数学","英语","物理","化学","生物","政治","历史","地理","总分"} 
Dim TotalName As String
For Each ColName As String In ColNames
    For i As Integer = 0 To pm.Count -1
        If pm(i)(0) = "" Then
            Continue For
        End If
        Dim drs As List(Of DataRow) = DataTables("成绩排名").Select("[考试年月] = '" & pm(i)(0) & "'And [班级] = '" & pm(i)(1) & "'", ColName & " DESC")
        pmc = 0
        TotalName = ColName & "排名"
        For n As Integer = 0 To drs.Count - 1
            pmc = pmc +1
            If n > 0 AndAlso drs(n)(ColName ) = drs(n-1)(ColName) Then
                drs(n)(TotalName ) = drs(n-1)(TotalName )
            Else
                drs(n)(TotalName ) = pmc
            End If
        Next
    Next
Next


Tables("成绩排名").Sort = "考试年月,班级,总分排名"
'Time1 = Date.Now
'e.Form.Controls("Label1").text="耗时 " & (Time1-Time).TotalSeconds & " 秒"


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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/6/19 11:34:00 [显示全部帖子]

2、单独执行代码

 

Dim t As Table = Tables("基础科统计")
For Each r As Row In t.Rows
    Dim fdr As DataRow = DataTables("任课教师").find("班级='" & r("班级") & "'")
    If fdr IsNot Nothing Then
        For Each c As Col In t.Cols
            If c.DataCol.Expression = Nothing Then
                For Each dc As DataCol In fdr.DataTable.DataCols
                    If c.Caption.Contains(dc.name) Then
                        r(c) = fdr(dc.name)
                        Exit For
                    End If
                Next
            End If
        Next
    End If
Next


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/6/19 15:10:00 [显示全部帖子]

以下是引用game178在2019/6/19 12:59:00的发言:
那如果我在统计表最左边加上一个学期,如何自动填充《成绩加载表》里面的学期,统计表里面如何填充教师姓名【要学期和班级一致,才填充相应学科教师姓名】

 

Dim t1 As Table = Tables("成绩加载表")
Dim t As Table = Tables("基础科统计")
For Each r As Row In t.Rows
    r("学期") = t1.current("学期")
    Dim fdr As DataRow = DataTables("任课教师").find("班级='" & r("班级") & "' and 学期='" & r("学期") & "'")
    If fdr IsNot Nothing Then
        For Each c As Col In t.Cols
            If c.DataCol.Expression = Nothing Then
                For Each dc As DataCol In fdr.DataTable.DataCols
                    If c.Caption.Contains(dc.name) Then
                        r(c) = fdr(dc.name)
                        Exit For
                    End If
                Next
            End If
        Next
    End If
Next


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/6/20 16:23:00 [显示全部帖子]

以下是引用game178在2019/6/20 16:17:00的发言:
如果清空成绩排名数据后,再点,没反应。

 

删除红色代码,即可

 

Dim f As New Filler
f.SourceTable = DataTables("成绩加载表")
f.SourceCols = "考试性质,考试年月,学校,班级,姓名,科类,考号,语文,数学,英语,物理,化学,生物,政治,历史,地理"
f.DataTable = DataTables("成绩排名")
f.DataCols = "考试性质,考试年月,学校,班级,姓名,科类,考号,语文,数学,英语,物理,化学,生物,政治,历史,地理"
f.ExcludeExistValue = True
f.ExcludeNullValue = True
f.Fill

 Dim pm As List(Of String()) = DataTables("成绩排名").getvalues("考试年月|班级","")
'获取考试年月和班级为名单

Dim pmc As Integer
Dim ColNames() As String = {"语文","数学","英语","物理","化学","生物","政治","历史","地理","总分"} 
Dim TotalName As String
For Each ColName As String In ColNames
    For i As Integer = 0 To pm.Count -1
        If pm(i)(0) = "" Then
            Continue For
        End If
        Dim drs As List(Of DataRow) = DataTables("成绩排名").Select("[考试年月] = '" & pm(i)(0) & "'And [班级] = '" & pm(i)(1) & "'", ColName & " DESC")
        pmc = 0
        TotalName = ColName & "排名"
        For n As Integer = 0 To drs.Count - 1
            pmc = pmc +1
            If n > 0 AndAlso drs(n)(ColName ) = drs(n-1)(ColName) Then
                drs(n)(TotalName ) = drs(n-1)(TotalName )
            Else
                drs(n)(TotalName ) = pmc
            End If
        Next
    Next
Next


Tables("成绩排名").Sort = "考试年月,班级,总分排名"
'Time1 = Date.Now
'e.Form.Controls("Label1").text="耗时 " & (Time1-Time).TotalSeconds & " 秒"


 回到顶部