Beispiel #1
0
        public ro_departamento_Info get_info(int IdEmpresa, int IdDepartamento)
        {
            try
            {
                ro_departamento_Info info = new ro_departamento_Info();

                using (Entities_rrhh Context = new Entities_rrhh())
                {
                    ro_Departamento Entity = Context.ro_Departamento.FirstOrDefault(q => q.IdEmpresa == IdEmpresa && q.IdDepartamento == IdDepartamento);
                    if (Entity == null)
                    {
                        return(null);
                    }

                    info = new ro_departamento_Info
                    {
                        IdEmpresa      = Entity.IdEmpresa,
                        IdDepartamento = Entity.IdDepartamento,
                        de_descripcion = Entity.de_descripcion,
                        Estado         = Entity.Estado,
                    };
                }

                return(info);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #2
0
        public bool anularDB(ro_departamento_Info info)
        {
            try
            {
                using (Entities_rrhh Context = new Entities_rrhh())
                {
                    ro_Departamento Entity = Context.ro_Departamento.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdDepartamento == info.IdDepartamento);
                    if (Entity == null)
                    {
                        return(false);
                    }
                    Entity.Estado = info.Estado = "I";

                    Entity.IdUsuarioUltAnu = info.IdUsuarioUltAnu;
                    Entity.Fecha_UltAnu    = info.Fecha_UltAnu = DateTime.Now;
                    Context.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #3
0
 public bool guardarDB(ro_departamento_Info info)
 {
     try
     {
         using (Entities_rrhh Context = new Entities_rrhh())
         {
             ro_Departamento Entity = new ro_Departamento
             {
                 IdEmpresa      = info.IdEmpresa,
                 IdDepartamento = info.IdDepartamento = get_id(info.IdEmpresa),
                 de_descripcion = info.de_descripcion,
                 Estado         = info.Estado = "A",
                 IdUsuario      = info.IdUsuario,
                 Fecha_Transac  = DateTime.Now
             };
             Context.ro_Departamento.Add(Entity);
             Context.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         throw;
     }
 }
        public Boolean GrabarDB(ro_Departamento_Info ro_info, ref int Id, ref string mensaje)
        {
            try
            {
                using (EntitiesRoles context = new EntitiesRoles())
                {
                    EntitiesRoles EDB = new EntitiesRoles();

                    var Q = from per in EDB.ro_Departamento
                            where per.IdDepartamento == ro_info.IdDepartamento &&
                            per.IdEmpresa == ro_info.IdEmpresa
                            select per;

                    if (Q.ToList().Count == 0)
                    {
                        var address = new ro_Departamento();
                        if (ro_info.IdDepartamentoPadre == 0)
                        {
                            address.IdDepartamentoPadre = null;
                        }
                        else
                        {
                            address.IdDepartamentoPadre = ro_info.IdDepartamentoPadre;
                        }

                        address.IdEmpresa           = ro_info.IdEmpresa;
                        address.IdDepartamento      = ro_info.IdDepartamento = Id = getId(ro_info.IdEmpresa);
                        address.IdDepartamentoPadre = ro_info.IdDepartamentoPadre;
                        address.de_descripcion      = ro_info.de_descripcion;
                        address.nom_pc        = ro_info.nom_pc;
                        address.IdUsuario     = (ro_info.IdUsuario == null) ? "" : ro_info.IdUsuario;
                        address.ip            = ro_info.ip;
                        address.Fecha_Transac = Convert.ToDateTime(ro_info.Fecha_Transac);
                        address.MotiAnula     = ro_info.MotiAnula;
                        address.Estado        = ro_info.Estado;

                        context.ro_Departamento.Add(address);
                        context.SaveChanges();

                        mensaje = "Se ha procedido a guardar el Dpto..# : " + ro_info.IdDepartamento.ToString() + " exitosamente";
                    }
                    else
                    {
                        return(false);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                mensaje = ex.InnerException + " " + ex.Message;
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                throw new Exception(ex.InnerException.ToString());
            }
        }
Beispiel #5
0
        public bool modificarDB(ro_departamento_Info info)
        {
            try
            {
                using (Entities_rrhh Context = new Entities_rrhh())
                {
                    ro_Departamento Entity = Context.ro_Departamento.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdDepartamento == info.IdDepartamento);
                    if (Entity == null)
                    {
                        return(false);
                    }
                    Entity.de_descripcion  = info.de_descripcion;
                    Entity.IdUsuarioUltMod = info.IdUsuarioUltMod;
                    Entity.Fecha_UltMod    = info.Fecha_UltMod = DateTime.Now;
                    Context.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }