コード例 #1
0
        public static void AgregarDiaLibre(DiaLibre diaLibre)
        {
            if (diaLibre.empleado.diasLibresAFavor >= 1)
            {
                ListaCanjesDiasLibres.Add(diaLibre);

                diaLibre.empleado.diasLibresAFavor -= 1;

                List <HoraExtra> listHorasExtras = HoraExtra.ObtenerHorasExtra();

                List <HoraExtra> sortedList = listHorasExtras.OrderBy(o => o.fecha).ToList();
                int totalCanjeado           = 0;
                foreach (HoraExtra horaExtra in sortedList)
                {
                    while (totalCanjeado <= 8)
                    {
                        if (diaLibre.empleado == horaExtra.empleado)
                        {
                            int horasCanjeables = (horaExtra.cantidadHorasAcumuladas - horaExtra.cantidadHorasCanjeadas);
                            if (horasCanjeables > 0)
                            {
                                int exceso = (totalCanjeado + horasCanjeables) - 8;
                                int canje  = (exceso > 0) ? (horasCanjeables - exceso) : horasCanjeables;

                                totalCanjeado += canje;
                                horaExtra.cantidadHorasCanjeadas += canje;
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
 public static void AgregarHoraExtra(HoraExtra h)
 {
     if (h.cantidadHorasAcumuladas >= 1 && h.cantidadHorasAcumuladas <= 4)
     {
         ListaHorasExtra.Add(h);
         h.empleado.AgregarDiaLibreAFavor(h);
     }
 }
コード例 #3
0
 public void AgregarDiaLibreAFavor(HoraExtra h)
 {
     diasLibresAFavor += (h.cantidadHorasAcumuladas - h.cantidadHorasCanjeadas) / 8;
 }