Foxtable(狐表)用户栏目专家坐堂 → 在临时表中的年龄数值分布怎么编码?


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

主题:在临时表中的年龄数值分布怎么编码?

美女呀,离线,留言给我吧!
yfy13338431925
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:512 积分:4492 威望:0 精华:0 注册:2018/12/5 23:10:00
在临时表中的年龄数值分布怎么编码?  发帖心情 Post By:2019/4/22 22:03:00 [只看该作者]

甜哥,统计政治面貌的年龄分布我做了一个临时表,数值分布不会,麻烦您了!

Dim dic As new Dictionary(of String, String)
For Each c As Col In Tables("人事档案基础信息").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("统计2")
    dtb.AddDef("工作单位", Gettype(String))
    dtb.AddDef("所在部门", Gettype(String))
    dtb.AddDef("政治面貌", Gettype(String))
    If fsd.count = 1 Then
        dtb.AddDef(fsd(0) & "岁以下", Gettype(Integer))
        dtb.AddDef(fsd(0) & "岁以上", Gettype(Integer))
    ElseIf fsd.count >= 2 Then
        dtb.AddDef(fsd(0) & "岁以下", Gettype(Integer))
        For fs As Integer = 0 To fsd.count-2
            dtb.AddDef(fsd(fs) & "岁-" & fsd(fs+1) & "岁", Gettype(Integer))
        Next
        dtb.AddDef(fsd(fsd.count-1) & "岁以上", Gettype(Integer))
    End If
    dtb.Build()
End If
Dim flt As String
Dim dt As DataTable =DataTables("人事档案基础信息")
Dim t1 As Table =Tables("统计2")
t1.StopRedraw
'统计编码


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 " & dic(dr("政治面貌"))
            If dc.Index = 4 Then
                flt+ = " < "  &  dc.name.split("岁")(0)
            ElseIf dc.Index =Tables("统计2").Cols.count -1 Then
                flt+ = " >= "  &  dc.name.split("岁")(0)
            ElseIf dc.Index > 4
                flt+ = " >= " &  dc.name.split("岁")(0) & " And " & dic(dr("科目")) & " < " & dc.Name.split("-")(1).split("岁")(0)
            Else
                Continue For
            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("统计_Table3").DataSource = DataTables("统计2")

 

 

 下载信息  [文件大小:   下载次数: ]
点击浏览该文件:管理项目1.table


 回到顶部
帅哥,在线噢!
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106011 积分:539142 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/4/22 22:56:00 [只看该作者]

Dim dt As DataTable =DataTables("人事档案基础信息")
Dim t1 As Table =Tables("统计2")
t1.StopRedraw
'统计编码

For Each sr As String() In dt.GetValues("工作单位|所在部门|政治面貌")
    Dim r2 As Row = t1.AddNew
    r2("工作单位") = sr(0)
    r2("所在部门") = sr(1)
    r2("政治面貌") = sr(2)
    Dim flt As String = "工作单位 = '" & sr(0) & "' and 所在部门 = '" & sr(1) & "' And 政治面貌 = '" & sr(2) & "'"
    
    For Each dc As Col In t1.Cols
        Dim filter As String = flt 
        If dc.Name.Contains("岁")  Then
            If dc.Name.Contains("岁以下") Then
                filter &= " and 年龄 < "  &  dc.name.split("岁")(0)
            ElseIf dc.Name.Contains("岁以上") Then
                filter &= "and 年龄 >= "  &  dc.name.split("岁")(0)
            Else
                Dim arr() As String = dc.name.split("-")
                filter &= "and 年龄 >= " &  arr(0).split("岁")(0) & " And 年龄 < " & arr(1).split("岁")(0)
            End If
            r2(dc.name) =dt.Compute("Count(姓名)",filter )
        End If
    Next
Next

 回到顶部