Package labsis.financeiro.dao

Source Code of labsis.financeiro.dao.DaoContas

package labsis.financeiro.dao;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import labsis.DataBase;
import labsis.financeiro.model.Contas;
import labsis.financeiro.model.ContasAPagar;
import labsis.financeiro.model.ContasAReceber;

public class DaoContas {

  private Connection conn;

  public DaoContas() throws SQLException {
    DataBase db = DataBase.getDb();
    conn = db.getConnection();
  }

  public ArrayList<ContasAPagar> listarContasAPagar() {
    CallableStatement cstmt = null;
    ArrayList<ContasAPagar> lista = new ArrayList<ContasAPagar>();

    try {

      cstmt = conn.prepareCall("exec listarContasAPagar");
      ResultSet rs = cstmt.executeQuery();

      while(rs.next()){
        ContasAPagar c2 = new ContasAPagar();
        c2.setCodigo(rs.getString(1));
        c2.setPedidoCompraId(rs.getInt(2));
        c2.setNumParcelas(rs.getInt(3));
        c2.setValor(rs.getFloat(4));
       
        lista.add(c2);
      }

      cstmt.close();

    }

    catch (Exception e) {
      e.printStackTrace();
    }

    finally {
      try {
        cstmt.close();

      }
      catch(Exception e) {
        e.printStackTrace();
      }
    }
    return lista;
  }
 
  public ArrayList<ContasAReceber> listarContasAReceber() {
    CallableStatement cstmt = null;
    ArrayList<ContasAReceber> lista = new ArrayList<ContasAReceber>();

    try {

      cstmt = conn.prepareCall("exec listarContasAReceber");
      ResultSet rs = cstmt.executeQuery();

      while(rs.next()){
        ContasAReceber cr = new ContasAReceber();
        cr.setCodigo(rs.getString(1));
        cr.setIdFormaPagamento(rs.getInt(2));
        cr.setChequesCodigo(rs.getInt(3));
        cr.setPedidoVendaId(rs.getInt(4));
        cr.setNumParcelas(rs.getInt(5));
        cr.setValor(rs.getFloat(6));     
       
        lista.add(cr);
      }

      cstmt.close();

    }

    catch (Exception e) {
      e.printStackTrace();
    }

    finally {
      try {
        cstmt.close();

      }
      catch(Exception e) {
        e.printStackTrace();
      }
    }
    return lista;
  }
}
TOP

Related Classes of labsis.financeiro.dao.DaoContas

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.