c# - Is there a better way to do this ? -
so here goes. have model of dataset works fine , imports data database , gives crystal report. solution works time consuming wondering if there other way of doing this...
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); string secondsql = "select statementnumber erocks.statement_data_domestic"; connection.open(); //oracleadapter = new oracledataadapter(firstsql, connection); //oracleadapter.fill(ds, "domestic"); oracleadapter = new oracledataadapter(secondsql, connection); oracleadapter.fill(ds, "statement"); connection.close(); reportdocument reportdoc = new reportdocument(); reportdoc.load(@"c:\users\desktop\statement.rpt"); datatable stmt = ds.tables["statement"]; string stmtnumber=""; (int = 0; < stmt.rows.count - 1; i++) { stmtnumber = stmt.rows[i][0].tostring(); 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 statement_data_domestic statement_header inner join statement_data_details statement_details on statement_header.statementnumber = statement_details.statementnumber statement_header.statementnumber="+stmtnumber; connection.open(); oracleadapter = new oracledataadapter(firstsql, connection); oracleadapter.fill(ds, "domestic"); oracleadapter.dispose(); connection.close(); reportdoc.setdatasource(ds.tables["domestic"]); exportoptions crexportoptions; diskfiledestinationoptions crdiskfiledestinationoptions = new diskfiledestinationoptions(); pdfrtfwordformatoptions crformattypeoptions = new pdfrtfwordformatoptions(); crdiskfiledestinationoptions.diskfilename = @"d:\pdf\"+ stmtnumber + ".pdf"; crexportoptions = reportdoc.exportoptions; { crexportoptions.exportdestinationtype = exportdestinationtype.diskfile; crexportoptions.exportformattype = exportformattype.portabledocformat; crexportoptions.destinationoptions = crdiskfiledestinationoptions; crexportoptions.formatoptions = crformattypeoptions; } reportdoc.export(); ds.tables["domestic"].clear(); } } } }
it faster if retrieve data statements, group statementid inside report , burst report group. bursting generate separate file each group. in such way able generate files 1 call database.
Comments
Post a Comment