2013年6月14日 星期五

Dynamic rdlc report

參考引用:Dynamic rdlc report
--


Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
If Me.TextBox1.Text = "" Or IsNumeric(Me.TextBox1.Text) = False Then
Return
End If
Dim MyConn As ADODB.Connection
Dim MyRecSet As ADODB.Recordset

Dim DelSql As String
Dim tmpSQL As String

MyConn = New ADODB.Connection
MyRecSet = New ADODB.Recordset
MyConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\boxus\Geral\Dados\UTLT.accdb;Persist Security Info = False"
MyConn.Open()
Try
DelSql = "DELETE FROM UNICRE_REPORT_COMM"
MyConn.Execute(DelSql)
tmpSQL = "INSERT INTO UNICRE_REPORT_COMM (C_NAME, TRX_AMNT, ACT, BUY_L_NAME, BUY_F_NAME, BUYER_MAIL, USER_LOG, SH_MESSAGE, TRX_DATE, AUT_NUMBER, DT_FECHO, TRXS_TOTAL, COMM, UTIL, CC_NOME, CC_LOCAL, CC_NOME_LOGIN, CC_OFFICE, CC_DEP) SELECT A.CORPORATE_NAME, A.TRANSACTION_AMOUNT, A.ACTION, A.BUYER_LAST_NAME, A.BUYER_FIRST_NAME, A.BUYER_EMAIL, A.USER_LOGIN, A.SHORT_MESSAGE, A.TRANSACTION_DATE, A.AUTORIZATION_NUMBER, B.DATA_FECHO, B.TRX_TOTAL, B.COMISSAO, B.UTILIZADOR, C.NOME, C.LOCALIZACAO, C.NOME_LOGIN, C.OFFICE, C.DEP FROM FECHO_UNICRE A, FECHO_UNICRE_REP B, UNICRE_CC C WHERE (B.DATA_FECHO = A.TRANSACTION_DATE AND C.NOME_LOGIN = A.USER_LOGIN)"
MyConn.Execute(tmpSQL)
Dim rs1 As ADODB.Recordset
Dim SomaSql As String
SomaSql = "SELECT SUM(TRX_AMNT) FROM UNICRE_REPORT_COMM"
rs1 = New ADODB.Recordset
Call rs1.Open(SomaSql, MyConn)
Me.TextBox2.Text = rs1.Fields(0).Value
MyConn.Close()
Dim p1 As New ReportParameter("teste", Val(Me.TextBox1.Text))
Dim p2 As New ReportParameter("soma", Val(Me.TextBox2.Text))
Unicre_Report_Comm.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {p1, p2})
Unicre_Report_Comm_SR.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {p1, p2})
Me.Close()
Catch ex As Exception
MsgBox(ex.Message).ToString()
End Try
Unicre_Report_Comm.Show()
Unicre_Report_Comm_SR.Show()
End Sub

沒有留言:

張貼留言