public ActionResult Nuevo(ro_tipo_gastos_personales_Info info)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var model = bus_gastos.get_info(info.IdTipoGasto);
             if (model != null)
             {
                 ViewBag.mensaje = "El codigo ya se encuentra registrado";
                 return(View(model));
             }
             if (!bus_gastos.guardarDB(info))
             {
                 return(View(info));
             }
             else
             {
                 return(RedirectToAction("Index"));
             }
         }
         else
         {
             return(View(info));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
 public ActionResult Modificar(ro_tipo_gastos_personales_Info info)
 {
     try
     {
         if (ModelState.IsValid)
         {
             if (!bus_gastos.modificarDB(info))
             {
                 return(View(info));
             }
             else
             {
                 return(RedirectToAction("Index"));
             }
         }
         else
         {
             return(View(info));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        public ro_tipo_gastos_personales_Info get_info(string IdTipoGasto)
        {
            try
            {
                ro_tipo_gastos_personales_Info info = new ro_tipo_gastos_personales_Info();

                using (Entities_rrhh Context = new Entities_rrhh())
                {
                    ro_tipo_gastos_personales Entity = Context.ro_tipo_gastos_personales.FirstOrDefault(q => q.IdTipoGasto == IdTipoGasto);
                    if (Entity == null)
                    {
                        return(null);
                    }

                    info = new ro_tipo_gastos_personales_Info
                    {
                        IdTipoGasto    = Entity.IdTipoGasto,
                        nom_tipo_gasto = Entity.nom_tipo_gasto,
                    };
                }

                return(info);
            }
            catch (Exception)
            {
                throw;
            }
        }
 public bool anularDB(ro_tipo_gastos_personales_Info info)
 {
     try
     {
         return(odata.anularDB(info));
     }
     catch (Exception)
     {
         throw;
     }
 }
 public ActionResult Nuevo()
 {
     try
     {
         ro_tipo_gastos_personales_Info info = new ro_tipo_gastos_personales_Info();
         return(View(info));
     }
     catch (Exception)
     {
         throw;
     }
 }
 public ActionResult Anular(ro_tipo_gastos_personales_Info info)
 {
     try
     {
         if (!bus_gastos.anularDB(info))
         {
             return(View(info));
         }
         else
         {
             return(RedirectToAction("Index"));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        // GET: RRHH/Division
        public ActionResult Index()
        {
            #region Validar Session
            if (string.IsNullOrEmpty(SessionFixed.IdTransaccionSession))
            {
                return(RedirectToAction("Login", new { Area = "", Controller = "Account" }));
            }
            SessionFixed.IdTransaccionSession       = (Convert.ToDecimal(SessionFixed.IdTransaccionSession) + 1).ToString();
            SessionFixed.IdTransaccionSessionActual = SessionFixed.IdTransaccionSession;
            #endregion

            ro_tipo_gastos_personales_Info model = new ro_tipo_gastos_personales_Info
            {
                IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSession)
            };

            List <ro_tipo_gastos_personales_Info> lista = bus_gastos.get_list(true);
            Lista_GastosPersonales.set_list(lista, Convert.ToDecimal(SessionFixed.IdTransaccionSession));

            return(View(model));
        }
        public bool modificarDB(ro_tipo_gastos_personales_Info info)
        {
            try
            {
                using (Entities_rrhh Context = new Entities_rrhh())
                {
                    ro_tipo_gastos_personales Entity = Context.ro_tipo_gastos_personales.FirstOrDefault(q => q.IdTipoGasto == info.IdTipoGasto);
                    if (Entity == null)
                    {
                        return(false);
                    }
                    Entity.nom_tipo_gasto = info.nom_tipo_gasto;
                    Context.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
 public bool guardarDB(ro_tipo_gastos_personales_Info info)
 {
     try
     {
         using (Entities_rrhh Context = new Entities_rrhh())
         {
             ro_tipo_gastos_personales Entity = new ro_tipo_gastos_personales
             {
                 IdTipoGasto    = info.IdTipoGasto,
                 nom_tipo_gasto = info.nom_tipo_gasto,
                 estado         = info.estado = "A",
                 Fecha_Transac  = DateTime.Now,
                 IdUsuario      = info.IdUsuario
             };
             Context.ro_tipo_gastos_personales.Add(Entity);
             Context.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         throw;
     }
 }