Beispiel #1
0
 public UIButton getButton(int index)
 {
     botones.ElementAt(index).Frame = new CGRect(0, 0, Images.basura48.Size.Width, Images.basura48.Size.Height);
     botones.ElementAt(index).SetBackgroundImage(Images.basura48, UIControlState.Normal);
     botones.ElementAt(index).BackgroundColor = UIColor.Clear;
     botones.ElementAt(index).TouchUpInside  += (sender, e) => {
         UIAlertView alert = new UIAlertView()
         {
             Title = "Borrar?", Message = "Deseas borrar esta lista?"
         };
         alert.AddButton("Aceptar");
         alert.AddButton("Cancelar");
         alert.Clicked += (s, o) => {
             if (o.ButtonIndex == 0)
             {
                 DestroyService destroyService = new DestroyService();
                 String         respuesta      = destroyService.destroyList(tableItems[index].id);
                 if (respuesta.Equals("\"correct\""))
                 {
                     UIAlertView alert1 = new UIAlertView()
                     {
                         Title = "Lita borrada", Message = "La lista ha sido borrada =)"
                     };
                     alert1.AddButton("Aceptar");
                     alert1.Show();
                     ListsService ls = new ListsService();
                     ls.setUserId(MainView.userId.ToString());
                     List <ListsService> listas = ls.All();
                     MyListsView.tableView.Source = new ListsTableSourceIphone(listas, this.controller);
                     MyListsView.tableView.ReloadData();
                 }
                 else if (respuesta.Equals("\"error\""))
                 {
                     UIAlertView alert2 = new UIAlertView()
                     {
                         Title = "Ups :S", Message = "Algo salio mal, por favor intentalo de nuevo"
                     };
                     alert2.AddButton("Aceptar");
                     alert2.Show();
                 }
             }
         };
         alert.Show();
     };
     return(botones.ElementAt(index));
 }
			public void buttonEvent(CGPoint buttonPosition){
				NSIndexPath indexPath = controller.tblProducts.IndexPathForRowAtPoint (buttonPosition);
				UIAlertView alert = new UIAlertView () { 
					Title = "Borrar?", Message = "Deseas borrar este producto?"
				};
				alert.AddButton ("Aceptar");
				alert.AddButton ("Cancelar");
				alert.Clicked += (s, o) => {
					try{
						if(o.ButtonIndex == 0){
							DestroyService destroyService = new DestroyService ();
							String respuesta = destroyService.destroyProductInList(tableItems[indexPath.Row].id,tableItems[indexPath.Row].list_id);
							if (respuesta.Equals ("\"correct\"")) {
								UIAlertView alert1 = new UIAlertView () { 
									Title = "Producto borrado", Message = "El producto ha sido borrado =)"
								};
								alert1.AddButton("Aceptar");
								alert1.Show ();
								ProductsInListService ls = new ProductsInListService();
								ls.setListId(ProductsInListView.list_id);
								List<ProductsInListService> productos = ls.All();
								ProductsInListView.tableView.Source = new ProductsTableSourceIphone(productos,this.controller);
								controller.productImages.Clear();
								foreach (var v in this.tableItems){
									Images image = new Images{ imageUrl = v.imagen};
									controller.productImages.Add(image);
								}
								ProductsInListView.tableView.ReloadData ();
							}else if(respuesta.Equals("\"error\"")){
								UIAlertView alert2 = new UIAlertView () { 
									Title = "Ups :S", Message = "Algo salio mal, por favor intentalo de nuevo"
								};
								alert2.AddButton("Aceptar");
								alert2.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 ex){
						Console.WriteLine(ex.ToString());
						UIAlertView alerta = new UIAlertView () { 
							Title = "Ups =S", Message = "Algo salio mal, por favor intentalo de nuevo."
						};
						alerta.AddButton("Aceptar");
						alerta.Show();
					}
				};
				alert.Show ();
			}
Beispiel #3
0
		public UIButton getButton(int index){
			botones.ElementAt(index).Frame = new CGRect (0, 0, Images.basura48.Size.Width, Images.basura48.Size.Height);
			botones.ElementAt(index).SetBackgroundImage(Images.basura48,UIControlState.Normal);
			botones.ElementAt(index).BackgroundColor = UIColor.Clear;
			botones.ElementAt(index).TouchUpInside += (sender, e) => {
				UIAlertView alert = new UIAlertView () { 
					Title = "Borrar?", Message = "Deseas borrar esta lista?"
				};
				alert.AddButton ("Aceptar");
				alert.AddButton ("Cancelar");
				alert.Clicked += (s, o) => {
					if(o.ButtonIndex == 0){
						DestroyService destroyService = new DestroyService ();
						String respuesta = destroyService.destroyList (tableItems[index].id);
						if (respuesta.Equals ("\"correct\"")) {
							UIAlertView alert1 = new UIAlertView () { 
								Title = "Lita borrada", Message = "La lista ha sido borrada =)"
							};
							alert1.AddButton("Aceptar");
							alert1.Show ();
							ListsService ls = new ListsService();
							ls.setUserId(MainView.userId.ToString());
							List<ListsService> listas = ls.All();
							MyListsView.tableView.Source = new ListsTableSourceIphone(listas,this.controller);
							MyListsView.tableView.ReloadData ();
						}else if(respuesta.Equals("\"error\"")){
							UIAlertView alert2 = new UIAlertView () { 
								Title = "Ups :S", Message = "Algo salio mal, por favor intentalo de nuevo"
							};
							alert2.AddButton("Aceptar");
							alert2.Show ();
						}
					}
				};
				alert.Show ();
			};
			return botones.ElementAt(index);
		}