public ActionResult DeleteConfirmed(int id) { espirometria espirometria = db.espirometria.Find(id); db.espirometria.Remove(espirometria); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Download(int id = 0) { string contentType = "application/pdf"; espirometria espirometria = db.espirometria.Find(id); if (espirometria == null) { return(HttpNotFound()); } return(File(Server.MapPath("~/Content/espirometria/") + espirometria.esp_archivo, contentType, espirometria.esp_archivo)); }
public ActionResult Details(int id = 0) { espirometria espirometria = db.espirometria.Find(id); if (espirometria == null) { return(HttpNotFound()); } paciente paciente = db.paciente.Find(espirometria.esp_paciente); ViewBag.paciente = paciente.pac_nombres + " " + paciente.pac_apellidos; return(View(espirometria)); }
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 })); } }
//public ActionResult Create(HttpPostedFileBase FileUpload,espirometria espirometria) public ActionResult Create(espirometria espirometria) { string nom_pac; if (Request.Files.Count > 0) { var file = Request.Files[0]; string fileName = Path.GetFileName(file.FileName); string ext = Path.GetExtension(fileName); if (fileName != "") { espirometria.esp_archivo = fileName; DateTime dd = DateTime.Now; espirometria.esp_fecha = dd.Date.ToString("d"); espirometria.esp_laboratorista = get_user(); espirometria.esp_orden = get_orden(espirometria.esp_fecha); if (ModelState.IsValid && ext == ".pdf") { string path = Path.Combine(Server.MapPath("~/Content/espirometria"), fileName); file.SaveAs(path); db.espirometria.Add(espirometria); db.SaveChanges(); return(RedirectToAction("Index")); } else { ModelState.AddModelError("ext", "Extensión no Válida"); } } else { ModelState.AddModelError("ext", "Debe seleccionar un archivo"); } } paciente paciente = db.paciente.Find(espirometria.esp_paciente); if (paciente != null) { nom_pac = paciente.pac_nombres + " " + paciente.pac_apellidos; } else { nom_pac = ""; } ViewBag.paciente = nom_pac; return(View(espirometria)); }
public ActionResult Edit(espirometria espirometria) { if (Request.Files.Count > 0) { var file = Request.Files[0]; string fileName = Path.GetFileName(file.FileName); string ext = Path.GetExtension(fileName); if (fileName != "") { if (ModelState.IsValid && ext == ".pdf") { if (fileName != espirometria.esp_archivo) { string path = Path.Combine(Server.MapPath("~/Content/espirometria"), fileName); file.SaveAs(path); } espirometria.esp_archivo = fileName; db.Entry(espirometria).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } else { ModelState.AddModelError("ext", "Extensión no Válida"); } } else { if (ModelState.IsValid) { UserManager usermanager = new UserManager(); espirometria.esp_responsable = usermanager.get_user_id(User); espirometria.esp_perfil = usermanager.get_perfil(User); db.Entry(espirometria).State = EntityState.Modified; db.SaveChanges(); if (espirometria.esp_observacion != "") { notificar(espirometria.esp_paciente); } return(RedirectToAction("Index")); } } } paciente paciente = db.paciente.Find(espirometria.esp_paciente); ViewBag.paciente = paciente.pac_nombres + " " + paciente.pac_apellidos; return(View(espirometria)); }
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(); }
public ActionResult Delete(int id = 0) { espirometria espirometria = db.espirometria.Find(id); if (espirometria == null) { return(HttpNotFound()); } paciente paciente = db.paciente.Find(espirometria.esp_paciente); string nom_pac = String.Empty; if (paciente != null) { nom_pac = paciente.pac_nombres + " " + paciente.pac_apellidos; } else { nom_pac = ""; } @ViewBag.paciente = nom_pac; return(View(espirometria)); }