Package maissocial.controle

Source Code of maissocial.controle.TurmaPisControle

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

package maissocial.controle;

import maissocial.exception.TurmaPisJaCadastradaException;
import java.util.List;
import maissocial.repositorio.TurmaPisRepositorio;

/**
*
* @author luciano
*/
public class TurmaPisControle {

    private TurmaPisRepositorio trpRep;

    public TurmaPisControle(){
        this.trpRep = new TurmaPisRepositorio();
    }

    public void salvarTurmaPis(TurmaPis trp) throws Exception, TurmaPisJaCadastradaException{
        if( trp == null || trp.getCodTurmaPis() == null || trp.getCodTurmaPis() == 0 || trp.getStatus() == 0){
            throw  new Exception("Parâmetros Inválidos!");
        }

        TurmaPis trp2 = this.trpRep.pesquisarTurmaPisPorCodigo(trp.getCodTurmaPis());
        if(trp2 == null){
            this.trpRep.salvarTurmaPis(trp);
        }else{
            throw new TurmaPisJaCadastradaException("Turma de PIS já cadastrado!");
        }

    }

    public void deletarTurmaPisPorObj(TurmaPis trp){
        this.trpRep.deletarTurmaPisPorObj(trp);
    }

    public void deletarTurmaPis(int cod){
        this.trpRep.deletarTurmaPis(cod);
    }

    public void alterarTurmaPis(TurmaPis trp) throws Exception, TurmaPisJaCadastradaException{
        if( trp == null || trp.getCodTurmaPis() == null || trp.getCodTurmaPis() == 0 || trp.getStatus() == 0){
            throw  new Exception("Parâmetros Inválidos!");
        }

        TurmaPis trp2 = this.trpRep.pesquisarTurmaPisPorCodigo(trp.getCodTurmaPis());
        if(trp2 == null){
            this.trpRep.alterarTurmaPis(trp);
        }else{
            throw new TurmaPisJaCadastradaException("Turma PIS já cadastrado!");
        }
    }

    public TurmaPis pesquisarTurmaPisPorCodigo(int cod){
        TurmaPis trp = this.trpRep.pesquisarTurmaPisPorCodigo(cod);
        return trp;
    }

    public List pesquisarTurmaPisTodos(){
        List trp = this.trpRep.pesquisarTurmaPisTodos();
        return trp;
    }

}
TOP

Related Classes of maissocial.controle.TurmaPisControle

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.