Пример #1
0
        public ActionResult Create(concepto concepto)
        {
            historia historia = db.historia.Find(concepto.con_id);

            if (ModelState.IsValid && validar_resultado(historia.his_tipo, concepto.con_valor))
            {
                db.concepto.Add(concepto);
                db.SaveChanges();
                //return RedirectToAction("Message", "Home", new {mensaje="Proceso Finalizado" });
                return(RedirectToAction("Firma", "Historia", new { id = concepto.con_id }));
            }

            if (historia.his_tipo == 2 || historia.his_tipo == 3)
            {
                ViewBag.con_resultado = res_periodica(concepto.con_resultado);
                ViewBag.con_valor     = val_periodica(concepto.con_valor);
            }

            else if (historia.his_tipo == 4)
            {
                ViewBag.con_resultado = res_retiro(concepto.con_resultado);
                ViewBag.con_valor     = val_retiro(concepto.con_valor);
            }
            ViewBag.con_id          = concepto.con_id;
            ViewBag.con_seguimiento = opcion(concepto.con_seguimiento);
            return(PartialView(concepto));
        }
Пример #2
0
        // GET: concepto/Delete/5
        public ActionResult Delete(int?id)
        {
            if (!(bool)Session["login"])
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            concepto concepto = db.concepto.Find(id);

            if (concepto == null)
            {
                return(HttpNotFound());
            }
            int cantidad        = db.proyecto.Count();
            int cantidadactivos = db.proyecto.Where(x => x.fechafin == null).Count();

            ViewBag.Mensaje = "Se dara de baja un total de " + cantidad + " registros en la cuenta corriente asociados a proyectos; de los cuales hay " + cantidadactivos + " registros de proyectos ACTIVOS.";
            if (cantidad == 0 && cantidadactivos == 0)
            {
                ViewBag.Mensaje = "";
            }
            return(View(concepto));
        }
Пример #3
0
        public ActionResult Create(int id)
        {
            concepto concepto = db.concepto.Find(id);

            if (concepto != null)
            {
                return(RedirectToAction("Edit", new { id = id }));
            }
            historia historia = db.historia.Find(id);

            if (historia.his_tipo == 2 || historia.his_tipo == 3)
            {
                ViewBag.con_resultado = res_periodica();
                ViewBag.con_valor     = val_periodica();
            }

            else if (historia.his_tipo == 4)
            {
                ViewBag.con_resultado = res_retiro();
                ViewBag.con_valor     = val_retiro();
            }
            else
            {
                ViewBag.con_resultado = res_periodica();
                ViewBag.con_valor     = val_periodica();
            }

            ViewBag.con_id          = id;
            ViewBag.con_seguimiento = opcion();
            return(PartialView());
        }
Пример #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            concepto concepto = db.concepto.Find(id);

            db.concepto.Remove(concepto);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #5
0
        //
        // GET: /Concepto/Details/5

        public ActionResult Details(int id = 0)
        {
            concepto concepto = db.concepto.Find(id);

            if (concepto == null)
            {
                return(HttpNotFound());
            }
            return(PartialView(concepto));
        }
Пример #6
0
        public ActionResult Delete(int id = 0)
        {
            concepto concepto = db.concepto.Find(id);

            if (concepto == null)
            {
                return(HttpNotFound());
            }
            return(View(concepto));
        }
Пример #7
0
        public ActionResult Edit([Bind(Include = "id,descripcion,positivo")] concepto concepto)
        {
            if (!(bool)Session["login"])
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (ModelState.IsValid)
            {
                db.Entry(concepto).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(concepto));
        }
Пример #8
0
        public ActionResult Create([Bind(Include = "id,descripcion,positivo")] concepto concepto)
        {
            if (!(bool)Session["login"])
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (ModelState.IsValid)
            {
                db.concepto.Add(concepto);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(concepto));
        }
Пример #9
0
        public ActionResult DeleteConfirmed(int id)
        {
            if (!(bool)Session["login"])
            {
                return(RedirectToAction("Login", "Account"));
            }

            db.ctacte.RemoveRange(db.ctacte.Where(x => x.idconcepto == id));
            db.SaveChanges();


            concepto concepto = db.concepto.Find(id);

            db.concepto.Remove(concepto);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #10
0
        // GET: concepto/Edit/5
        public ActionResult Edit(int?id)
        {
            if (!(bool)Session["login"])
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            concepto concepto = db.concepto.Find(id);

            if (concepto == null)
            {
                return(HttpNotFound());
            }
            return(View(concepto));
        }
Пример #11
0
        public ActionResult Certificado(int id, int pac_id)
        {
            try
            {
                dsCertificado dsCertificado = new dsCertificado();
                paciente      paciente      = db.paciente.Find(pac_id);
                historia      historia      = db.historia.Find(id);
                concepto      concepto      = db.concepto.Find(id);
                medico        medico        = db.medico.Find(historia.his_medico);

                if (concepto == null)
                {
                    return(RedirectToAction("Message", "Home", new { mensaje = "La historia no tiene información completa. Por llene toda la información y genere el certificado correspondiente" }));
                }
                var         consulta    = db.ocupacional.Where(o => o.ocu_paciente == pac_id && o.ocu_tipo == "actual" && o.ocu_estado == true);
                ocupacional ocupacional = new ocupacional();

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

                if (consulta.Any())
                {
                    ocupacional = consulta.First();
                }
                string conn = ConfigurationManager.AppSettings["conexion"];

                string strHistoria    = "Select * from historia where his_id=" + id;
                string strPaciente    = "Select * from paciente where pac_id=" + pac_id;
                string strConcepto    = "Select * from concepto where con_id=" + id;
                string strEmpresa     = "Select * from empresa where emp_id=" + paciente.pac_empresa;
                string strMedico      = "Select * from medico where med_id=" + historia.his_medico;
                string strOcupacional = String.Empty;
                if (ocupacional.ocu_id != null)
                {
                    strOcupacional = "Select * from ocupacional where ocu_id=" + ocupacional.ocu_id;
                }
                else
                {
                    strOcupacional = "Select top 1 * from ocupacional";
                }

                SqlConnection  sqlcon        = new SqlConnection(conn);
                SqlDataAdapter daHistoria    = new SqlDataAdapter(strHistoria, sqlcon);
                SqlDataAdapter daPaciente    = new SqlDataAdapter(strPaciente, sqlcon);
                SqlDataAdapter daConcepto    = new SqlDataAdapter(strConcepto, sqlcon);
                SqlDataAdapter daEmpresa     = new SqlDataAdapter(strEmpresa, sqlcon);
                SqlDataAdapter daMedico      = new SqlDataAdapter(strMedico, sqlcon);
                SqlDataAdapter daOcupacional = new SqlDataAdapter(strOcupacional, sqlcon);
                daHistoria.Fill(dsCertificado, "historia");
                daPaciente.Fill(dsCertificado, "paciente");
                daConcepto.Fill(dsCertificado, "concepto");
                daEmpresa.Fill(dsCertificado, "empresa");
                daMedico.Fill(dsCertificado, "medico");
                daOcupacional.Fill(dsCertificado, "ocupacional");
                Stream stream = MemoryStream.Null;
                if (concepto.con_resultado == "APTO")
                {
                    RptCerApto rp = new RptCerApto();
                    rp.Load(Path.Combine(Server.MapPath("~/Reports"), "RptCerApto.rpt"));
                    rp.SetDataSource(dsCertificado);
                    rp.SetParameterValue("fecha", get_fecha(historia.his_fecha));
                    stream = rp.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                    rp.Close();
                    rp.Dispose();
                }
                else if (concepto.con_resultado == "APTO CON RESTRICCIONES PERSONALES" || concepto.con_resultado == "APTO CON RESTRICCIONES LABORALES")
                {
                    RptCerAptoRes rp = new RptCerAptoRes();
                    rp.Load(Path.Combine(Server.MapPath("~/Reports"), "RptCerAptoRes.rpt"));
                    rp.SetDataSource(dsCertificado);
                    rp.SetParameterValue("fecha", get_fecha(historia.his_fecha));
                    stream = rp.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                    rp.Close();
                    rp.Dispose();
                }
                else if (concepto.con_resultado == "NO APTO")
                {
                    RptCerNoApto rp = new RptCerNoApto();
                    rp.Load(Path.Combine(Server.MapPath("~/Reports"), "RptCerNoApto.rpt"));
                    rp.SetDataSource(dsCertificado);
                    rp.SetParameterValue("fecha", get_fecha(historia.his_fecha));
                    stream = rp.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                    rp.Close();
                    rp.Dispose();
                }
                else if (concepto.con_resultado == "SATISFACTORIA" || concepto.con_resultado == "NO SATISFACTORIA")
                {
                    RptCerRetiro rp = new RptCerRetiro();
                    rp.Load(Path.Combine(Server.MapPath("~/Reports"), "RptCerRetiro.rpt"));
                    rp.SetDataSource(dsCertificado);
                    string nexo = String.Empty;
                    if (concepto.con_valor == "NO")
                    {
                        nexo = "NINGUNA";
                    }
                    else
                    {
                        nexo = "UNA";
                    }
                    rp.SetParameterValue("nexo", nexo);
                    rp.SetParameterValue("fecha", get_fecha(historia.his_fecha));
                    stream = rp.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                    rp.Close();
                    rp.Dispose();
                }

                Response.Buffer = false;
                Response.ClearContent();
                Response.ClearHeaders();
                stream.Seek(0, SeekOrigin.Begin);
                return(File(stream, "application/pdf", "Certificado.pdf"));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Message", "Home", new { mensaje = ex.Message }));
            }
        }