Actually I have to written for loop in DAL and it is added to DataGridView in Presentation layer.How to write code for this
Here is the sample code
for (int i = 0; i < Prodcode.Length; i++)
{
if (cn.State != ConnectionState.Open)
cn.Open();
cmd.Connection = cn;
string value = "";
cmd.CommandText = " select A.[prod_code] [Code],A.[prod_desc] [Desc],invd_uom [UOM],A.invd_qty-A.invd_qty_sent-(select isnull(sum(invd_qty_sent),0) from invoice_details where prod_code='" + Prodcode[i] + "' and comp_id='" + cpnyid + "' and Link_inv_no=B.inv_no) as reserve,B.inv_no as Invoice from invoice_details AS A" +
" INNER JOIN invoice_master AS B ON A.inv_no=B.inv_no " +
" WHERE (A.invd_qty-A.invd_qty_sent)>0 AND a.invd_qty_reservePros='false' and A.comp_id='" + cpnyid + "'and B.cust_code= '" + cfs.singlequotconver(txt_Custcode.Text)
+ "' and prod_code ='" + Prodcode[i] + "' and b.inv_no='" + Trnno[i] + "'and invd_qty_reserveDone<>'true' and invd_id='" + IdS[i] + "' union ";
cmd.CommandText += "select prod_code [Code],prod_desc [Desc],popr_uom [UOM],convert(decimal(18,0),popr_bqty)-(select isnull(sum(invd_qty_sent),0) from invoice_details where prod_code='" + Prodcode[i] + "' and comp_id='" + cpnyid + "' and Link_inv_no=product_open_balance_reserve.inv_no) as [reserve],inv_no as Invoice " +
" from product_open_balance_reserve where comp_id='" + cpnyid + "' and cust_code='" + cfs.singlequotconver(txt_Custcode.Text) +
"' and prod_code ='" + Prodcode[i] + "' and inv_no='" + Trnno[i] + "' and popr_deleted=0 and popr_id='" + IdS[i] + "' ";
dr = cmd.ExecuteReader();
object[] obj1 = { "", "", "", Properties.Settings.Default.SendBalance.ToString() };
if (i == 0)
{
dataGridViewEx1.Rows.Add(obj1);
}
while (dr.Read())
{
object[] obj = { "", dr["Code"].ToString(), "", dr["Desc"].ToString(), "", "", dr["reserve"].ToString(), dr["UOM"].ToString(), "", "", dr["reserve"].ToString(), "", "", "", "", "", "", "", "", "", "", dr["Invoice"].ToString() };
dataGridViewEx1.Rows.Add(obj);
} dr.Close();
}