/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.toscana.dao.managers;

import com.toscana.model.dao.implementations.DataCashOutDAOImplementation;
import com.toscana.model.dao.interfaces.DataCashOutDAO;
import com.toscana.model.reports.sources.DataCashOut;
import com.toscana.persistance.util.ToscanaHibernateUtil;
import java.util.ArrayList;

/**
 *
 * @author Arandi
 */
public class DataCashOutDAOManager {
    private DataCashOutDAO dataCashOutDAO;
    
    public DataCashOutDAOManager (){
        dataCashOutDAO = new DataCashOutDAOImplementation();
    }
    
    public void add (DataCashOut cashOut){
        try {
            ToscanaHibernateUtil.beginTransaction();
            dataCashOutDAO.add(cashOut);
            ToscanaHibernateUtil.commitTransaction();
        } catch (Exception e) {
            System.err.println(e);
            ToscanaHibernateUtil.rollbackTransaction();
        }
    }
    
    public  void delete(DataCashOut cashOut){
        try {
            ToscanaHibernateUtil.beginTransaction();
            dataCashOutDAO.delete(cashOut);
            ToscanaHibernateUtil.commitTransaction();
        } catch (Exception e) {
            System.err.println(e);
            ToscanaHibernateUtil.rollbackTransaction();
        }
    }
    
    public void update (DataCashOut cashOut){
        try {
            ToscanaHibernateUtil.beginTransaction();
            dataCashOutDAO.update(cashOut);
            ToscanaHibernateUtil.commitTransaction();
        } catch (Exception e) {
            System.err.println(e);
            ToscanaHibernateUtil.rollbackTransaction();
        }
    }
    
    public DataCashOut findByID(Integer ID){
        DataCashOut cashOut = null;
        try {
            ToscanaHibernateUtil.beginTransaction();
            cashOut =  dataCashOutDAO.findByID(DataCashOut.class, ID);
            ToscanaHibernateUtil.commitTransaction();
        } catch (Exception e) {
            System.err.println(e);
        }
        return cashOut;
    }
    
    public ArrayList findAll(){
        ArrayList<DataCashOut> cashOuts = null;
        try {
            ToscanaHibernateUtil.beginTransaction();
            cashOuts = (ArrayList<DataCashOut>) dataCashOutDAO.findAll(DataCashOut.class);
            ToscanaHibernateUtil.commitTransaction();
        } catch (Exception e) {
            System.err.println(e);
        }
        
        return cashOuts;
    }
}

@@ -655,35 +655,40 @@
 aCashOut cashOut
+ToAdd
 )%7B%0A
-
         try %7B%0A  
@@ -768,32 +768,37 @@
 tDAO.add(cashOut
+ToAdd
 );%0A            T
@@ -1017,32 +1017,40 @@
 aCashOut cashOut
+ToDelete
 )%7B%0A        try %7B
@@ -1136,32 +1136,40 @@
 O.delete(cashOut
+ToDelete
 );%0A            T
@@ -1396,16 +1396,24 @@
  cashOut
+TuUpdate
 )%7B%0A     
@@ -1515,16 +1515,24 @@
 (cashOut
+TuUpdate
 );%0A     
@@ -2172,17 +2172,20 @@
 ashOut%3E 
-c
+allC
 ashOuts 
@@ -2267,25 +2267,28 @@
             
-c
+allC
 ashOuts = (A
@@ -2504,25 +2504,28 @@
      return 
-c
+allC
 ashOuts;%0A   

Update DAO