public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { DelOAckIRD rpt = new DelOAckIRD(); rpt.Site = this.Site; return(rpt); }
private void Report3() { button1.Enabled = false; backgroundWorker1.RunWorkerAsync(); progressBar1.Visible = true; // To report progress from the background worker we need to set this property backgroundWorker1.WorkerReportsProgress = true; // This event will be raised on the worker thread when the worker starts backgroundWorker1.DoWork += new DoWorkEventHandler(backgroundWorker1_DoWork); // This event will be raised when we call ReportProgress backgroundWorker1.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker1_ProgressChanged); ParameterField paramField1 = new ParameterField(); //creating an object of ParameterFields class ParameterFields paramFields1 = new ParameterFields(); //creating an object of ParameterDiscreteValue class ParameterDiscreteValue paramDiscreteValue1 = new ParameterDiscreteValue(); //set the parameter field name paramField1.Name = "id"; //set the parameter value paramDiscreteValue1.Value = outid; //add the parameter value in the ParameterField object paramField1.CurrentValues.Add(paramDiscreteValue1); //add the parameter in the ParameterFields object paramFields1.Add(paramField1); ReportViewer f2 = new ReportViewer(); TableLogOnInfos reportLogonInfos = new TableLogOnInfos(); TableLogOnInfo reportLogonInfo = new TableLogOnInfo(); ConnectionInfo reportConInfo = new ConnectionInfo(); Tables tables = default(Tables); // Table table = default(Table); var with1 = reportConInfo; with1.ServerName = "tcp:KyotoServer,49172"; with1.DatabaseName = "ProductNRelatedDB"; with1.UserID = "sa"; with1.Password = "******"; ReportDocument cr = new ReportDocument(); if (brandid == 1) { cr = new DeliOAckOmron(); } else if (brandid == 2) { cr = new DelOAckWithoutLogo(); } else if (brandid == 3) { cr = new DelOAckAzbil(); } else if (brandid == 4) { cr = new DelOAckBusinessAutomation(); } else if (brandid == 5) { cr = new DelOAckIRD(); } else if (brandid == 6) { cr = new DelOAckKawashima(); } else if (brandid == 7) { cr = new DelOAckChigo(); } else if (brandid == 8) { cr = new DelOAckSamsung(); } tables = cr.Database.Tables; foreach (Table table in tables) { reportLogonInfo = table.LogOnInfo; reportLogonInfo.ConnectionInfo = reportConInfo; table.ApplyLogOnInfo(reportLogonInfo); } Sections m_boSections; ReportObjects m_boReportObjects; SubreportObject m_boSubreportObject; //create a new ReportDocument //get all the sections in the report m_boSections = cr.ReportDefinition.Sections; //loop through each section of the report foreach (Section m_boSection in m_boSections) { m_boReportObjects = m_boSection.ReportObjects; //loop through each report object foreach (ReportObject m_boReportObject in m_boReportObjects) { if (m_boReportObject.Kind == ReportObjectKind.SubreportObject) { //get the actual subreport object m_boSubreportObject = (SubreportObject)m_boReportObject; //set subreport to the dataset e.g.; // boReportDocument.SetDataSource(oDataSet); // or // boTable.SetDataSource(oDataSet.Tables[tableName]); } } } //show in reportviewer //crystalReportViewer1.ReportSource = m_boReportDocument; BArcode ds = new BArcode(); var content = refno; var writer = new BarcodeWriter { Format = BarcodeFormat.CODE_128, Options = new EncodingOptions { PureBarcode = true, Height = 100, Width = 465 } }; var png = writer.Write(content); System.IO.MemoryStream ms = new System.IO.MemoryStream(); png.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); DataRow dtr = ds.Tables[0].NewRow(); dtr["REF"] = refno; dtr["BarcodeImage"] = ms.ToArray(); ds.Tables[0].Rows.Add(dtr); cr.Subreports["BarCode.rpt"].DataSourceConnections.Clear(); cr.Subreports["BarCode.rpt"].SetDataSource(ds); f2.crystalReportViewer1.ParameterFieldInfo = paramFields1; f2.crystalReportViewer1.ReportSource = cr; this.Visible = false; f2.ShowDialog(); this.Visible = true; backgroundWorker1.CancelAsync(); backgroundWorker1.Dispose(); progressBar1.Visible = false; button1.Enabled = true; }