public static void CadastrarSetor(SetorView tela) { string nome = tela.tbNome.Text; Setor obj = new Setor(); obj.SetNome(nome); SetorDAO dao = new SetorDAO(); int resultado = dao.CadastraSetor(obj); if (resultado == 1) { MessageBox.Show("O setor foi cadastrado com sucesso."); PreencherTabela(tela); } else { MessageBox.Show("Houve um erro ao cadastrar o setor."); } }
public static void EditarSetor(SetorView tela) { int codigo = Convert.ToInt32(tela.tbCodigo.Text); string nome = tela.tbNome.Text; Setor obj = new Setor(); obj.SetCodSetor(codigo); obj.SetNome(nome); SetorDAO dao = new SetorDAO(); int resultado = dao.EditaSetor(obj); if (resultado == 1) { MessageBox.Show("Setor alterado com sucesso."); PreencherTabela(tela); } else { MessageBox.Show("Houve um erro ao editar o setor."); } }