I'm having some difficulty doing a search as the picture illustrates.
UsingcomboBoxworked,hereisthecode
Class
publicvoidpesquisar(intID){ArtigoList=newArtigo();SqlConnectionconexao=newSqlConnection(caminho);SqlCommandcmd=newSqlCommand();cmd.Connection=conexao;cmd.CommandType=CommandType.Text;stringobj="Select * From artigo Where id_artigo=@id_artigo";
cmd.Parameters.AddWithValue("@id_artigo", ID);
cmd.CommandText = obj;
SqlDataReader dr = null;
conexao.Open();
dr = cmd.ExecuteReader();
while (dr.Read())
{
id_artigo = Convert.ToInt32(dr["id_artigo"]);
item = dr["item"].ToString();
tipo_item = dr["tipo_item "].ToString();
preco_compra = Decimal.Parse(dr["preco_compra"].ToString());
preco_venda = Decimal.Parse(dr["preco_venda"].ToString());
}
}
Form
public void pesquisa_Detalhada()
{
Artigo obj = new Artigo();
obj.pesquisar(Convert.ToInt32(cb_Artigo.SelectedValue));
txt_Item.Text = obj.item.ToString();
txt_Tipo_Item.Text = obj.tipo_item.ToString();
txt_preco_vend.Text = Convert.ToDecimal(obj.preco_venda).ToString();
}