private void btnGravar_Click(object sender, EventArgs e) { CAMADAS.MODEL.Categorias categoria = new CAMADAS.MODEL.Categorias(); CAMADAS.BLL.Categorias bllCategoria = new CAMADAS.BLL.Categorias(); if (txtCategoria.Text != "") { categoria.desc_categoria = txtCategoria.Text; bllCategoria.Insert(categoria); dgvCategorias.DataSource = ""; dgvCategorias.DataSource = bllCategoria.Select(); limparControles(); } else { MessageBox.Show("É necessário preencher algum nome para a Categoria."); } }
private void btnEditar_Click(object sender, EventArgs e) { if (txtId.Text != "-1" && txtCategoria.Text != "") { CAMADAS.MODEL.Categorias categoria = new CAMADAS.MODEL.Categorias(); CAMADAS.BLL.Categorias bllCategoria = new CAMADAS.BLL.Categorias(); categoria.id_categoria = Convert.ToInt32(txtId.Text); categoria.desc_categoria = txtCategoria.Text; bllCategoria.Update(categoria); dgvCategorias.DataSource = ""; dgvCategorias.DataSource = bllCategoria.Select(); limparControles(); } else { MessageBox.Show("Preencha algum nome para a Categoria, para edita-la."); } }