private void btnCadastrarEstoque_Click(object sender, EventArgs e) { if (txtValor.Text == "" || txtDesc.Text == "" || nudQuantidade.Value <= 0) { MessageBox.Show("Preencha os campos corretamente!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { int id = int.Parse(txtid.Text); double valor = double.Parse(txtValor.Text); int qtd = Convert.ToInt32(nudQuantidade.Value); EstoquePeca estoquePeca = new EstoquePeca(id, txtDesc.Text, valor, qtd); try { if (_estoquePecasController.Cadastrar(estoquePeca, id)) { MessageBox.Show("Cadastro realizado com Sucesso!"); txtValor.Text = ""; txtDesc.Text = ""; nudQuantidade.Value = 0; txtid.Text = _estoquePecasController.PopulaID().ToString(); } } catch (RegistroExisteException ex) { MessageBox.Show(ex.Message); } catch (ConcorrenciaBancoException ex) { MessageBox.Show(ex.Message); } } }