Exemple #1
0
        public ActionResult ReporteCodigo(int id)
        {
            string   conn        = ConfigurationManager.AppSettings["conexion"];
            registro registro    = db.registro.Find(id);
            int      reg_id      = registro.reg_id;
            string   paciente    = registro.paciente.pac_nombres + " " + registro.paciente.pac_apellidos;
            string   strRegistro = "Select * from view_codigo where reg_id=" + reg_id + "";

            SqlConnection conexion = new SqlConnection(conn);
            DataTable     dt       = new DataTable();

            try
            {
                conexion.Open();
                SqlCommand     cmd = new SqlCommand(strRegistro, conexion);
                SqlDataAdapter dap = new SqlDataAdapter(cmd);
                dap.Fill(dt);

                RptCodigo rp = new RptCodigo();
                rp.Load(Path.Combine(Server.MapPath("~/Reports"), "RptCodigo.rpt"));
                rp.SetDataSource(dt);
                rp.SetParameterValue("paciente", paciente);

                Stream stream = rp.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                stream.Seek(0, SeekOrigin.Begin);
                return(File(stream, "application/pdf", reg_id + ".pdf"));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Message", "Home", new { mensaje = ex.Message }));
            }
        }
Exemple #2
0
        public ActionResult Codigo(registro registro)
        {
            var consulta = db.registro.Where(r => r.reg_paciente == registro.reg_paciente && r.reg_fecha == registro.reg_fecha && r.reg_estado == true);

            if (!consulta.Any())
            {
                return(RedirectToAction("Message", "Home", new { mensaje = "El paciente no tiene exámenes para esta fecha" + registro.reg_fecha + registro.reg_paciente }));
            }


            string conn        = ConfigurationManager.AppSettings["conexion"];
            int    reg_id      = consulta.First().reg_id;
            string paciente    = consulta.First().paciente.pac_nombres + " " + consulta.First().paciente.pac_apellidos;
            string strRegistro = "Select * from view_codigo where reg_id=" + reg_id;

            SqlConnection conexion = new SqlConnection(conn);
            DataTable     dt       = new DataTable();

            try
            {
                conexion.Open();
                SqlCommand     cmd = new SqlCommand(strRegistro, conexion);
                SqlDataAdapter dap = new SqlDataAdapter(cmd);
                dap.Fill(dt);

                RptCodigo rp = new RptCodigo();
                rp.Load(Path.Combine(Server.MapPath("~/Reports"), "RptCodigo.rpt"));
                rp.SetDataSource(dt);
                rp.SetParameterValue("paciente", paciente);

                Stream stream = rp.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                stream.Seek(0, SeekOrigin.Begin);
                return(File(stream, "application/pdf", reg_id + ".pdf"));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Message", "Home", new { mensaje = ex.Message }));
            }
        }