1

私が取り組んでいるデータセットの助けが必要です 2 つのテーブルを持つデータセットがあります。1 つは「Statementnumber」である主キー値のみを保持し、もう 1 つは 1 対多の関係で残りの詳細を保持します。

ここで、1 つのテーブルの各ステートメント番号を解析して、2 番目のテーブルから詳細を取得し、そのレコードを新しいデータ テーブルに配置します。プライマリ テーブルのレコードの最後に到達するまで、for ループを使用して一度に 1 レコードずつ。どうすればこれを行うことができますか?

これまでのところ、同じデータセットに両方のテーブルがあります。

ここに私がすでに持っているコードがあります。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Oracle.DataAccess.Client;
using System.Data;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;


namespace WebApplication1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string connetionString = null;
            OracleConnection connection;
            OracleDataAdapter OracleAdapter;
            DataSet ds = new DataSet();
            string firstSql = null;


            connetionString = "DataSoruce

            connection = new OracleConnection(connetionString);
            firstSql = @"SELECT DISTINCT statement_header.statementnumber,
                     statement_details.invoicedate,
                     statement_details.invoicenumber,
                     statement_details.invoicetotal,
                     statement_details.doc_type,
                     statement_header.statementtotal,
                     statement_details.bunumber_ru,
                     statement_details.bunumber,
                     statement_details.description,
                     statement_details.reference_number,
                     statement_header.remto_zip,
                     statement_header.remto_city,
                     statement_header.remto_state,
                     statement_header.remto_mailname,
                     statement_header.remto_addr1,
                     statement_header.remto_addr2,
                     statement_header.remto_addr3,
                     statement_header.soldto_city,
                     statement_header.soldto_state,
                     statement_header.soldto_zip,
                     statement_header.soldto_addr1,
                     statement_header.soldto_addr2,
                     statement_header.soldto_addr3,
                     statement_header.balance_forward,
                     statement_header.statementdate,
                     statement_header.custid,
                     statement_header.custname,
                     statement_header.phone_prefix,
                     statement_header.phone_number,
                     statement_details.purchases,
                     statement_details.payments,
                     statement_details.misc_credit2,
                     statement_details.misc_credit1,
                     statement_header.company_number,
                     statement_header.statementpurchases,
                     statement_header.statementpayments,
                     statement_header.statementmisc_credit1,
                     statement_header.statementmisc_credit2,
                     statement_header.nomailnoprint,
                     statement_header.SOLDTOCOUNTRYCODE,
                     statement_header.SOLDTOCOUNTRYNAME,
                     statement_header.CREDITZEROFLAG
       FROM STATEMENT_DATA_DOMESTIC statement_header
            INNER JOIN STATEMENT_DATA_DOM_DETAILS statement_details
               ON statement_header.statementnumber =
                     statement_details.statementnumber";
            string secondSql = "select statementnumber from statement_data_domestic";
                connection.Open();
                OracleAdapter = new OracleDataAdapter(firstSql, connection);
                OracleAdapter.Fill(ds, "domestic");
                OracleAdapter = new OracleDataAdapter(secondSql, connection);
                OracleAdapter.Fill(ds, "statement");

            OracleAdapter.Dispose();
                connection.Close();

                ds.Relations.Add("Statementnumber", ds.Tables["statement"].Columns["statementnumber"], ds.Tables["domestic"].Columns["statementnumber"]);



    //GridView1.DataSource = ds.Tables[1];
           //   GridView1.DataBind();
                ReportDocument reportDoc = new ReportDocument();
                reportDoc.Load(@"c:\users\soniara\desktop\statement.rpt");
                DataTable d3 = ds.Tables["statement"];
                foreach (DataRow arpan in d3.Rows)
                {
                    DataRow[] details = arpan.GetChildRows("Statementnumber");


                    foreach (DataRow detail in details)
                    {

                        reportDoc.SetDataSource(detail);
                        ExportOptions CrExportOptions;
                        DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
                        PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions();
                        CrDiskFileDestinationOptions.DiskFileName = @"d:\Converte5_1_13"+detail+".pdf";
                        CrExportOptions = reportDoc.ExportOptions;
                        {
                            CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                            CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
                            CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
                            CrExportOptions.FormatOptions = CrFormatTypeOptions;

                        }
                        reportDoc.Export();

                    }
                }








        }
    }
}

基本的に、ステートメントテーブルから一度に1つのレコードを取得し、詳細テーブルからすべての詳細を取得し、それをクリスタルレポートで実行してpdf出力を取得したい

データセット全体をソースとして crytalreport.setdatasrouce に渡すだけで、私のコードは問題なく動作します

しかし、それは小さな単一のステートメントファイルではなく、1 つの長い pdf ファイルを作成します。これが私がやろうとしていることです。

4

1 に答える 1