public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { rptInvoice rpt = new rptInvoice(); rpt.Site = this.Site; return(rpt); }
private void btnPrint_Click(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; timer1.Enabled = true; rptInvoice rpt = new rptInvoice(); //The report you created. cmd = new MySqlCommand(); MySqlDataAdapter myDA = new MySqlDataAdapter(); DataSet myDS = new DataSet(); //The DataSet you created. con = new MySqlConnection(connString()); cmd.Connection = con; cmd.CommandText = "SELECT * FROM invoicereport where InvoiceNo= '" + txtInvoiceNo.Text + "'"; cmd.CommandType = CommandType.Text; myDA.SelectCommand = cmd; myDA.Fill(myDS, "invoicereport"); //myDA.Fill(myDS, "configuration"); //myDA.Fill(myDS,"invoice"); //myDA.Fill(myDS, "sales"); //myDA.Fill(myDS, "Customer"); rpt.SetDataSource(myDS); frmInvoiceReport frm = new frmInvoiceReport(); frm.crystalReportViewer1.ReportSource = rpt; frm.Visible = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }