strdate 是日期
Dim dt As New DataTable Dim q1, q2 As String q1 = "SELECT SUM(CASE when AdjustmentFlag= 'D' then 0-Amount else Amount End) as total , rp.TransactionCode, rp.ReferenceDate, rp.TransactionFlag,rp.EncashDate " & _ " FROM dbo.ReceiptsPayments rp, dbo.ReceiptsPaymentsDetail rd" & _ " WHERE rp.TransactionCode = rd.TransactionCode AND (rp.EncashDate 为 NULL 或 rp.EncashDate > strDate)AND TransactionFlag = 'P' Group(BY) rp.TransactionCode、rp.ReferenceDate、rp.TransactionFlag、rp.EncashDate"
q2 = "SELECT SUM(CASE when AdjustmentFlag='D' then 0-Amount else Amount end)as total " & _
"FROM ReceiptsPayments rp, ReceiptsPaymentsDetail rd " & _
"WHERE rp.TransactionCode = rd.TransactionCode and ReferenceDate <= strDate" & _
"AND TransactionFlag = 'P'"
dt.Columns.Add("ReconciliationDate", System.Type.GetType("System.DateTime"), "")
dt.Columns.Add("CashbookBalance", System.Type.GetType("System.Decimal"), "")
dt.Columns.Add("ChequesdrawnnotCleared", System.Type.GetType("System.Int32"), "")
dt.Columns.Add("ChequesreceivedNotCleared", System.Type.GetType("System.Int32"), "")
Dim dr(3) As Object
dr(0) = strDate 'ReconciliationDate
dr(1) = GET_DATAVALUE(q2, conn) 'CashbookBalance
dr(2) = 23 'GET_DATAVALUE("", conn) 'ChequesdrawnNotcleared
dr(3) = 24 'GET_DATAVALUE("", conn) 'ChequesreceivedNotcleared
dt.Rows.Add(dr)
frmReportviewer.PrintReport(dt, "rptReconciliation.rpt")