1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| public int ajout_lots()
{
int n = 0;
for (int i = 0; i < list_lots_col.Count; i++ )
{
lot_struc lot = list_lots_col.ElementAt(i);
try
{
string cm1 = "INSERT INTO lots (reference,product_key,quantity,id_op) VALUES ( @reference , @product_key, @quantite,@id_operation)";
string cm4 = "INSERT INTO new_lots (reference,product_key,quantity,id_op) VALUES ( @reference , @product_key, @quantite,@id_operation)";
if (Oven_Class.list_Oven.ElementAt(oven_index).operation == "polymerisation")
{
// string cm2 = " SELECT id_lots FROM lots WHERE reference= ";
CNX.cmd.Parameters.AddWithValue("@reference", lot.lotnum);
CNX.cmd.Parameters.AddWithValue("@product_key", lot.product);
CNX.cmd.Parameters.AddWithValue("@quantite", lot.quantity);
CNX.cmd.Parameters.AddWithValue("@id_operation", id_operation);
// Class1.con.Open();
CNX.cmd.CommandText = cm1;
//CNX.reader = CNX.cmd.ExecuteReader();
CNX.reader.Close();
CNX.cmd.Parameters.Clear();
n++;
}
if( Oven_Class.list_Oven.ElementAt(oven_index).operation == "backing")
{
CNX.cmd.Parameters.AddWithValue("@reference", lot.lotnum);
CNX.cmd.Parameters.AddWithValue("@product_key", lot.product);
CNX.cmd.Parameters.AddWithValue("@quantite", lot.quantity);
CNX.cmd.Parameters.AddWithValue("@id_operation", id_operation);
// Class1.con.Open();
CNX.cmd.CommandText = cm4;
CNX.reader = CNX.cmd.ExecuteReader();
CNX.reader.Close();
CNX.cmd.Parameters.Clear();
}
n++;
}
}
catch (DivideByZeroException ex)
{
CNX.reader.Close();
CNX.cmd.Parameters.Clear();
listView1.SelectedIndex = i;
MessageBox.Show(ex.Message + " Reference : " + lot.lotnum + "\n already exists");
}
}
return n;
} |
Partager