Exemplo n.º 1
0
        public void Vacaciones(Vacaciones collection, DatosEmpleadoVacaciones datos, PeriodoVacaciones periodo)
        {
            string fechas   = collection.FechaInicio + "," + collection.FechaFin;
            var    cd       = GetDatosPersonales(datos.IdEmpleado);
            int    contrato = ctx.Empleado_Contrato.Where(x => x.IdEmpleado == datos.IdEmpleado).Select(x => x.IdContrato).FirstOrDefault();

            cd.Fecha_Inicio       = collection.FechaInicio.ToString("dd-MM-yyyy");
            cd.Fecha_Fin          = collection.FechaFin.ToString("dd-MM-yyyy");
            cd.Fecha_Presentacion = collection.Presentarse.ToString("dd-MM-yyyy");
            cd.Dias    = collection.DiasTomados.ToString();
            cd.Periodo = periodo.PeridoVacaciones;

            string titulo = GetTitulo(cd);

            NotificacionesCommon.CreateNotification(titulo, DateTime.Now, SessionHelpers.GetIdUsuario(), TiposNotificacion.Vacaciones, cd.IdCliente, cd, cd.IdSucursal, contrato, collection.FechaInicio.ToString("dd-MM-yyyy"));
        }
Exemplo n.º 2
0
        public bool CrearPeriodo(int id, DateTime real, int IdEmpleado)
        {
            DateTime hoy = DateTime.Now;

            // Difference in days, hours, and minutes.
            TimeSpan ts = hoy - real;
            // Difference in days.
            int differenceInDays     = ts.Days;
            int anti                 = GetAntiguedad(differenceInDays);
            IEnumerable <int> values = Enumerable.Range(1, anti);

            foreach (int n in values)
            {
                var factInt = ctx.C_FactoresIntegracion.FirstOrDefault(x => x.Antiguedad == n);
                if (factInt != null)
                {
                    string periodo = Convert.ToString(n);

                    var comprobar = ctx.PeriodoVacaciones.FirstOrDefault(x => x.IdEmpleado_Contrato == id && x.PeridoVacaciones == periodo);

                    if (comprobar == null)
                    {
                        var datos = new PeriodoVacaciones
                        {
                            PeridoVacaciones    = periodo,
                            DiasCorresponde     = factInt.DiasVacaciones,
                            IdEmpleado_Contrato = id
                        };

                        ctx.PeriodoVacaciones.Add(datos);
                        var r = ctx.SaveChanges();
                    }
                }
            }

            return(true);
        }