Example #1
0
  /*
   * Atualiza tabela (limpa tabela, refaz a consulta e adiciona os dados
   * novamente na tabela)
   */
  public void atualizaTabela() {

    try {

      if (!modelo.isEmpty()) {
        modelo.limpaLista();
      }
      lista.clear();

      SistemaDao2 dao2 = new SistemaDao2();
      lista = dao2.retornaAndamentoLotesPCP();

      if (!lista.isEmpty()) {

        modelo.adicionaLista(lista);
        sorter = new TableRowSorter<VisualizaDgqPcpTableModel>(modelo);
        tabela.setRowSorter(sorter);
        modelo.fireTableDataChanged();

      } else {
        JOptionPane.showMessageDialog(null, "Não há nenhum lote disponivel no momento.");
      }

    } catch (Exception e) {
      JOptionPane.showMessageDialog(null, "Erro ao atualizar a tabela: " + e);
    }
  }
Example #2
0
  public void excluirLote(List<JobLote> listaExcluir) {

    Connection conn = null;
    PreparedStatement stmt = null;
    String sql = "delete from joblote where job = ? and operacao = ? and lote =? ";

    try {

      conn = GerenciaConexaoSQLServer.abreConexao();
      conn.setAutoCommit(false);

      for (int i = 0; i <= listaExcluir.size() - 1; i++) {

        JobLote job = listaExcluir.get(i);

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

        alteraJobAposExclusao(conn, job);

        gravaJobsExcluidos(
            conn, job.getJob().trim().replace(".", ""), job.getOperNum(), job.getLote());
      }

      // adiciona a op na tela inicial
      for (int i = 0; i <= listaExcluir.size() - 1; i++) {
        JobLote job = listaExcluir.get(i);
        JobProtheus jobProtheus = retornaJob(conn, job);
        adicionaOPTelaInicial(conn, jobProtheus, job);
      }

      JOptionPane.showMessageDialog(this, "Job Excluido com Sucesso!");
      conn.commit();

    } catch (SQLException e) {

      if (conn != null) {

        try {

          conn.rollback();
          conn.setAutoCommit(true);

          JOptionPane.showMessageDialog(null, "Não foi possivel excluir! Descrição: " + e);

        } catch (SQLException ex) {
          JOptionPane.showMessageDialog(null, "Erro ao fazer o rollback! Descrição: " + ex);
        }
      }

    } finally {
      GerenciaConexaoSQLServer.closeConexao(conn, stmt);
    }
  }
Example #3
0
  public void atualizaTabela() {

    try {

      if (!modelo.isEmpty()) {
        modelo.limpaLista();
      }
      lista.clear();
      // refaz a consulta
      SistemaDao2 dao2 = new SistemaDao2();
      lista = dao2.retornaJobLoteFechadoPorWorkCenter();

      // adicionar uma lista vazia ao modelo dá erro, so podemos adicionar se a lista nao estiver
      // vazia
      if (!lista.isEmpty()) {
        // adiciona lista ao modelo e ordena a tabela
        modelo.adicionaLista(lista);
        sorter = new TableRowSorter<ExclusaoTableModel>(modelo);
        tabela.setRowSorter(sorter);
        modelo.fireTableDataChanged();
      }

      ajustaTabelaParaMobile();

    } catch (Exception e) {
      JOptionPane.showMessageDialog(null, "Erro ao atualizar a tabela: " + e);
    }
  }
Example #4
0
  private void jBPesquisarActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jBPesquisarActionPerformed
    // TODO add your handling code here:

    String text = jTFPesquisar.getText();

    if (text.length() == 0) {
      sorter.setRowFilter(null);
    } else {
      try {
        sorter.setRowFilter(RowFilter.regexFilter(text));
      } catch (PatternSyntaxException pse) {
        JOptionPane.showMessageDialog(null, "Bad regex pattern");

      } catch (RuntimeException ex2) {
        JOptionPane.showMessageDialog(null, "Erro: " + ex2.getMessage());
      }
    }
  } // GEN-LAST:event_jBPesquisarActionPerformed
Example #5
0
  public static java.util.Date converteStringParaData(String data) {

    java.util.Date dataConvertida = null;

    SimpleDateFormat formatador = new SimpleDateFormat("dd/MM/yyyy");
    try {
      dataConvertida = formatador.parse(data);
    } catch (ParseException ex) {
      JOptionPane.showMessageDialog(
          null, "Erro no metodo converteStringParaData(), classe: ConsultaJobs. Erro: " + ex);
    }

    return dataConvertida;
  }
Example #6
0
  public void excluir() {

    /*
     * percorre o modelo, pega o primeiro lote e verifica se esta marcado,
     * caso sim adiciona na lista dos que deverao ser excluidos
     */
    int total = modelo.getRowCount() - 1;
    listaExcluir = new ArrayList<JobLote>();
    List listaIndices = new ArrayList();
    for (int i = total; i >= 0; i--) {

      JobLote lote = modelo.getJob(i);

      if (lote.getStatus().equals(true)) {
        listaExcluir.add(lote);
        listaIndices.add(i);
      }
    }

    // verifica se nenhum foi selecionado, se algum foi, remove do modelo e do banco
    if (listaExcluir.isEmpty()) {
      JOptionPane.showMessageDialog(this, "Nenhum lote Selecionado!");
    } else {

      MensagemExclusaoLote msg = new MensagemExclusaoLote(null, true, this);
      msg.setVisible(true);

      if (msg.retornaOpcao()) {
        int indice = 0;
        int totalInd = listaIndices.size() - 1;
        for (int j = 0; j <= totalInd; j++) {

          indice = (Integer) listaIndices.get(j);
          modelo.removeJob(indice);
        }

        excluirLote(listaExcluir);
        ajustaCorLinhasColunasTabela();

      } else {
        // caso escolher a opção NAO, desmarca os items selecionados
        for (int i = 0; i <= listaIndices.size() - 1; i++) {
          Integer indice = (Integer) listaIndices.get(i);
          modelo.setValueAt(false, tabela.convertRowIndexToModel(indice), 0);
        }
      }
    }
  }
Example #7
0
  public void adicionaOPTelaInicial(Connection conn, JobProtheus jobProtheus, JobLote job)
      throws SQLException {

    if (jobProtheus != null) {

      //  antes de adicionar o job na tela de consultas jobs, verifica
      //  se ja existe, se ja existir remove e adiciona novamente
      int total = modeloConsultaJobs.getRowCount() - 1;
      for (int j = total; j >= 0; j--) {
        JobProtheus jobAtual = modeloConsultaJobs.getJob(j);

        if (jobAtual.getJob().trim().equals(job.getJob().trim())
            && jobAtual.getOperacao() == job.getOperNum()) {
          modeloConsultaJobs.removeJob(j);
        }
      }

      boolean temLinhaTempo =
          verificaSeSetorTemLinhaTempo(conn, jobProtheus.getCentroTrabalho().trim());
      if (temLinhaTempo) {
        if (jobProtheus.getQuantidadeCompleta() == 0) {
          desativaIniciado(
              conn, jobProtheus.getJob().trim().replace(".", ""), jobProtheus.getOperacao());
        } else {

          boolean iniciadoJaExiste =
              verificarSeJobEstaTabelaIniciado(
                  conn, jobProtheus.getJob().trim().replace(".", ""), jobProtheus.getOperacao());

          JobIniciado jobIniciado =
              retornaUltimoLote(
                  conn, jobProtheus.getJob().trim().replace(".", ""), jobProtheus.getOperacao());
          if (!iniciadoJaExiste) {
            incluiIniciado(conn, jobIniciado);
          } else {
            // fazer update jobsiniciados alterando os valores pelo lote mais atual
            alteraIniciado(conn, jobIniciado);
          }
        }
      }

      jLTotalAtrasados.setText(Principal.retornaTotalJobsAtrasados(modeloConsultaJobs));

    } else {

      JOptionPane.showMessageDialog(null, "Job não encontrado na SC2010: " + job);
    }
  }
Example #8
0
  private void jButtonRetrabalhoActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButtonRetrabalhoActionPerformed

    this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

    int contador = 0;
    listaJobLoteSelecionadoRetrabado = new ArrayList<JobLote>();
    for (int i = 0; i <= modelo.getRowCount() - 1; i++) {

      JobLote linha = modelo.getJob(i);

      if (linha.getStatus() == true) { // se estiver selecionado adiciona na lista
        listaJobLoteSelecionadoRetrabado.add(linha);
        contador++;
      }
    }

    /*Se houver mais de um joblote selecionado avisa que só é possivel selecionar um para lançar retrabalho*/
    if (contador < 1) {
      this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
      JOptionPane.showMessageDialog(null, "Selecione um lote!");

    } else if (contador > 1) {
      this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
      JOptionPane.showMessageDialog(null, "Só é permitido selecionar um Lote!");
      // desmarca tudo
      for (int i = 0; i <= modelo.getRowCount() - 1; i++) {
        modelo.setValueAt(false, tabela.convertRowIndexToModel(i), 0);
      }

    } else {

      timerTelaExclusao.stop();

      JobLote lote = listaJobLoteSelecionadoRetrabado.get(0);

      SistemaDao2 dao = new SistemaDao2();
      JobProtheus job = dao.retornaJob(lote);

      if (job == null) {

        JOptionPane.showMessageDialog(null, "Job não encontrado no sistema!");

      } else {

        boolean noturno = Principal.retornaTurnoSetorJobSelecionado(lote.getSetor().trim());
        boolean temTempoPadrao = Principal.getPossuiTempoPadrao(lote.getSetor().trim());

        LoteRejeitadoView tela =
            new LoteRejeitadoView(
                null,
                true,
                job,
                lote,
                job.getQuantidadeCompleta(),
                modelo,
                tabela,
                usuario,
                timer,
                setor,
                noturno,
                temTempoPadrao,
                "retrabalho",
                jBAtualizar);
        this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
        tela.setVisible(true);
      }
    }
  } // GEN-LAST:event_jButtonRetrabalhoActionPerformed
Example #9
-1
  private void jBPesquisarKeyTyped(
      java.awt.event.KeyEvent evt) { // GEN-FIRST:event_jBPesquisarKeyTyped

    if (evt.getKeyChar() == KeyEvent.VK_ENTER) {
      if (evt.getSource() == jBPesquisar) {

        String text = jTFPesquisar.getText();

        if (text.length() == 0) {
          sorter.setRowFilter(null);
        } else {
          try {
            sorter.setRowFilter(RowFilter.regexFilter(text));
            int total = calculaTotalPecas(text);
            jLabelTotalPecas.setText(String.valueOf(total));
          } catch (PatternSyntaxException pse) {
            JOptionPane.showMessageDialog(this, "Erro na pesquisa");
          } catch (RuntimeException ex2) {
            JOptionPane.showMessageDialog(null, "Erro: " + ex2.getMessage());
          }
        }
      }
    }
    tabela.grabFocus();
  } // GEN-LAST:event_jBPesquisarKeyTyped