partial void Done(NSObject sender)
        {
            var selectedDate = DateTime.SpecifyKind((DateTime)DatePicker.Date, DateTimeKind.Utc).ToLocalTime();

            DateSelected?.Invoke(this, selectedDate);
            Close();
        }
 public void OnDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth)
 {
     SelectedDate = new DateTime(year, monthOfYear + 1, dayOfMonth);
     if (DisplayText != null)
     {
         DisplayText.Text = SelectedDate.Value.ToString(DateFormat ?? DefaultDateFormat);
     }
     DateSelected?.Invoke(this, SelectedDate.Value);
 }
Пример #3
0
 public void OnDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth)
 {
     if (DateSelected != null)
     {
         DateSelected.Invoke
         (
             new DateTime(year, monthOfYear + 1, dayOfMonth)
             , EventArgs.Empty
         );
     }
 }
Пример #4
0
        public MauiTimePicker(Action dateSelected)
        {
            BorderStyle = UITextBorderStyle.RoundedRect;

            _picker = new UIDatePicker {
                Mode = UIDatePickerMode.Time, TimeZone = new NSTimeZone("UTC")
            };
            _dateSelected = dateSelected;

            if (PlatformVersion.IsAtLeast(14))
            {
                _picker.PreferredDatePickerStyle = UIDatePickerStyle.Wheels;
            }

            var width   = UIScreen.MainScreen.Bounds.Width;
            var toolbar = new UIToolbar(new RectangleF(0, 0, width, 44))
            {
                BarStyle = UIBarStyle.Default, Translucent = true
            };
            var spacer = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);

            var doneButton = new UIBarButtonItem(UIBarButtonSystemItem.Done, (o, a) =>
            {
                DateSelected?.Invoke(this, EventArgs.Empty);
                _dateSelected?.Invoke();
            });

            toolbar.SetItems(new[] { spacer, doneButton }, false);

            InputView          = _picker;
            InputAccessoryView = toolbar;

            InputView.AutoresizingMask          = UIViewAutoresizing.FlexibleHeight;
            InputAccessoryView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight;

            InputAssistantItem.LeadingBarButtonGroups  = null;
            InputAssistantItem.TrailingBarButtonGroups = null;

            AccessibilityTraits = UIAccessibilityTrait.Button;
        }
Пример #5
0
        public MauiTimePicker()
#endif
        {
            BorderStyle = UITextBorderStyle.RoundedRect;

            _picker = new UIDatePicker {
                Mode = UIDatePickerMode.Time, TimeZone = new NSTimeZone("UTC")
            };

#if !MACCATALYST
            _dateSelected = dateSelected;
#endif

            if (OperatingSystem.IsIOSVersionAtLeast(14))
            {
                _picker.PreferredDatePickerStyle = UIDatePickerStyle.Wheels;
            }

            InputView = _picker;

#if !MACCATALYST
            InputAccessoryView = new MauiDoneAccessoryView(() =>
            {
                DateSelected?.Invoke(this, EventArgs.Empty);
                _dateSelected?.Invoke();
            });

            InputAccessoryView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight;
#endif

            InputView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight;

            InputAssistantItem.LeadingBarButtonGroups  = null;
            InputAssistantItem.TrailingBarButtonGroups = null;

            AccessibilityTraits = UIAccessibilityTrait.Button;
        }
Пример #6
0
        public async void CalendarDateSelected(object s, EventArgs e)
        {
            var sl = s as CustomCalendarStackLayout;

            if (selectedLayout != null)
            {
                ClearPreviousSelected(selectedLayout);
            }
            selectedLayout     = sl;
            sl.BackgroundColor = selectedDateColor;
            switch (sl.dateType)
            {
            case GlobalVar.MonthView:
                selectedDate = sl.dateTime;
                DateSelected?.Invoke(this, selectedDate);
                await Navigation.PopModalAsync(false);

                break;

            case GlobalVar.YearView:
                MonthLayout(sl.DateTimeInfo);
                break;
            }
        }
 public DatePickerFragment(EditText displayText, Android.Support.V4.App.FragmentManager fragmentManager)
 {
     DisplayText              = displayText;
     DisplayText.TextChanged += (o, e) =>
     {
         try
         {
             String curDateString = DisplayText.Text.Trim();
             String format        = "";
             if (Regex.IsMatch(curDateString, "\\d{2}(\\/|-)[a-zA-Z]{3}(\\/|-)\\d{4}"))
             {
                 format = "dd/MMM/yyy";
             }
             else if (Regex.IsMatch(curDateString, "\\d{2}(\\/|-)\\d{2}(\\/|-)\\d{4}"))
             {
                 format = "dd/MM/yyy";
             }
             else
             {
                 return;
             }
             DateTime curDate = DateTime.Parse(curDateString);
             if (SelectedDate != null && curDate == SelectedDate)
             {
                 return;
             }
             SelectedDate     = curDate;
             DisplayText.Text = curDate.ToString(DefaultDateFormat);
             DateSelected?.Invoke(this, SelectedDate.Value);
         }
         catch (Exception)
         {
         }
     };
     DisplayText.Click += (o, e) => Show(fragmentManager, TAG);
 }
Пример #8
0
 public void NotifyDateSelected(DateTime dateSelected)
 {
     DateSelected?.Invoke(this, dateSelected);
 }
Пример #9
0
 private void DatePickerDateSelected(object sender, DateChangedEventArgs args)
 {
     DateSelected?.Invoke(sender, args);
 }
Пример #10
0
 void ActionButton_TouchUpInside(object sender, EventArgs e)
 {
     DateSelected?.Invoke(_datePicker.Date.ToDateTime());
 }
Пример #11
0
 private void button1_Click(object sender, EventArgs e)
 {
     DateSelected?.Invoke(this, new DateSelectedArgs {
         BeginDate = beginPicker.Value, EndDate = endPicker.Value
     });
 }
Пример #12
0
 protected virtual void OnDateSelection(DateSelectedEventArgs e)
 {
     DateSelected?.Invoke(this, e);
 }
Пример #13
0
        //Càlculo del MRP con las semanas o días definidos
        private async void Calcular()
        {
            foreach (var productoA in ProductoPrincipal.Productos)
            {
                if (productoA.Cantidad == null)
                {
                    productoA.Cantidad = 1.ToString();
                }

                if (productoA.InventarioInicial == null || string.IsNullOrEmpty(productoA.InventarioInicial))
                {
                    productoA.InventarioInicial = 0.ToString();
                }

                else if (ProductoPrincipal.Productos[0].Semanas.All(x => x.ReqBruto == null))
                {
                    await dialogService.ShowMessage("Error", "Al menos un campo con requerimiento bruto debe contener un valor mayor a cero"
                                                    );

                    return;
                }
                else
                {
                    foreach (var list in productoA.Semanas.Where(x => x.ReqBruto == null).ToList())
                    {
                        list.ReqBruto = 0.ToString();
                    }
                    IsVisiblePropiedad = false;
                }
                var difDias = 0;
                difDias = DateSelected.DayOfYear - DateTime.Today.DayOfYear;
                for (int i = 0; i < int.Parse(CantSemanas) + difDias; i++)
                {
                    //calculo primer dia

                    if (productoA.Dependencia != "0")
                    {
                        //Busca el producto con el mismo nombre que la dependencia
                        var libOrden = ProductoPrincipal.Productos.Find(x => x.Nombres == productoA.Dependencia);
                        productoA.Semanas[i].ReqBruto = libOrden.Semanas[i].LibOrden;
                    }
                    if (string.IsNullOrEmpty(productoA.Semanas[i].ReqBruto))
                    {
                        productoA.Semanas[i].ReqBruto = 0.ToString();
                    }
                    productoA.Semanas[i].ReqBruto          = (int.Parse(productoA.Semanas[i].ReqBruto) * int.Parse(productoA.Cantidad)).ToString();
                    productoA.Semanas[i].InventarioInicial = productoA.InventarioInicial;
                    productoA.Semanas[i].ReqNeto           = (int.Parse(productoA.Semanas[i].ReqBruto) - int.Parse(productoA.Semanas[i].InventarioInicial)).ToString();
                    if (int.Parse(productoA.Semanas[i].ReqNeto) <= 0)
                    {
                        productoA.Semanas[i].ReqNeto = 0.ToString();
                    }
                    productoA.Semanas[i].InvFinal = (int.Parse(productoA.Semanas[i].InventarioInicial) - int.Parse(productoA.Semanas[i].ReqBruto)).ToString();


                    if (int.Parse(productoA.Semanas[i].InvFinal) < 0)
                    {
                        //Index para ubicar en la lista el objeto guardado donde se tiene que hacer el pedido

                        Index = i - int.Parse(productoA.TiempoFabricacion);

                        //liberación de la orden
                        productoA.Semanas[Index].LibOrden      = productoA.Semanas[i].ReqNeto;
                        productoA.Semanas[Index].IsVisibleDate = true;
                        if (SemanasDias == false)
                        {
                            //Calculo de la fecha donde se debe realizar el pedido
                            productoA.Semanas[Index].DateSelectedLibOrden = DateSelected.Date.AddDays(Index).ToString().Remove(10);
                        }
                        else
                        {
                            productoA.Semanas[Index].DateSelectedLibOrden = DateSelected.AddDays(Index * 7).ToString().Remove(10);
                        }
                        productoA.Semanas[i].InvFinal = (int.Parse(productoA.Semanas[i].InventarioInicial) + int.Parse(productoA.Semanas[Index].LibOrden) - int.Parse(productoA.Semanas[i].ReqBruto)).ToString();
                    }



                    ProductoPrincipal.Calculo = true;
                }
            }
            foreach (var productoA in ProductoPrincipal.Productos)
            {
                dataService.Delete(productoA);
                dataService.Insert(productoA, true);
            }

            dataService.Update(ProductoPrincipal, true);
            SemanasCollection = new ObservableCollection <SemanasA>(ProductoPrincipal.Productos[0].Semanas);
            IsEnabled         = false;
            VisibleReCalcular = true;
        }
Пример #14
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);
        }
 public void NotifyDateSelected(DateTime dateSelected)
 {
     DateSelected.Dispatch(this, dateSelected);
 }
Пример #16
0
        public IList <AlertEntity> GetTable2(params String[] s)
        {
            DateSelected = DateSelected.AddDays(1).AddHours(-1);
            IAsyncResult ar1 = d1.BeginInvoke(null, null);
            IAsyncResult ar2 = d2.BeginInvoke(null, null);
            IAsyncResult ar3 = d3.BeginInvoke(null, null);

            while (!ar1.IsCompleted && !ar2.IsCompleted && !ar3.IsCompleted)
            {
                Thread.Sleep(50);                                                              //wait
            }
            IList <AlertTempEntity> l1 = d1.EndInvoke(ar1);
            IList <AlertTempEntity> l2 = d2.EndInvoke(ar2);
            IList <AlertTempEntity> l3 = d3.EndInvoke(ar3);
            IList <AlertTempEntity> l4 = new List <AlertTempEntity>();



            foreach (AlertTempEntity AmntRes in l3)
            {
                int AmtResCi = l2.Where(p => p.rsTime <= AmntRes.rsTime &&
                                        p.rentLoc == AmntRes.rentLoc && p.crGrp == AmntRes.crGrp).Sum(p => p.Amnt);
                int AmntFea = l1.Where(p => p.rsTime <= AmntRes.rsTime &&
                                       p.rentLoc == AmntRes.rentLoc && p.crGrp == AmntRes.crGrp).Sum(p => p.Amnt);

                if ((AmntFea - AmntRes.Amnt + AmtResCi) < 0)
                {
                    l4.Add(new AlertTempEntity
                    {
                        rsTime  = AmntRes.rsTime,
                        crGrp   = AmntRes.crGrp,
                        rentLoc = AmntRes.rentLoc,
                        Amnt    = AmntFea + AmtResCi - AmntRes.Amnt
                    });
                }
            }
            l4 = l4.OrderBy(d => d.Amnt).ThenBy(d => d.rentLoc).ThenBy(d => d.crGrp).ToList();
            AlertEntity[] ax = _alertsRetQ.GetQueryable(l4).ToArray();

            var lx = new List <AlertEntity>();

            String[] a1 = ax.Where(p => !String.IsNullOrEmpty(p.NextHour)).Select(p => p.NextHour).ToArray();
            String[] a2 = ax.Where(p => !String.IsNullOrEmpty(p.Follow4Hours)).Select(p => p.Follow4Hours).ToArray();
            String[] a3 = ax.Where(p => !String.IsNullOrEmpty(p.RestOfDay)).Select(p => p.RestOfDay).ToArray();
            String[] a4 = ax.Where(p => !String.IsNullOrEmpty(p.Custom)).Select(p => p.Custom).ToArray();

            Boolean b = true;

            Int32[] i = { 0, 0, 0, 0 };
            while (b)
            {
                string s1 = String.Empty, s2 = String.Empty, s3 = String.Empty, s4 = string.Empty;
                b = false;
                if (i[0] < a1.Length)
                {
                    s1 = a1[i[0]++];
                    b  = true;
                }
                if (i[1] < a2.Length)
                {
                    s2 = a2[i[1]++];
                    b  = true;
                }
                if (i[2] < a3.Length)
                {
                    s3 = a3[i[2]++];
                    b  = true;
                }
                if (i[3] < a4.Length)
                {
                    s4 = a4[i[3]++];
                    b  = true;
                }

                if (b)
                {
                    lx.Add(new AlertEntity
                    {
                        NextHour     = s1,
                        Follow4Hours = s2,
                        RestOfDay    = s3,
                        Custom       = s4,
                    });
                }
            }
            return(lx);
        }
Пример #17
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"); */
        }