Exemplo n.º 1
0
 public bool EliminarGestionDelCambio(int idgestiondelcambio)
 {
     using (SG_SSTContext context = new SG_SSTContext())
     {
         using (var transaction = context.Database.BeginTransaction())
         {
             RegistraLog registraLog = new RegistraLog();
             try
             {
                 GestionDelCambio Gest = context.Tbl_GestionDelCambio.Find(idgestiondelcambio);
                 context.Tbl_GestionDelCambio.Remove(Gest);
                 context.SaveChanges();
                 transaction.Commit();
                 return(true);
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 return(false);
             }
         }
     }
 }
Exemplo n.º 2
0
        public ActionResult ModificarGestioDelCambio(int PKGestionDelCambio)
        {
            var usuarioActual = ObtenerUsuarioEnSesion(System.Web.HttpContext.Current);

            if (usuarioActual == null)
            {
                ViewBag.mensaje1 = "Debe Registrarse para Ingresar a este Modulo.";
                return(RedirectToAction("Login", "Home"));
            }
            GestionDelCambio objgestcambio = db.Tbl_GestionDelCambio.Where(g => g.PK_GestionDelCambio == PKGestionDelCambio).FirstOrDefault();

            ViewBag.PK_GestionDelCambio = objgestcambio.PK_GestionDelCambio;
            GestionDelCambio gestcam = db.Tbl_GestionDelCambio.Find(PKGestionDelCambio);

            ViewBag.FK_Id_Rol = new SelectList(db.Tbl_Rol.Where(x => x.Fk_Id_Empresa == usuarioActual.IdEmpresa), "PK_Id_Rol", "Descripcion", gestcam.FK_Id_Rol);
            int tipoPeligro = gestcam.FK_Tipo_De_Peligro;

            ViewBag.FK_Tipo_De_Peligro = new SelectList(db.Tbl_Tipo_De_Peligro.Where(x => x.Descripcion_Del_Peligro.Length > 0), "PK_Tipo_De_Peligro", "Descripcion_Del_Peligro", gestcam.FK_Tipo_De_Peligro);
            List <ClasificacionDePeligro> clasesDePeligrosList = clasificacionDePeligrosServicios.ConsultarClasesDePeligros(tipoPeligro);

            ViewBag.FK_Clasificacion_De_Peligro = new SelectList(clasesDePeligrosList, "PK_Clasificacion_De_Peligro", "Descripcion_Clase_De_Peligro", gestcam.FK_Clasificacion_De_Peligro);
            return(View(objgestcambio));
        }
Exemplo n.º 3
0
        public EDGestionDelCambio GuardarGestionDelCambio(EDGestionDelCambio GestionCambio)
        {
            GestionDelCambio acccam = new GestionDelCambio();

            acccam.Fecha = GestionCambio.Fecha;
            acccam.DescripcionDeCambio         = GestionCambio.DescripcionDeCambio;
            acccam.FK_Clasificacion_De_Peligro = GestionCambio.FK_Clasificacion_De_Peligro;
            acccam.FK_Tipo_De_Peligro          = GestionCambio.FK_Tipo_De_Peligro;
            acccam.RequisitoLegal   = GestionCambio.RequisitoLegal;
            acccam.Recomendaciones  = GestionCambio.Recomendaciones;
            acccam.FechaEjecucion   = GestionCambio.FechaEjecucion;
            acccam.FechaSeguimiento = GestionCambio.FechaSeguimiento;
            acccam.FK_Id_Rol        = GestionCambio.FK_Id_Rol;
            acccam.FK_Empresa       = GestionCambio.fkempresa;
            acccam.Otro             = GestionCambio.Otro;

            try
            {
                using (SG_SSTContext db1 = new SG_SSTContext())
                {
                    if (GestionCambio.PK_GestionDelCambio > 0)
                    {
                        if (GestionCambio.FK_Tipo_De_Peligro != 8 && GestionCambio.FK_Clasificacion_De_Peligro != 46)
                        {
                            GestionDelCambio ObregLeg = db1.Tbl_GestionDelCambio.Where(g => g.PK_GestionDelCambio == GestionCambio.PK_GestionDelCambio).FirstOrDefault();
                            ObregLeg.Fecha = ObregLeg.Fecha;
                            ObregLeg.DescripcionDeCambio         = GestionCambio.DescripcionDeCambio;
                            ObregLeg.FK_Clasificacion_De_Peligro = GestionCambio.FK_Clasificacion_De_Peligro;
                            ObregLeg.FK_Tipo_De_Peligro          = GestionCambio.FK_Tipo_De_Peligro;
                            ObregLeg.RequisitoLegal   = GestionCambio.RequisitoLegal;
                            ObregLeg.Recomendaciones  = GestionCambio.Recomendaciones;
                            ObregLeg.FechaEjecucion   = GestionCambio.FechaEjecucion;
                            ObregLeg.FechaSeguimiento = GestionCambio.FechaSeguimiento;
                            ObregLeg.FK_Id_Rol        = GestionCambio.FK_Id_Rol;
                            ObregLeg.FK_Empresa       = GestionCambio.fkempresa;
                            ObregLeg.Otro             = "";
                            db1.Entry(ObregLeg).State = EntityState.Modified;
                            db1.SaveChanges();
                        }
                        else
                        if (GestionCambio.FK_Tipo_De_Peligro == 8 && GestionCambio.FK_Clasificacion_De_Peligro == 46)
                        {
                            GestionDelCambio ObregLeg = db1.Tbl_GestionDelCambio.Where(g => g.PK_GestionDelCambio == GestionCambio.PK_GestionDelCambio).FirstOrDefault();
                            ObregLeg.Fecha = ObregLeg.Fecha;
                            ObregLeg.DescripcionDeCambio         = GestionCambio.DescripcionDeCambio;
                            ObregLeg.FK_Clasificacion_De_Peligro = GestionCambio.FK_Clasificacion_De_Peligro;
                            ObregLeg.FK_Tipo_De_Peligro          = GestionCambio.FK_Tipo_De_Peligro;
                            ObregLeg.RequisitoLegal   = GestionCambio.RequisitoLegal;
                            ObregLeg.Recomendaciones  = GestionCambio.Recomendaciones;
                            ObregLeg.FechaEjecucion   = GestionCambio.FechaEjecucion;
                            ObregLeg.FechaSeguimiento = GestionCambio.FechaSeguimiento;
                            ObregLeg.FK_Id_Rol        = GestionCambio.FK_Id_Rol;
                            ObregLeg.FK_Empresa       = GestionCambio.fkempresa;
                            ObregLeg.Otro             = GestionCambio.Otro;
                            db1.Entry(ObregLeg).State = EntityState.Modified;
                            db1.SaveChanges();
                        }
                    }
                    else
                    {
                        db1.Tbl_GestionDelCambio.Add(acccam);
                        db1.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                string mensaje = ex.ToString();
            }
            return(GestionCambio);
        }
Exemplo n.º 4
0
        public List <EDGestiondelcambioVista> MostrarGestionDelCambioVista()
        {
            var usuarioActual = ObtenerUsuarioEnSesion(System.Web.HttpContext.Current);

            if (usuarioActual == null)
            {
                ViewBag.mensaje1 = "Debe Registrarse para Ingresar a este Modulo.";
            }
            List <EDGestiondelcambioVista> varmatreq     = new List <EDGestiondelcambioVista>();
            List <EDGestiondelcambioVista> varmatreqOtro = new List <EDGestiondelcambioVista>();
            GestionDelCambio obj = new GestionDelCambio();

            using (var context = new SG_SSTContext())
            {
                varmatreq = (from a in context.Tbl_GestionDelCambio
                             join b in context.Tbl_Clasificacion_De_Peligro on
                             a.FK_Clasificacion_De_Peligro equals b.PK_Clasificacion_De_Peligro
                             join e in context.Tbl_Tipo_De_Peligro on
                             a.FK_Tipo_De_Peligro equals e.PK_Tipo_De_Peligro
                             join c in context.Tbl_Rol on
                             a.FK_Id_Rol equals c.Pk_Id_Rol

                             where a.FK_Empresa == usuarioActual.IdEmpresa
                             select new EDGestiondelcambioVista()
                {
                    PK_GestionDelCambio = a.PK_GestionDelCambio,
                    Fecha = a.Fecha,
                    DescripcionDeCambio = a.DescripcionDeCambio,
                    RequisitoLegal = a.RequisitoLegal,
                    Recomendaciones = a.Recomendaciones,
                    FechaEjecucion = a.FechaEjecucion,
                    FechaSeguimiento = a.FechaSeguimiento,
                    Descripcion_Clase_De_Peligro = b.Descripcion_Clase_De_Peligro,
                    Descripcion = c.Descripcion,
                    Descripcion_Del_Peligro = e.Descripcion_Del_Peligro,
                    Otro = a.Otro,
                    fkClasificacionPeligro = a.FK_Clasificacion_De_Peligro,
                    //fkempresa = a.FK_Empresa,
                    //DescripcionOtro = b.Descripcion_Clase_De_Peligro
                }).ToList();
                varmatreqOtro = (from a in context.Tbl_GestionDelCambio
                                 join b in context.Tbl_Clasificacion_De_Peligro on
                                 a.FK_Clasificacion_De_Peligro equals b.PK_Clasificacion_De_Peligro
                                 join e in context.Tbl_Tipo_De_Peligro on
                                 a.FK_Tipo_De_Peligro equals e.PK_Tipo_De_Peligro
                                 join c in context.Tbl_Rol on
                                 a.FK_Id_Rol equals c.Pk_Id_Rol
                                 where a.FK_Empresa == usuarioActual.IdEmpresa
                                 select new EDGestiondelcambioVista()
                {
                    PK_GestionDelCambio = a.PK_GestionDelCambio,
                    Fecha = a.Fecha,
                    DescripcionDeCambio = a.DescripcionDeCambio,
                    RequisitoLegal = a.RequisitoLegal,
                    Recomendaciones = a.Recomendaciones,
                    FechaEjecucion = a.FechaEjecucion,
                    FechaSeguimiento = a.FechaSeguimiento,
                    Descripcion_Clase_De_Peligro = a.Otro,
                    Descripcion = c.Descripcion,
                    Descripcion_Del_Peligro = e.Descripcion_Del_Peligro,
                    fkClasificacionPeligro = a.FK_Clasificacion_De_Peligro,
                }).ToList();
                return(varmatreq);
            }
        }