Package projetAppliWeb.gestionnaires

Source Code of projetAppliWeb.gestionnaires.GestionnaireCommande

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package projetAppliWeb.gestionnaires;

import java.sql.Timestamp;
import java.util.Collection;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import projetAppliWeb.modeles.Commande;
import projetAppliWeb.modeles.LigneCommande;
import projetAppliWeb.modeles.Utilisateur;

/**
*
* @author Zakaria
*/
@Stateless
public class GestionnaireCommande {
   
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")

         @PersistenceContext
     private EntityManager em;


        public  void createCommande(Timestamp dateCommande, double totalCommande, Collection<LigneCommande> listeligneCommande, Utilisateur client){
            Commande commande=new Commande(dateCommande, totalCommande, listeligneCommande, client);
            em.persist(commande);

        }

         public Collection<Commande> getAllCommandes() {
         // Exécution d'une requête équivalente à un select *
         Query q = em.createQuery("select c from Commande c");
         return q.getResultList();
     }

     public Commande getCommandeById(int id) {
        Commande commande=em.find(Commande.class, id);
        return commande;
     }


          public Collection<Commande> getAllCommandeByIdUser(String user) {
       Query q = em.createQuery("select c from Commande c whare c.client.nom:nom");
       q.setParameter("nom", user);
       return q.getResultList();
     }


          public void deleteCommandebyId(int id){
              Commande commande=getCommandeById(id);
              em.remove(commande);
          }
}
TOP

Related Classes of projetAppliWeb.gestionnaires.GestionnaireCommande

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.