private void Imprimir(object p) { //Aca se deberá consultar los parametros para mostrar una hoja de trabajo u otra //this.CrystalReportSource1.Report.FileName = "HTrabajo2.rpt"; string informe = "../Informes/Turno.rpt"; Configuracion oCon = new Configuracion(); oCon = (Configuracion)oCon.Get(typeof(Configuracion), 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; Turno oTurno = new Turno(); oTurno = (Turno)oTurno.Get(typeof(Turno), int.Parse(p.ToString())); oCr.Report.FileName = informe; oCr.ReportDocument.SetDataSource(oTurno.GetDataSet()); oCr.ReportDocument.ParameterFields[0].CurrentValues.Add(encabezado1); oCr.ReportDocument.ParameterFields[1].CurrentValues.Add(encabezado2); oCr.ReportDocument.ParameterFields[2].CurrentValues.Add(encabezado3); oCr.DataBind(); //if (rdbImprimir.Items[0].Selected == true)//imprimir // oCr.ReportDocument.PrintToPrinter(1, false, 0,0); //else //{ 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=Turno.pdf"); Response.BinaryWrite(oStream.ToArray()); Response.End(); //} }
private void Imprimir(Turno oRegistro) { /////////////// Business.Reporte ticket = new Business.Reporte(); Configuracion oCon = new Configuracion(); oCon = (Configuracion)oCon.Get(typeof(Configuracion), 1); DataTable dt = oRegistro.GetDataSet(); string fechaHora = dt.Rows[0][1].ToString() + " " + dt.Rows[0][2].ToString(); string analisis = dt.Rows[0][9].ToString(); string recomendaciones = dt.Rows[0][10].ToString(); string paciente = oRegistro.IdPaciente.Apellido + " " + oRegistro.IdPaciente.Nombre; string dni = ""; if (oRegistro.IdPaciente.IdEstado != 2) { dni = "DU:" + oRegistro.IdPaciente.NumeroDocumento.ToString() + " - " + oRegistro.IdPaciente.Apellido + " " + oRegistro.IdPaciente.Nombre; } else { dni = "DU:" + "(Sin DU Temporal) - " + oRegistro.IdPaciente.Apellido + " " + oRegistro.IdPaciente.Nombre; } //if (oRegistro.IdPaciente.IdEstado >= 0) // dni = "DU:" + oRegistro.IdPaciente.NumeroDocumento.ToString(); //if (s_hiv != "False") paciente = oRegistro.IdPaciente.getSexo().sub oProt.Sexo + oProt.IdPaciente.Nombre.Substring(1, 2) + oProt.IdPaciente.Apellido.Substring(1, 2) + oProt.IdPaciente.FechaNacimiento.ToShortDateString().Replace("/", ""); //else paciente = oProt.IdPaciente.Apellido.ToUpper() + " " + oProt.IdPaciente.Nombre.ToUpper(); ticket.AddHeaderLine("LABORATORIO " + oCon.EncabezadoLinea1); ticket.AddSubHeaderLine(" "); //ticket.AddSubHeaderLine("___________________________________________________________________________________"); ticket.AddSubHeaderLine("TURNO " + fechaHora + " hs"); ticket.AddSubHeaderLine(" "); ticket.AddSubHeaderLine(paciente.ToUpper() + " " + dni + " Fecha de Nacimiento:" + oRegistro.IdPaciente.FechaNacimiento.ToShortDateString() + " Sexo:" + oRegistro.IdPaciente.getSexo().Substring(0, 1)); ticket.AddSubHeaderLine("___________________________________________________________________________________________"); if (analisis.Trim() != "") { int largo = analisis.Length; int cantidadFilas = largo / 90; if (cantidadFilas >= 0) { ticket.AddSubHeaderLine("PRACTICAS SOLICITADAS"); for (int i = 1; i <= cantidadFilas; i++) { int l = i * 90; analisis = analisis.Insert(l, "&"); } string[] tabla = analisis.Split('&'); /////Crea nuevamente los detalles. for (int i = 0; i <= tabla.Length - 1; i++) { ticket.AddSubHeaderLine(" " + tabla[i].ToUpper()); } ticket.AddSubHeaderLine("___________________________________________________________________________________________"); } } if (recomendaciones.Trim() != "") { int largo = recomendaciones.Length; int cantidadFilas = largo / 110; if (cantidadFilas >= 0) { for (int i = 1; i <= cantidadFilas; i++) { int l = i * 110; recomendaciones = recomendaciones.Insert(l, "&"); } string[] tabla = recomendaciones.Split('&'); for (int i = 0; i <= tabla.Length - 1; i++) { if (tabla[i].Trim() != "") { if (i == 0) { ticket.AddSubHeaderLine("INDICACIONES PARA EL PACIENTE"); ticket.AddSubHeaderLine(" "); ticket.AddSubHeaderLine(" " + tabla[i]); } else { ticket.AddSubHeaderLine(" " + tabla[i]); } } } ticket.AddSubHeaderLine("___________________________________________________________________________________________"); } } Session["Impresora"] = ddlImpresora.SelectedValue; ticket.PrintTicket(ddlImpresora.SelectedValue, ""); /////fin de impresion de archivos }