Exemplo n.º 1
0
        public bool modificarDB(ro_empleado_novedad_Info info)
        {
            try
            {
                using (Entities_rrhh Context = new Entities_rrhh())
                {
                    ro_empleado_Novedad Entity = Context.ro_empleado_Novedad.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdEmpleado == info.IdEmpleado && q.IdNovedad == info.IdNovedad);
                    if (Entity == null)
                    {
                        return(false);
                    }
                    Entity.IdNomina_Tipo      = info.IdNomina_Tipo;
                    Entity.IdNomina_TipoLiqui = info.IdNomina_TipoLiqui;
                    Entity.Observacion        = (info.Observacion) == null?"": info.Observacion;
                    Entity.Fecha           = info.Fecha.Date;
                    Entity.NumCoutas       = info.NumCoutas;
                    Entity.TotalValor      = info.TotalValor;
                    Entity.IdUsuarioUltMod = info.IdUsuarioUltMod;
                    Entity.Fecha_UltMod    = info.Fecha_UltMod = DateTime.Now;
                    Context.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 2
0
 public bool guardarDB(ro_empleado_novedad_Info info)
 {
     try
     {
         using (Entities_rrhh Context = new Entities_rrhh())
         {
             ro_empleado_Novedad Entity = new ro_empleado_Novedad
             {
                 IdEmpresa          = info.IdEmpresa,
                 IdNovedad          = info.IdNovedad = get_id(info.IdEmpresa, info.IdEmpleado),
                 IdNomina_Tipo      = info.IdNomina_Tipo,
                 IdNomina_TipoLiqui = info.IdNomina_TipoLiqui,
                 IdEmpleado         = info.IdEmpleado,
                 Fecha            = info.Fecha.Date,
                 TotalValor       = info.TotalValor,
                 Fecha_PrimerPago = info.Fecha_PrimerPago,
                 Observacion      = info.Observacion,
                 Estado           = info.Estado = "A",
                 IdUsuario        = info.IdUsuario,
                 Fecha_Transac    = info.Fecha_Transac = DateTime.Now
             };
             Context.ro_empleado_Novedad.Add(Entity);
             Context.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 3
0
        public ro_empleado_novedad_Info get_info(int IdEmpresa, decimal IdEmpleado, decimal IdNovedad)
        {
            try
            {
                ro_empleado_novedad_Info info = new ro_empleado_novedad_Info();

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

                    info = new ro_empleado_novedad_Info
                    {
                        IdEmpresa          = Entity.IdEmpresa,
                        IdNovedad          = Entity.IdNovedad,
                        IdNomina_Tipo      = Entity.IdNomina_Tipo,
                        IdNomina_TipoLiqui = Entity.IdNomina_TipoLiqui,
                        IdEmpleado         = Entity.IdEmpleado,
                        Fecha            = Entity.Fecha,
                        Fecha_PrimerPago = Entity.Fecha_PrimerPago,
                        Estado           = Entity.Estado,
                        Observacion      = Entity.Observacion
                    };
                }

                return(info);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 4
0
        public Boolean ModificarDB(ro_Empleado_Novedad_Info ro_info)
        {
            try
            {
                using (EntitiesRoles context = new EntitiesRoles())
                {
                    ro_empleado_Novedad contact = context.ro_empleado_Novedad.FirstOrDefault(var => var.IdEmpresa == ro_info.IdEmpresa &&
                                                                                             var.IdEmpleado == ro_info.IdEmpleado && var.IdNovedad == ro_info.IdNovedad);

                    if (contact != null)
                    {
                        contact.Estado          = ro_info.Estado;
                        contact.Fecha           = ro_info.Fecha;
                        contact.TotalValor      = ro_info.TotalValor;
                        contact.Fecha_UltMod    = ro_info.Fecha_UltMod;
                        contact.IdUsuarioUltMod = ro_info.IdUsuarioUltMod;
                        contact.Fecha_UltAnu    = ro_info.Fecha_UltAnu;
                        contact.IdUsuarioUltAnu = ro_info.IdUsuarioUltAnu;
                        context.SaveChanges();
                    }
                }

                mensaje = "Se ha procedido a actualizar la novedad # " + ro_info.IdNovedad;
                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());
            }
        }
Exemplo n.º 5
0
 public bool guardarDB(ro_empleado_novedad_Info info)
 {
     try
     {
         int IdSucursa = data_empleado.get_info(info.IdEmpresa, info.IdEmpleado).IdSucursal;
         using (Entities_rrhh Context = new Entities_rrhh())
         {
             ro_empleado_Novedad Entity = new ro_empleado_Novedad
             {
                 IdEmpresa          = info.IdEmpresa,
                 IdNovedad          = info.IdNovedad = get_id(info.IdEmpresa),
                 IdNomina_Tipo      = info.IdNomina_Tipo,
                 IdNomina_TipoLiqui = info.IdNomina_TipoLiqui,
                 IdEmpleado         = info.IdEmpleado,
                 IdJornada          = info.IdJornada,
                 Fecha         = info.Fecha.Date,
                 IdSucursal    = IdSucursa,
                 Observacion   = info.Observacion,
                 Estado        = info.Estado = "A",
                 IdUsuario     = info.IdUsuario,
                 Fecha_Transac = info.Fecha_Transac = DateTime.Now
             };
             Context.ro_empleado_Novedad.Add(Entity);
             Context.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         throw;
     }
 }
        public bool modificarDB(ro_empleado_novedad_Info info)
        {
            try
            {
                using (Entities_rrhh Context = new Entities_rrhh())
                {
                    ro_empleado_Novedad Entity = Context.ro_empleado_Novedad.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdNovedad == info.IdNovedad);
                    if (Entity == null)
                    {
                        return(false);
                    }
                    Entity.IdEmpleado         = info.IdEmpleado;
                    Entity.IdNomina_Tipo      = info.IdNomina_Tipo;
                    Entity.IdJornada          = info.IdJornada;
                    Entity.IdNomina_TipoLiqui = info.IdNomina_TipoLiqui;
                    Entity.Observacion        = (info.Observacion) == null?"": info.Observacion;
                    Entity.Fecha           = info.Fecha.Date;
                    Entity.IdUsuarioUltMod = info.IdUsuarioUltMod;
                    Entity.Fecha_UltMod    = info.Fecha_UltMod = DateTime.Now;
                    Context.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                tb_LogError_Data LogData = new tb_LogError_Data();
                LogData.GuardarDB(new tb_LogError_Info {
                    Descripcion = ex.Message, InnerException = ex.InnerException == null ? null : ex.InnerException.Message, Clase = "ro_empleado_novedad_Data", Metodo = "modificarDB", IdUsuario = info.IdUsuario
                });
                return(false);
            }
        }
Exemplo n.º 7
0
        public Boolean ModificarDB(ro_Empleado_Novedad_Info ro_info, ref string mensaje, decimal idTransaccion)
        {
            try
            {
                using (EntitiesRoles context = new EntitiesRoles()){
                    ro_empleado_Novedad contact = context.ro_empleado_Novedad.FirstOrDefault(var => var.IdEmpresa == ro_info.IdEmpresa &&
                                                                                             var.IdEmpleado == ro_info.IdEmpleado && var.IdNovedad == ro_info.IdNovedad);


                    if (contact != null)
                    {
                        contact.Estado          = ro_info.Estado;
                        contact.Fecha           = ro_info.Fecha;
                        contact.Fecha_UltMod    = ro_info.Fecha_UltMod;
                        contact.IdUsuarioUltMod = ro_info.IdUsuarioUltMod;

                        contact.Fecha_UltAnu    = ro_info.Fecha_UltAnu;
                        contact.IdUsuarioUltAnu = ro_info.IdUsuarioUltAnu;

                        double totalvalor = 0;

                        foreach (var item in ro_info.LstDetalle)
                        {
                            totalvalor = totalvalor + item.Valor;
                        }

                        contact.TotalValor = totalvalor;
                        context.SaveChanges();
                    }
                    else
                    {
                        //CREA UN NUEVO REGISTRO

                        decimal idNovedad = ro_info.IdNovedad;
                        if (GrabarDB(ro_info, ref mensaje, ref idNovedad, ref idTransaccion))
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }

                mensaje = "Se ha procedido a actualizar la novedad # " + ro_info.IdNovedad;
                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());
            }
        }
        public Boolean GrabarDB(ro_Empleado_Novedad_Info ro_info, ref decimal id, ref string mensaje)
        {
            try
            {
                // int IdNovedad;
                using (EntitiesRoles context = new EntitiesRoles())
                {
                    EntitiesRoles EDB = new EntitiesRoles();


                    // ro_info.IdNovedad = IdNovedad;

                    var address = new ro_empleado_Novedad();

                    address.IdNovedad          = ro_info.IdNovedad = id = GetIdNovedad(ro_info.IdEmpresa, Convert.ToDecimal(ro_info.IdEmpleado == null ? 0 : ro_info.IdEmpleado));;
                    address.IdEmpresa          = ro_info.IdEmpresa;
                    address.IdEmpleado         = Convert.ToDecimal(ro_info.IdEmpleado == null ? 0 : ro_info.IdEmpleado);
                    address.TotalValor         = ro_info.TotalValor;
                    address.Fecha              = ro_info.Fecha;
                    address.IdNomina_Tipo      = ro_info.IdNomina_Tipo;
                    address.IdNomina_TipoLiqui = ro_info.IdNomina_TipoLiqui;
                    //address.IdTipoLiqui_Rol_PeriocidadPago = ro_info.IdTipoLiqui_Rol_PeriocidadPago;
                    address.IdUsuario     = ro_info.IdUsuario;
                    address.Fecha_Transac = ro_info.Fecha_Transac;
                    address.nom_pc        = ro_info.nom_pc;
                    address.ip            = ro_info.ip;
                    address.Estado        = "A";


                    context.ro_empleado_Novedad.Add(address);
                    context.SaveChanges();
                }
                mensaje = "Se ha guardado la información exitosamente...";
                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());
            }
        }
        public bool AnularDB(ro_HorasProfesores_Info info)
        {
            try
            {
                ro_HorasProfesores_det_Data oda_det = new ro_HorasProfesores_det_Data();
                var lista = oda_det.get_list(info.IdEmpresa, info.IdCarga);
                using (Entities_rrhh contex = new Entities_rrhh())
                {
                    foreach (var item in lista)
                    {
                        ro_empleado_Novedad entity_det = contex.ro_empleado_Novedad.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdEmpleado == item.IdEmpleado && q.IdNovedad == item.IdNovedad);
                        if (entity_det != null)
                        {
                            string sql = "update ro_empleado_Novedad set Estado='I' where IdEmpresa='" + info.IdEmpresa + "' and IdEmpleado='" + item.IdEmpleado + "' and IdNovedad='" + item.IdNovedad + "'";
                            contex.Database.ExecuteSqlCommand(sql);
                            entity_det.Estado          = "I";
                            entity_det.IdUsuarioUltAnu = info.IdUsuarioUltAnu;
                            entity_det.Fecha_UltAnu    = DateTime.Now;
                            contex.SaveChanges();
                        }
                    }
                }

                using (Entities_rrhh contex = new Entities_rrhh())
                {
                    ro_HorasProfesores entity = contex.ro_HorasProfesores.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdCarga == info.IdCarga);

                    if (entity == null)
                    {
                        return(false);
                    }
                    entity.Fecha_UltAnu    = info.Fecha_UltAnu = DateTime.Now;
                    entity.IdUsuarioUltAnu = info.IdUsuarioUltAnu;
                    entity.Estado          = false;
                    contex.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 10
0
        public bool AnularDB(ro_EmpleadoNovedadCargaMasiva_Info info)
        {
            try
            {
                ro_EmpleadoNovedadCargaMasiva_det_Data oda_det = new ro_EmpleadoNovedadCargaMasiva_det_Data();
                var lista = oda_det.get_list(info.IdEmpresa, info.IdCarga);
                using (Entities_rrhh contex = new Entities_rrhh())
                {
                    foreach (var item in lista)
                    {
                        ro_empleado_Novedad entity_det = contex.ro_empleado_Novedad.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdEmpleado == item.IdEmpleado && q.IdNovedad == item.IdNovedad);
                        if (entity_det != null)
                        {
                            entity_det.Estado          = "I";
                            entity_det.IdUsuarioUltAnu = info.IdUsuarioUltAnu;
                            entity_det.Fecha_UltAnu    = DateTime.Now;
                            contex.SaveChanges();
                        }
                    }
                }

                using (Entities_rrhh contex = new Entities_rrhh())
                {
                    ro_EmpleadoNovedadCargaMasiva entity = contex.ro_EmpleadoNovedadCargaMasiva.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdCarga == info.IdCarga);

                    if (entity == null)
                    {
                        return(false);
                    }
                    entity.Fecha_UltAnu    = info.Fecha_UltAnu = DateTime.Now;
                    entity.IdUsuarioUltAnu = info.IdUsuarioUltAnu;
                    entity.Estado          = false;
                    contex.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
 public bool guardarDB(ro_empleado_novedad_Info info)
 {
     try
     {
         int IdSucursa = data_empleado.get_info(info.IdEmpresa, info.IdEmpleado).IdSucursal;
         using (Entities_rrhh Context = new Entities_rrhh())
         {
             ro_empleado_Novedad Entity = new ro_empleado_Novedad
             {
                 IdEmpresa          = info.IdEmpresa,
                 IdNovedad          = info.IdNovedad = get_id(info.IdEmpresa),
                 IdNomina_Tipo      = info.IdNomina_Tipo,
                 IdNomina_TipoLiqui = info.IdNomina_TipoLiqui,
                 IdEmpleado         = info.IdEmpleado,
                 IdJornada          = info.IdJornada,
                 Fecha         = info.Fecha.Date,
                 IdSucursal    = IdSucursa,
                 Observacion   = info.Observacion,
                 Estado        = info.Estado = "A",
                 IdUsuario     = info.IdUsuario,
                 Fecha_Transac = info.Fecha_Transac = DateTime.Now
             };
             Context.ro_empleado_Novedad.Add(Entity);
             Context.SaveChanges();
         }
         return(true);
     }
     catch (Exception ex)
     {
         tb_LogError_Data LogData = new tb_LogError_Data();
         LogData.GuardarDB(new tb_LogError_Info {
             Descripcion = ex.Message, InnerException = ex.InnerException == null ? null : ex.InnerException.Message, Clase = "ro_empleado_novedad_Data", Metodo = "guardarDB", IdUsuario = info.IdUsuario
         });
         return(false);
     }
 }
Exemplo n.º 12
0
        public bool anularDB(ro_empleado_novedad_Info info)
        {
            try
            {
                using (Entities_rrhh Context = new Entities_rrhh())
                {
                    ro_empleado_Novedad Entity = Context.ro_empleado_Novedad.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdEmpleado == info.IdEmpleado && q.IdNovedad == info.IdNovedad);
                    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;
            }
        }
        public bool GuardarDB(ro_HorasProfesores_Info info)
        {
            try
            {
                decimal IdNovedad = odata_novedad.get_id(info.IdEmpresa);


                using (Entities_rrhh Contex = new Entities_rrhh())
                {
                    ro_HorasProfesores entity = new ro_HorasProfesores
                    {
                        IdEmpresa     = info.IdEmpresa,
                        IdCarga       = info.IdCarga = Get_id(info.IdEmpresa),
                        FechaCarga    = info.FechaCarga.Date,
                        IdPeriodo     = info.IdPeriodo = Convert.ToInt32(info.FechaCarga.Year.ToString() + info.FechaCarga.Month.ToString().PadLeft(2, '0')),
                        Observacion   = info.Observacion,
                        IdNomina      = info.IdNomina,
                        IdNominaTipo  = info.IdNominaTipo,
                        IdUsuario     = info.IdUsuario,
                        Fecha_Transac = DateTime.Now,
                        Estado        = true
                    };
                    Contex.ro_HorasProfesores.Add(entity);

                    foreach (var item in info.detalle)
                    {
                        ro_empleado_Novedad Entity = new ro_empleado_Novedad
                        {
                            IdEmpresa          = info.IdEmpresa,
                            IdNovedad          = item.IdNovedad = IdNovedad,
                            IdNomina_Tipo      = info.IdNomina,
                            IdNomina_TipoLiqui = info.IdNominaTipo,
                            IdEmpleado         = item.IdEmpleado,
                            Fecha         = info.FechaCarga.Date,
                            IdSucursal    = item.IdSucursal,
                            Observacion   = item.ru_descripcion,
                            Estado        = "A",
                            IdUsuario     = info.IdUsuario,
                            Fecha_Transac = info.Fecha_Transac = DateTime.Now,
                            IdJornada     = item.IdJornada
                        };
                        Contex.ro_empleado_Novedad.Add(Entity);

                        ro_empleado_novedad_det Entity_det = new ro_empleado_novedad_det
                        {
                            IdEmpresa     = info.IdEmpresa,
                            IdNovedad     = item.IdNovedad,
                            FechaPago     = info.FechaCarga.Date,
                            IdRubro       = item.IdRubro,
                            Valor         = item.Valor,
                            Observacion   = item.Observacion + " del " + info.FechaCarga.Date.ToString().Substring(0, 10),
                            EstadoCobro   = "PEN",
                            CantidadHoras = item.NumHoras,
                            Secuencia     = 1
                        };

                        Contex.ro_empleado_novedad_det.Add(Entity_det);

                        ro_HorasProfesores_det Entity_det_ = new ro_HorasProfesores_det
                        {
                            IdEmpresa     = info.IdEmpresa,
                            IdCarga       = info.IdCarga,
                            IdNovedad     = item.IdNovedad,
                            IdRubro       = item.IdRubro,
                            IdEmpleado    = item.IdEmpleado,
                            Observacion   = item.Observacion,
                            Secuencia     = item.Secuencia,
                            IdEmpresa_nov = info.IdEmpresa,
                            ValorHora     = item.ValorHora,
                            NumHoras      = item.NumHoras,
                            IdSucursal    = item.IdSucursal
                        };
                        Contex.ro_HorasProfesores_det.Add(Entity_det_);
                        IdNovedad++;
                    }
                    Contex.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool AprobarHE(ro_nomina_x_horas_extras_Info info)
        {
            try
            {
                ro_empleado_novedad_Data odata_novedad = new ro_empleado_novedad_Data();
                decimal IdNovedad = odata_novedad.get_id(info.IdEmpresa);
                ro_nomina_x_horas_extras_det_Data odata = new ro_nomina_x_horas_extras_det_Data();
                ro_periodo_Data bus_periodo             = new ro_periodo_Data();
                ro_periodo_Info info_periodo            = new ro_periodo_Info();
                info_periodo = bus_periodo.get_info(info.IdEmpresa, info.IdPeriodo);
                //var  lst_horas_extras_aprobar = odata.get_lst_horas_extras_aprobar(info.IdEmpresa, info.IdNomina_Tipo, info.IdNomina_TipoLiqui, info.IdPeriodo);
                using (Entities_rrhh content = new Entities_rrhh())
                {
                    var ro_rubro_calculados = content.ro_rubros_calculados.FirstOrDefault(s => s.IdEmpresa == info.IdEmpresa);
                    if (ro_rubro_calculados == null)
                    {
                        return(false);
                    }
                    var ro_horas_extras = content.ro_nomina_x_horas_extras.FirstOrDefault(s => s.IdEmpresa == info.IdEmpresa && s.IdHorasExtras == info.IdHorasExtras);
                    if (ro_horas_extras == null)
                    {
                        return(false);
                    }
                    ro_horas_extras.Estado = "P";

                    foreach (var item in info.lst_nomina_horas_extras)
                    {
                        if (item.Valor25 > 0)
                        {
                            IdNovedad++;
                            ro_empleado_Novedad info_novedad_25 = new ro_empleado_Novedad()
                            {
                                IdNovedad          = IdNovedad,
                                IdEmpresa          = info.IdEmpresa,
                                IdSucursal         = item.IdSucursal,
                                IdEmpleado         = item.IdEmpleado,
                                IdNomina_Tipo      = info.IdNomina_Tipo,
                                IdNomina_TipoLiqui = info.IdNomina_TipoLiqui,
                                Observacion        = "Hora extra al 25 % correspondiente al periodo " + info.IdPeriodo.ToString(),
                                Fecha_Transac      = DateTime.Now,
                                IdUsuario          = info.IdUsuario,
                                Fecha  = item.FechaRegistro.Date,
                                Estado = "A"
                            };
                            content.ro_empleado_Novedad.Add(info_novedad_25);
                            ro_empleado_novedad_det info_det_25 = new ro_empleado_novedad_det()
                            {
                                IdEmpresa   = info.IdEmpresa,
                                IdNovedad   = IdNovedad,
                                Secuencia   = 1,
                                Valor       = Math.Round(item.Valor25, 2),
                                FechaPago   = info_periodo.pe_FechaFin,
                                IdRubro     = "7",
                                Observacion = "Hora extra al 25 % correspondiente al periodo " + info.IdPeriodo.ToString(),
                                EstadoCobro = "PEN"
                            };
                            content.ro_empleado_novedad_det.Add(info_det_25);
                        }
                        ;


                        if (item.Valor50 > 0)
                        {
                            IdNovedad++;
                            ro_empleado_Novedad info_novedad_50 = new ro_empleado_Novedad()
                            {
                                IdNovedad          = IdNovedad,
                                IdSucursal         = item.IdSucursal,
                                IdEmpresa          = info.IdEmpresa,
                                IdEmpleado         = item.IdEmpleado,
                                IdNomina_Tipo      = info.IdNomina_Tipo,
                                IdNomina_TipoLiqui = info.IdNomina_TipoLiqui,
                                Observacion        = "Hora extra al 50 % correspondiente al periodo " + info.IdPeriodo.ToString(),
                                Fecha_Transac      = DateTime.Now,
                                IdUsuario          = info.IdUsuario,
                                Fecha  = item.FechaRegistro.Date,
                                Estado = "A"
                            };
                            content.ro_empleado_Novedad.Add(info_novedad_50);
                            ro_empleado_novedad_det info_det_50 = new ro_empleado_novedad_det()
                            {
                                IdEmpresa   = info.IdEmpresa,
                                IdNovedad   = IdNovedad,
                                Secuencia   = 1,
                                Valor       = Math.Round(item.Valor50, 2),
                                FechaPago   = info_periodo.pe_FechaFin,
                                IdRubro     = "8",
                                Observacion = "Hora extra al 50 % correspondiente al periodo " + info.IdPeriodo.ToString(),
                                EstadoCobro = "PEN"
                            };
                            content.ro_empleado_novedad_det.Add(info_det_50);
                        }
                        ;

                        if (item.hora_extra100 > 0)
                        {
                            IdNovedad++;
                            ro_empleado_Novedad info_novedad_100 = new ro_empleado_Novedad()
                            {
                                IdNovedad          = IdNovedad,
                                IdSucursal         = item.IdSucursal,
                                IdEmpresa          = info.IdEmpresa,
                                IdEmpleado         = item.IdEmpleado,
                                IdNomina_Tipo      = info.IdNomina_Tipo,
                                IdNomina_TipoLiqui = info.IdNomina_TipoLiqui,
                                Observacion        = "Hora extra al 50 % correspondiente al periodo " + info.IdPeriodo.ToString(),
                                Fecha_Transac      = DateTime.Now,
                                IdUsuario          = info.IdUsuario,
                                Fecha  = item.FechaRegistro.Date,
                                Estado = "A"
                            };
                            content.ro_empleado_Novedad.Add(info_novedad_100);
                            ro_empleado_novedad_det info_det_100 = new ro_empleado_novedad_det()
                            {
                                IdEmpresa   = info.IdEmpresa,
                                IdNovedad   = IdNovedad,
                                Secuencia   = 1,
                                Valor       = Math.Round(item.Valor100, 2),
                                FechaPago   = info_periodo.pe_FechaFin,
                                IdRubro     = "8",
                                Observacion = "Hora extra al 100 % correspondiente al periodo " + info.IdPeriodo.ToString(),
                                EstadoCobro = "PEN"
                            };
                            content.ro_empleado_novedad_det.Add(info_det_100);
                        }
                        ;
                    }
                    content.SaveChanges();
                    odata.Modificar_estado_aprobacion(info.IdHorasExtras, 1);
                }

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 15
0
        public Boolean GrabarDB(ro_Empleado_Novedad_Info ro_info, ref string mensaje, ref decimal idnovedad, ref decimal idTransaccion)
        {
            try
            {
                ro_Novedad_x_Empleado_Data BusNovedadXEmpleado = new ro_Novedad_x_Empleado_Data();
                int IdNovedad;
                using (EntitiesRoles context = new EntitiesRoles())
                {
                    EntitiesRoles EDB = new EntitiesRoles();
                    IdNovedad         = GetIdNovedad(ro_info.IdEmpresa, Convert.ToDecimal(ro_info.IdEmpleado == null ? 0 : ro_info.IdEmpleado));
                    idTransaccion     = BusNovedadXEmpleado.getId(ro_info.IdEmpresa);
                    ro_info.IdNovedad = IdNovedad;
                    idnovedad         = IdNovedad;
                    var address = new ro_empleado_Novedad();
                    address.IdNovedad          = ro_info.IdNovedad;
                    address.IdEmpresa          = ro_info.IdEmpresa;
                    address.IdEmpleado         = Convert.ToDecimal(ro_info.IdEmpleado == null ? 0 : ro_info.IdEmpleado);
                    address.TotalValor         = ro_info.TotalValor;
                    address.Fecha              = ro_info.Fecha;
                    address.IdNomina_Tipo      = ro_info.IdNomina_Tipo;
                    address.IdNomina_TipoLiqui = ro_info.IdNomina_TipoLiqui;
                    address.IdUsuario          = ro_info.IdUsuario;
                    address.Fecha_Transac      = ro_info.Fecha_Transac;
                    address.nom_pc             = ro_info.nom_pc;
                    address.ip           = ro_info.ip;
                    address.Estado       = "A";
                    address.IdCalendario = ro_info.IdCalendario;
                    context.ro_empleado_Novedad.Add(address);
                    context.SaveChanges();


                    ro_Empleado_Novedad_Det_Data DataDet = new ro_Empleado_Novedad_Det_Data();
                    ro_Novedad_x_Empleado_Data   oRo_Novedad_x_Empleado_Data = new ro_Novedad_x_Empleado_Data();

                    int sec = 0;

                    foreach (var item in ro_info.LstDetalle)
                    {
                        item.IdNovedad     = ro_info.IdNovedad;
                        item.IdNomina      = ro_info.IdNomina_Tipo;
                        item.IdNominaLiqui = ro_info.IdNomina_TipoLiqui;
                        item.Secuencia     = ++sec;
                        if (!DataDet.GrabarDB(item, ref mensaje))
                        {
                            return(false);
                        }
                    }
                }
                mensaje = "Se ha guardado la información exitosamente...";
                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());
            }
        }
        public bool guardarDB(ro_SancionesPorMarcaciones_Info info)
        {
            try
            {
                ro_empleado_novedad_Data odata_novedad = new ro_empleado_novedad_Data();

                decimal IdNovedad = odata_novedad.get_id(info.IdEmpresa);

                int secuancia = 1;
                using (Entities_rrhh Context = new Entities_rrhh())
                {
                    ro_SancionesPorMarcaciones entity = new ro_SancionesPorMarcaciones
                    {
                        IdEmpresa          = info.IdEmpresa,
                        IdAjuste           = info.IdAjuste = get_id(info.IdEmpresa),
                        IdNomina_Tipo      = info.IdNomina_Tipo,
                        IdNomina_TipoLiqui = info.IdNomina_TipoLiqui,
                        FechaInicio        = info.FechaInicio, FechaFin = info.FechaFin,
                        Observacion        = info.Observacion,
                        Fecha_Transac      = DateTime.Now,
                        IdUsuario          = info.IdUsuario,
                        Estado             = true,
                        FechaNovedades     = info.FechaNovedades
                    };
                    Context.ro_SancionesPorMarcaciones.Add(entity);
                    foreach (var item in info.detalle)
                    {
                        ro_SancionesPorMarcaciones_det entity_det = new ro_SancionesPorMarcaciones_det
                        {
                            IdEmpresa     = info.IdEmpresa,
                            IdSucursal    = item.IdSucursal,
                            IdAjuste      = info.IdAjuste,
                            IdCalendario  = item.IdCalendario,
                            IdEmpleado    = item.IdEmpleado,
                            EsHoraIngreso = item.HoraIni,
                            HoraIngreso   = item.time_entrada1,
                            EsHoraSalida  = item.HoraFin,
                            HoraSalio     = item.time_salida1,
                            Minutos       = item.Minutos,
                            FechaRegistro = item.es_fechaRegistro,
                            Secuencia     = secuancia
                        };
                        Context.ro_SancionesPorMarcaciones_det.Add(entity_det);
                        secuancia++;
                    }

                    // agrupnado para obter valor para novedad
                    secuancia = 1;
                    var lista_novedades = (from q in info.detalle
                                           group q by new
                    {
                        q.IdEmpresa,
                        q.IdSucursal,
                        q.IdEmpleado,
                        q.Minutos,
                        q.Sueldo
                    } into Grupo
                                           select new ro_SancionesPorMarcaciones_x_novedad_Info
                    {
                        IdEmpresa = Grupo.Key.IdEmpresa,
                        IdSucursal = Grupo.Key.IdSucursal,
                        IdEmpleado = Grupo.Key.IdEmpleado,
                        Valor = Grupo.Sum(s => s.Minutos),
                        Sueldo = Grupo.Key.Sueldo
                    }).ToList();
                    // grabando novedades
                    foreach (var item in lista_novedades)
                    {
                        ro_empleado_Novedad novedad = new ro_empleado_Novedad
                        {
                            IdEmpresa          = info.IdEmpresa,
                            IdSucursal         = item.IdSucursal,
                            IdNovedad          = IdNovedad,
                            IdEmpleado         = item.IdEmpleado,
                            IdNomina_Tipo      = info.IdNomina_Tipo,
                            IdNomina_TipoLiqui = info.IdNomina_TipoLiqui,
                            Observacion        = "Novedad generada por proceso del sistema fecha descuento " + info.FechaNovedades.ToString().Substring(0, 10),
                            Fecha         = info.FechaNovedades,
                            Estado        = "A",
                            Fecha_Transac = DateTime.Now,
                            IdUsuario     = info.IdUsuario
                        };
                        Context.ro_empleado_Novedad.Add(novedad);

                        ro_empleado_novedad_det novedad_det = new ro_empleado_novedad_det
                        {
                            IdEmpresa   = info.IdEmpresa,
                            IdNovedad   = IdNovedad,
                            IdRubro     = "200",
                            Valor       = item.Valor * (((Convert.ToDouble(item.Sueldo)) / 240) / 60),
                            FechaPago   = info.FechaNovedades,
                            EstadoCobro = "PEN",
                            Observacion = "Novedad generda por proceso del sistema",
                            Secuencia   = 1,
                        };
                        novedad_det.Valor = Math.Round(novedad_det.Valor, 2);
                        Context.ro_empleado_novedad_det.Add(novedad_det);

                        ro_SancionesPorMarcaciones_x_novedad novedad_x_sanc = new ro_SancionesPorMarcaciones_x_novedad
                        {
                            IdEmpresa          = info.IdEmpresa,
                            IdAjuste           = info.IdAjuste,
                            Secuencia          = secuancia,
                            IdNovedad          = novedad.IdNovedad,
                            IdEmpresa_nov      = info.IdEmpresa,
                            IdEmpleado         = item.IdEmpleado,
                            IdNomina_Tipo      = info.IdNomina_Tipo,
                            IdNomina_TipoLiqui = info.IdNomina_TipoLiqui
                        };
                        Context.ro_SancionesPorMarcaciones_x_novedad.Add(novedad_x_sanc);
                        IdNovedad++;
                        secuancia++;
                    }

                    Context.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public bool modificarDB(ro_SancionesPorMarcaciones_Info info)
        {
            try
            {
                ro_SancionesPorMarcaciones_x_novedad_Data odata_novedad_x_sanciones = new ro_SancionesPorMarcaciones_x_novedad_Data();
                ro_empleado_novedad_Data odata_novedad = new ro_empleado_novedad_Data();
                var lista_novedades_a_eliminar         = odata_novedad_x_sanciones.get_list(info.IdEmpresa, info.IdAjuste).ToList();


                using (Entities_rrhh Context = new Entities_rrhh())
                {
                    #region modificando cabecera
                    ro_SancionesPorMarcaciones entity = Context.ro_SancionesPorMarcaciones.Where(v => v.IdEmpresa == info.IdEmpresa && v.IdAjuste == info.IdAjuste).FirstOrDefault();
                    if (entity == null)
                    {
                        return(false);
                    }
                    entity.FechaInicio     = info.FechaInicio;
                    entity.FechaFin        = info.FechaFin;
                    entity.Observacion     = info.Observacion;
                    entity.FechaNovedades  = info.FechaNovedades;
                    entity.IdUsuarioUltMod = info.IdUsuarioUltMod;
                    entity.Fecha_UltMod    = DateTime.Now;
                    #endregion


                    #region eliminado detalle
                    #region eliminando novedad por sancion
                    var ro_sanciones_det = Context.ro_SancionesPorMarcaciones_det.Where(v => v.IdEmpresa == info.IdEmpresa && v.IdAjuste == info.IdAjuste);
                    Context.ro_SancionesPorMarcaciones_det.RemoveRange(ro_sanciones_det);

                    #endregion
                    #endregion
                    #region eliminando novedad por sancion
                    var ro_novedad_x_sanciones = Context.ro_SancionesPorMarcaciones_x_novedad.Where(v => v.IdEmpresa == info.IdEmpresa && v.IdAjuste == info.IdAjuste);
                    Context.ro_SancionesPorMarcaciones_x_novedad.RemoveRange(ro_novedad_x_sanciones);

                    #endregion


                    #region eliminado_novedades

                    foreach (var item in lista_novedades_a_eliminar)
                    {
                        var info_novedad_det = Context.ro_empleado_novedad_det.Where(q => q.IdEmpresa == item.IdEmpresa && q.IdNovedad == item.IdNovedad).FirstOrDefault();
                        Context.ro_empleado_novedad_det.Remove(info_novedad_det);

                        var info_novedad = Context.ro_empleado_Novedad.Where(q => q.IdEmpresa == item.IdEmpresa && q.IdNovedad == item.IdNovedad && q.IdEmpleado == item.IdEmpleado).FirstOrDefault();
                        Context.ro_empleado_Novedad.Remove(info_novedad);
                    }
                    #endregion

                    #region grabando novedades

                    decimal IdNovedad = odata_novedad.get_id(info.IdEmpresa);
                    int     secuancia = 1;

                    foreach (var item in info.detalle)
                    {
                        ro_SancionesPorMarcaciones_det entity_det = new ro_SancionesPorMarcaciones_det
                        {
                            IdEmpresa     = info.IdEmpresa,
                            IdSucursal    = item.IdSucursal,
                            IdAjuste      = info.IdAjuste,
                            IdCalendario  = item.IdCalendario,
                            IdEmpleado    = item.IdEmpleado,
                            EsHoraIngreso = item.HoraIni,
                            HoraIngreso   = item.time_entrada1,
                            EsHoraSalida  = item.HoraFin,
                            HoraSalio     = item.time_salida1,
                            Minutos       = item.Minutos,
                            FechaRegistro = item.es_fechaRegistro,
                            Secuencia     = secuancia
                        };
                        Context.ro_SancionesPorMarcaciones_det.Add(entity_det);
                        secuancia++;
                    }

                    // agrupnado para obter valor para novedad
                    secuancia = 1;
                    var lista_novedades = (from q in info.detalle
                                           group q by new
                    {
                        q.IdEmpresa,
                        q.IdSucursal,
                        q.IdEmpleado,
                        q.Minutos,
                        q.Sueldo
                    } into Grupo
                                           select new ro_SancionesPorMarcaciones_x_novedad_Info
                    {
                        IdEmpresa = Grupo.Key.IdEmpresa,
                        IdSucursal = Grupo.Key.IdSucursal,
                        IdEmpleado = Grupo.Key.IdEmpleado,
                        Valor = Grupo.Sum(s => s.Minutos),
                        Sueldo = Grupo.Key.Sueldo
                    }).ToList();
                    // grabando novedades
                    foreach (var item in lista_novedades)
                    {
                        ro_empleado_Novedad novedad = new ro_empleado_Novedad
                        {
                            IdEmpresa          = info.IdEmpresa,
                            IdSucursal         = item.IdSucursal,
                            IdNovedad          = IdNovedad,
                            IdEmpleado         = item.IdEmpleado,
                            IdNomina_Tipo      = info.IdNomina_Tipo,
                            IdNomina_TipoLiqui = info.IdNomina_TipoLiqui,
                            Observacion        = "Novedad generada por proceso del sistema fecha descuento " + info.FechaNovedades.ToString().Substring(0, 10),
                            Fecha         = info.FechaNovedades,
                            Estado        = "A",
                            Fecha_Transac = DateTime.Now,
                            IdUsuario     = info.IdUsuario
                        };
                        Context.ro_empleado_Novedad.Add(novedad);

                        ro_empleado_novedad_det novedad_det = new ro_empleado_novedad_det
                        {
                            IdEmpresa   = info.IdEmpresa,
                            IdNovedad   = IdNovedad,
                            IdRubro     = "200",
                            Valor       = item.Valor * (((Convert.ToDouble(item.Sueldo)) / 240) / 60),
                            FechaPago   = info.FechaNovedades,
                            EstadoCobro = "PEN",
                            Observacion = "Novedad generda por proceso del sistema",
                            Secuencia   = 1,
                        };
                        novedad_det.Valor = Math.Round(novedad_det.Valor, 2);
                        Context.ro_empleado_novedad_det.Add(novedad_det);

                        ro_SancionesPorMarcaciones_x_novedad novedad_x_sanc = new ro_SancionesPorMarcaciones_x_novedad
                        {
                            IdEmpresa          = info.IdEmpresa,
                            IdAjuste           = info.IdAjuste,
                            Secuencia          = secuancia,
                            IdNovedad          = novedad.IdNovedad,
                            IdEmpresa_nov      = info.IdEmpresa,
                            IdEmpleado         = item.IdEmpleado,
                            IdNomina_Tipo      = info.IdNomina_Tipo,
                            IdNomina_TipoLiqui = info.IdNomina_TipoLiqui
                        };
                        Context.ro_SancionesPorMarcaciones_x_novedad.Add(novedad_x_sanc);
                        IdNovedad++;
                        secuancia++;
                    }


                    #endregion

                    Context.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public Boolean ModificarDB(ro_Empleado_Novedad_Info ro_info, ref string mensaje, decimal idTransaccion)
        {
            try{
                using (EntitiesRoles context = new EntitiesRoles()){
                    ro_empleado_Novedad contact = context.ro_empleado_Novedad.FirstOrDefault(var => var.IdEmpresa == ro_info.IdEmpresa &&
                                                                                             var.IdEmpleado == ro_info.IdEmpleado && var.IdNovedad == ro_info.IdNovedad);


                    if (contact != null)//ACTUALIZA REGISTRO
                    {
                        contact.Estado          = ro_info.Estado;
                        contact.Fecha           = ro_info.Fecha;
                        contact.Fecha_UltMod    = ro_info.Fecha_UltMod;
                        contact.IdUsuarioUltMod = ro_info.IdUsuarioUltMod;

                        contact.Fecha_UltAnu    = ro_info.Fecha_UltAnu;
                        contact.IdUsuarioUltAnu = ro_info.IdUsuarioUltAnu;

                        double totalvalor = 0;

                        foreach (var item in ro_info.LstDetalle)
                        {
                            totalvalor = totalvalor + item.Valor;
                        }

                        contact.TotalValor = totalvalor;
                        context.SaveChanges();
                    }
                    else
                    {//CREA UN NUEVO REGISTRO
                        decimal idNovedad = ro_info.IdNovedad;
                        if (GrabarDB(ro_info, ref mensaje, ref idNovedad, ref idTransaccion))
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }


                    ////ACTUALIZAR EL DETALLE 1
                    //ro_Empleado_Novedad_Det_Data DetData = new ro_Empleado_Novedad_Det_Data();
                    //foreach (var item in ro_info.LstDetalle)
                    //{

                    //    if (DetData.EliminarDB(ro_info.IdEmpresa, ro_info.IdNovedad, ro_info.IdEmpleado, item.IdRubro, ref mensaje))
                    //    {
                    //        int sec = 0;
                    //        sec = DetData.getSecuencia(item.IdEmpresa, item.IdNovedad, item.IdEmpleado);
                    //        item.Secuencia = sec;
                    //        if (!DetData.GrabarDB(item, ref mensaje))
                    //        { return false; }
                    //    }
                    //    else
                    //    {
                    //        return false;
                    //    }
                    //}


                    ////ACTUALIZAR EL DETALLE 2
                    //ro_Novedad_x_Empleado_Data oRo_Novedad_x_Empleado_Data = new ro_Novedad_x_Empleado_Data();
                    //foreach (var item in ro_info.lstNovedadEmpleado){
                    //    if (oRo_Novedad_x_Empleado_Data.BorrarDB(item ,ref mensaje)){
                    //        if (!oRo_Novedad_x_Empleado_Data.GrabarDB(item, item.IdTransaccion, ref mensaje)) { return false; }
                    //    }else{
                    //        return false;
                    //    }
                    //}
                }

                mensaje = "Se ha procedido a actualizar la novedad # " + ro_info.IdNovedad;
                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());
            }
        }
Exemplo n.º 19
0
        public bool GuardarDB(ro_EmpleadoNovedadCargaMasiva_Info info)
        {
            try
            {
                decimal IdNovedad = odata_novedad.get_id(info.IdEmpresa);


                using (Entities_rrhh Contex = new Entities_rrhh())
                {
                    ro_EmpleadoNovedadCargaMasiva entity = new ro_EmpleadoNovedadCargaMasiva
                    {
                        IdEmpresa     = info.IdEmpresa,
                        IdCarga       = info.IdCarga = Get_id(info.IdEmpresa),
                        FechaCarga    = info.FechaCarga.Date,
                        Observacion   = info.Observacion,
                        IdNomina      = info.IdNomina,
                        IdNominaTipo  = info.IdNominaTipo,
                        IdSucursal    = info.IdSucursal,
                        IdRubro       = info.IdRubro,
                        IdUsuario     = info.IdUsuario,
                        Fecha_Transac = DateTime.Now,
                        Estado        = true
                    };
                    Contex.ro_EmpleadoNovedadCargaMasiva.Add(entity);

                    foreach (var item in info.detalle)
                    {
                        ro_empleado_Novedad Entity = new ro_empleado_Novedad
                        {
                            IdEmpresa          = info.IdEmpresa,
                            IdSucursal         = info.IdSucursal,
                            IdNovedad          = item.IdNovedad = IdNovedad,
                            IdNomina_Tipo      = info.IdNomina,
                            IdNomina_TipoLiqui = info.IdNominaTipo,
                            IdEmpleado         = item.IdEmpleado,
                            Fecha = info.FechaCarga.Date,

                            Observacion   = info.Observacion == null?"":info.Observacion,
                            Estado        = "A",
                            IdUsuario     = info.IdUsuario,
                            Fecha_Transac = info.Fecha_Transac = DateTime.Now
                        };
                        Contex.ro_empleado_Novedad.Add(Entity);

                        ro_empleado_novedad_det Entity_det = new ro_empleado_novedad_det
                        {
                            IdEmpresa     = info.IdEmpresa,
                            IdNovedad     = item.IdNovedad,
                            FechaPago     = info.FechaCarga.Date,
                            IdRubro       = info.IdRubro,
                            Valor         = item.Valor,
                            Observacion   = item.Observacion,
                            EstadoCobro   = "PEN",
                            Secuencia     = 1,
                            CantidadHoras = item.CantidadHoras
                        };
                        Contex.ro_empleado_novedad_det.Add(Entity_det);

                        ro_EmpleadoNovedadCargaMasiva_det Entity_det_ = new ro_EmpleadoNovedadCargaMasiva_det
                        {
                            IdEmpresa     = info.IdEmpresa,
                            IdCarga       = info.IdCarga,
                            IdNovedad     = item.IdNovedad,
                            IdEmpleado    = item.IdEmpleado,
                            Observacion   = item.Observacion,
                            Secuencia     = item.Secuancia,
                            IdEmpresa_nov = info.IdEmpresa
                        };
                        Contex.ro_EmpleadoNovedadCargaMasiva_det.Add(Entity_det_);
                        IdNovedad++;
                    }
                    Contex.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool guardarDB(ro_NominasPagosCheques_Info info)
        {
            try
            {
                int     secuencia = 1;
                decimal IdNovedad = odata_novedad.get_id(info.IdEmpresa);

                using (Entities_rrhh Context = new Entities_rrhh())
                {
                    var info_rubros_calculados    = Context.ro_rubros_calculados.Where(v => v.IdEmpresa == info.IdEmpresa).FirstOrDefault();
                    ro_NominasPagosCheques Entity = new ro_NominasPagosCheques
                    {
                        IdEmpresa          = info.IdEmpresa,
                        IdTransaccion      = info.IdTransaccion = Convert.ToInt32(get_id(info.IdEmpresa)),
                        IdNomina_Tipo      = info.IdNomina_Tipo,
                        IdNomina_TipoLiqui = info.IdNomina_TipoLiqui,
                        IdPeriodo          = info.IdPeriodo,
                        Observacion        = info.Observacion,
                        Estado             = info.Estado = true,
                        IdUsuario          = info.IdUsuario,
                        FechaTransac       = info.FechaTransac = DateTime.Now
                    };
                    Context.ro_NominasPagosCheques.Add(Entity);

                    foreach (var item in info.detalle)
                    {
                        ro_NominasPagosCheques_det Entity_ = new ro_NominasPagosCheques_det
                        {
                            IdEmpresa     = item.IdEmpresa,
                            IdTransaccion = item.IdTransaccion = info.IdTransaccion,
                            IdSucursal    = item.IdSucursal,
                            IdEmpleado    = item.IdEmpleado,
                            Valor         = item.Valor,
                            Secuencia     = secuencia,
                            IdEmpresa_op  = info.IdEmpresa,
                            IdOrdenPago   = item.IdOrdenPago,
                            Secuancia_op  = item.Secuancia_op,
                            IdEmpresa_dc  = item.IdEmpresa_dc,
                            IdTipoCbte    = item.IdTipoCbte,
                            IdCbteCble    = item.IdCbteCble
                        };
                        Context.ro_NominasPagosCheques_det.Add(Entity_);
                        secuencia++;


                        if (info_rubros_calculados != null)
                        {
                            if (info_rubros_calculados.IdRubro_novedad_proceso != null)
                            {
                                ro_empleado_Novedad Entity_nov = new ro_empleado_Novedad
                                {
                                    IdEmpresa          = info.IdEmpresa,
                                    IdSucursal         = item.IdSucursal,
                                    IdNovedad          = IdNovedad,
                                    IdNomina_Tipo      = info.IdNomina_Tipo,
                                    IdNomina_TipoLiqui = info.IdNomina_TipoLiqui,
                                    IdEmpleado         = Convert.ToInt32(item.IdEmpleado),
                                    Fecha = DateTime.Now.Date,

                                    Observacion   = info.Observacion == null ? "" : info.Observacion,
                                    Estado        = "A",
                                    IdUsuario     = info.IdUsuario,
                                    Fecha_Transac = DateTime.Now
                                };
                                Context.ro_empleado_Novedad.Add(Entity_nov);

                                ro_empleado_novedad_det Entity_nov_det = new ro_empleado_novedad_det
                                {
                                    IdEmpresa   = info.IdEmpresa,
                                    IdNovedad   = IdNovedad,
                                    FechaPago   = DateTime.Now.Date,
                                    IdRubro     = info_rubros_calculados.IdRubro_novedad_proceso,
                                    Valor       = item.Valor,
                                    Observacion = item.Observacion,
                                    EstadoCobro = "PEN",
                                    Secuencia   = 1
                                };
                                Context.ro_empleado_novedad_det.Add(Entity_nov_det);
                                IdNovedad++;
                            }
                        }
                    }

                    Context.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }