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


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

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

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


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


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


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

甜老师:

项目中的最高最低平均数按钮,我想再增加几个字段,试着做了一下,有些问题

你帮我看看怎么改,改的地方请用颜色标记一下。

再问一个问题:你计算的时候,最大max、最小min等,怎么没有声明变量?

 

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), 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 t1 As Table =Tables("统计")
t1.StopRedraw

Dim bjs As List(of String) = dt.GetUniqueValues("","班级")
Dim njs As List(of String) = dt.GetUniqueValues("","年级")
Dim cks As List(of String) = dt.GetUniqueValues("","参考人数")
For Each flt In bjs
    Dim f As New Filler
    f.SourceTable =DataTables("科目表")
    f.DataTable = t1.DataTable
    f.Fill()
    t1.DataTable.ReplaceFor("班级",flt,"班级 Is null")
    t1.DataTable.ReplaceFor("年级",flt,"年级 Is null")
    t1.DataTable.ReplaceFor("参考人数",flt,"参考人数 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("班级") & "'"
            flt = "年级 = '" & dr("年级") & "'"
            flt = "参考人数 = '" & dr("参考人数") & "'"
            Select Case dc.Index
                Case 2
                    exp = "Max(" & dic(dr("科目")) & ")"
                Case 3
                    exp = "Min(" & dic(dr("科目")) & ")"
                Case 4
                    exp = "Avg(" & dic(dr("科目")) & ")"
                Case 5
                    exp = "Std(" & dic(dr("标准偏差")) & ")"
                Case 6
                    exp = "StdPop(" & dic(dr("总体标准偏差")) & ")"
                Case 7
                    exp = "Var(" & dic(dr("样本方差")) & ")"
                Case 8
                    exp = "VarPop(" & dic(dr("总样本方差")) & ")"
                Case 9
                    exp = "count(" & dic(dr("参考人数")) & ")"
                   
                   
            End Select
            dr(dc.name) =dt.Compute(exp,flt)
        Next
    End If
Next

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


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


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

具体项目发上来测试

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


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

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


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


加好友 发短信
等级:版主 帖子:72502 积分:363620 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/11/1 13:00: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), 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)
                               
        End Select
    Next
Next

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

 


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


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

【参考人数】??

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


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

            Case "参考人数"
                exp = "count(" & dic(dr("科目")) & ")"
                dr(dc.name) =dt.Compute(exp,flt)

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


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

建立的主窗口,启动后点击功能按钮,即退出窗口,怎么解决?

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


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

以下是引用fytea在2018/11/1 19:28:00的发言:
建立的主窗口,启动后点击功能按钮,即退出窗口,怎么解决?

 

实例发上来测试。


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


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

以下代码执行时报错:无法在 System.Double 和 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.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 Then
        fsd.add(r1("分数段"))
    End If
Next
If fsd.count> 0 Then
    fsd.sort
    Dim dtb As New DataTableBuilder("统计")
    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.GetUniqueValues("","班级")
For Each flt In bjs
    Dim f As New Filler
    f.SourceTable =DataTables("科目表")
    f.DataTable = t1.DataTable   
    f.Fill()
    t1.DataTable.ReplaceFor("班级",flt,"班级 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 " & dic(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("统计_Table1").DataSource = DataTables("统计")


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