private async void ExecuteEliminar() { try { // Estados this.IsRunning = true; this.IsEnabled = false; /// pregunta al usuario (Confirmacion) if (await App.Current.MainPage.DisplayAlert("Eliminar", "¿esta seguro de eliminar este registro? \n" + this.nombreCategoria, "Aceptar", "Cancelar") == false) { return; } // localhost:8080/admeli/xcore2/xcore/services.php/categorias/eliminar Response response = await webService.POST <Categoria, Response>("categorias", "eliminar", (Categoria)this); await App.Current.MainPage.DisplayAlert("Eliminar", response.Message, "Aceptar"); // Refrescar la lista CategoriaViewModel.GetInstance().ExecuteRefresh(); } catch (Exception ex) { // Error message await App.Current.MainPage.DisplayAlert("Error", ex.Message, "Aceptar"); } finally { // Estados this.IsRunning = false; this.IsEnabled = true; } }
public CategoriaItemPage() { InitializeComponent(); CategoriaViewModel categoriaViewModel = CategoriaViewModel.GetInstance(); BindingContext = categoriaViewModel.CurrentCategoria; }
private async void ExecuteAnular() { try { // Estados this.IsRunning = true; this.IsEnabled = false; /// Verificacion si el registro esta anulado if (this.estado == 0) { await App.Current.MainPage.DisplayAlert("Anular", "Este registro ya esta anulado \n" + this.nombreCategoria, "Aceptar"); return; } /// pregunta al usuario (Confirmacion) if (await App.Current.MainPage.DisplayAlert("Anular", "¿esta seguro de anular este registro? \n" + this.nombreCategoria, "Aceptar", "Cancelar") == false) { return; } /// Preparando el objeto para enviar Categoria categoria = new Categoria(); categoria.idCategoria = this.idCategoria; /// Ejecutando el webservice // localhost:8080/admeli/xcore2/xcore/services.php/categoria/desactivar Response response = await webService.POST <Categoria, Response>("categoria", "desactivar", (Categoria)this); // Message response await App.Current.MainPage.DisplayAlert("Anular", response.Message, "Aceptar"); // Refrescar la lista CategoriaViewModel.GetInstance().ExecuteRefresh(); } catch (Exception ex) { // Error message await App.Current.MainPage.DisplayAlert("Error", ex.Message, "Aceptar"); } finally { // Estados this.IsRunning = false; this.IsEnabled = true; } }
private void ExecuteEditar() { CategoriaViewModel categoriaViewModel = CategoriaViewModel.GetInstance(); categoriaViewModel.SetCurrentCategoria(this); App.CategoriaPage.Navigation.PushAsync(new CategoriaItemPage()); // Navegacion this.Nuevo = false; /// Importante indicaque se modificara el registro actual this.DeleteIsEnabled = true; // Establecer valores al modificar CategoriaPadreSelectedItem = CategoriaPadreItems.Find(c => c.idCategoria == this.idPadreCategoria); // selecciona la categoria por defecto o la categoria seleccionada MostrarEnSelectedItem = MostrarEnItems.Find(x => x.idMostrarEn == this.mostrarProductosEn); OrdenVisualSelectedItem = OrdenVisualPadreItems.Find(x => x.idOrdenVisual == this.ordenVisualizacionProductos); }
private async void ExecuteGuardarAsync() { try { /// validacion de los campos if (string.IsNullOrEmpty(this.nombreCategoria)) { await Application.Current.MainPage.DisplayAlert("Alerta", "Nombre de la categoria \n Campo obligatoria", "Aceptar"); return; } if (CategoriaPadreSelectedItem == null) { await Application.Current.MainPage.DisplayAlert("Alerta", "Seleccione un categoria padre \n Campo obligatoria", "Aceptar"); return; } // Estados this.IsRunning = true; this.IsEnabled = false; // Preparando el objeto para enviar this.idPadreCategoria = CategoriaPadreSelectedItem.idCategoria; // CATEGORIA PADRE this.padre = CategoriaPadreSelectedItem.nombreCategoria; // CATEGORIA PADRE this.ordenVisualizacionProductos = OrdenVisualSelectedItem.idOrdenVisual; this.mostrarProductosEn = MostrarEnSelectedItem.idMostrarEn; this.numeroColumnas = (this.numeroColumnas == 0) ? 1 : this.numeroColumnas; // Numero de datos si es cero valor por defecto 1 this.orden = (this.orden == 0) ? 1 : this.orden; // Numero de orden si es 0 es 1 this.cabeceraPagina = (this.cabeceraPagina != null) ? this.cabeceraPagina : ""; this.metaTagsSeo = (this.metaTagsSeo != null) ? this.metaTagsSeo : ""; this.piePagina = (this.piePagina != null) ? this.piePagina : ""; this.tieneRegistros = (this.tieneRegistros != null) ? this.tieneRegistros : ""; this.tituloCategoriaSeo = (this.tituloCategoriaSeo != null) ? this.tituloCategoriaSeo : ""; this.urlCategoriaSeo = (this.urlCategoriaSeo != null) ? this.urlCategoriaSeo : ""; if (this.Nuevo) { this.afecta = true; } if (this.Nuevo) { // localhost:8080/admeli/xcore2/xcore/services.php/categorias/guardar Response response = await webService.POST <Categoria, Response>("categorias", "guardar", (Categoria)this); await App.Current.MainPage.DisplayAlert("Guardar", response.Message, "Aceptar"); } else { // localhost:8080/admeli/xcore2/xcore/services.php/categorias/modificar Response response = await webService.POST <Categoria, Response>("categorias", "modificar", (Categoria)this); await App.Current.MainPage.DisplayAlert("Modificar", response.Message, "Aceptar"); } // Refrescar y regresar a la pagina anterior CategoriaViewModel.GetInstance().ExecuteRefresh(); await App.CategoriaItemPage.Navigation.PopAsync(); } catch (Exception ex) { // Error message await App.Current.MainPage.DisplayAlert("Error", ex.Message, "Aceptar"); } finally { // Estados this.IsRunning = false; this.IsEnabled = true; } }