Beispiel #1
0
        public ActionResult Create(T_PLAN_DE_SALUD planSalud)
        {
            if (ModelState.IsValid)
            {
                db.T_PLAN_DE_SALUD.Add(planSalud);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.id_investigacion_comercial = new SelectList(db.T_INVESTIGACION_COMERCIAL, "id_investigacion_comercial", "nombre", planSalud.id_investigacion_comercial);
            return(View(planSalud));
        }
Beispiel #2
0
        public ActionResult IndexSave()
        {
            try
            {
                int             plan_salud_id = Int32.Parse(Request["plan_salud_id"]);
                T_PLAN_DE_SALUD ps            = db.T_PLAN_DE_SALUD.Find(plan_salud_id);

                if (ps != null)
                {
                    TempData["pla_sal.id_plan_salud"] = plan_salud_id;

                    List <string> seguimiento = new List <string>(); //Cambios realizados para auditoria

                    if (ps.nombre_plan != Request["plan_salud_nombre"])
                    {
                        seguimiento.Add("Se ha modificado el campo NOMBRE_PLAN de <<" + ps.nombre_plan + ">> a " + "<<" + Request["plan_salud_nombre"] + ">>");
                        ps.nombre_plan = Request["plan_salud_nombre"];
                    }

                    if (ps.descripcion != Request["plan_salud_descripcion"])
                    {
                        seguimiento.Add("Se ha modificado el campo DESCRIPCION de <<" + ps.descripcion + ">> a " + "<<" + Request["plan_salud_descripcion"] + ">>");
                        ps.descripcion = Request["plan_salud_descripcion"];
                    }

                    // -- El campo fecha_inicio NO es modificable --

                    if (Util.DateTimeToShort(ps.fecha_fin) != Request["plan_salud_fecha_fin"])
                    {
                        seguimiento.Add("Se ha modificado el campo FECHA_FIN de <<" + ps.fecha_fin + ">> a " + "<<" + Request["plan_salud_fecha_fin"] + ">>");
                        ps.fecha_fin = DateTime.Parse(Request["plan_salud_fecha_fin"]);
                    }

                    if (ps.objetivo != Request["plan_salud_objetivo"])
                    {
                        seguimiento.Add("Se ha modificado el campo OBJETIVO de <<" + ps.objetivo + ">> a " + "<<" + Request["plan_salud_objetivo"] + ">>");
                        ps.objetivo = Request["plan_salud_objetivo"];
                    }

                    if (ps.estado != Request["plan_salud_estado"])
                    {
                        seguimiento.Add("Se ha modificado el campo ESTADO de <<" + ps.estado + ">> a " + "<<" + Request["plan_salud_estado"] + ">>");
                        ps.estado = Request["plan_salud_estado"];
                    }

                    db.Entry(ps).State = EntityState.Modified;
                    db.SaveChanges();

                    //B:Auditoria
                    if (seguimiento.Count > 0)
                    {
                        T_BITACORA_INCIDENCIA bt = new T_BITACORA_INCIDENCIA()
                        {
                            id_plan_salud   = plan_salud_id,
                            tipo_incidencia = "APORTE",
                            fecha_registro  = DateTime.Now,
                            descripcion     = "MODIF.PLANSALUD",
                            estado          = "COMPLETO"
                        };
                        db.T_BITACORA_INCIDENCIA.Add(bt);
                        db.SaveChanges();

                        foreach (var s in seguimiento)
                        {
                            T_SEGUIMIENTO sg = new T_SEGUIMIENTO()
                            {
                                id_bitacora    = bt.id_bitacora,
                                seguimiento    = s,
                                fecha_registro = DateTime.Now,
                                usuario        = "DURBANO"
                            };
                            db.T_SEGUIMIENTO.Add(sg);
                            db.SaveChanges();
                        }
                    }
                    //E:Auditoria

                    TempData["pla_sal.Message"] = "El plan de salud ha sido modificado correctamente";
                }
                else
                {
                    TempData["pla_sal.Message"] = "El plan de salud que inteta modificar o existe";
                }
            }
            catch (Exception e)
            {
                TempData["pla_sal.Message"] = "El plan de salud NO se ha modificado";
            }
            return(RedirectToAction("Index"));
        }