Package sn.unitech.stock.dao

Source Code of sn.unitech.stock.dao.EventsDao

/*public class EventsDao<E> extends DataAccess<Events> implements IEventsDao<Events>{

*/
package sn.unitech.stock.dao;



import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;

import sn.unitech.stock.dao.iface.IEventsDao;
import sn.unitech.stock.entity.DetailEvent;
import sn.unitech.stock.entity.DetailEventId;
import sn.unitech.stock.entity.Events;
import sn.unitech.stock.entity.Taxes;
import sn.unitech.stock.modal.Resultat;

public class EventsDao extends DataAccess implements IEventsDao{
   
  public EventsDao() {
   
  }

  @Override
  public Resultat saveEvents(List<DetailEvent> listDetailEvent,
      List<Taxes> listTaxe) {
    Events events=listDetailEvent.get(0).getEvents();
    EntityManager em=getEntityManager();
    EntityTransaction tx=em.getTransaction();
    tx.begin();
    try{
    this.persist(events, em);
    for(int i=0;i<listDetailEvent.size();i++){
      listDetailEvent.get(i).setEvents(events);
      listDetailEvent.get(i).setId(new DetailEventId(events.getIdLot(),i));
      this.persist(listDetailEvent.get(i), em);
    }
    new SysEcritsDao(listDetailEvent,listTaxe,em).persistAllEcrits();
    tx.commit();
    return new Resultat(true,"Validation effectuee avec succes.",events.getIdLot());
    }catch(Exception e){
      e.printStackTrace();
      tx.rollback();
      return new Resultat(false,"Erreur fatale: "+e.getMessage());
    }finally{
      em.close();
    }
  }
 
     
 
}
TOP

Related Classes of sn.unitech.stock.dao.EventsDao

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.