Exemplo n.º 1
0
        public ActionResult Descargar(int id)
        {
            try
            {
                string         contentType  = "application/pdf";
                dsEspirometria dsPrueba     = new dsEspirometria();
                string         conn         = ConfigurationManager.AppSettings["conexion"];
                espirometria   espirometria = db.espirometria.Find(id);
                string         fileName     = String.Empty;
                //if (String.IsNullOrEmpty(fileName))
                //    fileName = "firma.png";
                //string path01 = Path.Combine(Server.MapPath("~/Content/firmas"), fileName);

                string strEspirometria = "Select * from view_espirometria where esp_id=" + id;


                SqlConnection  sqlcon         = new SqlConnection(conn);
                SqlDataAdapter daEspirometria = new SqlDataAdapter(strEspirometria, sqlcon);
                daEspirometria.Fill(dsPrueba, "view_espirometria");

                RptEspirometria_ rp = new RptEspirometria_();
                rp.Load(Path.Combine(Server.MapPath("~/Reports"), "RptEspirometria_.rpt"));
                rp.SetDataSource(dsPrueba);
                rp.SetParameterValue("hc", "");
                rp.SetParameterValue("orden", "");
                //rp.SetParameterValue("picturePath", path01);
                rp.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Path.Combine(Server.MapPath("~/Content/espirometria"), id + ".pdf"));

                //Stream stream = rp.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                //stream.Seek(0, SeekOrigin.Begin);
                //return File(stream, "application/pdf", esp_id + ".pdf");

                var    document = new Document();
                var    ms       = new MemoryStream();
                string archivo1 = Path.Combine(Server.MapPath("~/Content/espirometria"), id + ".pdf");
                string archivo2 = Path.Combine(Server.MapPath("~/Content/espirometria"), espirometria.esp_archivo);
                fileName = "Reporte" + id + ".pdf";
                string   fileTarget = Path.Combine(Server.MapPath("~/Content/espirometria/") + fileName);
                string[] Lista      = { archivo1, archivo2 };

                Merge(fileTarget, Lista);
                return(File(fileTarget, contentType, fileName));
            }
            catch (Exception ex)
            {
                ViewBag.mensaje = ex.Message;
                //return View("Message");
                return(RedirectToAction("Message", "Home", new { mensaje = ex.Message }));
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.reportDocument != null)
            {
                this.reportDocument.Close();
                this.reportDocument.Dispose();
            }

            dsEspirometria dsPrueba     = new dsEspirometria();
            string         conn         = ConfigurationManager.AppSettings["conexion"];
            int            id           = Convert.ToInt32(Session["esp_id"]);
            espirometria   espirometria = db.espirometria.Find(id);

            //string fileName = medico.med_firma;
            //if (String.IsNullOrEmpty(fileName))
            //    fileName = "firma.png";

            string strEspirometria = "Select * from espirometria where esp_id=" + id;
            string strPaciente     = "Select * from paciente where pac_id=" + espirometria.esp_paciente;



            SqlConnection  sqlcon         = new SqlConnection(conn);
            SqlDataAdapter daEspirometria = new SqlDataAdapter(strEspirometria, sqlcon);
            SqlDataAdapter daPaciente     = new SqlDataAdapter(strPaciente, sqlcon);

            daEspirometria.Fill(dsPrueba, "espirometria");
            daPaciente.Fill(dsPrueba, "paciente");

            reportDocument = new ReportDocument();
            //Report path
            string reportPath = Server.MapPath("~/Reports/RptEspirometria.rpt");

            reportDocument.Load(reportPath);
            reportDocument.SetDataSource(dsPrueba);
            reportDocument.SetParameterValue("hc", "");
            reportDocument.SetParameterValue("orden", "");
            //string path01 = Path.Combine(Server.MapPath("~/Content/firmas"), fileName);
            //reportDocument.SetParameterValue("picturePath", path01);
            crViewer.ReportSource = reportDocument;
            crViewer.DataBind();
        }