示例#1
0
        private void BtnGrabar_Click(object sender, RoutedEventArgs e)
        {
            BCategoria Bcategoria = null;
            bool       result     = true;

            try
            {
                //0: Listar todas las categorias
                Bcategoria = new BCategoria();

                int proxId = Bcategoria.ObtenerProxId();

                //MessageBox.Show("ID: " + proxId.ToString());

                if (ID > 0)
                {
                    result = Bcategoria.Actualizar(new Categoria {
                        IdCategoria = ID, NombreCategoria = txtNombre.Text, Descripcion = txtDescripcion.Text
                    });
                }
                else
                {
                    result = Bcategoria.Insertar(new Categoria {
                        IdCategoria = proxId, NombreCategoria = txtNombre.Text, Descripcion = txtDescripcion.Text
                    });
                }

                if (!result)
                {
                    MessageBox.Show("Comunicarse con el Administrador");
                }

                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Comunicarse con el Administrador");
                throw ex;
            }
            finally
            {
                Bcategoria = null;
            }
        }