public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { CrystalReport2 rpt = new CrystalReport2(); rpt.Site = this.Site; return(rpt); }
private void btnGenerate_Click(object sender, EventArgs e) { if (label17.Text == "Payment Voucher") { label12.Text = label18.Text + label19.Text + label20.Text; label11.Text = NumberToWords(Convert.ToInt32(textBox1.Text)) + " Only"; //Page Header Section CrystalReport1 cr = new CrystalReport1(); TextObject VoucherNo = (TextObject)cr.ReportDefinition.Sections["Section2"].ReportObjects["Text5"]; VoucherNo.Text = label12.Text; crystalReportViewer1.ReportSource = cr; TextObject Date = (TextObject)cr.ReportDefinition.Sections["Section2"].ReportObjects["Text6"]; Date.Text = label13.Text; crystalReportViewer1.ReportSource = cr; //Details Section TextObject sumofrupees = (TextObject)cr.ReportDefinition.Sections["Section3"].ReportObjects["Text9"]; sumofrupees.Text = textBox1.Text; crystalReportViewer1.ReportSource = cr; TextObject inwords = (TextObject)cr.ReportDefinition.Sections["Section3"].ReportObjects["Text11"]; inwords.Text = label11.Text; crystalReportViewer1.ReportSource = cr; TextObject paidto = (TextObject)cr.ReportDefinition.Sections["Section3"].ReportObjects["Text13"]; paidto.Text = textBox2.Text; crystalReportViewer1.ReportSource = cr; TextObject onbehalfof = (TextObject)cr.ReportDefinition.Sections["Section3"].ReportObjects["Text16"]; onbehalfof.Text = textBox3.Text; crystalReportViewer1.ReportSource = cr; } else if (label17.Text == "Sales Receipt") { label12.Text = label21.Text + label24.Text; ReportDocument cryRpt = new ReportDocument(); cryRpt.Load(@"C:\Users\Devesh\Documents\Visual Studio 2008\Projects\BillingSystem\BillingSystem\UI\CrystalReport2.rpt"); crystalReportViewer2.ReportSource = cryRpt; crystalReportViewer2.Refresh(); CrystalReport2 cr = new CrystalReport2(); //Report Header Section TextObject billno = (TextObject)cr.ReportDefinition.Sections["Section1"].ReportObjects["Text22"]; billno.Text = label12.Text; crystalReportViewer2.ReportSource = cr; TextObject date = (TextObject)cr.ReportDefinition.Sections["Section1"].ReportObjects["Text23"]; date.Text = label13.Text; crystalReportViewer2.ReportSource = cr; TextObject name = (TextObject)cr.ReportDefinition.Sections["Section1"].ReportObjects["Text9"]; name.Text = textBox5.Text; crystalReportViewer2.ReportSource = cr; TextObject address = (TextObject)cr.ReportDefinition.Sections["Section1"].ReportObjects["Text6"]; address.Text = textBox4.Text; crystalReportViewer2.ReportSource = cr; //Report Footer Section TextObject subtotal = (TextObject)cr.ReportDefinition.Sections["Section4"].ReportObjects["Text10"]; subtotal.Text = label1.Text; crystalReportViewer2.ReportSource = cr; TextObject discount = (TextObject)cr.ReportDefinition.Sections["Section4"].ReportObjects["Text31"]; discount.Text = label2.Text; crystalReportViewer2.ReportSource = cr; TextObject discountamount = (TextObject)cr.ReportDefinition.Sections["Section4"].ReportObjects["Text12"]; discountamount.Text = label14.Text; crystalReportViewer2.ReportSource = cr; TextObject cgstamount = (TextObject)cr.ReportDefinition.Sections["Section4"].ReportObjects["Text13"]; cgstamount.Text = label6.Text; crystalReportViewer2.ReportSource = cr; TextObject sgstamount = (TextObject)cr.ReportDefinition.Sections["Section4"].ReportObjects["Text14"]; sgstamount.Text = label8.Text; crystalReportViewer2.ReportSource = cr; TextObject igstamount = (TextObject)cr.ReportDefinition.Sections["Section4"].ReportObjects["Text15"]; igstamount.Text = label7.Text; crystalReportViewer2.ReportSource = cr; TextObject grandtotal = (TextObject)cr.ReportDefinition.Sections["Section4"].ReportObjects["Text21"]; grandtotal.Text = label9.Text; crystalReportViewer2.ReportSource = cr; clear(); } }