测评结果统计与计算 麻烦老师看看代码是否还能够简化一下不
当前代码如下:
Dim e As RequestEventArgs = rq.e
Dim cmd As New SQLC ommand
cmd.Con nectio nName = "主数据源"
Dim dt,dt1,dt12 As DataTable
Dim a,b,c,d,e1,f,g,h As Integer
cmd.CommandText = "del ete {测评汇总表}" '运行之前先清空 干部平时考核民主测评汇总表
cmd.ExecuteReader
cmd.CommandText = "SEL ECT * From {测评表}"
dt = cmd.ExecuteReader()
cmd.CommandText = "SELE CT * From {汇总表}"
dt1 = cmd.ExecuteReader(True)
cmd.CommandText = "SELE CT * From {干部台账} where 所属部门='领导'"
dt12 = cmd.ExecuteReader()
'获取对应年度季度总的已完成且属于领导的考评数据
Vars.Add("年度",Gettype(String),e.Values("年度"))
Vars.Add("季度",Gettype(String),e.Values("季度"))
If e.Values("季度")="第1季度" Then
Vars("季度")="第一季度"
Else If e.Values("季度")="第2季度" Then
Vars("季度")="第二季度"
Else If e.Values("季度")="第3季度" then
Vars("季度")="第三季度"
Else If e.Values("季度")="第4季度" then
Vars("季度")="第四季度"
End If
cmd.CommandText ="Se lect Count(*) From {干部平时考核民主测评表} where 年度='"&e.Values("年度")&"'and 季度='"&e.Values("季度")&"' and 是否完成='已完成' and 所属部门='领导'"
'msg(cmd.CommandText)
If cmd.ExecuteScalar > 0 Then
e1= cmd.ExecuteScalar/48
' msg(e1)
End If
'获取对应年度季度总的已完成且属于非领导的考评数据
cmd.CommandText ="Sele ct Count(*) From {干部平时考核民主测评表} where 年度='"&e.Values("年度")&"'and 季度='"&e.Values("季度")&"' and 是否完成='已完成'and 所属部门<>'领导'"
'msg(cmd.CommandText)
If cmd.ExecuteScalar > 0 Then
f= cmd.ExecuteScalar/48
' msg(f)
End If
Dim Products As List(Of String)
Products = dt.GetValues("测评对象") '从干部平时考核民主测评表中获取测评对象 不重复值
Dim Products12 As List(Of String)
Products12 = dt12.GetValues("姓名","姓名<>''") '从干部台账中获取所属部门属于领导的姓名 不重复值
Dim cnt,cnt1,cnt2,cnt3,cnt4,cnt5,cnt40,cnt1140 As Integer
Dim cnt11,cnt111,cnt112,cnt113,cnt114,cnt115 As Integer
For Each Product As String In Products '遍历所有测评对象值,
Dim dr As DataRow
dr =dt1.AddNew
dr("guid")=System.Guid.NewGuid().ToString()
dr("测评对象")=Product
Dim dt3 As DataTable
cmd.CommandText = "SEL ECT * From {干部台账}"
dt3 = cmd.ExecuteReader()
Dim Products1 As List(Of String())
Products1 = dt3.GetValues("职级|考核类型|编制属性|考核类别|职务","姓名= '" &Product & "'") '考核类型='一般干部' And
For Each Product1 As String() In Products1
dr("职务职级")=Product1(4)
dr("考核类型")=Product1(1)
dr("编制类型")=Product1(2)
dr("考核类别")=Product1(3)
dr("年度")= e.Values("年度")
dr("季度")=e.Values("季度")
dr("测评对象身份")=Product1(0)
next
dr("是否完成")="已完成"
cnt = dt.Compute("Count([好])", "好='√' and 测评对象 = '"& Product &"' and 所属部门='领导'") '如果操作人员属于领导,则将对应的好等次的数据 计算为A好里面的
If cnt>0 Then
dr("A好")=cnt
Else
dr("A好")=Nothing
End If
cnt1 = dt.Compute("Count([较好])", "较好='√' and 测评对象 = '"& Product &"' and 所属部门='领导'")
If cnt1>0 Then
dr("A较好")=cnt1
Else
dr("A较好")=Nothing
End If
cnt2 = dt.Compute("Count([一般])", "一般='√' and 测评对象 = '"& Product &"' and 所属部门='领导'")
If cnt2>0 Then
dr("A一般")=cnt2
Else
dr("A一般")=Nothing
End If
cnt3 = dt.Compute("Count([较差])", "较差='√' and 测评对象 = '"& Product &"' and 所属部门='领导'")
If cnt3>0 Then
dr("A较差")=cnt3
Else
dr("A较差")=Nothing
End If
cnt4 = dt.Compute("Count([弃权])", "弃权='√' and 测评对象 = '"& Product &"' and 所属部门='领导'")
If cnt4>0 Then
dr("A弃权")=cnt4
Else
dr("A弃权")=Nothing
End If
cnt11 = dt.Compute("Count([好])", "好='√' and 测评对象 = '"& Product &"' and 所属部门<>'领导'") '如果操作人员不属于领导,则将对应的好等次的数据 计算为B好里面的
If cnt11>0 Then
dr("B好")=cnt11
dr("B好")=Nothing
End If
cnt111 = dt.Compute("Count([较好])", "较好='√' and 测评对象 = '"& Product &"' and 所属部门<>'领导'")
If cnt111>0 Then
dr("B较好")=cnt111
Else
dr("B较好")=Nothing
End If
cnt112 = dt.Compute("Count([一般])", "一般='√' and 测评对象 = '"& Product &"' and 所属部门<>'领导'")
If cnt112>0 Then
dr("B一般")=cnt112
Else
dr("B一般")=Nothing
End If
cnt113 = dt.Compute("Count([较差])", "较差='√' and 测评对象 = '"& Product &"' and 所属部门<>'领导'")
If cnt113>0 Then
dr("B较差")=cnt113
Else
dr("B较差")=Nothing
End If
cnt114 = dt.Compute("Count([弃权])", "弃权='√' and 测评对象 = '"& Product &"' and 所属部门<>'领导'")
If cnt114>0 Then
dr("B弃权")=cnt114
Else
dr("B弃权")=Nothing
End If
'End If
'
'计算好 较好 一般 较差 总数据
dr("好")=dr("A好")+dr("B好")
dr("较好")=dr("A较好")+dr("B较好")
dr("一般")=dr("A一般")+dr("B一般")
dr("较差")=dr("A较差")+dr("B较差")
dr("弃权")=dr("A弃权")+dr("B弃权")
cnt40=e1'领导有效piao数
dr("A参评")=e1
dr("A有效")=dr("A好")+dr("A较好")+dr("A一般")+dr("A较差")+dr("A弃权")
cnt3=g '领导弃权piao数
cnt1140=f'普通干部有效piao数
dr("B参评")=f
dr("B有效")=dr("B好")+dr("B较好")+dr("B一般")+dr("B较差")+dr("B弃权")
cnt113=h '普通干部弃权piao数
Dim i1,i2 As Integer
dr("A总分")=Format((((dr("A好")*1)+(dr("A较好")*0.8)+(dr("A一般")*0.6)+(dr("A弃权")*0.3))/dr("A有效"))*100,"00.00")
dr("B总分")=Format((((dr("B好")*1)+(dr("B较好")*0.8)+(dr("B一般")*0.6)+(dr("B弃权")*0.3))/dr("B有效"))*100,"00.00")
dr("总分")= Format((dr("A总分")+dr("B总分"))/2,"00.00")
dr.save
Next