예제 #1
0
  public String alterar(TO to) throws Exception {
    try {
      Connection con = new Conexao().getConexao(dbf.getArquivo().getPath());

      PreparedStatement ps =
          con.prepareStatement(
              "UPDATE GERNFEIT SET NUMR_NFE = ?, MODL_NFECE = ?, DESC_PROD = ?, "
                  + "QTDE_PRODT = ?, VALR_UNITT = ?, VALR_DESCN = ?, VALR_TOTAL = ? "
                  + "WHERE NUMR_NFE = ?");
      ps.setString(1, to.getNum_nfe());
      ps.setString(2, to.getMod_nfece());
      ps.setString(3, to.getDes_prod());
      ps.setInt(4, to.getQtde_prod());
      ps.setDouble(5, to.getVal_unit());
      ps.setDouble(6, to.getVal_desc());
      ps.setDouble(7, to.getVal_total());
      ps.setString(8, to.getNum_nfe());
      ps.execute();
      con.close();
      return "Alteração OK";
    } catch (Exception ex) {
      System.out.println("ERRO ao alterar \n" + ex.getMessage());
    }
    return "";
  }
예제 #2
0
  public String inserir(TO to) throws Exception {
    try {
      Connection con = new Conexao().getConexao(dbf.getArquivo().getPath());

      PreparedStatement ps =
          con.prepareStatement(
              "INSERT INTO GERNFEIT (NUMR_NFE,MODL_NFECE,DESC_PROD,QTDE_PRODT,"
                  + "VALR_UNITT,VALR_DESCN,VALR_TOTAL) VALUE (?,?,?,?,?,?,?)");
      ps.setString(1, to.getNum_nfe());
      ps.setString(2, to.getMod_nfece());
      ps.setString(3, to.getDes_prod());
      ps.setInt(4, to.getQtde_prod());
      ps.setDouble(5, to.getVal_unit());
      ps.setDouble(6, to.getVal_desc());
      ps.setDouble(7, to.getVal_total());
      ps.execute();
      con.close();
      return "Inserção OK";
    } catch (Exception ex) {
      System.out.println("Erro ao inserir \n" + ex.getMessage());
    }
    return "";
  }