Dim dtb As New DataTableBuilder("统计表1")
dtb.AddDef("部门", GetType(String), 16)
dtb.AddDef("福利待遇满意度_得分", GetType(Double))
dtb.AddDef("福利待遇满意度_份数", GetType(Integer))
dtb.AddDef("福利待遇满意度_平均分", GetType(Double))
dtb.Build()
Dim f As New Filler
f.SourceTable = DataTables("员工满意明细")
f.SourceCols = "部门"
f.DataTable = DataTables("员工满意分析细表")
f.DataCols = "部门"
f.Fill()
Dim b As New CrossTableBuilder("统计表1", DataTables("员工满意明细"))
b.HGroups.AddDef("部门") '
b.VGroups.AddDef("调查项目") '
b.Totals.AddDef("得分") '
b.Totals.AddDef("份数")
b.Totals.AddDef("分值", "平均分")
Dim dict As New Dictionary(Of String, String)
Dim dt As DataTable = DataTables("员工满意明细")
For Each c As Col In Tables("员工满意分析细表").Cols
If c.Caption Like "*_*" Then
dict.Add(c.Caption, c.Name)
End If
Next
For Each r As Row In Tables("员工满意分析细表").Rows
For Each c As Col In Tables("员工满意分析细表").Cols
If c.Caption Like "*_份数" Then
r(c.Name) = dt.GetValues("员工编号", "部门='" & r("部门") & "' and 调查项目='" & c.Caption.Split("_")(0) & "'").count
ElseIf c.Caption Like "*_平均分" Then
Dim cl As String = c.Caption.Split("_")(0)
If r(dict(cl & "_份数")) > 0 Then
r(c.Name) = r(dict(cl & "_得分"))
r(c.Name) = r(dict(cl & "_得分")) / r(dict(cl & "_份数"))
End If
End If
Next
Next
MainTable = Tables("员工满意分析细表")
上面代码执行,有2个问题
问题一:得分没统计出来和平均分为0,这是错,得分和平均分正确计算是有值,如何处理?
问题二:代码执行,窗口自动退出,如何让窗口不自动退出?