Example #1
0
        private async void guardar()
        {
            if (!validarCampos())
            {
                return;                   // Validacion del los campos
            }
            try
            {
                cargarObjeto();
                appLoadding(true, 25);
                if (nuevo)
                {
                    Response response = await categoriaModel.guardar(categoria);

                    appLoadding(false, 100);
                    MessageBox.Show(response.msj, "Guardar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    Response response = await categoriaModel.modificar(categoria);

                    appLoadding(false, 100);
                    MessageBox.Show(response.msj, "Modificar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "Guardar", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                appLoadding(false, 0);
            }
        }