示例#1
0
        public bool DeleteTransaction(LigneCommande ligneCommande)
        {
            bool isDeleted = false;

            using (Helper)
            {
                Helper.PrepareCommand("DELETE FROM LigneCommande WHERE CommandeId = @CommandeId AND ProduitId = @ProduitId");
                Helper.AddInParameter("CommandeId", DbType.Int32, ligneCommande.Commande.Id);
                Helper.AddInParameter("ProduitId", DbType.Int32, ligneCommande.Produit.Id);

                isDeleted = Helper.ExecuteNonQuery();
            }

            return isDeleted;
        }
 public bool UpdateTransactionByState(LigneCommande ligneCommande)
 {
     var res = false;
     switch (ligneCommande.StateEnum)
     {
         case State.New:
             res = CreateTransaction(ligneCommande); break;
         case State.Deleted:
             res = DeleteTransaction(ligneCommande); break;
         case State.Updated:
             res = UpdateTransaction(ligneCommande); break;
         case State.Unchanged:
             res = true; break;
     }
     return res;
 }
示例#3
0
        public bool CreateTransaction(LigneCommande ligneCommande)
        {
            var isCreated = false;

            using (Helper)
            {
                Helper.PrepareCommand("INSERT INTO LigneCommande (CommandeId, ProduitId, QteKilo, QteDemiKilo) "
                                                       + " VALUES(@CommandeId, @ProduitId, @QteKilo, @QteDemiKilo)");
                Helper.AddInParameter("CommandeId", DbType.Int32, ligneCommande.Commande.Id);
                Helper.AddInParameter("ProduitId", DbType.Int32, ligneCommande.Produit.Id);
                Helper.AddInParameter("QteKilo", DbType.Int32, ligneCommande.Qtekilo);
                Helper.AddInParameter("QteDemiKilo", DbType.Int32, ligneCommande.QteDemiKilo);

                isCreated = Helper.ExecuteNonQuery();
            }

            return isCreated;
        }
示例#4
0
        private void btnProduitAjouter_Click(object sender, EventArgs e)
        {
            try
            {
                if (lstProduit.SelectedItem == null)
                {
                    MessageBox.Show(@"Vous devez choisir un produit", @"Séléction de produit", MessageBoxButtons.OK,
                                                   MessageBoxIcon.Information);
                    return;

                }

                if (txtQteKilo.Value == 0 && txtQteDemiKilo.Value == 0)
                {
                    MessageBox.Show(@"Vous devez enter une quantité.", @"Séléction de produit", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    return;
                }

                LigneCommande = new LigneCommande
                                    {
                                        Commande = null,
                                        Produit = lstProduit.SelectedItem as Produit,
                                        Qtekilo = (int)txtQteKilo.Value,
                                        QteDemiKilo = (int)txtQteDemiKilo.Value
                                    };
                LigneCommande.Produit.Famille = lstFamille.SelectedItem as Famille;
                OnCloseForm();
            }
            catch (Exception exception)
            {
                GestionException.TraiterException(exception, "Gestion des commandes");
            }
        }
 private bool UpdateTransaction(LigneCommande ligneCommande)
 {
     return _ligneCommandeData.UpdateTransaction(ligneCommande);
 }
 public bool DeleteTransaction(LigneCommande ligneCommande)
 {
     return _ligneCommandeData.DeleteTransaction(ligneCommande);
 }
 public bool CreateTransaction(LigneCommande ligneCommande)
 {
     return _ligneCommandeData.CreateTransaction(ligneCommande);
 }
示例#8
0
        public bool UpdateTransaction(LigneCommande ligneCommande)
        {
            bool isUpdated;

            using (Helper)
            {
                Helper.PrepareCommand("UPDATE LigneCommande set QteKilo = @QteKilo, QteDemiKilo = @QteDemiKilo "
                                    + " WHERE CommandeId = @CommandeId AND ProduitId = @ProduitId");

                Helper.AddInParameter("QteKilo", DbType.Int32, ligneCommande.Qtekilo);
                Helper.AddInParameter("QteDemiKilo", DbType.Int32, ligneCommande.QteDemiKilo);
                Helper.AddInParameter("CommandeId", DbType.Int32, ligneCommande.Commande.Id);
                Helper.AddInParameter("ProduitId", DbType.Int32, ligneCommande.Produit.Id);

                isUpdated = Helper.ExecuteNonQuery();
            }

            return isUpdated;
        }