for (int i = 0; i < lvProductInfo.Items.Count; i++)
{
ProductCode = Convert.ToInt32(lvProductInfo.Items[i].SubItems[1].Text);
ProductQuantity = Convert.ToInt32(lvProductInfo.Items[i].SubItems[2].Text);
ProductPrice = Convert.ToInt32(lvProductInfo.Items[i].SubItems[3].Text);
totalPrice = Convert.ToInt32(lvProductInfo.Items[i].SubItems[4].Text);
sql = "";
sql = "INSERT INTO PurchaseLog (ProductCode,ProductQuantity,ProductPrice,TotalPrice)"
+ " VALUES ('" + ProductCode + "','" + ProductQuantity + "','" + ProductPrice + "','" + totalPrice + "')";
clsConnection clsCn = new clsConnection();
SqlConnection cn = null;
SqlCommand cmd = new SqlCommand();
clsCn.fnc_ConnectToDB(ref cn);
cmd.Connection = cn;
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
this.Close();
}
}