public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { CRContract rpt = new CRContract(); rpt.Site = this.Site; return rpt; }
private void BtnPrint_Click(object sender, EventArgs e) { if (LUEcontractid.ItemIndex < 0) return; //RepCRGeneralFrm RepForm = new RepCRGeneralFrm(); CReports.CRContract CRRep = new CReports.CRContract(); CRRep.SetParameterValue(0, LUEcontractid.EditValue); CrystalDecisions.Shared.TableLogOnInfos crtableLogoninfos = new CrystalDecisions.Shared.TableLogOnInfos(); CrystalDecisions.Shared.TableLogOnInfo crtableLogoninfo = new CrystalDecisions.Shared.TableLogOnInfo(); CrystalDecisions.Shared.ConnectionInfo crConnectionInfo = new CrystalDecisions.Shared.ConnectionInfo(); CrystalDecisions.CrystalReports.Engine.Tables CrTables = CRRep.Database.Tables; //System.Data.SqlClient.SqlConnectionStringBuilder ConString = new System.Data.SqlClient.SqlConnectionStringBuilder(MyCL.SqlConStr); System.Data.OleDb.OleDbConnectionStringBuilder AccConString = new OleDbConnectionStringBuilder(MyCL.AccConStr); crConnectionInfo.ServerName = AccConString.DataSource; crConnectionInfo.DatabaseName = ""; crConnectionInfo.UserID = ""; crConnectionInfo.Password = ""; CRRep.DataSourceConnections[0].SetConnection("", AccConString.FileName, false); foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables) { crtableLogoninfo = CrTable.LogOnInfo; crtableLogoninfo.ConnectionInfo = crConnectionInfo; CrTable.ApplyLogOnInfo(crtableLogoninfo); } //CRRep.PrintToPrinter(new System.Drawing.Printing.PrinterSettings(), new System.Drawing.Printing.PageSettings(), true); CRRep.PrintToPrinter(1, true, 1, 2); //RepForm.CRViewer.ReportSource = MyCL.crRep[Convert.ToInt16(mbReports.EditValue)].CRReport; //RepForm.CRViewer.Refresh(); //RepForm.ReportName = MyCL.crRep[Convert.ToInt16(mbReports.EditValue)].RepCaption; //RepForm.MdiParent = this; //RepForm.Show(); }