public void createDetailsCommande(List <DetailCommande> detailCommandes, string id_commande) { Connexion connexion = new Connexion(); MySqlConnection connection = connexion.GetConnection(); connection.Open(); MySqlCommand command = connection.CreateCommand(); MySqlTransaction transaction; transaction = connection.BeginTransaction(); command.Connection = connection; command.Transaction = transaction; Commande commande = new Commande(); commande.IdCommande = Int32.Parse(id_commande); Duree duree = new Duree(); duree.Commande = commande; duree.HeureCommande = DateTime.Now; DureeDAO dureeDAO = new DureeDAO(); try { dureeDAO.ValiderDuree(command, duree); for (int i = 0; i < detailCommandes.Count; i++) { this.AjoutDetailsCommande(command, detailCommandes[i]); } if (transaction != null) { transaction.Commit(); } } catch (Exception exception) { transaction.Rollback(); throw exception; } finally { if (command != null) { command.Dispose(); } if (transaction != null) { transaction.Dispose(); } if (connection != null) { connection.Close(); } } }
public void Sortie(string id_commande, string id_magasinier, string id_binome) { Connexion connexion = new Connexion(); MySqlConnection connection = connexion.GetConnection(); connection.Open(); MySqlCommand command = connection.CreateCommand(); MySqlTransaction transaction; transaction = connection.BeginTransaction(); command.Connection = connection; command.Transaction = transaction; Duree duree = new Duree(); Commande commande = new Commande(); commande.IdCommande = Int32.Parse(id_commande); duree.Commande = commande; duree.HeureSortie = DateTime.Now; DureeDAO dureeDAO = new DureeDAO(); try { this.SortieCommande(command, commande); this.SortieStock(command, id_magasinier, id_binome, commande); dureeDAO.UpdateDuree(command, duree, "SORTIE"); if (transaction != null) { transaction.Commit(); } } catch (Exception exception) { transaction.Rollback(); throw exception; } finally { connexion.CloseAll(command, transaction, connection); } }
public void Valider(string id_commande) { Connexion connexion = new Connexion(); MySqlConnection connection = connexion.GetConnection(); connection.Open(); MySqlCommand command = connection.CreateCommand(); MySqlTransaction transaction; transaction = connection.BeginTransaction(); command.Connection = connection; command.Transaction = transaction; Duree duree = new Duree(); Commande commande = new Commande(); commande.IdCommande = Int32.Parse(id_commande); duree.Commande = commande; duree.HeureLivraison = DateTime.Now; DureeDAO dureeDAO = new DureeDAO(); try { this.ValiderCommande(command, id_commande); dureeDAO.UpdateDuree(command, duree, "LIVRAISON"); if (transaction != null) { transaction.Commit(); } } catch (Exception exception) { transaction.Rollback(); throw exception; } finally { connexion.CloseAll(command, transaction, connection); } }