private void btnConsultarEstoque_Click(object sender, EventArgs e) { if (txtIDEstoqueConsulta.Text == "") { MessageBox.Show("Preencha o campo do Identificador!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { try { int id = int.Parse(txtIDEstoqueConsulta.Text); EstoquePeca estoquePeca = _estoquePecasController.BuscarEstoquePecas(id); if (estoquePeca == null) { MessageBox.Show("Não existe cadastro com esse Identificador!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { DataTable dt = new DataTable(); dt.Columns.Add("ID", typeof(int)); dt.Columns.Add("Descrição", typeof(string)); dt.Columns.Add("Valor", typeof(double)); dt.Columns.Add("Quantidade", typeof(int)); dt.Rows.Add(estoquePeca.Id, estoquePeca.Descricao, estoquePeca.ValorUnit, estoquePeca.Quantidade); dgEstoqueConsulta.DataSource = dt; EstoquePeca = estoquePeca; ListaEstoquePecas = new List <EstoquePeca>(); ListaEstoquePecas.Add(estoquePeca); estoquePeca = null; } } catch (ConcorrenciaBancoException ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }