0

我已经在网上查过了,但似乎没有什么能让我在没有这个问题的情况下显示我的报告。我的报告只有 1 个带有 3 个参数的子报告。我也检查了拼写。如果我注释掉子报告部分,那么我可以在子报告部分附近看到带有错误的报告(这很有意义,因为它希望我添加数据。下面是代码。知道我缺少什么吗?

私人无效Form2_Load(对象发件人,EventArgs e){

        DataSet ds1 = DataAdapterSelectQuery("SELECT DISTINCTROW tblInvoice.*, tblInvoiceDetail.intNo, tblInvoiceDetail.memDescription, tblInvoiceDetail.dblQuantity, tblInvoiceDetail.strUnit, tblInvoiceDetail.curAmount, [dblQuantity] *[curAmount] -[curDiscount] +[curTax] AS curTotal, ([strFirstName] + ' ') & [strSirName] AS strCustomer, tblInvoice.memQRCode, [memDescription] + ('(' & [strtaxcodes] & ')') AS DetailWithTaxCodes, IIf([tblInvoice]![strVMSInvType] = 'Normal', ' ============ FISCAL INVOICE ============ ', ' ===== THIS IS NOT A FISCAL RECEIPT ===== ') AS strTop, IIf([tblInvoice]![strVMSInvType]='Normal',' ======== END OF FISCAL INVOICE ========= ',' ===== THIS IS NOT A FISCAL RECEIPT ===== ') AS strBottom, tblInvoiceDetail.curDiscount, [curTotal]/[dblQuantity] AS curUnitAfterTax FROM(tblCustomers INNER JOIN tblInvoice ON tblCustomers.strCustCode = tblInvoice.strCustCode) INNER JOIN tblInvoiceDetail ON(tblInvoice.intInvType = tblInvoiceDetail.intInvType) AND(tblInvoice.lngInvNo = tblInvoiceDetail.lngInvNo) AND(tblInvoice.strVMSInvType = tblInvoiceDetail.strVMSInvType);");
        DataTable dt1 = ds1.Tables[0];
        dt1.TableName = "DataSet1";
        this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", dt1));

        DataSet ds2 = DataAdapterSelectQuery("SELECT strName, memAddress, s_GUID, oleLogo, strTaxNo FROM tblSystem");
        DataTable dt2 = ds2.Tables[0];
        dt2.TableName = "DataSet2";
        this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet2", dt2));

        DataSet ds3 = DataAdapterSelectQuery("SELECT strName, memAddress, s_GUID, oleLogo, strTaxNo FROM tblSystem");
        DataTable dt3 = ds3.Tables[0];
        dt3.TableName = "DataSet3";
        this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet3", dt3));

        this.reportViewer1.RefreshReport();

        reportViewer1.LocalReport.SubreportProcessing +=
              new SubreportProcessingEventHandler(InvoiceVMSSubTaxSubreportProcessingEventHandler);

        this.reportViewer1.RefreshReport();
        reportViewer1.LocalReport.Refresh();
    }

    private DataTable GetInvoiceVMSSubTaxSubReport(int lngInvNo, int intInvType, string strVMSInvType)
    {
        DataSet dsSubReport = DataAdapterSelectQuery("SELECT tblInvoiceTax.strVMSInvType, tblInvoiceTax.lngInvNo, tblInvoiceTax.intInvType, tblInvoiceTax.strLabel, tblInvoiceTax.strName, Format(tblInvoiceTax.[dblRate], 'Fixed') & [strSuffix] AS strRate, tblInvoiceTax.curTax FROM tblTaxCodes INNER JOIN tblInvoiceTax ON tblTaxCodes.strTaxLabel = tblInvoiceTax.strLabel WHERE lngInvNo = " + lngInvNo + " AND intInvType = " + intInvType + " AND strVMSInvType = '" + strVMSInvType + "'; ");
        DataTable dtSubreport = dsSubReport.Tables[0];
        dtSubreport.TableName = "DataSet1";
        this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", dtSubreport));
        return dtSubreport;
    }

    void InvoiceVMSSubTaxSubreportProcessingEventHandler(object sender, SubreportProcessingEventArgs e)
    {
        int lngInvNoParameter = int.Parse(e.Parameters["lngInvNoParameter"].Values[0].ToString());
        int intInvTypeParameter = int.Parse(e.Parameters["intInvTypeParameter"].Values[0].ToString());
        string strVMSInvTypeParameter = e.Parameters["strVMSInvTypeParameter"].Values[0].ToString();

        DataTable dtInvoiceVMSSubTaxSubReport = GetInvoiceVMSSubTaxSubReport(lngInvNoParameter, intInvTypeParameter, strVMSInvTypeParameter);

        ReportDataSource ds = new ReportDataSource("DataSet1", dtInvoiceVMSSubTaxSubReport);
        e.DataSources.Add(ds);

    }


    public static DataSet DataAdapterSelectQuery(string sqlQuery)
    {
        //TODO: Error Handling is left
        //TODO: Need global connection string
        string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["WindowsFormsApp2.Properties.Settings.VMS_DataConnectionString"].ConnectionString;

        //try                                   WindowsFormsApp2.Properties.Settings.VMS_DataConnectionString

        //{                

        using (OleDbConnection con = new OleDbConnection(connectionString))

        {

            con.Open();

            OleDbDataAdapter dAdapter = new OleDbDataAdapter(sqlQuery, con);

            DataSet dataSet = new DataSet();
            dAdapter.Fill(dataSet);

            return dataSet;
        }
        //catch (Exception ex)            
    }
4

0 回答 0