DataTables("个人统计").datarows.Clear
Tables("个人统计").StopRedraw
Dim dt As DataTable = DataTables("个人信息")
Dim cList As List(of String) = DataTables("个人信息").GetUniqueValues("","村")
Dim cList2 As List(of String) = DataTables("个人信息").GetUniqueValues("","社")
If cList IsNot Nothing Then
For Each s As String In cList
Dim dr As DataRow = DataTables("个人统计").AddNew
dr("村")=s
dr("总人数")=dt.Compute("count(姓名)","村=\'" & s & "\'")
dr("其中女")=dt.Compute("count(姓名)","村=\'" & s & "\' and 性别 = \'女\'")
dr("党员_总数")=dt.Compute("count(姓名)","村=\'" & s & "\' and 政治面貌 = \'党员\'")
dr("党员_其中女")=dt.Compute("count(姓名)","村=\'" & s & "\' and 政治面貌 = \'党员\' and 性别 = \'女\'")
dr("团员_总数")=dt.Compute("count(姓名)","村=\'" & s & "\' and 政治面貌 = \'团员\'")
dr("团员_其中女")=dt.Compute("count(姓名)","村=\'" & s & "\' and 政治面貌 = \'团员\' and 性别 = \'女\'")
dr("残疾人数")=dt.Compute("count(姓名)","村=\'" & s & "\' and 身体状况 = \'残疾\'")
dr("外出务工_人数")=dt.Compute("count(姓名)","村=\'" & s & "\' and 人员去向 like \'*务工*\'")
dr("外出务工_其中女")=dt.Compute("count(姓名)","村=\'" & s & "\' and 人员去向 like \'*务工*\' and 性别 = \'女\'")
dr("农村低保_一类")=dt.Compute("count(姓名)","村=\'" & s & "\' and 农村低保 = \'农村一类\'")
dr("农村低保_二类")=dt.Compute("count(姓名)","村=\'" & s & "\' and 农村低保 = \'农村二类\'")
dr("农村低保_三类")=dt.Compute("count(姓名)","村=\'" & s & "\' and 农村低保 = \'农村三类\'")
dr("农村低保_四类")=dt.Compute("count(姓名)","村=\'" & s & "\' and 农村低保 = \'农村四类\'")
dr("农村低保_无低保")=dt.Compute("count(姓名)","村=\'" & s & "\' and 农村低保 = \'无低保\'")
dr("合作医疗_已参合")=dt.Compute("count(姓名)","村=\'" & s & "\' and 合作医疗 = \'已参合\'")
dr("合作医疗_未参合")=dt.Compute("count(姓名)","村=\'" & s & "\' and 合作医疗 = \'未参合\'")
dr("养老保险_已投保")=dt.Compute("count(姓名)","村=\'" & s & "\' and 养老保险 = \'已投保\'")
dr("养老保险_未投保")=dt.Compute("count(姓名)","村=\'" & s & "\' and 养老保险 = \'未投保\'")
dr("养老保险_领取养老金")=dt.Compute("count(姓名)","村=\'" & s & "\' and 养老保险 like \'*领*\'")
Next
If cList2 IsNot Nothing Then
For Each s As String In cList2
Dim dr2 As DataRow = DataTables("个人统计").AddNew
dr2("社")=s
dr2("总人数")=dt.Compute("count(姓名)","社=\'" & s & "\'")
dr2("其中女")=dt.Compute("count(姓名)","社=\'" & s & "\' and 性别 = \'女\'")
dr2("党员_总数")=dt.Compute("count(姓名)","社=\'" & s & "\' and 政治面貌 = \'中共党员\'")
dr2("党员_其中女")=dt.Compute("count(姓名)","社=\'" & s & "\' and 政治面貌 = \'中共党员\' and 性别 = \'女\'")
dr2("团员_总数")=dt.Compute("count(姓名)","社=\'" & s & "\' and 政治面貌 = \'团员\'")
dr2("团员_其中女")=dt.Compute("count(姓名)","社=\'" & s & "\' and 政治面貌 = \'团员\' and 性别 = \'女\'")
dr2("残疾人数")=dt.Compute("count(姓名)","社=\'" & s & "\' and 身体状况 = \'残疾\'")
dr2("外出务工_人数")=dt.Compute("count(姓名)","社=\'" & s & "\' and 人员去向 like \'*务工*\'")
dr2("外出务工_其中女")=dt.Compute("count(姓名)","社=\'" & s & "\' and 人员去向 like \'*务工*\' and 性别 = \'女\'")
dr2("农村低保_一类")=dt.Compute("count(姓名)","社=\'" & s & "\' and 农村低保 = \'农村一类\'")
dr2("农村低保_二类")=dt.Compute("count(姓名)","社=\'" & s & "\' and 农村低保 = \'农村二类\'")
dr2("农村低保_三类")=dt.Compute("count(姓名)","社=\'" & s & "\' and 农村低保 = \'农村三类\'")
dr2("农村低保_四类")=dt.Compute("count(姓名)","社=\'" & s & "\' and 农村低保 = \'农村四类\'")
dr2("农村低保_无低保")=dt.Compute("count(姓名)","社=\'" & s & "\' and 农村低保 = \'无低保\'")
dr2("合作医疗_已参合")=dt.Compute("count(姓名)","社=\'" & s & "\' and 合作医疗 = \'已参合\'")
dr2("合作医疗_未参合")=dt.Compute("count(姓名)","社=\'" & s & "\' and 合作医疗 = \'未参合\'")
dr2("养老保险_已投保")=dt.Compute("count(姓名)","社=\'" & s & "\' and 养老保险 = \'已投保\'")
dr2("养老保险_未投保")=dt.Compute("count(姓名)","社=\'" & s & "\' and 养老保险 = \'未投保\'")
dr2("养老保险_领取养老金")=dt.Compute("count(姓名)","社=\'" & s & "\' and 养老保险 like \'*领*\'")
Next
End If
End If
Tables("个人统计").ResumeRedraw