public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { UIAlertView alert = new UIAlertView() { Title = "Agregar?", Message = "Deseas agregar este producto a la lista?" }; alert.AddButton("Aceptar"); alert.AddButton("Cancelar"); alert.Show(); alert.Clicked += (sender, e) => { try{ if (e.ButtonIndex == 0) { AddProductToListService addproduct = new AddProductToListService(); String respuesta = addproduct.SetData(producto, tableItems [indexPath.Row].id, this.cantidad.ToString()); if (respuesta.Equals("\"El producto ya existe en esta lista\"")) { UIAlertView alert2 = new UIAlertView() { Title = "Ups =S", Message = "Este producto ya se encuentra registrado en esta lista." }; alert2.AddButton("Aceptar"); alert2.Show(); } else { UIAlertView alert3 = new UIAlertView() { Title = "Producto agregado", Message = "Este producto ha sido agregado a la lista \"" + tableItems[indexPath.Row].nombre + "\"" }; 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(); } }; }
public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { UIAlertView alert = new UIAlertView () { Title = "Agregar?", Message = "Deseas agregar este producto a la lista?" }; alert.AddButton ("Aceptar"); alert.AddButton ("Cancelar"); alert.Show (); alert.Clicked += (sender, e) => { try{ if(e.ButtonIndex == 0){ AddProductToListService addproduct = new AddProductToListService (); String respuesta = addproduct.SetData (producto, tableItems [indexPath.Row].id,this.cantidad.ToString()); if (respuesta.Equals ("\"El producto ya existe en esta lista\"")) { UIAlertView alert2 = new UIAlertView () { Title = "Ups =S", Message = "Este producto ya se encuentra registrado en esta lista." }; alert2.AddButton ("Aceptar"); alert2.Show (); } else { UIAlertView alert3 = new UIAlertView () { Title = "Producto agregado", Message = "Este producto ha sido agregado a la lista \""+tableItems[indexPath.Row].nombre+"\"" }; 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 (); } }; }