示例#1
0
        //private void crystalReportViewer1_Load(object sender, EventArgs e)
        //{


        //    CrystalReport4 rpt = new CrystalReport4();


        //    DataSet1 db = new DataSet1();

        //    rpt.SetDataSource(from employee in db.Employees.Take(100)
        //                                select employee.FirstName );


        //    //rpt.SetDataSource(db);

        //    //rpt.SetDataSource(from u in db.Employees
        //    //                      select new
        //    //                      {
        //    //                          u.EmployeeID,
        //    //                          u.FirstName,
        //    //                          u.LastName
        //    //                      });

        //   // crystalReportViewer1.ReportSource = rpt;
        //    crystalReportViewer1.RefreshReport();
        //}

        private void crystalReportViewer2_Load(object sender, EventArgs e)
        {
            DataSet1 db = new DataSet1();

            DataSet dsReport = new DataSet();

            var EmployeeTable = db.Employees.Copy();
            var OrdersTable   = db.Orders.Copy();


            dsReport.Tables.Add(EmployeeTable);
            dsReport.Tables.Add(OrdersTable);

            CrystalReportDataSet crystalReport = new CrystalReportDataSet();

            //var path = @"C:\Users\jaqbs\source\repos\CrystalReportsSolution\CrystalReportsEntity1\CrystalReportDataSet.rpt";
            //crystalReport.Load(path);
            crystalReport.SetDataSource(dsReport);
            CrystalReportViewer rv = new CrystalReportViewer();

            rv.ReportSource = crystalReport;
            crystalReportViewer2.ReportSource = crystalReport;
            crystalReportViewer2.Refresh();

            //rpt.SetDataSource(from employee in db.Employees.Take(100)
            //                  select employee.FirstName);
        }
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            CrystalReportDataSet rpt = new CrystalReportDataSet();

            rpt.Site = this.Site;
            return(rpt);
        }
示例#3
0
        public Form1()
        {
            InitializeComponent();
            CrystalReportDataSet crystalReport = new CrystalReportDataSet();

            using (DataSet1 dataSet1 = new DataSet1())
            {
                DataSet1 dsReport      = new DataSet1();
                var      EmployeeTable = dataSet1.Employees.Copy();
                var      OrdersTable   = dataSet1.Orders.Copy();


                dsReport.Tables.Add(EmployeeTable);
                dsReport.Tables.Add(OrdersTable);

                var path = @"C:\Users\jaqbs\source\repos\CrystalReportsSolution\CrystalReportsEntity1\CrystalReportDataSet.rpt";
                crystalReport.Load(path);
                crystalReport.SetDataSource(dsReport);
                //                  select employee.FirstName);
            }

            crystalReportViewer2.ReportSource = crystalReport;
            crystalReportViewer2.Refresh();
        }