private void Imprimir(object p, string p_2) { Business.Data.Laboratorio.Protocolo oProt = new Business.Data.Laboratorio.Protocolo(); oProt = (Business.Data.Laboratorio.Protocolo)oProt.Get(typeof(Business.Data.Laboratorio.Protocolo), int.Parse(p.ToString())); oProt.GrabarAuditoriaProtocolo("Genera PDF Comprobante", int.Parse(Session["idUsuario"].ToString())); Configuracion oCon = new Configuracion(); oCon = (Configuracion)oCon.Get(typeof(Configuracion), 1); oCon = (Configuracion)oCon.Get(typeof(Configuracion), "IdConfiguracion", 1); ParameterDiscreteValue encabezado1 = new ParameterDiscreteValue(); encabezado1.Value = oCon.EncabezadoLinea1; ParameterDiscreteValue encabezado2 = new ParameterDiscreteValue(); encabezado2.Value = oCon.EncabezadoLinea2; ParameterDiscreteValue encabezado3 = new ParameterDiscreteValue(); encabezado3.Value = oCon.EncabezadoLinea3; ParameterDiscreteValue tipoNumeracion = new ParameterDiscreteValue(); tipoNumeracion.Value = oCon.TipoNumeracionProtocolo; oCr.Report.FileName = "../Informes/Protocolo.rpt"; oCr.ReportDocument.SetDataSource(oProt.GetDataSet("Protocolo", "", oProt.IdTipoServicio.IdTipoServicio)); oCr.ReportDocument.ParameterFields[0].CurrentValues.Add(encabezado1); oCr.ReportDocument.ParameterFields[1].CurrentValues.Add(encabezado2); oCr.ReportDocument.ParameterFields[2].CurrentValues.Add(encabezado3); oCr.ReportDocument.ParameterFields[3].CurrentValues.Add(tipoNumeracion); oCr.DataBind(); if (p_2 == "I") { oCr.ReportDocument.PrintToPrinter(1, false, 0, 0); } else { MemoryStream oStream; // using System.IO oStream = (MemoryStream)oCr.ReportDocument.ExportToStream(ExportFormatType.PortableDocFormat); Response.Clear(); Response.Buffer = true; Response.ContentType = "application/pdf"; Response.AddHeader("Content-Disposition", "attachment;filename=Protocolo.pdf"); Response.BinaryWrite(oStream.ToArray()); Response.End(); } }
private void Imprimir(string p, string p_2) { Business.Data.Laboratorio.Protocolo oProt = new Business.Data.Laboratorio.Protocolo(); oProt = (Business.Data.Laboratorio.Protocolo)oProt.Get(typeof(Business.Data.Laboratorio.Protocolo), int.Parse(p)); oCr.Report.FileName = "../Informes/Protocolo.rpt"; oCr.ReportDocument.SetDataSource(oProt.GetDataSet("Protocolo", "", oProt.IdTipoServicio.IdTipoServicio)); oCr.DataBind(); switch (p_2) { case "Pantalla": { CrystalReportViewer1.ReportSourceID = oCr.ID; CrystalReportViewer1.ReportSource = oCr; Condiciones_del_visualizador(); } break; case "I": { oCr.ReportDocument.PrintToPrinter(1, true, 1, 100); } break; case "PDF": { oCr.ReportDocument.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "Protocolo.pdf"); // MemoryStream oStream; // using System.IO //oStream = (MemoryStream)oCr.ReportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); //Response.Clear(); //Response.Buffer = true; //Response.ContentType = "application/pdf"; //Response.AddHeader("Content-Disposition", "attachment;filename=Protocolo.pdf"); //Response.BinaryWrite(oStream.ToArray()); //Response.End(); } break; } }