以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  在临时表中的年龄数值分布怎么编码?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=133884)

--  作者:yfy13338431925
--  发布时间: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


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