Good afternoon. I need a help, I have a datagridwier and I have a column where I type a code for a product. Now I need that when the user enters the code of a product in the cell of the code column to enter the enter it fill the fields field and also the batch combobox with data from a select that I bring from the database. How can I do this?
Below is the screen of my datagridwier
SqlConnectionconnection=newSqlConnection(Properties.Settings.Default.DADOSADVConnectionString); SqlCommandcommand=null; publicfrmSolicitationAmostraPic() { InitializeComponent(); }
privatevoidlbl_email_Click(objectsender,EventArgse){}privatevoidbtn_ok_Click(objectsender,EventArgse){if(txt_codcli.Text!="")
{
SqlCommand comando = new SqlCommand(@"SELECT
SA.A1_NREDUZ AS CLIENTE,
+'(' + SA.A1_DDD + ')' + ' ' + SA.A1_TEL AS TELEFONE,
SA.A1_CEP AS CEP,
SA.A1_END AS ENDERECO,
SA.A1_BAIRRO AS BAIRRO,
SA.A1_MUN AS CIDADE,
SA.A1_EST AS ESTADO,
CONVERT(VARCHAR(10), CAST(SA.A1_DTNASC AS DATE), 103) AS DATA
FROM SA1010 AS SA
WHERE SA.A1_COD = '" + txt_codcli.Text + "'", conex);
comando.CommandType = CommandType.Text;
conex.Open();
SqlDataReader dr = comando.ExecuteReader();
while (dr.Read())
{
txt_cliente.Text = dr["CLIENTE"].ToString();
txt_telefone.Text = dr["TELEFONE"].ToString();
txt_cep.Text = dr["CEP"].ToString();
txt_endereco.Text = dr["ENDERECO"].ToString();
txt_bairro.Text = dr["BAIRRO"].ToString();
txt_cidade.Text = dr["CIDADE"].ToString();
txt_uf.Text = dr["ESTADO"].ToString();
txt_dtcadastro.Text = dr["DATA"].ToString();
}
conex.Close();
}
else
{
MessageBox.Show("Código do cliente invalido, por favor digitar um código de clinete válido");
return;
}
}
}
}