Example #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         Cursor         = Cursors.WaitCursor;
         timer1.Enabled = true;
         rptSuppliers rpt = new rptSuppliers();
         //The report you created.
         frmSuppliersReport frm          = new frmSuppliersReport();
         SqlConnection      myConnection = default(SqlConnection);
         SqlCommand         MyCommand    = new SqlCommand();
         SqlDataAdapter     myDA         = new SqlDataAdapter();
         POS_DBDataSet      myDS         = new POS_DBDataSet();
         //The DataSet you created.
         myConnection          = new SqlConnection(cs.DBConn);
         MyCommand.Connection  = myConnection;
         MyCommand.CommandText = "select * from Supplier Order by SupplierName";
         MyCommand.CommandType = CommandType.Text;
         myDA.SelectCommand    = MyCommand;
         myDA.Fill(myDS, "Supplier");
         rpt.SetDataSource(myDS);
         frm.crystalReportViewer1.ReportSource = rpt;
         frm.Show();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            rptSuppliers rpt = new rptSuppliers();

            rpt.Site = this.Site;
            return(rpt);
        }