Exemple #1
0
        //Despliegue de semanas o días para calcular
        private async void Display()
        {
            if (DateSelected.DayOfWeek == DayOfWeek.Saturday || DateSelected.DayOfWeek == DayOfWeek.Sunday)
            {
                await dialogService.ShowMessage("Mensaje", "La fecha seleccionada " + DateSelected.ToString().Remove(10) + " pertenece al fin de semana. Por lo que se tomará en cuenta el día de semana más próximo.");
            }

            var difDias = 0;

            if (int.Parse(CantSemanas) <= TiempoFabricacionTotal())
            {
                await dialogService.ShowMessage("Error", "La cantidad de días debe ser mayor, ya que el tiempo de fabricación total será de " + TiempoFabricacionTotal() + " días");

                return;
            }
            foreach (var productoA in ProductoPrincipal.Productos)
            {
                productoA.Semanas = new List <SemanasA>();

                if (string.IsNullOrEmpty(productoA.TiempoFabricacion))
                {
                    productoA.TiempoFabricacion = 0.ToString();
                }


                difDias = DateSelected.DayOfYear - DateTime.Today.DayOfYear;

                var contador = 0;
                //Agregado de objetos a la lista, empieza en 1 para poder visualizar desde ese número y no desde 0
                for (int i = 1; i <= (int.Parse(CantSemanas) + difDias); i++)
                {
                    Semanas = new SemanasA();
                    if (DateSelected.Date == DateTime.Today)
                    {
                        //Agregado de fecha
                        if (DateSelected.Date.AddDays(contador).DayOfWeek == DayOfWeek.Saturday || DateSelected.Date.AddDays(contador).DayOfWeek == DayOfWeek.Sunday)
                        {
                            contador          = contador + 2;
                            Semanas.FechaDias = DateSelected.Date.AddDays(contador).ToString().Remove(10);
                        }
                        else
                        {
                            Semanas.FechaDias = DateSelected.Date.AddDays(contador).ToString().Remove(10);
                        }
                    }
                    else
                    {
                        //Agregado de fecha al lado del dia con la resta necesaria para empezar la cuenta desde el día de hoy
                        if (DateSelected.Date.AddDays(contador - difDias).DayOfWeek == DayOfWeek.Saturday || DateSelected.Date.AddDays(contador - difDias).DayOfWeek == DayOfWeek.Sunday)
                        {
                            contador          = contador + 2;
                            Semanas.FechaDias = DateSelected.Date.AddDays(contador - difDias).ToString().Remove(10);
                        }
                        else
                        {
                            Semanas.FechaDias = DateSelected.Date.AddDays(contador - difDias).ToString().Remove(10);
                        }
                    }
                    contador++;
                    Semanas.IsEnabled          = true;
                    Semanas.SemanasNumero      = i.ToString();
                    Semanas.SemanasDiasCalculo = SemanasDiasCalculo.Replace("s", "");
                    productoA.Semanas.Add(Semanas);
                }

                //Bloqueo de días anteriores a los permitidos por la fecha de fabricación
                if (DateSelected.Date == DateTime.Today)
                {
                    for (int i = 0; i < TiempoFabricacionTotal(); i++)
                    {
                        productoA.Semanas[i].IsEnabled = false;
                    }
                }
                if (DateSelected.Date != DateTime.Today)
                {
                    for (int i = 0; i < difDias; i++)
                    {
                        productoA.Semanas[i].IsEnabled = false;
                    }
                }

                IsEnabled = true;
            }
            SemanasCollection = new ObservableCollection <SemanasA>(ProductoPrincipal.Productos[0].Semanas);
        }
Exemple #2
0
        async void Guardar()
        {
            IsEnabled = false;

            #region Eleazar
            var fecha = DateSelected.ToString("dd/MM/yyyy");

            if (string.IsNullOrEmpty(ApellidoUno) || string.IsNullOrEmpty(ApellidoDos) || string.IsNullOrEmpty(Nombres) || string.IsNullOrEmpty(Cedula) ||
                string.IsNullOrEmpty(fecha) || string.IsNullOrEmpty(Edad))
            {
                await Application.Current.MainPage.DisplayAlert("Error", "Llene los campos obligatorios", "aceptar");

                IsEnabled = true;
                return;
            }
            #endregion

            #region Miranda: Guardar Tabla

            #region Limpiar Cache //borrar los datos existentes en persistencia

            if (Application.Current.Properties.ContainsKey("ContadorContacto"))
            {
                Elementos = int.Parse((Application.Current.Properties["ContadorContacto"]) as string);
            }
            else
            {
                Elementos = 0;
            }
            for (int j = 0; j < Elementos; j++) //Elementos va a representar el total de elementos o filas existentes en mi persistencia
            {
                if (Application.Current.Properties.ContainsKey("TipoContacto" + j))
                {
                    Application.Current.Properties.Remove("TipoContacto" + j);
                }
                if (Application.Current.Properties.ContainsKey("Detalle" + j))
                {
                    Application.Current.Properties.Remove("Detalle" + j);
                }
                if (Application.Current.Properties.ContainsKey("NombreContacto" + j))
                {
                    Application.Current.Properties.Remove("NombreContacto" + j);
                }
                if (Application.Current.Properties.ContainsKey("ContadorContacto"))
                {
                    Application.Current.Properties.Remove("ContadorContacto");
                }
            }

            #endregion

            #region Ciclo para Guardar en Persistencia
            i = 0; //inicio el contador de mis elementos o filas en (0)
            foreach (var contact in Contactos)
            {
                Application.Current.Properties["NombreContacto" + i] = contact.NombreContacto.ToString();
                Application.Current.Properties["TipoContacto" + i]   = contact.TipoContacto.ToString();
                Application.Current.Properties["Detalle" + i]        = contact.DetalleContacto.ToString();
                i++;
                Application.Current.Properties["ContadorContacto"] = i.ToString();
                await Application.Current.SavePropertiesAsync();
            }

            #endregion

            int filas;
            HeighListView = 44 * i;
            if (Application.Current.Properties.ContainsKey("ContadorContacto"))
            {
                filas = int.Parse(Application.Current.Properties["ContadorContacto"] as string);
            }
            else
            {
                filas = 0;
            }
            await Application.Current.MainPage.DisplayAlert("Notificación", "El Numero de Filas Guardadas es: " + filas.ToString(), "Excelente");

            IsEnabled = true;

            #endregion

            /*
             * await Application.Current.MainPage.DisplayAlert(
             *  "Hola",
             *  ApellidoUno + " " + ApellidoDos + " " + Nombres + " " + CodigoFloraNueva + " " + Sexo + " " + Cedula + " " + Edad + " " + EstadoCivil + " " + GrupoEtnico,
             *  "Aceptar"); */
        }