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

            try{
                UIBarButtonItem home = new UIBarButtonItem();
                home.Style  = UIBarButtonItemStyle.Plain;
                home.Target = this;
                home.Image  = UIImage.FromFile("Images/home.png");
                this.NavigationItem.RightBarButtonItem = home;
                UIViewController[] vistas = NavigationController.ViewControllers;
                home.Clicked += (sender, e) => {
                    this.NavigationController.PopToViewController(vistas[0], true);
                };

                //Configuramos la vista popup de nueva lista
                NewListView.Layer.BorderWidth  = 1.0f;
                NewListView.Layer.BorderColor  = UIColor.Black.CGColor;
                NewListView.Layer.CornerRadius = 8;
                tblLists.Add(this.NewListView);
                NewListView.Hidden = true;
                //Configuramos la vista popup de cantidad
                QuantityView.Layer.BorderWidth  = 1.0f;
                QuantityView.Layer.BorderColor  = UIColor.Black.CGColor;
                QuantityView.Layer.CornerRadius = 8;
                this.Add(QuantityView);
                QuantityView.Hidden = true;

                //Configuramos la vista de popup de listas
                ListsView.Layer.BorderWidth  = 1.0f;
                ListsView.Layer.BorderColor  = UIColor.Black.CGColor;
                ListsView.Layer.CornerRadius = 8;
                this.Add(this.ListsView);
                ListsView.Hidden = true;

                if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
                {
                    this.btnMapa.SetBackgroundImage(Images.mapa, UIControlState.Normal);
                }
                else
                {
                    this.btnMapa.SetBackgroundImage(Images.mapa, UIControlState.Normal);
                }

                this.btnMapa.TouchUpInside += (sender, e) => {
                    SecondMapViewController mapView = new SecondMapViewController();
                    mapView.setTienda(this.producto);
                    NavigationController.PushViewController(mapView, true);
                };

                var documents = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                _pathToDatabase = Path.Combine(documents, "db_sqlite-net.db");

                //Hacemos la conexion a la bd para buscar si hay un usuario registrado
                using (var db = new SQLite.SQLiteConnection(_pathToDatabase))
                {
                    people = new List <Person> (from p in db.Table <Person> () select p);
                }

                NSUrl nsUrl = new NSUrl(producto.imagen);
                data = NSData.FromUrl(nsUrl);
                if (data != null)
                {
                    Images.imagenDetalle   = UIImage.LoadFromData(data);
                    this.imgProducto.Image = Images.imagenDetalle;
                }
                else
                {
                    this.imgProducto.Image = Images.sinImagen;
                }

                //Establecemos la informacion del producto
                this.lblNombre.Text = producto.nombre;
                double precio = Double.Parse(producto.precio);
                this.lblPrecio.Text      = precio.ToString("C2");
                this.lblDescripcion.Text = producto.descripcion;
                if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
                {
                    this.lblDescripcion.Font = UIFont.SystemFontOfSize(10);
                }
                else
                {
                    this.lblDescripcion.Font = UIFont.SystemFontOfSize(25);
                }
                //Establecemos la informacion de la tienda
                NSUrl  nsurl = new NSUrl(producto.tienda_imagen);
                NSData data1 = NSData.FromUrl(nsurl);
                if (data1 != null)
                {
                    Images.imagenDetalleTienda = UIImage.LoadFromData(data1);
                    this.imgTienda.Image       = Images.imagenDetalleTienda;
                }
                else
                {
                    this.imgTienda.Image = Images.sinImagen;
                }
                this.lblTiendaNombre.Text    = producto.tienda_nombre;
                this.lblTiendaDireccion.Text = producto.tienda_direccion + "\n \nTeléfono: " + producto.tienda_telefono;
                if (distancia != 0)
                {
                    this.lblTiendaDistancia.Text = "A " + Math.Round(distancia, 2) + "km de tu ubicación";
                }
                else
                {
                    this.lblTiendaDistancia.Text = "Distancia no disponible";
                }
                this.lblVigencia.Text = "Vigencia del " + producto.inicio_validez + " Al " + producto.final_validez;

                this.btnLista.TouchUpInside += (sender, e) => {
                    if (people.Count > 0)
                    {
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "Añadir a mi lista", Message = "¿Deseas añadir este producto a una de tus listas?"
                        };
                        alert.AddButton("Añadir");
                        alert.AddButton("Cancelar");
                        alert.Show();
                        alert.Clicked += (s, o) => {
                            if (o.ButtonIndex == 0)
                            {
                                QuantityView.Hidden = false;
                            }
                        };
                    }
                    else
                    {
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "Espera!", Message = "Debes iniciar sesión para acceder a tus listas"
                        };
                        alert.AddButton("Aceptar");
                        alert.Show();
                    }
                };

                int cantidad = 1;
                this.cmpCantidad.Text = cantidad.ToString();
                btnMas.TouchUpInside += (sender, e) => {
                    cantidad++;
                    this.cmpCantidad.Text = cantidad.ToString();
                };

                btnMenos.TouchUpInside += (sender, e) => {
                    cantidad--;
                    if (cantidad < 1)
                    {
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "Espera!", Message = "La cantidad minima es 1"
                        };
                        alert.AddButton("Aceptar");
                        alert.Show();
                        cantidad = 1;
                        this.cmpCantidad.Text = cantidad.ToString();
                    }
                    else
                    {
                        this.cmpCantidad.Text = cantidad.ToString();
                    }
                };

                this.btnAceptarCantidad.TouchUpInside += (sender, e) => {
                    try{
                        if (cmpCantidad.Text.Equals(""))
                        {
                            UIAlertView alert = new UIAlertView()
                            {
                                Title = "Espera!", Message = "Debes ingresar la cantidad"
                            };
                            alert.AddButton("Registrar");
                            alert.AddButton("Cancelar");
                            alert.Show();
                        }
                        else
                        {
                            cmpCantidad.ResignFirstResponder();
                            QuantityView.Hidden = true;
                            ls = new ListsService();
                            Person persona = people.ElementAt(0);
                            ls.setUserId(persona.ID.ToString());
                            List <ListsService> tableItems = ls.All();
                            if (tableItems.Count > 0)
                            {
                                this.tblLists.Source = new AddToListsTableSource(tableItems, this, this.producto, int.Parse(cmpCantidad.Text));
                                ListsView.Add(this.tblLists);
                                this.tblLists.ReloadData();
                                ListsView.Hidden = false;
                                cmpCantidad.Text = "";
                            }
                            else
                            {
                                UIAlertView alert = new UIAlertView()
                                {
                                    Title = "No tienes listas", Message = "No tienes listas registradas, porfavor ve a \"Mis listas\" para crear una nueva"
                                };
                                alert.AddButton("Registrar");
                                alert.AddButton("Cancelar");
                                alert.Show();
                            }
                        }
                    }catch (System.FormatException ex) {
                        Console.WriteLine(ex.ToString());
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "Espera!", Message = "Debes ingresar solo números"
                        };
                        alert.AddButton("Aceptar");
                        alert.Show();
                        QuantityView.Hidden = false;
                    }catch (System.Net.WebException) {
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "Ups :S", Message = "Algo salio mal,no se pudieron cargar tus listas, verifica tu conexión a internet e inténtalo de nuevo"
                        };
                        alert.AddButton("Aceptar");
                        alert.Show();
                    }catch (System.Exception ext) {
                        Console.WriteLine(ext.ToString());
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "Ups :S", Message = "Ocurrió un problema, inténtalo de nuevo"
                        };
                        alert.AddButton("Aceptar");
                        alert.Show();
                    }
                };

                btnCerrarLista.TouchUpInside += (sender, e) => {
                    ListsView.Hidden = true;
                };

                btnBadPrice.TouchUpInside += (sender, e) => {
                    if (MainView.userId != 0)
                    {
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "Gracias por su reporte", Message = "Estamos revisando constantemente los precios de los productos y le agradecemos su aportación, ¿le gustaría reportar el precio de este producto para su revision?"
                        };
                        alert.AddButton("SI");
                        alert.AddButton("NO");
                        alert.Clicked += (s, o) => {
                            try{
                                if (o.ButtonIndex == 0)
                                {
                                    ReportService report    = new ReportService();
                                    String        respuesta = report.SetData(MainView.userId.ToString(), this.producto.id, this.producto.tienda_id, this.producto.precio);
                                    if (respuesta.Equals("\"correct\""))
                                    {
                                        UIAlertView alert2 = new UIAlertView()
                                        {
                                            Title = "Muchas gracias!", Message = "En FixBuy estamos comprometidos con ofrecer siempre la informacion correcta, muchas gracias por tu reporte =)"
                                        };
                                        alert2.AddButton("Aceptar");
                                        alert2.Show();
                                    }
                                    else
                                    {
                                        UIAlertView alert3 = new UIAlertView()
                                        {
                                            Title = "UPS :S", Message = "Algo salio mal, verifica tu conexión a internet e intentalo de nuevo"
                                        };
                                        alert3.AddButton("Aceptar");
                                        alert3.Show();
                                    }
                                }
                            }catch (System.Net.WebException) {
                                UIAlertView alerta = new UIAlertView()
                                {
                                    Title = "UPS :S", Message = "Algo salio mal, verifica tu conexión a internet e intentalo de nuevo"
                                };
                                alerta.AddButton("Aceptar");
                                alerta.Show();
                            }catch (Exception) {
                                UIAlertView alerta = new UIAlertView()
                                {
                                    Title = "UPS :S", Message = "Algo salio mal, por favor intentalo de nuevo"
                                };
                                alerta.AddButton("Aceptar");
                                alerta.Show();
                            }
                        };
                        alert.Show();
                    }
                    else
                    {
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "Espera!", Message = "Debes iniciar sesión para poder reportar el precio incorrecto"
                        };
                        alert.AddButton("Aceptar");
                        alert.Show();
                    }
                };

                btnFacebook.TouchUpInside += (sender, e) => {
                    try{
                        if (MainView.isWithFacebook == true)
                        {
                            UIAlertView alert = new UIAlertView()
                            {
                                Title = "Quieres publicar este producto?", Message = "Deseas publicar este producto en tu perfil de Facebook?"
                            };
                            alert.AddButton("Aceptar");
                            alert.AddButton("Cancelar");
                            alert.Clicked += (s, o) => {
                                if (o.ButtonIndex == 0)
                                {
                                    var post = new NSMutableDictionary();
                                    if (data != null)
                                    {
                                        post.Add(new NSString("message"), new NSString(producto.imagen + "\t" + producto.nombre + "\t(" + producto.descripcion + ")" + "\nGracias a FixBuy encontre mi producto =D"));
                                    }
                                    else
                                    {
                                        post.Add(new NSString("message"), new NSString(producto.nombre + "\t(" + producto.descripcion + ")" + "\nGracias a FixBuy encontre mi producto =D "));
                                    }
                                    // Ask for publish_actions permissions in context
                                    if (!FBSession.ActiveSession.Permissions.Contains("publish_actions"))
                                    {
                                        // No permissions found in session, ask for it
                                        FBSession.ActiveSession.RequestNewPublishPermissions(new [] { "publish_actions" }, FBSessionDefaultAudience.Friends, (session, error) => {
                                            if (error != null)
                                            {
                                                InvokeOnMainThread(() => new UIAlertView("Ups =S", "Ocurrio un error intentalo de nuevo", null, "Aceptar", null).Show());
                                            }
                                            else
                                            {
                                                // If permissions granted, publish the story
                                                FBRequestConnection.StartWithGraphPath("me/feed", post, "POST", (connection, result, err) => {
                                                    if (err != null)
                                                    {
                                                        InvokeOnMainThread(() => new UIAlertView("Ups =S", "Ocurrio un error intentalo de nuevo", null, "Aceptar", null).Show());
                                                    }
                                                    else
                                                    {
                                                        HelloId = (result as FBGraphObject)["id"] as NSString;
                                                        InvokeOnMainThread(() => new UIAlertView("Producto publicado =)", "El producto que FixBuy te ayudo a encontrar a sido publicado en tu biografia =)", null, "Aceptar", null).Show());
                                                    }
                                                });
                                            }
                                        });
                                    }
                                    else
                                    {
                                        // If permissions is found, publish the story
                                        FBRequestConnection.StartWithGraphPath("me/feed", post, "POST", (connection, result, err) => {
                                            if (err != null)
                                            {
                                                InvokeOnMainThread(() => new UIAlertView("Ups =S", "Ocurrio un error intentalo de nuevo", null, "Ok", null).Show());
                                            }
                                            else
                                            {
                                                HelloId = (result as FBGraphObject)["id"] as NSString;
                                                InvokeOnMainThread(() => new UIAlertView("Producto publicado =)", "El producto que FixBuy te ayudo a encontrar a sido publicado en tu biografia =)", null, "Aceptar", null).Show());
                                            }
                                        });
                                    }
                                }
                            };
                            alert.Show();
                        }
                        else
                        {
                            InvokeOnMainThread(() => new UIAlertView("No has entrado a Facebook", "Debes iniciar sesion en Facebook para poder publicar tu producto, por favor regresa a la pantalla inicial para iniciar sesion en Facebook", null, "Aceptar", null).Show());
                        }
                    }catch (Exception exc) {
                        Console.WriteLine("UPS: " + exc.ToString());
                    }
                    //Console.WriteLine(HelloId.ToString());
                };

                btnNuevaLista.TouchUpInside += (sender, e) => {
                    this.NewListView.Hidden = false;
                };

                btnAceptarNuevaLista.TouchUpInside += (sender, e) => {
                    try{
                        if (cmpNewList.Text == "")
                        {
                            UIAlertView alert = new UIAlertView()
                            {
                                Title = "Espera!", Message = "Debes ingresar el nombre de la lista"
                            };
                            alert.AddButton("Aceptar");
                            alert.Show();
                        }
                        else
                        {
                            nls = new NewListService();
                            String respuesta = nls.SetListData(cmpNewList.Text, MainView.userId.ToString());
                            if (respuesta.Equals("\"lista ya existe\""))
                            {
                                UIAlertView alert = new UIAlertView()
                                {
                                    Title = "Ups :S", Message = "Ese nombre de lista ya se encuentra registrado"
                                };
                                alert.AddButton("Aceptar");
                                alert.Show();
                                //cmpNewList.Hidden = true;
                                cmpNewList.Text = "";
                                cmpNewList.ResignFirstResponder();
                            }
                            else
                            {
                                UIAlertView alert = new UIAlertView()
                                {
                                    Title = "Lista creada", Message = "Tu nueva lista \"" + cmpNewList.Text + "\" ha sido creada =D"
                                };
                                alert.AddButton("Aceptar");
                                alert.Show();
                                ls = new ListsService();
                                ls.setUserId(MainView.userId.ToString());
                                List <ListsService> items = ls.All();
                                this.tblLists.Source = new AddToListsTableSource(items, this, producto, 1);
                                this.tblLists.ReloadData();
                                cmpNewList.Text    = "";
                                NewListView.Hidden = true;
                                cmpNewList.ResignFirstResponder();
                            }
                        }
                    }catch (System.Net.WebException) {
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "Ups =S", Message = "Algo salio mal, verifica tu conexión a internet e intentalo de nuevo"
                        };
                        alert.AddButton("Aceptar");
                        alert.Show();
                    }catch (Exception exc) {
                        Console.WriteLine(exc.ToString());
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "Ups =S", Message = "Algo salio mal, por favor intentalo de nuevo"
                        };
                        alert.AddButton("Aceptar");
                        alert.Show();
                    }
                };

                btnCerrarNombreNL.TouchUpInside += (sender, e) => {
                    this.NewListView.Hidden = true;
                    this.cmpNewList.ResignFirstResponder();
                };
            }catch (Exception e) {
                Console.WriteLine(e.ToString());
                UIAlertView alert = new UIAlertView()
                {
                    Title = "Ups =S", Message = "Algo salio mal, por favor intentalo de nuevo."
                };
                alert.AddButton("Aceptar");
                alert.Show();
            }

            try{
                //Registramos la visita al producto en la aplicacion web
                RegisterVisit(producto.tienda_id, MainView.userId);
            }
            catch (Exception) {
                /*Atrapamos la excepcion en caso de que el registro de la visita no pueda hacerse
                 * sin mostrar ningun mensaje ni detener el flujo de la aplicacion*/
            }

            try{
                //Leemos el servicio de los banners
                this.bannersService = new BannersService();
                banners             = bannersService.All();
            } catch (System.Net.WebException) {
                UIAlertView alert = new UIAlertView()
                {
                    Title = "UPS :S", Message = "Hubo un error al conectarse a internet la seccion de banners no puede mostrarse, por favor verifica tu conexión a internet"
                };
                alert.AddButton("Aceptar");
                alert.Show();
            }

            button = new UIButton(new CGRect(0, 0, bannerImage.Bounds.Width, bannerImage.Bounds.Height));
            bannerImage.Add(button);
            button.TouchUpInside += (sender, e) => {
                try{
                    if (bannerError == false)
                    {
                        if (element.imagen != "")
                        {
                            NSUrl url = new NSUrl(element.link);
                            UIApplication.SharedApplication.OpenUrl(url);
                        }
                    }
                }catch (Exception) {
                    //solo atrapamos la excepcion, no hacemos nada
                }
            };
        }
Example #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Perform any additional setup after loading the view, typically from a nib.
            try{
                //Configuramos la vista popup de cantidad
                AmountView.Layer.BorderWidth  = 1.0f;
                AmountView.Layer.BorderColor  = UIColor.Black.CGColor;
                AmountView.Layer.CornerRadius = 8;
                tblProducts.Add(AmountView);
                AmountView.Hidden           = true;
                NameSearchResultView.amount = AmountView;

                //Configuramos la vista de popup de listas
                ListsView.Layer.BorderWidth  = 1.0f;
                ListsView.Layer.BorderColor  = UIColor.Black.CGColor;
                ListsView.Layer.CornerRadius = 8;
                tblProducts.Add(this.ListsView);
                ListsView.Hidden = true;

                //Configuramos la vista popup de nueva lista
                newListView.Layer.BorderWidth  = 1.0f;
                newListView.Layer.BorderColor  = UIColor.Black.CGColor;
                newListView.Layer.CornerRadius = 8;
                tblProducts.Add(newListView);
                newListView.Hidden = true;

                ps.setProductSearchString(this.nombre);
                List <ProductSearchService> tableItems = ps.All();

                this.productImages.Clear();
                foreach (var v in tableItems)
                {
                    Images image = new Images {
                        imageUrl = v.imagen
                    };
                    this.productImages.Add(image);
                }

                if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
                {
                    this.tblProducts.Source = new ProductsTableSourceIphone(tableItems, this, MainView.userId);
                }
                else
                {
                    this.tblProducts.Source = new ProductsTableSource(tableItems, this, MainView.userId);
                }
                this.lblSearch.Text = "Resultados para \"" + nombre + "\"";
                this.tblProducts.TableHeaderView = this.headerView;
                Add(this.tblProducts);
                if (tableItems.Count == 0)
                {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "Lo sentimos =(", Message = "La búsqueda de " + "\"" + nombre + "\"" + "\n No produjo ningun resultado."
                    };
                    alert.AddButton("Aceptar");
                    alert.Clicked += (sender, e) => {
                        NavigationController.PopViewController(true);
                    };
                    alert.Show();
                }

                this.btnAceptar.TouchUpInside += (sender, e) => {
                    try{
                        AmountView.Hidden = true;
                        ListsService ls = new ListsService();
                        ls.setUserId(MainView.userId.ToString());
                        List <ListsService> listItems = ls.All();
                        if (listItems.Count > 0)
                        {
                            this.tblLists.Source = new AddToListsTableSource(listItems, this, NameSearchResultView.product_id, int.Parse(cmpAmount.Text));
                            ListsView.Add(tblLists);
                            this.tblLists.ReloadData();
                            ListsView.Hidden = false;
                        }
                        else
                        {
                            UIAlertView alert = new UIAlertView()
                            {
                                Title = "No tienes listas", Message = "No tienes listas registradas, porfavor ve a \"Mis listas\" para crear una nueva"
                            };
                            alert.AddButton("Aceptar");
                            alert.Show();
                        }
                    }catch (System.Net.WebException) {
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "Ups =S", Message = "Algo salio mal,no se pudieron cargar tus listas, verifica tu conexión a internet e intentalo de nuevo."
                        };
                        alert.AddButton("Aceptar");
                        alert.Show();
                    }catch (Exception) {
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "Ups =S", Message = "Algo salio mal, por favor intentalo de nuevo."
                        };
                        alert.AddButton("Aceptar");
                        alert.Show();
                    }
                };

                btnCerrar.TouchUpInside += (sender, e) => {
                    this.ListsView.Hidden = true;
                };

                int cantidad = 1;
                this.cmpAmount.Text   = cantidad.ToString();
                btnMas.TouchUpInside += (sender, e) => {
                    cantidad++;
                    this.cmpAmount.Text = cantidad.ToString();
                };

                btnMenos.TouchUpInside += (sender, e) => {
                    cantidad--;
                    if (cantidad < 1)
                    {
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "Espera!", Message = "La cantidad minima es 1"
                        };
                        alert.AddButton("Aceptar");
                        alert.Show();
                        cantidad            = 1;
                        this.cmpAmount.Text = cantidad.ToString();
                    }
                    else
                    {
                        this.cmpAmount.Text = cantidad.ToString();
                    }
                };

                btnNuevaLista.TouchUpInside += (sender, e) => {
                    this.newListView.Hidden = false;
                };

                btnCancelarLista.TouchUpInside += (sender, e) => {
                    this.newListView.Hidden = true;
                };

                btnAceptarLista.TouchUpInside += (sender, e) => {
                    try{
                        if (cmpListName.Text == "")
                        {
                            UIAlertView alert = new UIAlertView()
                            {
                                Title = "Espera!", Message = "Debes ingresar el nombre de la lista"
                            };
                            alert.AddButton("Aceptar");
                            alert.Show();
                        }
                        else
                        {
                            nls = new NewListService();
                            String respuesta = nls.SetListData(cmpListName.Text, MainView.userId.ToString());
                            if (respuesta.Equals("\"lista ya existe\""))
                            {
                                UIAlertView alert = new UIAlertView()
                                {
                                    Title = "Ups :S", Message = "Ese nombre de lista ya se encuentra registrado"
                                };
                                alert.AddButton("Aceptar");
                                alert.Show();
                                cmpListName.Text = "";
                            }
                            else
                            {
                                UIAlertView alert = new UIAlertView()
                                {
                                    Title = "Lista creada", Message = "Tu nueva lista \"" + cmpListName.Text + "\" ha sido creada =D"
                                };
                                alert.AddButton("Aceptar");
                                alert.Show();
                                ls = new ListsService();
                                ls.setUserId(MainView.userId.ToString());
                                List <ListsService> items = ls.All();
                                this.tblLists.Source = new AddToListsTableSource(items, this, NameSearchResultView.product_id, int.Parse(cmpAmount.Text));
                                this.tblLists.ReloadData();
                                cmpListName.Text   = "";
                                newListView.Hidden = true;
                                cmpListName.ResignFirstResponder();
                            }
                        }
                    }catch (System.Net.WebException) {
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "Ups =S", Message = "Algo salio mal, verifica tu conexión a internet e intentalo de nuevo"
                        };
                        alert.AddButton("Aceptar");
                        alert.Show();
                    }catch (Exception exc) {
                        Console.WriteLine(exc.ToString());
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "Ups =S", Message = "Algo salio mal, por favor intentalo de nuevo"
                        };
                        alert.AddButton("Aceptar");
                        alert.Show();
                    }
                };
            }catch (WebException) {
                UIAlertView alert = new UIAlertView()
                {
                    Title = "Ups =S", Message = "Algo salio mal, verifica tu conexión a internet e intentalo de nuevo."
                };
                alert.AddButton("Aceptar");
                alert.Clicked += (sender, e) => {
                    NavigationController.PopViewController(true);
                };
                alert.Show();
            }catch (Exception) {
                UIAlertView alert = new UIAlertView()
                {
                    Title = "Ups =S", Message = "Algo salio mal, por favor intentalo de nuevo."
                };
                alert.AddButton("Aceptar");
                alert.Clicked += (sender, e) => {
                    NavigationController.PopViewController(true);
                };
                alert.Show();
            }
        }
Example #3
0
        void ReleaseDesignerOutlets()
        {
            if (btnCancelarLista != null)
            {
                btnCancelarLista.Dispose();
                btnCancelarLista = null;
            }

            if (btnAceptarLista != null)
            {
                btnAceptarLista.Dispose();
                btnAceptarLista = null;
            }

            if (cmpListName != null)
            {
                cmpListName.Dispose();
                cmpListName = null;
            }

            if (newListView != null)
            {
                newListView.Dispose();
                newListView = null;
            }

            if (AmountView != null)
            {
                AmountView.Dispose();
                AmountView = null;
            }

            if (btnAceptar != null)
            {
                btnAceptar.Dispose();
                btnAceptar = null;
            }

            if (btnCerrar != null)
            {
                btnCerrar.Dispose();
                btnCerrar = null;
            }

            if (btnMas != null)
            {
                btnMas.Dispose();
                btnMas = null;
            }

            if (btnMenos != null)
            {
                btnMenos.Dispose();
                btnMenos = null;
            }

            if (btnNuevaLista != null)
            {
                btnNuevaLista.Dispose();
                btnNuevaLista = null;
            }

            if (cmpAmount != null)
            {
                cmpAmount.Dispose();
                cmpAmount = null;
            }

            if (headerView != null)
            {
                headerView.Dispose();
                headerView = null;
            }

            if (lblSearch != null)
            {
                lblSearch.Dispose();
                lblSearch = null;
            }

            if (ListsView != null)
            {
                ListsView.Dispose();
                ListsView = null;
            }

            if (tblLists != null)
            {
                tblLists.Dispose();
                tblLists = null;
            }

            if (tblProducts != null)
            {
                tblProducts.Dispose();
                tblProducts = null;
            }
        }
Example #4
0
        void ReleaseDesignerOutlets()
        {
            if (btnAceptarCantidad != null)
            {
                btnAceptarCantidad.Dispose();
                btnAceptarCantidad = null;
            }

            if (btnAceptarNuevaLista != null)
            {
                btnAceptarNuevaLista.Dispose();
                btnAceptarNuevaLista = null;
            }

            if (btnBadPrice != null)
            {
                btnBadPrice.Dispose();
                btnBadPrice = null;
            }

            if (btnCerrarLista != null)
            {
                btnCerrarLista.Dispose();
                btnCerrarLista = null;
            }

            if (btnCerrarNombreNL != null)
            {
                btnCerrarNombreNL.Dispose();
                btnCerrarNombreNL = null;
            }

            if (btnFacebook != null)
            {
                btnFacebook.Dispose();
                btnFacebook = null;
            }

            if (btnLista != null)
            {
                btnLista.Dispose();
                btnLista = null;
            }

            if (btnMapa != null)
            {
                btnMapa.Dispose();
                btnMapa = null;
            }

            if (btnMas != null)
            {
                btnMas.Dispose();
                btnMas = null;
            }

            if (btnMenos != null)
            {
                btnMenos.Dispose();
                btnMenos = null;
            }

            if (btnNuevaLista != null)
            {
                btnNuevaLista.Dispose();
                btnNuevaLista = null;
            }

            if (cmpCantidad != null)
            {
                cmpCantidad.Dispose();
                cmpCantidad = null;
            }

            if (cmpNewList != null)
            {
                cmpNewList.Dispose();
                cmpNewList = null;
            }

            if (imgProducto != null)
            {
                imgProducto.Dispose();
                imgProducto = null;
            }

            if (imgTienda != null)
            {
                imgTienda.Dispose();
                imgTienda = null;
            }

            if (lblDescripcion != null)
            {
                lblDescripcion.Dispose();
                lblDescripcion = null;
            }

            if (lblNombre != null)
            {
                lblNombre.Dispose();
                lblNombre = null;
            }

            if (lblPrecio != null)
            {
                lblPrecio.Dispose();
                lblPrecio = null;
            }

            if (lblTiendaDireccion != null)
            {
                lblTiendaDireccion.Dispose();
                lblTiendaDireccion = null;
            }

            if (lblTiendaDistancia != null)
            {
                lblTiendaDistancia.Dispose();
                lblTiendaDistancia = null;
            }

            if (lblTiendaNombre != null)
            {
                lblTiendaNombre.Dispose();
                lblTiendaNombre = null;
            }

            if (lblVigencia != null)
            {
                lblVigencia.Dispose();
                lblVigencia = null;
            }

            if (ListsView != null)
            {
                ListsView.Dispose();
                ListsView = null;
            }

            if (NewListView != null)
            {
                NewListView.Dispose();
                NewListView = null;
            }

            if (QuantityView != null)
            {
                QuantityView.Dispose();
                QuantityView = null;
            }

            if (bannerImage != null)
            {
                bannerImage.Dispose();
                bannerImage = null;
            }

            if (tblLists != null)
            {
                tblLists.Dispose();
                tblLists = null;
            }
        }
        //check if listings and supplier has been selected and creates new lists item if _isEdit = false and vise versa
        //created by will fritz 2/11/15
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ItemListing itemListing = (ItemListing)lvList.SelectedItems[0];
                Supplier supplier = (Supplier)cboSelectSupplier.SelectedItem;

                Lists newLists = new Lists();
                newLists.ItemListID = itemListing.ItemListID;
                newLists.SupplierID = supplier.SupplierID;
                newLists.DateListed = new DateTime();

                if (_isEdit == false)
                {
                    _prodMang.AddLists(newLists);
                }
                else
                {
                    _prodMang.EditLists(_oldLists, newLists);
                }

                //opens old window and closes this one
                if (ListsView.Instance == null)
                {
                    var listsWin = new ListsView();
                    listsWin.Show();
                }
                else
                {
                    var listsWin = ListsView.Instance;
                    listsWin.BringIntoView();
                    listsWin.Show();
                    listsWin.FillList();

                    System.Media.SystemSounds.Asterisk.Play();
                }
                this.Close();

            }
            catch (Exception)
            {
                lblError.Content = "You Must Select a ItemListing and a Supplier Or there was an error with the database";
            }
        }