/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.siso.horario.MySqlDAO;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import pe.siso.horario.Beans.BloquePrimariaInicial;
import pe.siso.horario.DAO.BloqueInicialPrimariaDAO;

/**
 *
 * @author sistem16user
 */
public class MySqlBloquePriIniDAO implements BloqueInicialPrimariaDAO {

    @Override
    public ArrayList<BloquePrimariaInicial> cargarBloqueGeneral() throws Exception {
        ArrayList<BloquePrimariaInicial> lista = new ArrayList<BloquePrimariaInicial>();
        String base = "horario";
        Connection cnx = null;
        try {
            cnx = MySqlDAOFactory.obtenerConexion(base);
            Statement st = cnx.createStatement();

            String query = "SELECT codBloGen,nomBloGen from bloque_general WHERE estBloGen='1'";

            ResultSet rs = st.executeQuery(query);

            while (rs.next()) {
                BloquePrimariaInicial bloqueG = new BloquePrimariaInicial();
                bloqueG.setCodBloGen(rs.getInt("codBloGen"));
                bloqueG.setNomBloGen(rs.getString("nomBloGen"));

                lista.add(bloqueG);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            cnx.close();
        }
        return lista;
    }

}
