Dim CombGetColTbl As WinForm.ComboBox = e.Form.Controls("CombGetColTbl") \'CombGetColTbl对应第一张图的{产值付款流程表}
If CombGetColTbl.Items.Count<1 Then
MessageBox.Show("没有需要统计的表")
Return
End If
Dim MainSumTable As String = CombGetColTbl.Items(0) \'统计使用的主表
Dim CombSumCol As WinForm.ListBox = e.Form.Controls("LstSumCol1")\'对应第一张图的{SUM(申报金额) SUM(批复金额)}
If CombSumCol.Items.Count<1 Then
MessageBox.Show("没有选定统计列")
Return
End If
Dim SumName As String = e.Form.Controls("TxtGroup1").TEXT \'生成查询表的名字
Dim tStr As String = ""
If SUMNAME.Trim() = "" Then
SUMNAME= MainSumTable & "统计表"
e.Form.Controls("TxtGroup1").TEXT = SUMNAME
End If
Dim DetailCol As WinForm.ListBox = e.Form.Controls("LstDetailDec1") \'对应第一张图的{都匀电厂补水管,都匀电厂柴油机,都匀电厂复用水}
Dim nCn As Integer = DetailCol.Items.Count -1
Dim bdx(CombSumCol.Items.Count-1 , iif(nCn<0 ,0 , nCn) ) As SQLGroupTableBuilder \'
Dim dtx(CombSumCol.Items.Count-1 , iif(nCn<0 ,0 , nCn) ) As fxDataSource
Dim vSum(CombSumCol.Items.Count-1) As mColValue \'
Functions.Execute("Fun分离lstboxs数据",CombSumCol,vSum,MainSumTable,"",False)
Dim vGrp(iif(nCn<0 ,0 , nCn)) As mColValue \'
Functions.Execute("Fun分离lstboxs数据",DetailCol,vGrp,MainSumTable,e.Form.Controls("CombGetColTbl1").text,False)
For i As Integer=0 To CombSumCol.Items.Count -1
For j As Integer=0 To iif(nCn<1,0,ncn)
If i=0 And j=0 Then
bdx(0,0) = New SQLGroupTableBuilder(SUMNAME,MainSumTable )
Else
bdx(I,J) = New SQLGroupTableBuilder(SUMNAME & i & j,MainSumTable )
End If
bdx(I,J).C
Next
Next
For L As Integer = 0 To CombGetColTbl.Items.Count -1 \'\'连接多表
Dim CombLinkCol01 As WinForm.ComboBox = e.Form.Controls("CombLinkCol" & L & "1") \'连接字段
Dim CombLinkCol02 As WinForm.ComboBox = e.Form.Controls("CombLinkCol" & L & "2") \'连接字段
If L>0 Then
If CombLinkCol01.Text <> "" AndAlso CombLinkCol02.text <> "" Then
For i As Integer=0 To CombSumCol.Items.Count -1
For j As Integer =0 To iif(nCn<1,0,ncn)
bdx(I,J).AddTable(MainSumTable ,CombLinkCol01.Text ,CombGetColTbl.Items(L) ,CombLinkCol02.Text )
Next
Next
End If
End If
Next
Dim LstGrpName As WinForm.ListBox = e.Form.Controls("LstDesColName1") \' 统计时的分组列
Dim grpN(LstGrpName.Items.Count-1) As String
Dim il As Integer =0
For i As Integer =0 To (LstGrpName.Items.Count -1)
tStr = LstGrpName.Items(i)
il=tStr.IndexOf("}.")
grpN(i)=tstr.Trim()
For j As Integer = 0 To CombSumCol.Items.Count -1
For k As Integer = 0 To iif(nCn<1,0,ncn)
bdx(j,k).Groups.AddDef( tStr ,IIF(IL>0, tStr.SubString(tStr.IndexOf("}.") +2 ),tStr) ) \'
\'MessageBox.Show("J" & J & " K" & K & "GRP:" & tStr, & "GRP:" & tStr)
Next
Next
Next
For i As Integer =0 To CombSumCol.Items.Count -1 \'\'开始统计
For j As Integer = 0 To iif(nCn<1,0,ncn) \'DetailCol
bdx(I,j).Totals.AddDef( vSum(i).Value , vSum(i).Value & "_" & vGrp(j).dfVal) \' tStr.SubString(tStr.IndexOf("}.") +2 ) )
\'MessageBox.Show("IvSum(i).Value " & vSum(i).Value & " vSum(i).Value _ vGrp(j).dfVal" & vSum(i).Value & "_" & vGrp(j).dfVal & "GRP:" & tStr)
If vGrp(j).dfVal<>"" Then bdx(I,j).Filter = vGrp(j).Value & " = \'" & vGrp(j).dfVal & "\'"
dtx(i,j) = bdx(I,j).BuildDataSource()
\'
If i<> 0 Or j<> 0 Then \'
\' MessageBox.Show("grpN(0) I" & i & grpN(0) & " grpN(1) J" & J & grpN(1) & "vSum(J).dfVal" & vGrp(j).dfVal )
dtx(0,0).Combine(grpN ,dtx(I,j), grpN)\'
End If
Next
Next
Tables("通用分组查询器_TblData").DataSource = bdx(0,0) \'这个结果出来后,见图第二张,怎么会没有动呢?
Tables("通用分组查询器_TblData").AutoSizeCols()