还是一样的问题,以下是全部的代码
MessageBox.Show(1)
Dim BMHZ As String = e.Form.Controls("ComboBox1").text
Dim KMHZ As String = e.Form.Controls("ComboBox2").text
Dim tj21,tj22 As WinForm.CheckBox
tj21 = Forms("部门科目同期预算").Controls("CheckBox1")
tj22 = Forms("部门科目同期预算").Controls("CheckBox2")
Dim Filter As String = "1=1"
With e.Form.Controls("BM")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
If BMHZ Is Nothing Then
Filter = Filter & "部门名称 In ( '" & .Value.replace(",","','") & "')"
ElseIf BMHZ = "部门名称" Then
Filter = Filter & "部门名称 In ( '" & .Value.replace(",","','") & "')"
ElseIf BMHZ = "上级汇总" Then
Filter = Filter & "上级汇总 In ( '" & .Value.replace(",","','") & "')"
ElseIf BMHZ = "一级汇总" Then
Filter = Filter & "一级汇总 In ( '" & .Value.replace(",","','") & "')"
ElseIf BMHZ = "公司汇总" Then
Filter = Filter & "公司汇总 In ( '" & .Value.replace(",","','") & "')"
End If
End If
End With
With e.Form.Controls("KM")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
If KMHZ Is Nothing Then
Filter = Filter & "科目名称 In ( '" & .Value.replace(",","','") & "')"
ElseIf KMHZ = "科目名称" Then
Filter = Filter & "科目名称 In ( '" & .Value.replace(",","','") & "')"
ElseIf KMHZ = "二级科目" Then
Filter = Filter & "二级科目 In ( '" & .Value.replace(",","','") & "')"
ElseIf KMHZ = "科目汇总" Then
Filter = Filter & "科目汇总 In ( '" & .Value.replace(",","','") & "')"
ElseIf KMHZ = "成本大类" Then
Filter = Filter & "成本大类 In ( '" & .Value.replace(",","','") & "')"
ElseIf KMHZ = "公司汇总" Then
Filter = Filter & "公司汇总 In ( '" & .Value.replace(",","','") & "')"
End If
End If
End With
Dim Filter1 As String = "1=1"
With e.Form.Controls("BM")
If .Value IsNot Nothing Then
If Filter1 > "" Then
Filter1 = Filter1 & " And "
End If
If BMHZ Is Nothing Then
Filter1 = Filter1 & "{责任中心档案}.部门名称 In ( '" & .Value.replace(",","','") & "')"
ElseIf BMHZ = "部门名称" Then
Filter1 = Filter1 & "{责任中心档案}.部门名称 In ( '" & .Value.replace(",","','") & "')"
ElseIf BMHZ = "上级汇总" Then
Filter1 = Filter1 & "{责任中心档案}.上级汇总 In ( '" & .Value.replace(",","','") & "')"
ElseIf BMHZ = "一级汇总" Then
Filter1 = Filter1 & "{责任中心档案}.一级汇总 In ( '" & .Value.replace(",","','") & "')"
ElseIf BMHZ = "公司汇总" Then
Filter1 = Filter1 & "{责任中心档案}.公司汇总 In ( '" & .Value.replace(",","','") & "')"
End If
End If
End With
With e.Form.Controls("KM")
If .Value IsNot Nothing Then
If Filter1 > "" Then
Filter1 = Filter1 & " And "
End If
If KMHZ Is Nothing Then
Filter1 = Filter1 & "{费用科目档案}.科目名称 In ( '" & .Value.replace(",","','") & "')"
ElseIf KMHZ = "科目名称" Then
Filter1 = Filter1 & "{费用科目档案}.科目名称 In ( '" & .Value.replace(",","','") & "')"
ElseIf KMHZ = "二级科目" Then
Filter1 = Filter1 & "{费用科目档案}.二级科目 In ( '" & .Value.replace(",","','") & "')"
ElseIf KMHZ = "科目汇总" Then
Filter1 = Filter1 & "{费用科目档案}.科目汇总 In ( '" & .Value.replace(",","','") & "')"
ElseIf KMHZ = "成本大类" Then
Filter1 = Filter1 & "{费用科目档案}.成本大类 In ( '" & .Value.replace(",","','") & "')"
ElseIf KMHZ = "公司汇总" Then
Filter1 = Filter1 & "{费用科目档案}.公司汇总 In ( '" & .Value.replace(",","','") & "')"
End If
End If
End With
MessageBox.Show(2)
Dim jb1 As New SQLJoinTableBuilder("查询表1","辅助总账")
jb1.AddTable("辅助总账","科目编码","科目档案","科目编号")
jb1.AddTable("辅助总账", "部门编码","责任中心档案","部门编号")
jb1.AddCols("科目编码","科目名称","一级科目","二级科目","科目汇总","成本大类","部门名称","上级汇总","一级汇总","公司汇总","部门属性","会计期间")
jb1.AddExp("金额","贷方金额")
jb1.Filter = "(科目编号 like '6001%' or 科目编号 like '6051%' or 科目编号 like '6301%') And (" & filter & ")"
Dim jb2 As New SQLJoinTableBuilder("查询表1","辅助总账")
jb2.AddTable("辅助总账","科目编码","科目档案","科目编号")
jb2.AddTable("辅助总账", "部门编码","责任中心档案","部门编号")
jb2.AddCols("科目编码","科目名称","一级科目","二级科目","科目汇总","成本大类","部门名称","上级汇总","一级汇总","公司汇总","部门属性","会计期间")
jb2.AddExp("金额","借方金额")
jb2.Filter = "(科目编号 like '6601%' or 科目编号 like '6602%' or 科目编号 like '6603%') And (" & filter & ")"
jb1.Union(jb2,True) '组合jb2
jb1.Build()
MessageBox.Show(3)
Dim bd1 As New GroupTableBuilder("统计表1",DataTables("查询表1"))
Dim dt1 As fxDataSource
If tj21.Checked=True And tj22.Checked=False Then
bd1.Groups.AddDef(KMHZ,"科目名称")
ElseIf tj22.Checked=True And tj21.Checked=False Then
bd1.Groups.AddDef(BMHZ,"部门名称")
Else
bd1.Groups.AddDef(BMHZ,"部门名称")
bd1.Groups.AddDef(KMHZ,"科目名称")
End If
bd1.Totals.AddDef("金额","本期")
dt1 = bd1.BuildDataSource()
MessageBox.Show(4)
Dim bd2 As New SQLGroupTableBuilder("统计表2","同期预算")
Dim dt2 As fxDataSource
bd2.AddTable("同期预算","部门名称","责任中心档案","部门名称")
bd2.AddTable("同期预算","科目名称","费用科目档案","科目名称")
If tj21.Checked=True And tj22.Checked=False Then
bd2.Groups.AddDef(KMHZ,"{费用科目档案}.科目名称")
ElseIf tj22.Checked=True And tj21.Checked=False Then
bd2.Groups.AddDef(BMHZ,"{责任中心档案}.部门名称")
Else
bd2.Groups.AddDef(BMHZ,"{责任中心档案}.部门名称")
bd2.Groups.AddDef(KMHZ,"{费用科目档案}.科目名称")
End If
bd2.Totals.AddDef("同期金额","同期")
bd2.Filter = filter1
dt2 = bd2.BuildDataSource()
MessageBox.Show(5)
Dim nms As String() = {BMHZ,KMHZ}
dt1.Combine(nms,dt2,nms)
此主题相关图片如下:企业微信截图_15481324246364.png
[此贴子已经被作者于2019/1/22 13:16:59编辑过]