示例#1
0
        public DocIdentificacionItemPage()
        {
            InitializeComponent();
            DocIdentificacionViewModel docIdentificacionViewModel = DocIdentificacionViewModel.GetInstance();

            BindingContext = docIdentificacionViewModel.CurrentDocIdentificacion;
        }
        private async void ExecuteGuardarAsync()
        {
            try
            {
                /// validacion de los campos
                if (string.IsNullOrEmpty(this.nombre))
                {
                    await Application.Current.MainPage.DisplayAlert("Alerta", "Campo nombre obligatoria", "Aceptar");

                    return;
                }

                if (this.numeroDigitos == 0)
                {
                    await Application.Current.MainPage.DisplayAlert("Alerta", "Campo digitos obligatoria", "Aceptar");

                    return;
                }

                // Estados
                this.IsRunning = true;
                this.IsEnabled = false;

                // Preparando el objeto para enviar
                if (this.Nuevo)
                {
                }

                if (this.Nuevo)
                {
                    // localhost:8080/admeli/xcore2/xcore/services.php/documentoidentificacion/guardar
                    Response response = await webService.POST <DocIdentificacion, Response>("documentoidentificacion", "guardar", (DocIdentificacion)this);

                    await App.Current.MainPage.DisplayAlert("Guardar", response.Message, "Aceptar");
                }
                else
                {
                    // localhost:8080/admeli/xcore2/xcore/services.php/documentoidentificacion/modificar
                    Response response = await webService.POST <DocIdentificacion, Response>("documentoidentificacion", "modificar", (DocIdentificacion)this);

                    await App.Current.MainPage.DisplayAlert("Modificar", response.Message, "Aceptar");
                }

                // Refrescar y regresar a la pagina anterior
                DocIdentificacionViewModel.GetInstance().ExecuteRefresh();
                await App.DocIdentificacionItemPage.Navigation.PopAsync();
            }
            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()
        {
            DocIdentificacionViewModel docIdentificacionViewModel = DocIdentificacionViewModel.GetInstance();

            docIdentificacionViewModel.SetCurrentDocIdentificacion(this);
            this.Nuevo           = false;                                                    /// Importante indicaque se modificara el registro actual
            this.DeleteIsEnabled = true;
            App.DocIdentificacionPage.Navigation.PushAsync(new DocIdentificacionItemPage()); // Navegacion

            // Establecer valores al modificar
            TipoDocumentoSelectedItem = TipoDocumentoItems.Find(x => x.idTipoDocumento == this.tipoDocumento);
        }