public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { DOCIRD rpt = new DOCIRD(); rpt.Site = this.Site; return(rpt); }
private void Report2() { 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 = quotationId; //add the parameter value in the ParameterField object paramField1.CurrentValues.Add(paramDiscreteValue1); //add the parameter in the ParameterFields object paramFields1.Add(paramField1); ReportView f2 = new ReportView(); 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 DOCOmron(); } else if (brandid == 2) { cr = new DOCWithoutLogo(); } else if (brandid == 3) { cr = new DOCAzbil(); } else if (brandid == 4) { cr = new DOCBusinessAutomation(); } else if (brandid == 5) { cr = new DOCIRD(); } else if (brandid == 6) { cr = new DOCKawaShima(); } tables = cr.Database.Tables; foreach (Table table in tables) { reportLogonInfo = table.LogOnInfo; reportLogonInfo.ConnectionInfo = reportConInfo; table.ApplyLogOnInfo(reportLogonInfo); } BArcode ds = new BArcode(); var content = comboBox1.Text; 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"] = comboBox1.Text; 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; }