private void btn_gravar_Click(object sender, EventArgs e) { try { objCategoriaDTO.Descricao = txt_descricao.Text; if (txt_id.Text == "") { objCategoriaBLL.InserirCategoria(objCategoriaDTO); MessageBox.Show("Categoria Cadastrada"); } else //Se o ID estiver preenchido { objCategoriaDTO.ID = int.Parse(txt_id.Text); objCategoriaBLL.AlterarCategoria(objCategoriaDTO); MessageBox.Show("Dados da categoria atualizados com sucesso."); } CarregarGridCategoria(); Limpar(); } catch (Exception ex) { MessageBox.Show("ERRO.\n" + ex.Message); } }
protected void btnGravar_Click(object sender, EventArgs e) { objCategoria.Nome = txtNome.Text; if (string.IsNullOrEmpty(txtID.Text)) { objCategoria.InserirCategoria(); } else { objCategoria.AlterarCategoria(txtID.Text); } LimparTela(); CarregarGridView(); }