I need to make a foreach per item in my code, but I can not do it.
Eg: I have a note that has 2 items, and I need to read the information of the note by item, I read item 01 and then I read item 02, but I am not able to implement this in my code below. >
Follow my code.
private void btn_laudo_Click(object sender, EventArgs e)
{
string ItemNota = @"SELECT
SD.D2_COD,
SD.D2_LOTECTL,
QR.QER_REVI,
SD.D2_ITEM
FROM SD2020 AS SD
INNER JOIN QER020 AS QR WITH(NOLOCK) ON QR.QER_LOTE = SD.D2_LOTECTL
WHERE SD.D2_DOC = '" + txt_nota.Text + "' AND SD.D2_ITEM = '" + txt_item.Text + "'";
SqlCommand comando = new SqlCommand(ItemNota, conex);
conex.Open();
SqlDataReader ler = comando.ExecuteReader();
if (ler.Read() == true)
{
txt_lote.Text = ler[1].ToString();
txt_codprod.Text = ler[0].ToString();
txt_revi.Text = ler[2].ToString();
}
conex.Close();
this.CabeçalhoLaudoTableAdapter.Fill_CabLaudo(this.DSLaudosPS.CabeçalhoLaudo, txt_nota.Text, txt_item.Text);
this.CorpoLaudoTableAdapter.Fill_CorpoLaudo(this.DSLaudosPS.CorpoLaudo, txt_codprod.Text, txt_lote.Text, txt_revi.Text);
this.rpw_laudo.RefreshReport();
}