コード例 #1
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            rptEventsReport1 rpt = new rptEventsReport1();

            rpt.Site = this.Site;
            return(rpt);
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor         = Cursors.WaitCursor;
                timer1.Enabled = true;
                frmEventReport frm = new frmEventReport();

                rptEventsReport1 rpt = new rptEventsReport1();
                //The report you created.
                SqlConnection  myConnection = default(SqlConnection);
                SqlCommand     MyCommand    = new SqlCommand();
                SqlDataAdapter myDA         = new SqlDataAdapter();
                ERPS_DBDataSet myDS         = new ERPS_DBDataSet();
                //The DataSet you created.


                myConnection          = new SqlConnection(cs.DBcon);
                MyCommand.Connection  = myConnection;
                MyCommand.CommandText = "select *  from Event";

                MyCommand.CommandType = CommandType.Text;
                myDA.SelectCommand    = MyCommand;
                myDA.Fill(myDS, "Event");
                rpt.SetDataSource(myDS);
                frm.crystalReportViewer1.ReportSource = rpt;
                frm.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }