Foxtable(狐表)用户栏目专家坐堂 → 转置后的临时表怎么用


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

主题:转置后的临时表怎么用

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


加好友 发短信
等级:三尾狐 帖子:607 积分:4241 威望:0 精华:0 注册:2015/7/25 19:14:00
  发帖心情 Post By:2018/11/2 15:34:00 [只看该作者]

问题找到了,是

Dim fsd As New List(of Integer)
For Each r1 As Row In Tables("自定义统计分数段").Rows
    If r1.Checked Then
        fsd.add(r1("分数段"))
    End If

没有添加数据


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


加好友 发短信
等级:三尾狐 帖子:607 积分:4241 威望:0 精华:0 注册:2015/7/25 19:14:00
  发帖心情 Post By:2018/11/5 17:38:00 [只看该作者]

甜老师,在统计表中,添加字段“考试期数”如何添加

 

 

Dim g As New CrossTableBuilder("成绩转置", DataTables("成绩登记表"))
g.HGroups.AddDef("考试期数")
g.HGroups.AddDef("年级")
g.HGroups.AddDef("班级")
g.HGroups.AddDef("学号")
g.HGroups.AddDef("姓名", "", "参考人数")
g.VGroups.AddDef("课程名称")
g.Totals.AddDef("分数", "分数")
g.HorizontalTotal = True
g.Build()
MainTable = Tables("成绩转置")
'Std:标准偏差
'StdPop:总体标准偏差
'Sum:累积值
'Var:方差
'VarPop:总体方差

'--------------------------
Dim dtb As New DataTableBuilder("统计")
dtb.AddDef("参考人数", Gettype(String))

dtb.AddDef("年级", Gettype(String))
dtb.AddDef("考试期数", Gettype(String))
dtb.AddDef("班级", Gettype(String))
dtb.AddDef("科目", Gettype(String), 32)
dtb.AddDef("最高分", Gettype(Double))
dtb.AddDef("最低分", Gettype(Double))
dtb.AddDef("平均分", Gettype(Double))
dtb.AddDef("标准偏差", Gettype(Double), 32)
dtb.AddDef("总体标准偏差", Gettype(Double))
dtb.AddDef("样本方差", Gettype(Double))
dtb.AddDef("总样本方差", Gettype(Double))

dtb.Build()
'--------
Dim dic As new Dictionary(of String, String)
For Each c As Col In Tables("成绩转置").cols
    dic.add(c.caption, c.name)
    '--------
Next
Dim exp,flt As String
Dim dt As DataTable =DataTables("成绩转置")
Dim t As Table = Tables("成绩转置")
Dim t1 As Table =Tables("统计")
't1.StopRedraw

Dim bjs As List(of String()) = dt.Getvalues("年级|班级")
For Each bj As String() In bjs
    Dim f As New Filler
    f.SourceTable =DataTables("科目表")
    f.DataTable = t1.DataTable
    f.Fill()
  
    t1.DataTable.ReplaceFor("班级",bj(1),"班级 Is null")
    t1.DataTable.ReplaceFor("年级",bj(0),"年级 Is null")
Next

For Each dc As Col In t1.Cols
    For Each dr As Row In t1.Rows
        flt = "班级 = '" & dr("班级") & "' and 年级 = '" & dr("年级") & "'"
        Select Case dc.name
            Case "最高分"
                exp = "Max(" & dic(dr("科目")) & ")"
                dr(dc.name) =dt.Compute(exp,flt)
            Case "最低分"
                exp = "Min(" & dic(dr("科目")) & ")"
                dr(dc.name) =dt.Compute(exp,flt)
            Case "平均分"
                exp = "Avg(" & dic(dr("科目")) & ")"
                dr(dc.name) =dt.Compute(exp,flt)
            Case "标准偏差"
                t.filter = flt
                Dim c1 = t.Cols(dic(dr("科目"))).Index
                dr(dc.name) = t.Aggregate(AggregateEnum.std, 0, c1, t.Rows.count-1, c1)
            Case "总体标准偏差"
                t.filter = flt
                Dim c1 = t.Cols(dic(dr("科目"))).Index
                dr(dc.name) = t.Aggregate(AggregateEnum.StdPop, 0, c1, t.Rows.count-1, c1)
            Case "样本方差"
                t.filter = flt
                Dim c1 = t.Cols(dic(dr("科目"))).Index
                dr(dc.name) = t.Aggregate(AggregateEnum.Var, 0, c1, t.Rows.count-1, c1)
            Case "总样本方差"
                t.filter = flt
                Dim c1 = t.Cols(dic(dr("科目"))).Index
                dr(dc.name) = t.Aggregate(AggregateEnum.VarPop, 0, c1, t.Rows.count-1, c1)
Case "参考人数"
                exp = "count(" & dic(dr("科目")) & ")"
                dr(dc.name) =dt.Compute(exp,flt)
               
               
        End Select
    Next
Next

t1.DataTable.SysStyles("EmptyArea").BackColor = Color.White
t1.ResumeRedraw
MainTable = t1
'------------------

'---------
Tables("统计_Table2").DataSource = DataTables("统计")

With Tables("统计")
    .MergeMode = MergeModeEnum.Standard
    .MergeCols.Clear()
    .MergeCols.Add("参考人数")
    .MergeSort = ""
    .AllowMerge = True
End With


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


加好友 发短信
等级:三尾狐 帖子:607 积分:4241 威望:0 精华:0 注册:2015/7/25 19:14:00
  发帖心情 Post By:2018/11/5 17:49:00 [只看该作者]

我是这样写的,问题在什么地方?

 

 

Dim g As New CrossTableBuilder("成绩转置", DataTables("成绩登记表"))
g.HGroups.AddDef("考试期数")
g.HGroups.AddDef("年级")
g.HGroups.AddDef("班级")
g.HGroups.AddDef("学号")
g.HGroups.AddDef("姓名", "", "参考人数")
g.VGroups.AddDef("课程名称")
g.Totals.AddDef("分数", "分数")
g.HorizontalTotal = True
g.Build()
MainTable = Tables("成绩转置")
'Std:标准偏差
'StdPop:总体标准偏差
'Sum:累积值
'Var:方差
'VarPop:总体方差

'--------------------------
Dim dtb As New DataTableBuilder("统计")
dtb.AddDef("参考人数", Gettype(String))

dtb.AddDef("年级", Gettype(String))
dtb.AddDef("考试期数", Gettype(String))
dtb.AddDef("班级", Gettype(String))
dtb.AddDef("科目", Gettype(String), 32)
dtb.AddDef("最高分", Gettype(Double))
dtb.AddDef("最低分", Gettype(Double))
dtb.AddDef("平均分", Gettype(Double))
dtb.AddDef("标准偏差", Gettype(Double), 32)
dtb.AddDef("总体标准偏差", Gettype(Double))
dtb.AddDef("样本方差", Gettype(Double))
dtb.AddDef("总样本方差", Gettype(Double))

dtb.Build()
'--------
Dim dic As new Dictionary(of String, String)
For Each c As Col In Tables("成绩转置").cols
    dic.add(c.caption, c.name)
    '--------
Next
Dim exp,flt As String
Dim dt As DataTable =DataTables("成绩转置")
Dim t As Table = Tables("成绩转置")
Dim t1 As Table =Tables("统计")
't1.StopRedraw

Dim bjs As List(of String()) = dt.Getvalues("年级|班级|考试期数")
For Each bj As String() In bjs
    Dim f As New Filler
    f.SourceTable =DataTables("科目表")
    f.DataTable = t1.DataTable
    f.Fill()
    t1.DataTable.ReplaceFor("考试期数",bj(1),"考试期数 Is null")
    t1.DataTable.ReplaceFor("班级",bj(1),"班级 Is null")
    t1.DataTable.ReplaceFor("年级",bj(0),"年级 Is null")
Next

For Each dc As Col In t1.Cols
    For Each dr As Row In t1.Rows
        flt = "班级 = '" & dr("班级") & "' and 年级 = '" & dr("年级") & "' and 考试期数 = '" & dr("考试期数") & "'"
        Select Case dc.name
            Case "最高分"
                exp = "Max(" & dic(dr("科目")) & ")"
                dr(dc.name) =dt.Compute(exp,flt)
            Case "最低分"
                exp = "Min(" & dic(dr("科目")) & ")"
                dr(dc.name) =dt.Compute(exp,flt)
            Case "平均分"
                exp = "Avg(" & dic(dr("科目")) & ")"
                dr(dc.name) =dt.Compute(exp,flt)
            Case "标准偏差"
                t.filter = flt
                Dim c1 = t.Cols(dic(dr("科目"))).Index
                dr(dc.name) = t.Aggregate(AggregateEnum.std, 0, c1, t.Rows.count-1, c1)
            Case "总体标准偏差"
                t.filter = flt
                Dim c1 = t.Cols(dic(dr("科目"))).Index
                dr(dc.name) = t.Aggregate(AggregateEnum.StdPop, 0, c1, t.Rows.count-1, c1)
            Case "样本方差"
                t.filter = flt
                Dim c1 = t.Cols(dic(dr("科目"))).Index
                dr(dc.name) = t.Aggregate(AggregateEnum.Var, 0, c1, t.Rows.count-1, c1)
            Case "总样本方差"
                t.filter = flt
                Dim c1 = t.Cols(dic(dr("科目"))).Index
                dr(dc.name) = t.Aggregate(AggregateEnum.VarPop, 0, c1, t.Rows.count-1, c1)
Case "参考人数"
                exp = "count(" & dic(dr("科目")) & ")"
                dr(dc.name) =dt.Compute(exp,flt)
               
               
        End Select
    Next
Next

t1.DataTable.SysStyles("EmptyArea").BackColor = Color.White
t1.ResumeRedraw
MainTable = t1
'------------------

'---------
Tables("统计_Table2").DataSource = DataTables("统计")

With Tables("统计")
    .MergeMode = MergeModeEnum.Standard
    .MergeCols.Clear()
    .MergeCols.Add("参考人数")
    .MergeSort = ""
    .AllowMerge = True
End With


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


加好友 发短信
等级:版主 帖子:72502 积分:363620 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/11/5 18:55:00 [只看该作者]

参考

 

    t1.DataTable.ReplaceFor("考试期数",bj(2),"考试期数 Is null")


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


加好友 发短信
等级:三尾狐 帖子:607 积分:4241 威望:0 精华:0 注册:2015/7/25 19:14:00
  发帖心情 Post By:2018/11/5 20:37:00 [只看该作者]

甜老师:

按分数段统计,增加了“考试期数”和年级,结果是“无法在 System.Boolean 和 System.String 上执行“<”操作。

 

Dim g As New CrossTableBuilder("成绩转置1", DataTables("成绩登记表"))
g.HGroups.AddDef("考试期数")
g.HGroups.AddDef("年级")
g.HGroups.AddDef("班级")
g.HGroups.AddDef("学号")
g.HGroups.AddDef("姓名")
g.VGroups.AddDef("课程名称")
g.Totals.AddDef("分数", "分数")
g.HorizontalTotal = True
g.Build()
MainTable = Tables("成绩转置1")
Tables("成绩转置1").grid.Cols("合计").caption = "总分"
Dim dic As new Dictionary(of String, String)
For Each c As Col In Tables("成绩转置1").cols
dic.add(c.caption, c.name)
Next
'---------------------------------
Dim fsd As New List(of Integer)

 

For Each r1 As Row In Tables("自定义统计分数段").Rows

If r1.Checked = False Then
MessageBox.Show("请定义统计分数段,并把无用的数据删除,否则系统将无法统计运行","提示")
Return
 Else
 If r1.Checked Then
        fsd.add(r1("分数段"))
    End If
End If

Next
If fsd.count> 0 Then
    fsd.sort
    Dim dtb As New DataTableBuilder("统计")
dtb.AddDef("考试期数", Gettype(String))
dtb.AddDef("年级", Gettype(String))
    dtb.AddDef("班级", Gettype(String))
    dtb.AddDef("科目", Gettype(String), 32)
    For Each fs As Integer In fsd
        dtb.AddDef(fs & "分" & iif(fs = fsd(0), "以下","以上") , Gettype(Integer))
    Next
    dtb.Build()
End If

Dim flt As String
Dim dt As DataTable =DataTables("成绩转置1")
Dim t1 As Table =Tables("统计")
t1.StopRedraw

Dim bjs As List(of String()) = dt.Getvalues("年级|班级|考试期数")
For Each bj As String() In bjs
    Dim f As New Filler
    f.SourceTable =DataTables("科目表")
    f.DataTable = t1.DataTable
    f.Fill()
    t1.DataTable.ReplaceFor("考试期数",bj(2),"考试期数 Is null")
    t1.DataTable.ReplaceFor("班级",bj(1),"班级 Is null")
    t1.DataTable.ReplaceFor("年级",bj(0),"年级 Is null")
Next

For Each dc As Col In t1.Cols
    If dc.Index > 1 Then
        For Each dr As Row In t1.Rows
            flt = "班级 = '" & dr("班级") & "' and 年级 = '" & dr("年级") & "' and 考试期数 = '" & dr("考试期数") & "'"
            If dc.Index =2 Then
                flt+ = " < "  &  dc.name.split("分")(0)
            ElseIf dc.Index =Tables("统计").Cols.count -1 Then
                flt+ = " >= "  &  dc.name.split("分")(0)
            Else
                flt+ = " >= " &  dc.name.split("分")(0) & " And " & dic(dr("科目")) & " < " & t1.Cols(dc.Index+1).Name.split("分")(0)
            End If
            dr(dc.name) =dt.Compute("Count(姓名)",flt)
        Next
    End If
Next

t1.DataTable.SysStyles("EmptyArea").BackColor = Color.White
t1.ResumeRedraw
MainTable = t1
Tables("统计_Table2").DataSource = DataTables("统计")


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


加好友 发短信
等级:超级版主 帖子:23372 积分:119198 威望:0 精华:7 注册:2015/6/24 9:21:00
  发帖心情 Post By:2018/11/5 20:50:00 [只看该作者]

这段代码想干啥?没看懂

flt = "班级 = '" & dr("班级") & "' and 年级 = '" & dr("年级") & "' and 考试期数 = '" & dr("考试期数") & "'"
            If dc.Index =2 Then
                flt+ = " < "  &  dc.name.split("分")(0)
            ElseIf dc.Index =Tables("统计").Cols.count -1 Then
                flt+ = " >= "  &  dc.name.split("分")(0)
            Else
                flt+ = " >= " &  dc.name.split("分")(0) & " And " & dic(dr("科目")) & " < " & t1.Cols(dc.Index+1).Name.split("分")(0)
            End If
            dr(dc.name) =dt.Compute("Count(姓名)",flt)

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


加好友 发短信
等级:三尾狐 帖子:607 积分:4241 威望:0 精华:0 注册:2015/7/25 19:14:00
  发帖心情 Post By:2018/11/5 21:32:00 [只看该作者]

有点蓝老师,你好,帮我看看找找问题


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


 

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:成绩管理试做.table


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


加好友 发短信
等级:超级版主 帖子:23372 积分:119198 威望:0 精华:7 注册:2015/6/24 9:21:00
  发帖心情 Post By:2018/11/5 21:54:00 [只看该作者]

同一个问题,26楼那段代码是干嘛用的?您想达到什么效果?

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


加好友 发短信
等级:三尾狐 帖子:607 积分:4241 威望:0 精华:0 注册:2015/7/25 19:14:00
  发帖心情 Post By:2018/11/5 21:58:00 [只看该作者]

在一个分数段中有几人

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


加好友 发短信
等级:三尾狐 帖子:607 积分:4241 威望:0 精华:0 注册:2015/7/25 19:14:00
  发帖心情 Post By:2018/11/5 22:09:00 [只看该作者]

发一个可用的项目,蓝老师,如何把“年级”,和“考试期数”两字段加入表中
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:成绩管理试做.table

[此贴子已经被作者于2018/11/5 22:10:51编辑过]

 回到顶部
总数 96 上一页 1 2 3 4 5 6 7 8 9 10 下一页