Dim st As Date = Date.Now
Dim com2 As WinForm.ComboBox = e.Form.Controls("ComboBox2")
Dim com3 As WinForm.ComboBox = e.Form.Controls("ComboBox3")
Dim zgsztnd As String = com2.Value
Dim zgsztyf As String = com3.Value
Dim com As WinForm.ComboBox = e.Form.Controls("ComboBox1")
Dim zfc As String
zfc = "select 纵向科目, c.pzzb5,c.pzzb6,c.pzzb7, sum(d.pzzb8) as pzzb8,sum(d.pzzb9) as pzzb9,c.pzzb12,c.pzzb44,c.pzzb45,'' as 横向科目 ,1*0 as 金额 from (Select distinct a.pzzb12 As 纵向科目, a.pzzb5,b.pzzb6,a.pzzb7,b.pzzb12 as pzzb12,a.pzzb44,a.pzzb45 from (select pzzb5,pzzb6,pzzb7,pzzb12,pzzb44,pzzb45 from {dtpzzbwb} where pzzb2 = '" & zgsztnd & "' and pzzb3 <= '" & zgsztyf & "' and pzzb12 in ('股本', '固定资产','现金', '银行存款') group by pzzb12,pzzb5,pzzb6,pzzb7,pzzb44,pzzb45) as a left join {dtpzzbwb} as b on a.pzzb5=b.pzzb5) as c inner join {dtpzzbwb} as d on c.pzzb5=d.pzzb5 and c.pzzb12=d.pzzb12 and iif(c.pzzb6 is null, true, c.pzzb6=d.pzzb6) group by 纵向科目, c.pzzb5,c.pzzb6,c.pzzb7,c.pzzb12,c.pzzb44,c.pzzb45"
zfc = zfc.Replace("dtpzzbwb",com.Value)
output.show(zfc)
'MessageBox.Show("耗时: " & (Date.Now - st).TotalSeconds & "秒")
'MessageBox.Show(zfc)
Dim cmd As New SQLCommand
Dim kmmxz As DataTable
cmd.CommandText = zfc
kmmxz = cmd.ExecuteReader()
MessageBox.Show("耗时: " & (Date.Now - st).TotalSeconds & "秒")
Dim tb As WinForm.Table = e.Form.Controls("Table1")
tb.Table.DataSource = kmmxz
tb.Table.Cols("横向科目").Width = 200
tb.Table.Cols("pzzb7").Width = 200
tb.Table.Cols("纵向科目").Width = 120
tb.Table.Cols("pzzb12").Width = 150
tb.Table.AllowEdit = True