Beispiel #1
0
        private bool horaCorrecta(TextBox box, out CustomHour hour)
        {
            bool resultado = true;

            string[] split = box.Text.Split(':');
            int      horaParseada;

            foreach (string hora in split)
            {
                if (!int.TryParse(hora, out horaParseada))
                {
                    resultado = false;
                }
            }

            if (resultado)
            {
                try{
                    hour = new CustomHour(int.Parse(split[0]), int.Parse(split[1]));
                }catch (ArgumentOutOfRangeException ex) {
                    resultado = false;
                    hour      = null;
                }
            }
            else
            {
                hour = null;
            }

            return(resultado);
        }
        /// <summary>
        /// Hora1 debe ser anterior a hora2
        /// </summary>
        public static bool esMultiplo30(CustomHour hora1, CustomHour hora2)
        {
            if (hora1.esDespues(hora2))
            {
                return(false);
            }

            return(((hora1.toMinutes() - hora2.toMinutes()) % 30) == 0);
        }
 public bool esAntes(CustomHour hour)
 {
     if (hora == hour.hora)
     {
         return(minuto < hour.minuto);
     }
     else if (hora < hour.hora)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
 public bool esDespues(CustomHour hour)
 {
     if (hora == hour.hora)
     {
         return(minuto > hour.minuto);
     }
     else if (hora > hour.hora)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #5
0
        private void generarTurnos(CustomHour horaInicio, CustomHour horaFin, DateTime fecha)
        {
            int cantTurnos = ((horaInicio.toMinutes() - horaFin.toMinutes()) / 30) * -1;
            int i;

            for (i = 0; i < cantTurnos; i++)
            {
                CustomHour aux = CustomHour.FromMinutes(horaInicio.toMinutes() + 30 * i);
                fecha = fecha.AddHours(aux.hora);
                fecha = fecha.AddMinutes(aux.minuto);

                //Genero el turno
                Dictionary <string, object> parametros = new Dictionary <string, object>()
                {
                    { "@matricula", profesional.Matricula },
                    { "@especialidad", profesional.Especialidades[listaEspecialidades.SelectedIndex].Id },
                    { "@fecha", fecha }
                };
                ConexionesDB.ExecuteNonQuery("Turno_Agregar", parametros);
                fecha = fecha.AddHours(-aux.hora);
                fecha = fecha.AddMinutes(-aux.minuto);
            }
        }