Exemple #1
0
  public ValoresAtualizaJob retornaNovosValores(Connection conn, JobLote job) throws SQLException {

    PreparedStatement stmt = null;
    ResultSet rs = null;
    ValoresAtualizaJob obj = null;

    String sql =
        " select sum(qtd_transf) qtd_transf, sum(qtd_sucata) qtd_sucata, sum(hr_tot) hr_tot from joblote\n"
            + " where job = ? and operacao = ? ";

    stmt = conn.prepareStatement(sql);
    stmt.setString(1, job.getJob().trim().replace(".", ""));
    stmt.setInt(2, job.getOperNum());
    rs = stmt.executeQuery();

    if (rs.next()) {

      obj = new ValoresAtualizaJob();
      obj.setQtdTransf(rs.getDouble("qtd_transf"));
      obj.setQtdSucata(rs.getDouble("qtd_sucata"));
      obj.setHoraTotal(rs.getDouble("hr_tot"));
    }

    return obj;
  }
Exemple #2
0
  public void alteraJobAposExclusao(Connection conn, JobLote job) throws SQLException {

    ValoresAtualizaJob valores = retornaNovosValores(conn, job);

    PreparedStatement stmt = null;
    String update =
        "update job set qtd_transf = ?, hr_tot = ?, qtd_sucata = ?, status = ? where job = ? and operacao = ? ";

    stmt = conn.prepareStatement(update);
    stmt.setDouble(1, valores.getQtdTransf());
    stmt.setDouble(2, valores.getHoraTotal());
    stmt.setDouble(3, valores.getQtdSucata());
    stmt.setString(4, "R");
    stmt.setString(5, job.getJob().trim().replace(".", ""));
    stmt.setInt(6, job.getOperNum());
    stmt.executeUpdate();
  }