/// <summary> /// Insertion_DEMCOUT /// </summary> /// <param name="row"></param> public void Insertion_DEMCOUT(List <CsTdemCout> rows) { cn = new SqlConnection(ConnectionString); cmd = new SqlCommand(); cmd.Connection = cn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = EnumProcedureStockee.InsertDEMCOUT.Trim(); cmd.Parameters.Clear(); try { foreach (CsTdemCout row in rows) { cmd.Parameters.Add("@CENTRE", SqlDbType.VarChar).Value = row.CENTRE; cmd.Parameters.Add("@PRODUIT", SqlDbType.VarChar).Value = row.PRODUIT; cmd.Parameters.Add("@TDEM", SqlDbType.VarChar).Value = row.TDEM; cmd.Parameters.Add("@COPER1", SqlDbType.VarChar).Value = row.COPER1; cmd.Parameters.Add("@OBLI1", SqlDbType.VarChar).Value = row.OBLI1; cmd.Parameters.Add("@AUTO1", SqlDbType.VarChar).Value = row.AUTO1; cmd.Parameters.Add("@MONTANT1", SqlDbType.Decimal).Value = row.MONTANT1; cmd.Parameters.Add("@TAXE1", SqlDbType.VarChar).Value = row.TAXE1; cmd.Parameters.Add("@COPER2", SqlDbType.VarChar).Value = row.COPER2; cmd.Parameters.Add("@OBLI2", SqlDbType.VarChar).Value = row.OBLI2; cmd.Parameters.Add("@AUTO2", SqlDbType.VarChar).Value = row.AUTO2; cmd.Parameters.Add("@MONTANT2", SqlDbType.Decimal).Value = row.MONTANT2; cmd.Parameters.Add("@TAXE2", SqlDbType.VarChar).Value = row.TAXE2; cmd.Parameters.Add("@COPER3", SqlDbType.VarChar).Value = row.COPER3; cmd.Parameters.Add("@OBLI3", SqlDbType.VarChar).Value = row.OBLI3; cmd.Parameters.Add("@AUTO3", SqlDbType.VarChar).Value = row.AUTO3; cmd.Parameters.Add("@MONTANT3", SqlDbType.Decimal).Value = row.MONTANT3; cmd.Parameters.Add("@TAXE3", SqlDbType.VarChar).Value = row.TAXE3; cmd.Parameters.Add("@COPER4", SqlDbType.VarChar).Value = row.COPER4; cmd.Parameters.Add("@OBLI4", SqlDbType.VarChar).Value = row.OBLI4; cmd.Parameters.Add("@AUTO4", SqlDbType.VarChar).Value = row.AUTO4; cmd.Parameters.Add("@MONTANT4", SqlDbType.Decimal).Value = row.MONTANT4; cmd.Parameters.Add("@TAXE4", SqlDbType.VarChar).Value = row.TAXE4; cmd.Parameters.Add("@COPER5", SqlDbType.VarChar).Value = row.COPER5; cmd.Parameters.Add("@OBLI5", SqlDbType.VarChar).Value = row.OBLI5; cmd.Parameters.Add("@AUTO5", SqlDbType.VarChar).Value = row.AUTO5; cmd.Parameters.Add("@MONTANT5", SqlDbType.Decimal).Value = row.MONTANT5; cmd.Parameters.Add("@TAXE5", SqlDbType.VarChar).Value = row.TAXE5; cmd.Parameters.Add("@DMAJ", SqlDbType.DateTime).Value = row.DMAJ; cmd.Parameters.Add("@TRANS", SqlDbType.VarChar).Value = row.TRANS; DBBase.SetDBNullParametre(cmd.Parameters); if (cn.State == ConnectionState.Closed) { cn.Open(); } StartTransaction(cn); cmd.ExecuteNonQuery(); } CommitTransaction(cmd.Transaction); } catch (Exception ex) { RollBackTransaction(cmd.Transaction); throw new Exception(EnumProcedureStockee.InsertDEMCOUT + ":" + ex.Message); } finally { if (cn.State == ConnectionState.Open) { cn.Close(); // Fermeture de la connection } cmd.Dispose(); } }