1
I’m having some difficulty doing a search as the image illustrates
Using combobox worked, here’s the code
Class
public void pesquisar(int ID)
{
Artigo List = new Artigo();
SqlConnection conexao = new SqlConnection(caminho);
SqlCommand cmd = new SqlCommand();
cmd.Connection = conexao;
cmd.CommandType = CommandType.Text;
string obj = "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();
}
you can enter the code where you get the text present in the textbox?
– João Silva
the method
pesquisar(int ID)
is within the classArtigo
? post your code please– Rovann Linhalis
I tried to subtweet here: obj.search(txt_codigo_barra.Text). Tostring(); and nothing
– António Mateta