2013-06-12 80 views
0

strdate是日期需要通過總晶體報告

昏暗dt的作爲新的DataTable 昏暗Q1,Q2作爲字符串 Q1 =「SELECT SUM(CASE當AdjustmentFlag = 'd',那麼0-金額別的金額完)爲總,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") 

回答

0

暗淡strDate如日期 strDate =格式(dtpMonthOf.Value, 「DD-MM-YYYY」)

昏暗dt的作爲新的DataTable 昏暗Q1,Q2作爲字符串 Q1 =「SELECT SUM( CASE當AdjustmentFlag ='D'然後0-金額其他金額結束)作爲總,rp.TransactionCode,rp.ReferenceDate,rp.TransactionFlag,rp.EncashDate「&_ 」從dbo.ReceiptsPayments rp,dbo.ReceiptsPaymentsDetail rd「& _ 「WHERE rp.TransactionCode = rd.TransactionCode AND(rp.EncashDate is NULL or rp.EncashDate> strDate)AND TransactionFlag ='P'Grou p(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.Double"), "") 
     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")