代码如下: 我是想判断表格是不是空 但这样写 提示代码有错
Tables("装配表").Filter=" [日期] = '" & e.Form.Controls("DateTimePicker1").Value & "'"
'判断是有已经有装配表 有则不再产生装配表
If Tables("装配表") !=null Then
SystemReady = False
Dim n,n1,n2 As Integer
Dim d As Date = e.Sender.Text
Dim drs As List(Of DataRow) = DataTables("蔬菜采收表").Select("日期 = #" & d & "#")
Dim drs_y As List(Of DataRow) = DataTables("蔬菜采收表").Select("日期 = #" & d.AddDays(-1) & "#")
Dim drs_by As List(Of DataRow) = DataTables("蔬菜采收表").Select("日期 = #" & d.AddDays(-2) & "#")
For Each dr As DataRow In DataTables("当天配送会员").Select("日期 = #" & d & "#")
'统计是否满足装箱总斤数
n=0
n1=0
n2=0
Dim idx As Integer = 0
For Each cdr As DataRow In drs
Dim ndr As DataRow = DataTables("装配表").addnew
If idx < drs_y.Count Then
ndr("昨天品种") = drs_y(idx)("品种")
Dim fdr_y As DataRow = DataTables("蔬菜喜好表").Find("会员编号 = '" & dr("会员编号") & "' and 产品 = '" & drs_y(idx)("品种") & "'")
If fdr_y IsNot Nothing Then
If fdr_y("喜好") = "吃" Then
ndr("昨天配比") = 1
ElseIf fdr_y("喜好") = "爱吃" Then
ndr("昨天配比") = 2
Else
ndr("昨天配比") = 0
End If
'没有找到记录 '
Else
n1=n1+1
If n1<=5 Then
ndr("昨天配比") = 1
Else
ndr("昨天配比") = 0
End If
End If
End If
If idx < drs_by.Count Then
ndr("前天品种") = drs_by(idx)("品种")
Dim fdr_by As DataRow = DataTables("蔬菜喜好表").Find("会员编号 = '" & dr("会员编号") & "' and 产品 = '" & drs_by(idx)("品种") & "'")
If fdr_by IsNot Nothing Then
If fdr_by("喜好") = "吃" Then
ndr("前天配比") = 1
ElseIf fdr_by("喜好") = "爱吃" Then
ndr("前天配比") = 2
Else
ndr("前天配比") = 0
End If
'没有找到记录 '
Else
n2=n2+1
If n2<=5 Then
ndr("前天配比") = 1
Else
ndr("前天配比") = 0
End If
End If
End If
ndr("日期") = dr("日期")
ndr("会员编号") = dr("会员编号")
ndr("品种") = cdr("品种")
ndr("装箱总斤数")=dr("装箱斤数")
Dim fdr As DataRow = DataTables("蔬菜喜好表").Find("会员编号 = '" & dr("会员编号") & "' and 产品 = '" & cdr("品种") & "'")
If fdr IsNot Nothing Then
ndr("喜好") = fdr("喜好")
If fdr("喜好") = "吃" Then
ndr("配比") = 1
ElseIf fdr("喜好") = "爱吃" Then
ndr("配比") = 2
Else
ndr("配比") = 0
End If
'没有找到记录 '
Else
n=n+1
'配比超过5斤
If n<=5 Then
ndr("喜好")="吃"
ndr("配比") = 1
Else
ndr("喜好")="吃"
ndr("配比") = 0
End If
End If
idx += 1
Next
Next
For Each dr As DataRow In DataTables("装配表").Select("日期 = #" & d & "#")
dr("小计") = DataTables("装配表").compute("sum(配比)", "日期 = #" & dr("日期") & "# and 会员编号 = '" & dr("会员编号") & "'")
dr("装箱参考")=dr("配比")
Next
SystemReady = True
End If
Dim t As Table = Forms("装配窗体").Controls("Table1").Table
Dim b As New GroupTableBuilder("统计表1", DataTables("装配表"))
b.Groups.AddDef("品种") '根据产品分组
b.Totals.AddDef("配比", AggregateEnum.Sum, "总数量") '对数量进行统计
b.Filter = "日期 = #" & d & "#"
t.DataSource = b.BuildDataSource '生成统计表
t.DataTable.DataCols.Add("实际产量", Gettype(Integer))
For Each r As Row In t.Rows
Dim fdr As DataRow = DataTables("蔬菜采收表").Find("日期 = #" & d & "# And 品种 = '" & r("品种") & "'")
If fdr IsNot Nothing Then
r("实际产量") = fdr("实际产量")
End If
Next