以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]1.排名错误:无法找到 2.填充对应班级的教师姓名  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=136693)

--  作者:game178
--  发布时间:2019/6/19 11:21:00
--  [求助]1.排名错误:无法找到 2.填充对应班级的教师姓名

图片点击可在新窗口打开查看此主题相关图片如下:qq2.png
图片点击可在新窗口打开查看

图片点击可在新窗口打开查看此主题相关图片如下:qq1.png
图片点击可在新窗口打开查看
问题1:我想把成绩按考试年月和班级进行排名,但程序显示无法找到语文
问题2:统计栏,我想把相应的任课教师加进去。怎么办?
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:cs.table


--  作者:有点甜
--  发布时间: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 & " 秒"


--  作者:有点甜
--  发布时间: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


--  作者:game178
--  发布时间:2019/6/19 11:49:00
--  
我看看先,谢谢
[此贴子已经被作者于2019/6/19 11:49:32编辑过]

--  作者:game178
--  发布时间:2019/6/19 11:53:00
--  
谢谢,搞定了,我慢慢来看原来的问题是什么,谢谢
--  作者:game178
--  发布时间:2019/6/19 12:54:00
--  
以下是引用有点甜在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


那如果我在统计表最左边加上一个学期,要取学期和班级一致,才填充相应学科怎么处理呢?


--  作者:game178
--  发布时间:2019/6/19 12:59:00
--  
那如果我在统计表最左边加上一个学期,如何自动填充《成绩加载表》里面的学期,统计表里面如何填充教师姓名【
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:cs2.table

学期和班级一致,才填充相应学科教师姓名】

--  作者:有点甜
--  发布时间: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


--  作者:game178
--  发布时间:2019/6/20 16:17:00
--  
如果清空成绩排名数据后,再点,没反应。
--  作者:有点甜
--  发布时间: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 & " 秒"