public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { PurchaseCrystalReport rpt = new PurchaseCrystalReport(); rpt.Site = this.Site; return(rpt); }
protected void ckblPurchase_SelectedIndexChanged(object sender, EventArgs e) { if (vcr != null) { vcr.Dispose(); } vcr = new PurchaseCrystalReport(); conn = new SqlConnection("Data Source=DESKTOP-M8T503R\\SQLSERVER;Initial Catalog=ADTeam1;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework"); conn.Open(); string query = "SELECT [CategoryName],[Description],[PurchaseDate],[QtyOrdered] FROM[ADTeam1].[dbo].[View_Purchase] where 1=2"; foreach (ListItem item in chklPurchase.Items) { if (item.Selected) { query = query + " or CategoryName=" + "'" + item.Value + "'"; } } query = query + " and PurchaseDate >= DATEADD(MONTH,-3,GETDATE())"; SqlCommand cmd = new SqlCommand(query, conn); SqlDataAdapter da = new SqlDataAdapter(cmd); ReportDataSet rds = new ReportDataSet(); rds.EnforceConstraints = false; da.Fill(rds.View_Purchase); conn.Close(); //PurchaseCrystalReport cr = new PurchaseCrystalReport(); vcr.SetDataSource(rds); CrystalReportViewer1.ReportSource = vcr; }