Ejemplo n.º 1
0
        public void AgregarDatosCita(string grasaVis, string CMB, string cirCad, string bodyAge, string cirCin, string musculoPorc, string grasaPorc, string IMC, string peso, DateTime fecha, int id)
        {
            var validac = new Validacion();

            if (validac.Longitud(grasaVis, 1, 5) && validac.Longitud(CMB, 1, 5) && validac.Longitud(cirCad, 1, 5) && validac.Longitud(bodyAge, 1, 3) && validac.Longitud(cirCin, 1, 5) && validac.Longitud(musculoPorc, 1, 3) && validac.Longitud(grasaPorc, 1, 3) && validac.Longitud(IMC, 1, 5) && validac.Longitud(peso, 1, 5))
            {
                if (validac.MayorA(Convert.ToInt32(grasaVis), 0) && validac.MayorA(Convert.ToInt32(CMB), 0) && validac.MayorA(Convert.ToInt32(cirCad), 0) && validac.MayorA(Convert.ToInt32(bodyAge), 0) && validac.MayorA(Convert.ToInt32(cirCin), 0) && validac.MayorA(Convert.ToInt32(musculoPorc), 0) && validac.MayorA(Convert.ToInt32(grasaPorc), 0) && validac.MayorA(Convert.ToInt32(IMC), 0) && validac.MayorA(Convert.ToInt32(peso), 0))
                {
                    if (validac.MenorA(Convert.ToInt32(peso), 801) && validac.MenorA(Convert.ToInt32(grasaPorc), 101) && validac.MenorA(Convert.ToInt32(musculoPorc), 101) && validac.MenorA(Convert.ToInt32(bodyAge), 101))
                    {
                        if (validac.FechaMayorIgualA(fecha, DateTime.Today))
                        {
                            try
                            {
                                var modelodc = new ModeloDatosxCita();
                                modelodc.AgregarDatosCita(grasaVis, CMB, cirCad, bodyAge, cirCin, musculoPorc, grasaPorc, IMC, peso, fecha, id);
                            }
                            catch (Exception ex)
                            {
                                throw new Exception(ex.Message);
                            }
                        }
                        else
                        {
                            error = "Fecha invalida";
                            return;
                        }
                    }
                    else
                    {
                        error = "Alguna cantidad paso el rango establecido";
                        return;
                    }
                }
                else
                {
                    error = "Las cantidades deben ser mayor a cero";
                    return;
                }
            }
            else
            {
                error = "Los campos con * no deben estar vacios";
                return;
            }
        }
Ejemplo n.º 2
0
        //Facade
        public void AgregarCita(DateTime fecha, string nombre, string apellido, string telefono, string hora)
        {
            string telefonovar    = telefono;
            string replacedString = telefono.Replace("(", "");

            telefonovar = replacedString.Replace(")", "");
            telefonovar = telefonovar.Replace("-", "");
            telefonovar = telefonovar.Replace(" ", "");
            string horavar = hora;

            horavar = horavar.Replace(":", "");
            horavar = horavar.Replace(" ", "");
            var validac = new Validacion();

            if (validac.Longitud(nombre, 1, 50) == true && validac.Longitud(apellido, 1, 50) == true && validac.Longitud(hora, 1, 50) == true)
            {
                if (validac.Longitud(horavar, 4, 4))
                {
                    string izq = horavar.Substring(0, 2);
                    string der = horavar.Substring(2, 2);
                    if (izq.IndexOf('0') == 0)
                    {
                        izq = izq.Substring(1, 1);
                    }
                    if (der.IndexOf('0') == 0)
                    {
                        der = der.Substring(1, 1);
                    }
                    if (validac.MenorA(Convert.ToInt32(izq), 24) && (validac.MenorA(Convert.ToInt32(der), 60)))
                    {
                        if (validac.FechaMayorIgualA(fecha, DateTime.Today))
                        {
                            if (validac.Longitud(telefonovar, 1, 10))
                            {
                                if (validac.Longitud(telefonovar, 7, 10))
                                {
                                    try
                                    {
                                        var modeloCitas = new ModeloCitas();
                                        modeloCitas.AgregarCita(fecha, nombre, apellido, telefono, hora);
                                    }
                                    catch (Exception ex)
                                    {
                                        throw new Exception(ex.Message);
                                    }
                                }
                                else
                                {
                                    error = "Telefono debe tener entre 7 y 10 numeros";
                                    return;
                                }
                            }
                            else
                            {
                                try
                                {
                                    var modeloCitas = new ModeloCitas();
                                    modeloCitas.AgregarCita(fecha, nombre, apellido, telefono, hora);
                                }
                                catch (Exception ex)
                                {
                                    throw new Exception(ex.Message);
                                }
                            }
                        }
                        else
                        {
                            error = "Fecha invalida";
                            return;
                        }
                    }
                    else
                    {
                        error = "Hora invalida";
                    }
                }
                else
                {
                    error = "Hora invalida";
                    return;
                }
            }
            else
            {
                error = "Los campos con * son obligatorios";
                return;
            }
        }