请麻烦修改一下:
If e.Form.Controls("日期").Value Is Nothing OrElse e.Form.Controls("申购单号").Value Is Nothing Then
MessageBox.Show("请检查条件是否全部输入!", "提示")
Return
Else
Dim Filter As String
With e.Form.Controls("日期")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "日期 = '" & .Value & "'"
End If
End With
With e.Form.Controls("申购单号")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "申购单号 = '" & .Value & "'"
End If
End With
Dim jb1 As New SQLJoinTableBuilder("查询表1","申购主表")
jb1.C
Dim dt As DataTable
jb1.AddCols("日期","客户编码","客户名称","仓库","保管员","录入员","申购单号")
jb1.Filter = Filter
dt = jb1.Build(True) '生成一个DataTable
Dim Cols1() As String = {"客户编码","客户名称","仓库","保管员","录入员","申购单号"}
Dim Cols2() As String = {"客户编码","客户名称","仓库","保管员","录入员","申报单号"}
For Each dr1 As DataRow In dt.Select("")
'For Each dr1 As DataRow In DataTables("原辅料明细").Select("")
Dim dr2 As DataRow = DataTables("出库主表").AddNew()
dr2("日期") = Forms("生成出库单").Controls("日期").value
'dr2("出库单号") = Tables("出库主表").Current("出库单号")
'dr2("客户编码") = Tables("出库主表").Current("客户编码")
'dr2("学校或单位") = Tables("出库主表").Current("客户名称")
For i As Integer = 0 To Cols1.Length -1
dr2(Cols2(i)) = dr1(Cols1(i))
Next
Next
Dim jb2 As New SQLJoinTableBuilder("查询表1","申购明细")
jb2.C
Dim dt2 As DataTable
jb2.AddCols("申购单号","存货编码","存货名称","存货单位","申购数量","客户编码","客户名称","大类","小类","采购品分类","拼音编码")
jb2.Filter = Filter
dt2 = jb2.Build(True) '生成一个DataTable
Dim Cols3() As String = {"申购单号","存货编码","存货名称","存货单位","申购数量","客户编码","客户名称","大类","小类","采购品分类","拼音编码"}
Dim Cols4() As String = {"申报单号","存货编码","存货名称","存货单位","申购数量","客户编码","学校或单位","大类","小类","采购品分类","拼音编码"}
For Each dr3 As DataRow In dt2.Select("")
'For Each dr1 As DataRow In DataTables("原辅料明细").Select("")
Dim dr4 As DataRow = DataTables("出库明细").AddNew()
dr4("日期") = Forms("生成出库单").Controls("日期").value
dr4("出库单号") = Forms("生成出库单").Controls("出库单号").value
'dr2("学校或单位") = Tables("出库主表").Current("客户名称")
For i As Integer = 0 To Cols3.Length -1
dr4(Cols4(i)) = dr3(Cols3(i))
'dr4("出库数量") = dr4("申购数量") + dr4("增减数量")
Next
Next
End If