Exemple #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            using (UIScrollView scrollView = new UIScrollView(new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height)))
            {
                foreach (MembresiaModel membresia in new PickerItemsController().GetMembresias())
                {
                    double subtotal = membresia.Membresia_Precio_Base;

                    Membresias.Add(membresia.Membresia_Id, new CarritoModel
                    {
                        Membresia_Cantidad = 0,
                        Sucursal_Id        = 0
                    });
                    if (Carrito.ContainsKey(membresia.Membresia_Id))
                    {
                        if (DateTime.Parse(Carrito[membresia.Membresia_Id].Membresia_Fecha_Inicio) >= DateTime.Now)
                        {
                            Membresias[membresia.Membresia_Id].Membresia_Cantidad     = (int)Carrito[membresia.Membresia_Id].Membresia_Cantidad;
                            Membresias[membresia.Membresia_Id].Sucursal_Id            = Carrito[membresia.Membresia_Id].Sucursal_Id;
                            Membresias[membresia.Membresia_Id].Membresia_Fecha_Inicio = Carrito[membresia.Membresia_Id].Membresia_Fecha_Inicio;
                            CanPay = true;
                        }
                    }

                    scrollView.AddSubview(new STLLine(size));

                    size += 10;

                    UILabel lblMembresia = new STLLabel(membresia.Membresia_Descripcion, size, 14)
                    {
                        Frame = new CGRect(10, size, UIScreen.MainScreen.Bounds.Width / 2 + 30, 30),
                        Text  = membresia.Membresia_Descripcion
                    };
                    scrollView.AddSubview(lblMembresia);
                    UITextField txtCantidad = new UITextField
                    {
                        Text         = Membresias[membresia.Membresia_Id].Membresia_Cantidad.ToString(),
                        Frame        = new CGRect(UIScreen.MainScreen.Bounds.Width - 120, size, 30, 30),
                        Font         = UIFont.SystemFontOfSize(14),
                        KeyboardType = UIKeyboardType.NumberPad
                    };

                    scrollView.AddSubview(txtCantidad);
                    UIStepper stpMembresia = new UIStepper
                    {
                        Frame        = new CGRect(UIScreen.MainScreen.Bounds.Width - 100, size, 55, 30),
                        Value        = Membresias[membresia.Membresia_Id].Membresia_Cantidad,
                        MaximumValue = Convert.ToDouble(membresia.Membresia_Espacios_Disponibles)
                    };

                    scrollView.AddSubview(stpMembresia);
                    size += 45;
                    ///
                    scrollView.AddSubview(new STLLabel("Tarifa Mensual", size));
                    scrollView.AddSubview(new STLLabel(membresia.Membresia_Precio_Base.ToString("C"))
                    {
                        Frame = new CGRect(UIScreen.MainScreen.Bounds.Width * 2 / 3, size, UIScreen.MainScreen.Bounds.Width / 4, 30)
                    });
                    size += 45;
                    scrollView.AddSubview(new STLLabel("Tarifa Inscripción", size));
                    scrollView.AddSubview(new STLLabel(membresia.Inscripcion_Precio_Base.ToString("C"))
                    {
                        Frame = new CGRect(UIScreen.MainScreen.Bounds.Width * 2 / 3, size, UIScreen.MainScreen.Bounds.Width / 4, 30)
                    });
                    ///
                    size += 45;
                    UITextField txtSucursal = new STLTextField("Sucursal", size)
                    {
                        Text = Carrito.ContainsKey(membresia.Membresia_Id) ? Carrito[membresia.Membresia_Id].Sucursal_Descripcion : ""
                    };
                    txtSucursal.EditingDidBegin += (sender, e) =>
                    {
                        selectView = new UIDropdownList(txtSucursal, View);
                    };
                    txtSucursal.EditingDidEnd += (sender, e) =>
                    {
                        Membresias[membresia.Membresia_Id].Sucursal_Id = new SucursalController().GetSucursalId(txtSucursal.Text);
                        selectView.RemoveFromSuperview();
                    };
                    scrollView.AddSubview(txtSucursal);
                    size += 40;
                    scrollView.AddSubview(new STLLabel("Fecha de Inicio", size, 14));
                    size += 30;

                    UIDatePicker dpFechaInicio = new UIDatePicker
                    {
                        Mode        = UIDatePickerMode.Date,
                        Frame       = new CGRect(40, size, UIScreen.MainScreen.Bounds.Width - 80, 100),
                        Date        = !string.IsNullOrEmpty(Membresias[membresia.Membresia_Id].Membresia_Fecha_Inicio) ? (NSDate)DateTime.SpecifyKind(DateTime.Parse(Membresias[membresia.Membresia_Id].Membresia_Fecha_Inicio), DateTimeKind.Utc) : (NSDate)DateTime.Now,
                        MinimumDate = (NSDate)DateTime.Now
                    };

                    scrollView.Add(dpFechaInicio);
                    size += 100;
                    /////
                    UILabel lblMeses = new STLLabel("Cantidad de meses", size, 14);
                    scrollView.AddSubview(lblMeses);
                    UITextField txtMesesCantidad = new UITextField
                    {
                        Text         = "1",
                        Frame        = new CGRect(UIScreen.MainScreen.Bounds.Width - 120, size, 30, 30),
                        Font         = UIFont.SystemFontOfSize(14),
                        KeyboardType = UIKeyboardType.NumberPad
                    };

                    scrollView.AddSubview(txtMesesCantidad);
                    UIStepper stpMesesMembresia = new UIStepper
                    {
                        Frame        = new CGRect(UIScreen.MainScreen.Bounds.Width - 100, size, 55, 30),
                        MinimumValue = 1
                    };

                    scrollView.AddSubview(stpMesesMembresia);
                    UILabel lblProporcional = new STLLabel(subtotal.ToString("C")), lblTotal = new STLLabel((membresia.Membresia_Precio_Base * stpMesesMembresia.Value).ToString("C"));
                    stpMesesMembresia.ValueChanged += (sender, e) =>
                    {
                        txtMesesCantidad.Text = stpMesesMembresia.Value.ToString();
                        lblTotal.Text         = (((membresia.Membresia_Precio_Base * (Convert.ToDouble(txtMesesCantidad.Text) - 1)) + subtotal + (membresia.Inscripcion_Precio_Base * (Convert.ToDouble(txtMesesCantidad.Text) - 1))) * Convert.ToDouble(txtCantidad.Text)).ToString("C");
                    };
                    txtMesesCantidad.EditingChanged += (sender, e) =>
                    {
                        if (!string.IsNullOrEmpty(txtMesesCantidad.Text) || txtMesesCantidad.Text != "0")
                        {
                            lblTotal.Text = (((membresia.Membresia_Precio_Base * (Convert.ToDouble(txtMesesCantidad.Text) - 1)) + subtotal + (membresia.Inscripcion_Precio_Base * (Convert.ToDouble(txtMesesCantidad.Text) - 1))) * Convert.ToDouble(txtCantidad.Text)).ToString("C");
                        }
                    };
                    size += 45;
                    scrollView.AddSubview(new STLLabel("Proporcional al mes", size));
                    subtotal = (membresia.Membresia_Precio_Base / DateHelper.GetMonthsDays((DateTime)dpFechaInicio.Date) *
                                (DateHelper.GetMonthsDays((DateTime)dpFechaInicio.Date) - ((DateTime)dpFechaInicio.Date).Day + 1));
                    lblTotal.Text        = (((membresia.Membresia_Precio_Base * (Convert.ToDouble(txtMesesCantidad.Text) - 1)) + subtotal + (membresia.Inscripcion_Precio_Base * (Convert.ToDouble(txtMesesCantidad.Text) - 1))) * Convert.ToDouble(txtCantidad.Text)).ToString("C");
                    lblProporcional.Text = (subtotal * Convert.ToDouble(txtCantidad.Text)).ToString("C");

                    lblProporcional.Frame      = new CGRect(UIScreen.MainScreen.Bounds.Width * 2 / 3, size, UIScreen.MainScreen.Bounds.Width / 4, 30);
                    stpMembresia.ValueChanged += (sender, e) =>
                    {
                        txtCantidad.Text = stpMembresia.Value.ToString();
                        Membresias[membresia.Membresia_Id].Membresia_Cantidad = (int)stpMembresia.Value;
                        CanPay  = (stpMembresia.Value > 0);
                        Changed = CanPay;
                        double EndMonth   = DateHelper.GetMonthsDays((DateTime)dpFechaInicio.Date);
                        double currentDay = ((DateTime)dpFechaInicio.Date).Day;
                        subtotal             = Convert.ToInt32(txtCantidad.Text) == 0 ? 0 : (membresia.Membresia_Precio_Base / EndMonth * (EndMonth - currentDay + 1));
                        lblProporcional.Text = subtotal.ToString("C");
                        lblTotal.Text        = (((membresia.Membresia_Precio_Base * (Convert.ToDouble(txtMesesCantidad.Text) - 1)) + subtotal + (membresia.Inscripcion_Precio_Base * (Convert.ToDouble(txtMesesCantidad.Text) - 1))) * Convert.ToDouble(txtCantidad.Text)).ToString("C");
                    };
                    txtCantidad.EditingChanged += (sender, e) =>
                    {
                        if (!string.IsNullOrEmpty(txtCantidad.Text))
                        {
                            if (Convert.ToDouble(txtCantidad.Text) > Convert.ToDouble(membresia.Membresia_Espacios_Disponibles))
                            {
                                new MessageDialog().SendMessage("Tamaño de " + membresia.Membresia_Descripcion, "Superaste el tamaño permitido");
                                txtCantidad.Text = membresia.Membresia_Espacios_Disponibles;
                            }
                            double EndMonth   = DateHelper.GetMonthsDays((DateTime)dpFechaInicio.Date);
                            double currentDay = ((DateTime)dpFechaInicio.Date).Day;
                            subtotal             = Convert.ToInt32(txtCantidad.Text) == 0 ? 0 : (membresia.Membresia_Precio_Base / EndMonth * (EndMonth - currentDay + 1));
                            lblProporcional.Text = subtotal.ToString("C");
                            lblTotal.Text        = (((membresia.Membresia_Precio_Base * (Convert.ToDouble(txtMesesCantidad.Text) - 1)) + subtotal + (membresia.Inscripcion_Precio_Base * (Convert.ToDouble(txtMesesCantidad.Text) - 1))) * Convert.ToDouble(txtCantidad.Text)).ToString("C");
                            stpMembresia.Value   = Convert.ToDouble(txtCantidad.Text);
                            Membresias[membresia.Membresia_Id].Membresia_Cantidad = (int)stpMembresia.Value;
                            CanPay  = (stpMembresia.Value > 0);
                            Changed = CanPay;
                        }
                    };
                    txtMesesCantidad.EditingChanged += (sender, e) =>
                    {
                        if (!string.IsNullOrEmpty(txtMesesCantidad.Text))
                        {
                            if (Convert.ToInt32(txtMesesCantidad.Text) < 1)
                            {
                                new MessageDialog().SendMessage("La cantidad de meses a contratar debe ser mínimo 1", "Meses de membresias");
                                txtMesesCantidad.Text = "1";
                            }
                            double EndMonth   = DateHelper.GetMonthsDays((DateTime)dpFechaInicio.Date);
                            double currentDay = ((DateTime)dpFechaInicio.Date).Day;
                            subtotal                = Convert.ToInt32(txtMesesCantidad.Text) == 0 ? 0 : (membresia.Membresia_Precio_Base / EndMonth * (EndMonth - currentDay + 1));
                            lblProporcional.Text    = subtotal.ToString("C");
                            lblTotal.Text           = (((membresia.Membresia_Precio_Base * (Convert.ToDouble(txtMesesCantidad.Text) - 1)) + subtotal + (membresia.Inscripcion_Precio_Base * (Convert.ToDouble(txtMesesCantidad.Text) - 1))) * Convert.ToDouble(txtCantidad.Text)).ToString("C");
                            stpMesesMembresia.Value = Convert.ToDouble(txtMesesCantidad.Text);
                            Membresias[membresia.Membresia_Id].Membresia_Cantidad = (int)stpMesesMembresia.Value;
                            CanPay  = (stpMesesMembresia.Value > 0);
                            Changed = CanPay;
                        }
                    };
                    dpFechaInicio.ValueChanged += (sender, e) =>
                    {
                        double EndMonth   = DateHelper.GetMonthsDays(((DateTime)(((UIDatePicker)sender).Date)));
                        double currentDay = ((DateTime)(((UIDatePicker)sender).Date)).Day;
                        subtotal             = Convert.ToInt32(txtCantidad.Text) == 0 ? 0 : (membresia.Membresia_Precio_Base / EndMonth * (EndMonth - currentDay + 1));
                        lblProporcional.Text = subtotal.ToString("C");
                        lblTotal.Text        = (((membresia.Membresia_Precio_Base * (Convert.ToDouble(txtMesesCantidad.Text) - 1)) + subtotal + (membresia.Inscripcion_Precio_Base * (Convert.ToDouble(txtMesesCantidad.Text) - 1))) * Convert.ToDouble(txtCantidad.Text)).ToString("C");
                    };
                    scrollView.AddSubview(lblProporcional);
                    size += 45;
                    scrollView.AddSubview(new STLLabel("Total", size));
                    lblTotal.Frame = new CGRect(UIScreen.MainScreen.Bounds.Width * 2 / 3, size, UIScreen.MainScreen.Bounds.Width / 4, 30);
                    scrollView.AddSubview(lblTotal);
                    ///
                    size += 45;
                }
                scrollView.ContentSize = new CGSize(UIScreen.MainScreen.Bounds.Width, size + 30);
                View.AddSubview(scrollView);
            }
            NavigationItem.SetRightBarButtonItem(new UIBarButtonItem(UIImage.FromBundle("ic_shopping_cart"), UIBarButtonItemStyle.Plain, (sender, e) =>
            {
                if (CanPay)
                {
                    if (new CarritoController().AddCarrito(Membresias, TiposServicios.Membresia, KeyChainHelper.GetKey("Usuario_Id")))
                    {
                        CarritoCompraController controller = (CarritoCompraController)Storyboard.InstantiateViewController("CarritoCompraController");
                        controller.Title = "Confirmación de compra";
                        NavigationController.PushViewController(controller, true);
                    }
                    else
                    {
                        new MessageDialog().SendMessage("Debe de seleccionar alguna sucursal", "Aviso");
                    }
                }
                else
                {
                    new MessageDialog().SendMessage("Debe de seleccionar alguna membresía", "Aviso");
                }
            }), true);
            NavigationItem.SetLeftBarButtonItem(new UIBarButtonItem(UIBarButtonSystemItem.Cancel, (sender, e) =>
            {
                if (Changed)
                {
                    if (new CarritoController().AddCarrito(Membresias, TiposServicios.Membresia, KeyChainHelper.GetKey("Usuario_Id")))
                    {
                        NavigationController.PopViewController(true);
                    }
                    else
                    {
                        new MessageDialog().SendMessage("Debe de seleccionar alguna sucursal", "Aviso");
                    }
                }
                else
                {
                    NavigationController.PopViewController(true);
                }
            }), true);
        }
Exemple #2
0
        /// <summary>
        /// Vista de la busqueda
        /// </summary>
        void SearchView()
        {
            UITextField txtNombre = new STLTextField("Nombre", 130);

            txtPais = new STLTextField("País", 190);
            txtPais.EditingDidBegin += (sender, e) =>
            {
                selectView = new UIDropdownList(txtPais, View);
            };
            txtPais.EditingDidEnd += (sender, e) =>
            {
                selectView.RemoveFromSuperview();
            };
            txtEstado = new STLTextField("Estado", 250);
            txtEstado.EditingDidBegin += (sender, e) =>
            {
                if (!string.IsNullOrEmpty(txtPais.Text))
                {
                    selectView = new UIDropdownList(txtEstado, View, txtPais.Text);
                }
            };
            txtEstado.EditingDidEnd += (sender, e) =>
            {
                if (!string.IsNullOrEmpty(txtPais.Text))
                {
                    selectView.RemoveFromSuperview();
                }
            };
            txtMunicipio = new STLTextField("Municipio", 310);
            txtMunicipio.EditingDidBegin += (sender, e) =>
            {
                if (!string.IsNullOrEmpty(txtEstado.Text))
                {
                    selectView = new UIDropdownList(txtMunicipio, View, txtEstado.Text);
                }
            };
            txtMunicipio.EditingDidEnd += (sender, e) =>
            {
                if (!string.IsNullOrEmpty(txtEstado.Text))
                {
                    selectView.RemoveFromSuperview();
                }
            };
            txtGiro = new STLTextField("Giro", 370);
            txtGiro.EditingDidBegin += (sender, e) =>
            {
                selectView = new UIDropdownList(txtGiro, View);
            };
            txtGiro.EditingDidEnd += (sender, e) =>
            {
                selectView.RemoveFromSuperview();
            };

            UIButton btnBuscar = new STLButton("Buscar")
            {
                Frame = new CGRect(20, 400, 100, 30)
            };

            btnBuscar.TouchUpInside += (sender, e) =>
            {
                position = 32;
                FillData(txtNombre.Text, txtPais.Text, txtEstado.Text, txtMunicipio.Text, txtGiro.Text);
                searchView.RemoveFromSuperview();
                selectView.RemoveFromSuperview();
            };

            UIButton btnClose = new STLButton(UIImage.FromBundle("ic_clear"))
            {
                Frame = new CGRect(UIScreen.MainScreen.Bounds.Width - 40, 70, 30, 30)
            };

            btnClose.Layer.CornerRadius = 15;
            btnClose.TouchUpInside     += (sender, e) =>
            {
                searchView.RemoveFromSuperview();
            };
            searchView = new UIScrollView(new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height))
            {
                btnClose,

                new STLLabel("Nombre", 100),
                txtNombre,

                new STLLabel("País", 160),
                txtPais,

                new STLLabel("Estado", 220),
                txtEstado,

                new STLLabel("Municipio", 280),
                txtMunicipio,

                new STLLabel("Giro", 340),
                txtGiro,

                btnBuscar
            };
            searchView.BackgroundColor = UIColor.White;

            searchView.ContentSize = new CGSize(UIScreen.MainScreen.Bounds.Width, 500);

            View.AddSubview(searchView);
        }
Exemple #3
0
        void SearchView()
        {
            UITextField txtNombre      = new STLTextField("Nombre", 30);
            UITextField txtApellidos   = new STLTextField("Apellidos", 90);
            UITextField txtPuesto      = new STLTextField("Puesto", 150);
            UITextField txtProfesion   = new STLTextField("Profesión", 210);
            UITextField txtHabilidades = new STLTextField("Habilidades", 270);
            UITextField txtPais        = new STLTextField("País", 330);

            txtPais.EditingDidBegin += (sender, e) =>
            {
                selectView = new UIDropdownList(txtPais, View);
            };
            txtPais.EditingDidEnd += (sender, e) =>
            {
                selectView.RemoveFromSuperview();
            };
            UITextField txtEstado = new STLTextField("Estado", 390);

            txtEstado.EditingDidBegin += (sender, e) =>
            {
                if (!string.IsNullOrEmpty(txtPais.Text))
                {
                    selectView = new UIDropdownList(txtEstado, View, txtPais.Text);
                }
            };
            txtEstado.EditingDidEnd += (sender, e) =>
            {
                if (!string.IsNullOrEmpty(txtPais.Text))
                {
                    selectView.RemoveFromSuperview();
                }
            };
            UITextField txtMunicipio = new STLTextField("Municipio", 450);

            txtMunicipio.EditingDidBegin += (sender, e) =>
            {
                if (!string.IsNullOrEmpty(txtEstado.Text))
                {
                    selectView = new UIDropdownList(txtMunicipio, View, txtEstado.Text);
                }
            };
            txtMunicipio.EditingDidEnd += (sender, e) =>
            {
                if (!string.IsNullOrEmpty(txtEstado.Text))
                {
                    selectView.RemoveFromSuperview();
                }
            };
            UITextField txtEmpresa       = new STLTextField("Empresa", 510);
            UICheckBox  cbDisponibilidad = new UICheckBox(20, 550, true);


            UIButton btnBuscar = new STLButton("Buscar")
            {
                Frame = new CGRect(20, 580, 100, 30)
            };

            btnBuscar.TouchUpInside += (sender, e) =>
            {
                position = 0;
                FillData(txtNombre.Text, txtApellidos.Text, txtPuesto.Text, txtProfesion.Text, txtHabilidades.Text, cbDisponibilidad.IsChecked, txtPais.Text, txtEstado.Text, txtMunicipio.Text);
                searchView.RemoveFromSuperview();
            };

            UIButton btnClose = new STLButton(UIImage.FromBundle("ic_clear"))
            {
                Frame = new CGRect(UIScreen.MainScreen.Bounds.Width - 40, 0, 30, 30)
            };

            btnClose.TouchUpInside += (sender, e) =>
            {
                searchView.RemoveFromSuperview();
            };
            searchView = new UIScrollView(new CGRect(0, 70, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height))
            {
                btnClose,

                new STLLabel("Nombre", 0),
                txtNombre,

                new STLLabel("Apellidos", 60),
                txtApellidos,

                new STLLabel("Puesto", 120),
                txtPuesto,

                new STLLabel("Profesión", 180),
                txtProfesion,

                new STLLabel("Habilidades", 240),
                txtHabilidades,

                new STLLabel("País", 300),
                txtPais,

                new STLLabel("Estado", 360),
                txtEstado,

                new STLLabel("Municipio", 420),
                txtMunicipio,

                new STLLabel("Empresa", 480),
                txtEmpresa,

                new STLLabel("Disponibilidad", 545)
                {
                    Frame = new CGRect(50, 545, UIScreen.MainScreen.Bounds.Width, 30)
                },
                cbDisponibilidad,

                btnBuscar
            };
            searchView.BackgroundColor = UIColor.White;

            searchView.ContentSize = new CGSize(UIScreen.MainScreen.Bounds.Width, 780);

            View.AddSubview(searchView);
        }