private void BtnGravar_Click(object sender, EventArgs e) { if (txtMatricula.Text.Equals(" ") || txtNome.Text.Equals(" ")) { MessageBox.Show("Preencha todos os campos !"); } else { int cod = Int32.Parse(txtMatricula.Text); string nome = txtNome.Text; string cargo = txtCargo.Text; int ativo = 0; if (cbAtivo.Checked) { ativo = 1; } int idSetor = comboSetor.SelectedIndex; SetorBd setorBd = new SetorBd(); Setor setor; idSetor++; // recebe o setor do banco pelo id do comboBox setor = setorBd.selecionado(idSetor); Funcionario funcionario = new Funcionario(cod, nome, cargo, ativo, setor); txtNome.Text = " "; txtCargo.Text = " "; txtMatricula.Text = " "; FuncionarioBd bd = new FuncionarioBd(); bd.salvar(funcionario); MessageBox.Show("Funcionario Salvo !"); } }
private void BtnGravar_Click(object sender, EventArgs e) { Setor setor = new Setor(txtSetor.Text); SetorBd bd = new SetorBd(); bd.salvar(setor); txtSetor.Text = " "; MessageBox.Show("Setor salvo !"); }