今天上午打开程序,在局域网运行下面的代码出错,但是前几天运行没有问题,不知问题出在哪里?请各位老师帮助看看。谢谢!!
Case "当月日汇总"
Dim sql As String
Dim ny As String = Forms("数据载入").Controls("ComboBox1").Text
If ny = "请选择年月" Then
MessageBox.Show("请点击日报填报,在右侧窗口选择报表年月","提示")
Return
End If
'根据年月生成临时表
sql = "Select TOP 100 PERCENT 报表年月,日期,单位,Sum(加工费) As 加工费, Sum(投工) As 投工,0.1-0.1 As 人均 FROM {日报源表} WHERE 报表年月 = " & ny & " Group By 报表年月,日期,单位 ORDER BY 单位,日期,报表年月"
'根据临时表生成年度汇总表
Dim b As New CrossTableBuilder("当月日汇总",sql,"SCGL")
b.HGroups.AddDef("单位")
b.VGroups.AddDef("日期",DateGroupEnum.Month,"{0}月")
b.VGroups.AddDef("日期",DateGroupEnum.Day,"{0}日")
b.Totals.AddDef("加工费")
b.Totals.AddDef("投工","在册人数")
b.Totals.AddDef("人均","人均加工费")
b.HorizontalTotal = True
b.VerticalTotal = True
b.Build()
MainTable = Tables("当月日汇总") '打开生成的统计表
Dim t As Table = Tables("当月日汇总")
Dim i As Integer =(Tables("当月日汇总").Cols.Count-4)/3
For Each r As Row In t.Rows
For j As Byte = 1 To i
If r("投工_" & j) <> 0 Then
r("人均_" & j) = r("加工费_" & j)/r("投工_" & j)
End If
Next
Next
t.DataTable.DataCols.Add("合计_月均人数", Gettype(Double),"[合计_投工]/" & i)
t.DataTable.DataCols.Add("合计_人均加工费", Gettype(Double),"合计_加工费/合计_月均人数")
t.DataTable.DataCols.Add("合计_名次", Gettype(Byte))
t.Cols.Remove("合计_投工","合计_人均")
Dim drs As List(Of DataRow) = t.DataTable.Select("[单位] <> '合计'","合计_人均加工费 DESC")
For n As Byte = 0 To drs.Count - 1 '遍历所有行
If n > 0 AndAlso drs(n)("合计_人均加工费") = drs(n-1)("合计_人均加工费") Then '如果月人均加工费和上一行相同
drs(n)("合计_名次") = drs(n-1)("合计_名次") '则排名等于上一行
Else
drs(n)("合计_名次") = n + 1 '设置名次
End If
Next
Dim s As String
For Each dc As DataCol In t.DataTable.DataCols
If dc.name <> "单位" AndAlso dc.name <> "合计_名次" Then
s="0.00"
t.DataTable.DataCols(dc.Name).SetFormat(s)
End If
Next
t.Cols("单位").TextAlign = TextAlignEnum.Center
t.Cols("合计_名次").TextAlign = TextAlignEnum.Center
t.AutoSizeCols()
MainTable =t
For Each dc As DataCol In DataTables("当月日汇总").dataCols
If dc.name.StartsWith("投工_") Then
dc.SetFormat("####0")
End If
Next
With Tables("当月日汇总")
.Cols("合计_加工费").Move(1)
.Cols("合计_月均人数").Move(2)
.Cols("合计_人均加工费").Move(3)
.Cols("合计_名次").Move(4)
End With
Tables("当月日汇总").Cols.Frozen = 5
DataTables("当月日汇总").SysStyles("Frozen").BackColor = Color.LightCyan
DataTables("当月日汇总").SysStyles("CurrentRow").BackColor = Color.Blue
DataTables("当月日汇总").SysStyles("CurrentRow").ForeColor = Color.White
此主题相关图片如下:c.png
[此贴子已经被作者于2011-10-8 9:58:50编辑过]