private void limparTabela() {
   DefaultTableModel modelo = (DefaultTableModel) this.tbCargos.getModel();
   int numLinhas = tbCargos.getRowCount();
   for (int i = 0; i < numLinhas; i++) {
     modelo.removeRow(0);
   }
 }
 public void removeRow() {
   try {
     if (tblUnitList.getSelectedRow() < 0) {
       Message.showWarning("Please select in the table");
       return;
     }
     //            if (((Number) model.getValueAt(0, 2)).intValue() > 0) {
     //                deleteUnitList.add((Integer) model.getValueAt(tblUnitList.getSelectedRow(),
     // 4));
     //            }
     if (userTask >= GlobalMode.EDIT
         && (int) model.getValueAt(tblUnitList.getSelectedRow(), 4) > 0) {
       if (JOptionPane.showConfirmDialog(
               this,
               "This unit is already in use. This will be permanently delete to the database. Do you still want to continue?",
               "WARNING",
               JOptionPane.YES_NO_OPTION)
           == JOptionPane.YES_OPTION) {
         totalLeaseArea -=
             ((Number) model.getValueAt(tblUnitList.getSelectedRow(), 1)).doubleValue();
         rDB.deleteRentalDetailID(
             ((Number) model.getValueAt(tblUnitList.getSelectedRow(), 4)).intValue(),
             totalLeaseArea);
         model.removeRow(tblUnitList.getSelectedRow());
       }
     } else {
       totalLeaseArea -=
           ((Number) model.getValueAt(tblUnitList.getSelectedRow(), 1)).doubleValue();
       model.removeRow(tblUnitList.getSelectedRow());
     }
   } catch (Exception e) {
     Message.showError(e.getMessage());
   }
 }
  private void jButton5ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton5ActionPerformed
    int rows2Delete = jTable1.getSelectedRowCount();

    int[] selectedRows = jTable1.getSelectedRows();

    if (rows2Delete < 1) {

      java.awt.Toolkit.getDefaultToolkit().beep();

      javax.swing.JOptionPane.showMessageDialog(this, "There are no selected rows to delete!");

    } else {

      if (rows2Delete > 1) {

        for (int i = 0; i < selectedRows.length; i++) {

          javax.swing.table.DefaultTableModel defTableModel =
              (javax.swing.table.DefaultTableModel) jTable1.getModel();

          defTableModel.removeRow(selectedRows[i]);
        }

      } else {

        javax.swing.table.DefaultTableModel defTableModel =
            (javax.swing.table.DefaultTableModel) jTable1.getModel();

        defTableModel.removeRow(jTable1.getSelectedRow());
      }
    } // Add your handling code here:
  } // GEN-LAST:event_jButton5ActionPerformed
Exemple #4
0
 @Override
 public void actionPerformed(ActionEvent e) {
   ID = (Integer) hashRoomType.get(boxRoomTypeID.getSelectedItem().toString());
   IDSTATUS = (Integer) hashRoomStatus.get(boxRoomStatusID.getSelectedItem().toString());
   if (e.getSource() == buttonInsert) {
     try {
       Rooms rooms = new Rooms(txtRoomNumber.getText(), txtDescription.getText(), ID, IDSTATUS);
       RoomsController.roomsController.save(rooms);
       int c = model.getRowCount();
       for (int i = c - 1; i >= 0; i--) {
         model.removeRow(i);
         jRoom.revalidate();
       }
       all();
       JOptionPane.showMessageDialog(this, "ok");
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
   if (e.getSource() == buttonUpdate) {
     try {
       Rooms rooms = new Rooms(txtRoomNumber.getText(), txtDescription.getText(), ID, IDSTATUS);
       rooms.setRoomID(IDROOM);
       RoomsController.roomsController.update(rooms);
       int c = model.getRowCount();
       for (int i = c - 1; i >= 0; i--) {
         model.removeRow(i);
         jRoom.revalidate();
       }
       all();
       JOptionPane.showMessageDialog(this, "Update to succeed !");
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
   if (e.getSource() == buttonDelete) {
     try {
       List<CheckIn> temp = CheckInController.checkInController.all();
       for (int i = 0; i < temp.size(); i++) {
         if (IDROOM == temp.get(i).getRoomID()) {
           this.error = 0;
         } else {
           this.error = 0;
           RoomsController.roomsController.delete(IDROOM);
           int c = model.getRowCount();
           for (int ii = c - 1; ii >= 0; ii--) {
             model.removeRow(ii);
             jRoom.revalidate();
           }
           all();
         }
       }
       JOptionPane.showMessageDialog(this, "Delete to succeed !");
     } catch (Exception ex) {
       JOptionPane.showMessageDialog(this, "can't delete row bcause check still !");
     }
   }
   if (e.getSource() == buttonRefresh) {}
 }
 @SuppressWarnings("unchecked")
 @Override
 public int loop() {
   synchronized (lock) {
     try {
       if (!ui.isVisible()) handler.stopMod(getName());
       World world = minecraft.getWorld();
       JTable list = ui.getList();
       DefaultTableModel model = (DefaultTableModel) list.getModel();
       TableRowSorter<TableModel> sorter = (TableRowSorter<TableModel>) list.getRowSorter();
       if (world != null) {
         Player currentPlayer = minecraft.getPlayer();
         int playerX = (int) java.lang.Math.round(currentPlayer.getX());
         int playerY = (int) java.lang.Math.round(currentPlayer.getY());
         int playerZ = (int) java.lang.Math.round(currentPlayer.getZ());
         ArrayList<Block> blocks = new ArrayList<Block>();
         for (int x = playerX - radius; x < playerX + radius; x++)
           for (int y = playerY - radius; y < playerY + radius; y++)
             for (int z = playerZ - radius; z < playerZ + radius; z++)
               if (world.getBlockIDAt(x, y, z) == blockID) blocks.add(new Block(x, y, z));
         label:
         for (int row = 0; row < model.getRowCount(); row++) {
           int x = (Integer) model.getValueAt(row, 1);
           int y = (Integer) model.getValueAt(row, 2);
           int z = (Integer) model.getValueAt(row, 3);
           for (Block block : blocks) {
             if (x == block.getX() && y == block.getY() && z == block.getZ()) {
               model.setValueAt(getDistanceTo(x, y, z, currentPlayer), row, 0);
               continue label;
             }
           }
           model.removeRow(row);
         }
         label:
         for (Block block : blocks) {
           for (int row = 0; row < model.getRowCount(); row++) {
             int x = (Integer) model.getValueAt(row, 1);
             int y = (Integer) model.getValueAt(row, 2);
             int z = (Integer) model.getValueAt(row, 3);
             if (x == block.getX() && y == block.getY() && z == block.getZ()) continue label;
           }
           model.addRow(
               new Object[] {
                 getDistanceTo(block.getX(), block.getY(), block.getZ(), minecraft.getPlayer()),
                 block.getX(),
                 block.getY(),
                 block.getZ()
               });
         }
         sorter.sort();
         list.repaint();
       } else {
         for (int i = model.getRowCount() - 1; i >= 0; i--) model.removeRow(i);
       }
     } catch (Exception exception) {
     }
   }
   return 500;
 }
 private void btnEliminarMouseClicked(
     java.awt.event.MouseEvent evt) { // GEN-FIRST:event_btnEliminarMouseClicked
   DefaultTableModel modelo = (DefaultTableModel) tabla.getModel();
   int indice = tabla.getSelectedRow();
   if (indice != -1) {
     modelo.removeRow(indice);
   } else {
     modelo.removeRow(modelo.getRowCount() - 1);
   }
 } // GEN-LAST:event_btnEliminarMouseClicked
  private void ClearButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_ClearButtonActionPerformed
    DefaultTableModel dtm = (DefaultTableModel) IPTable.getModel();
    while (dtm.getRowCount() > 0) {
      dtm.removeRow(0);
    }

    dtm = (DefaultTableModel) PacketInfoTable.getModel();
    while (dtm.getRowCount() > 0) dtm.removeRow(0);
    PacketDataTextArea.setText(null);
    // TODO add your handling code here:
  } // GEN-LAST:event_ClearButtonActionPerformed
Exemple #8
0
  private void btnGuardarActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnGuardarActionPerformed
    // TODO add your handling code here:
    if (!txtnombre.getText().isEmpty()) {

      mthunidadmedidas obj = new mthunidadmedidas();

      obj.setNombre(txtnombre.getText());

      if (obj.save_unidad()) {
        // Este metodo es para volver el modelo de la tabla a como era al inicio, entonces la clase
        // toma el modelo y vuelve a cargar los datos ya actualizados
        try {
          DefaultTableModel modelo = (DefaultTableModel) tablaunidadmedidas.getModel();
          int filas = tablaunidadmedidas.getRowCount();
          for (int i = 0; filas > i; i++) {
            modelo.removeRow(0);
          }
          mthunidadmedidas para_actualizar = new mthunidadmedidas();
          para_actualizar.tabla_unidad();
          limpiar();
        } catch (Exception e) {
          JOptionPane.showMessageDialog(null, "Error al limpiar la tabla.");
        }
        JOptionPane.showMessageDialog(this, "Datos guardados");
      } else {
        JOptionPane.showMessageDialog(this, "Error al guardar datos");
      }
    } else {
      JOptionPane.showMessageDialog(this, "Por favor llene todos los campos");
    }
  } // GEN-LAST:event_btnGuardarActionPerformed
  private void jButtonMoveUpActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButtonMoveUpActionPerformed

    if (jTable1.getSelectedRow() > 0) {
      DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel();
      int[] indices = jTable1.getSelectedRows();
      for (int i = indices.length - 1; i >= 0; --i) {
        if (indices[i] == 0) continue;

        Object val = jTable1.getValueAt(indices[i], 0);
        dtm.removeRow(indices[i]);
        dtm.insertRow(indices[i] - 1, new Object[5]);
        setRowValues((MeterInterval) val, indices[i] - 1);
        indices[i]--;
      }

      DefaultListSelectionModel dlsm = (DefaultListSelectionModel) jTable1.getSelectionModel();
      dlsm.setValueIsAdjusting(true);
      dlsm.clearSelection();
      for (int i = 0; i < indices.length; ++i) {
        dlsm.addSelectionInterval(indices[i], indices[i]);
      }
      dlsm.setValueIsAdjusting(false);
    }
  } // GEN-LAST:event_jButtonMoveUpActionPerformed
 private void pcodeKeyReleased(java.awt.event.KeyEvent evt) { // GEN-FIRST:event_pcodeKeyReleased
   // TODO add your handling code here:
   String code = pcode.getText();
   int tblsize = tblProduct_model.getRowCount();
   for (int i = 0; i < tblsize; i++) {
     tblProduct_model.removeRow(0);
   }
   pdesc.setText("");
   if (!code.trim().equals("")) {
     OptionGroup_Controller group = new OptionGroup_Controller();
     String groupName = group.seekGroup(code);
     if (groupName != null && !groupName.equals("")) {
       pdesc.setText(groupName);
       setDataToGrid(group.getOptionDetail(code));
     } else {
       pdesc.setText("**** GroupFile Error ****");
     }
   }
   if (evt.getKeyCode() == java.awt.event.KeyEvent.VK_ENTER) {
     if (!pdesc.getText().equals("**** GroupFile Error ****")
         && !pdesc.getText().trim().equals("")) {
       option.requestFocus();
     }
   }
 } // GEN-LAST:event_pcodeKeyReleased
 public void displayQuizOptions() {
   // displays the the quizzes the pupil can do based on their skill level
   int quizNum = 0;
   int total = 0;
   String quizSkill = "";
   try {
     DatabaseConnect.init();
     Connection conn = DatabaseConnect.getConnection();
     Statement stmt = conn.createStatement();
     String query = "SELECT * FROM QUIZ where QUIZ_LEVEL ='" + skillLevel + "'";
     ResultSet result = stmt.executeQuery(query);
     DefaultTableModel model = (DefaultTableModel) tblQuiz.getModel();
     while (model.getRowCount() > 0) {
       model.removeRow(0);
     }
     if (result != null) {
       while (result.next()) {
         quizNum = result.getInt("QUIZ_NUMBER");
         total = result.getInt("TOTAL_POINTS");
         quizSkill = result.getString("QUIZ_LEVEL");
         int number = NumQuestions(quizNum);
         model.addRow(new Object[] {quizNum, quizSkill, total, number});
       }
     }
     stmt.close();
     conn.close();
     result.close();
   } // end try
   catch (Exception ex) {
     System.err.print("SQLException: ");
     System.err.println(ex.getMessage());
   }
 } // END method
 public void actionPerformed(ActionEvent e) {
   if (e.getActionCommand().equals("Add Column")) {
     PopMessage.popMsg("Invalid new column for this window");
     // defaultModel.addColumn("AddColumn");
   }
   if (e.getActionCommand().equals("Add Row")) defaultModel.addRow(new Vector());
   if (e.getActionCommand().equals("Remove Column")) {
     PopMessage.popMsg("Invalid new column for this window");
     //            int columncount = defaultModel.getColumnCount() - 1;
     //            if (columncount >= 0) {
     //                TableColumnModel columnModel = table.getColumnModel();
     //                TableColumn tableColumn = columnModel.getColumn(columncount);
     //                columnModel.removeColumn(tableColumn);
     //                defaultModel.setColumnCount(columncount);
     //            }
   }
   if (e.getActionCommand().equals("Remove Row")) {
     int rowcount = defaultModel.getRowCount() - 1;
     if (rowcount >= 0) {
       defaultModel.removeRow(rowcount);
       defaultModel.setRowCount(rowcount);
     }
   }
   table.revalidate();
 }
  private void jButton3ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton3ActionPerformed
    // TODO add your handling code here:
    try {
      Class.forName("com.mysql.jdbc.Driver");

      // MENYIAPKAN KONEKSI DAN PARAMETERNYA
      String urldb = "jdbc:mysql://localhost:3306/hotel";
      String user = "******";
      String password = "";
      Connection koneksi = DriverManager.getConnection(urldb, user, password);
      // Query SQL dan Eksekuusinya

      Statement st = koneksi.createStatement();

      String strSQL = "delete from master_costumer where id_ktp='" + txtid.getText() + "'";
      st.executeUpdate(strSQL);
      tblModel.removeRow(row);

      txtid.setText("");
      txtnama.setText("");
      txtalamat.setText("");

      st.close();
      koneksi.close();
    } catch (ClassNotFoundException cnfe) {
      System.out.println("KESALAHAN SAAT" + "ME-LOAD DRIVER JDBC \n" + cnfe.getMessage());
    } catch (SQLException sqle) {
      System.out.println(
          "KESALAHAN SAAT KONEKSI ATAU " + "KESALAHAN QUERY SQL \n" + sqle.getMessage());
    }
  } // GEN-LAST:event_jButton3ActionPerformed
 private void btnEliminarTodoMouseClicked(
     java.awt.event.MouseEvent evt) { // GEN-FIRST:event_btnEliminarTodoMouseClicked
   DefaultTableModel modelo = (DefaultTableModel) tabla.getModel();
   for (int i = modelo.getRowCount() - 1; i >= 0; i--) {
     modelo.removeRow(i);
   }
 } // GEN-LAST:event_btnEliminarTodoMouseClicked
Exemple #15
0
  public void loadTableData() {

    while (tableModel1.getRowCount() > 0) {
      tableModel1.removeRow(0);
    }

    vatList = dbValue.getVatDetail();
    yearList = dbValue.getFinancialYearDetail();
    /*
     * Collections.sort(yearList, new Comparator<FinancialYearModal>() {
     *
     * @Override public int compare(FinancialYearModal year1,
     * FinancialYearModal year2) {
     *
     * if(year1.getStartYear()==year2.getStartYear()) return 0; else return
     * year1.getStartYear()-year2.getStartYear();
     *
     * } });
     */
    for (int i = 0; i < vatList.size(); i++) {
      int startYear = 0, endYear = 0;
      vatModel = vatList.get(i);
      for (FinancialYearModal yearModel : yearList) {
        if (yearModel.getYearId() == vatModel.getYearId()) {
          startYear = yearModel.getStartYear();
          endYear = yearModel.getEndYear();
        }
      }
      tableModel1.addRow(new Object[] {i + 1, vatModel.getVatPercent(), startYear, endYear});
    }
  }
Exemple #16
0
  /** Method to update the friend's list. */
  public void updateFriends() {
    // Clear rows
    int count = friendListData.getRowCount();
    boolean online = false;

    for (int i = 0; i < count; i++) friendListData.removeRow(0);

    // Add rows
    for (Client c : Constants.getFriends()) {
      if (c.isOnline()) {
        switch (c.getStatus()) {
          case 0:
            if (!c.isPlayedSound()) {
              online = true;
              c.setPlayedSound(true);
            }
            friendListData.addRow(new Object[] {Constants.onlineIcon, c.getUsername()});
            break;
          case 1:
            friendListData.addRow(new Object[] {Constants.awayIcon, c.getUsername()});
            break;
          case 2:
            friendListData.addRow(new Object[] {Constants.dndIcon, c.getUsername()});
            break;
        }
      } else {
        friendListData.addRow(new Object[] {Constants.offlineIcon, c.getUsername()});
      }
    }

    repaint();

    if (Constants.isPlaySounds() && online) Constants.getAudioPlayer().play(AudioPlayer.ONLINE);
  }
Exemple #17
0
 public void llenarTabla() {
   // limpiar tabla
   try {
     DefaultTableModel model = (DefaultTableModel) tabla.getModel();
     int filas = tabla.getRowCount();
     for (int i = 0; filas > i; i++) {
       model.removeRow(0);
     }
   } catch (Exception e) {
     System.out.println("Error al limpiar tabla:" + e);
   }
   // fin de limpiar tabla
   String[] registros = new String[4];
   conexion nc = new conexion();
   try {
     Connection n = nc.conectar();
     Statement st = n.createStatement();
     ResultSet rs = st.executeQuery("SELECT codigo,item,price,stock FROM inventario");
     while (rs.next()) {
       registros[0] = rs.getString("codigo");
       registros[1] = rs.getString("item");
       registros[2] = rs.getString("price");
       registros[3] = rs.getString("stock");
       ((DefaultTableModel) tabla.getModel()).addRow(registros);
     }
   } catch (Exception e) {
     System.out.println(e);
   }
   nc.cerrarConexion();
 }
  private static void updateRegisteredKeypairsTable() {
    DefaultTableModel defaultTableModel = (DefaultTableModel) keypairsTable.getModel();
    while (defaultTableModel.getRowCount() != 0) {
      defaultTableModel.removeRow(0);
    }
    keypairs.clear();

    ArrayList<KeypairPOJO> registeredKeypairs = null;
    try {
      registeredKeypairs = KeypairDAO.getKeypairs();
    } catch (Exception e) {
      e.printStackTrace();
    }

    if (registeredKeypairs != null) {
      for (KeypairPOJO keypair : registeredKeypairs) {
        defaultTableModel.addRow(
            new String[] {
              keypair.getKeypairDescription(), keypair.getGenerationTimestampAsString()
            });
        keypairs.add(keypair);
      }
    }
    keypairsTable.setModel(defaultTableModel);
  }
 /**
  * Выводит в таблицу результат поиска
  *
  * @param findGenre поиск по имени или все: ByName, ByAllGenres
  * @param str название жанра
  */
 private void showTable(FindGenre findGenre, String str) {
   if (strings == null) {
     strings = new ArrayList<>();
   } else {
     strings.clear();
   }
   DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
   for (int i = jTable1.getRowCount(); i > 0; i--) {
     model.removeRow(i - 1);
   }
   try {
     switch (findGenre) {
       case ByName:
         strings = ctrl.findGenreByName(str);
         break;
       case ByAllGenres:
         strings = ctrl.findAllGenre();
         break;
     }
   } catch (IOException e) {
     Logger.getLogger(GenreFrame.class.getName()).log(Level.SEVERE, null, e);
     errorMessage("Ошибка при открытии файла");
   } catch (ClassNotFoundException ex) {
     Logger.getLogger(GenreFrame.class.getName()).log(Level.SEVERE, null, ex);
     errorMessage("ClassNotFoundException!");
   }
   for (String string : strings) {
     model.addRow(new Object[] {string});
   }
 }
Exemple #20
0
 private void updateTable(List list, final DefaultTableModel dftm) {
   int num = dftm.getRowCount();
   for (int i = 0; i < num; i++) dftm.removeRow(0);
   Iterator iterator = list.iterator();
   TbKhinfo khInfo;
   while (iterator.hasNext()) {
     List info = (List) iterator.next();
     Item item = new Item();
     item.setId((String) info.get(0));
     item.setName((String) info.get(1));
     khInfo = Dao.getKhInfo(item);
     Vector rowData = new Vector();
     rowData.add(khInfo.getId().trim());
     rowData.add(khInfo.getKhname().trim());
     rowData.add(khInfo.getAddress().trim());
     rowData.add(khInfo.getJian().trim());
     rowData.add(khInfo.getBianma().trim());
     rowData.add(khInfo.getTel().trim());
     rowData.add(khInfo.getFax().trim());
     rowData.add(khInfo.getLian().trim());
     rowData.add(khInfo.getLtel().trim());
     rowData.add(khInfo.getMail().trim());
     rowData.add(khInfo.getXinhang().trim());
     rowData.add(khInfo.getHao().trim());
     dftm.addRow(rowData);
   }
 }
  /**
   * Listens for a topic being removed from the space for either a MainMenuController or a
   * ChatroomController.
   */
  @Override
  public void notify(RemoteEvent remoteEvent) throws UnknownEventException, RemoteException {
    try {
      // Get the event that triggered the notification
      AvailabilityEvent availEvent = (AvailabilityEvent) remoteEvent;
      JMSTopicDeleted topicDeleted = (JMSTopicDeleted) availEvent.getEntry();

      if (isChatroomController) {
        // If the listener is for a ChatroomController, inform the given
        // chatroom that the chatroom's topic has been deleted
        chatroomController.handleTopicDeleted();
      } else {
        // If the listener is for a MainMenuController, remove the given
        // topic from the MainMenuController's topic list.
        DefaultTableModel topicTableModel = mainMenuController.getTopicTableModel();

        // Loop through all of the topics in the MainMenuController's
        // topic list and remove the one that was deleted
        for (int i = 0; i < topicTableModel.getRowCount(); i++) {
          UUID topicIdInTable = (UUID) topicTableModel.getValueAt(i, 3);
          JMSTopic topicRemoved = topicDeleted.getTopic();
          UUID topicDeletedId = topicRemoved.getId();

          if (topicIdInTable.equals(topicDeletedId)) {
            topicTableModel.removeRow(i);

            break;
          }
        }
      }
    } catch (Exception e) {
      System.err.println("Failed to remove topic from list or send notifications to users.");
      e.printStackTrace();
    }
  }
  private void buscar() {
    CategoriaBL objCategoriaBL = new CategoriaBL();
    DefaultTableModel temp = (DefaultTableModel) this.tbCategoria.getModel();
    for (int i = temp.getRowCount() - 1; i >= 0; --i) {
      temp.removeRow(i);
    }
    String temp1 = "";
    for (int i = 0; i < this.txtNombre.getText().length(); ++i) {
      if (this.txtNombre.getText().charAt(i) != '\'') {
        temp1 += this.txtNombre.getText().charAt(i);
      }
    }
    String temp2 = "";
    for (int i = 0; i < this.txtDescripcion.getText().length(); ++i) {
      if (this.txtDescripcion.getText().charAt(i) != '\'') {
        temp2 += this.txtDescripcion.getText().charAt(i);
      }
    }
    ArrayList<CategoriaBE> alstResultado = objCategoriaBL.buscarCategoria(temp2, temp1);
    for (int i = 0; i < alstResultado.size(); ++i) {
      Object[] nuevo = {
        alstResultado.get(i).getIdCategoria(),
        alstResultado.get(i).getNombre(),
        alstResultado.get(i).getDescripcion()
      };
      temp.addRow(nuevo);
    }

    this.txtDescripcion.setText("");
    this.txtNombre.setText("");
  }
  private void jButton4ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton4ActionPerformed

    int respuesta =
        JOptionPane.showConfirmDialog(
            this,
            "¿Desea suprimir el contacto?\n" + salidaSeleccionada.getCod_salida(),
            "Confirmación",
            JOptionPane.YES_NO_OPTION,
            JOptionPane.WARNING_MESSAGE);
    // Comprobar si se ha pulsado Aceptar o Cancelar
    if (respuesta == JOptionPane.YES_OPTION) {
      salidaSeleccionada.getCod_salida();
      gestionSalidas.delete(salidaSeleccionada.getCod_salida());
      modelTablaSalidas.removeRow(jTable1.getSelectedRow());
    } else {
      // Si no se ha seleccionado un contacto de la lista hay que notificarlo
      JOptionPane.showMessageDialog(
          this,
          "Debe seleccionar un contacto previamente",
          "Atención",
          JOptionPane.WARNING_MESSAGE);
    }
    observaciones.setText("");
    jLabelFecha.setText("");
    jLabelHora.setText("");
    jLabelNombreVol.setText("");
    jLabelNombreCor.setText("");
  } // GEN-LAST:event_jButton4ActionPerformed
 private void removeSelectedRows() {
   DefaultTableModel model = (DefaultTableModel) jtable.getModel();
   int[] rows = jtable.getSelectedRows();
   for (int i = 0; i < rows.length; i++) {
     model.removeRow(rows[i] - i);
   }
 }
  /**
   * Updates the content of the table.
   *
   * <p>This method will be called by an observable element.
   *
   * <ul>
   *   <li>If the observable is a {@link MailSaver} object, a new row will be added to the table,
   *       and the {@link UIModel} will be updated;
   *   <li>If the observable is a {@link ClearAllButton} object, all the cells of the table will be
   *       removed, and the {@link UIModel} will be updated.
   * </ul>
   *
   * @param o the observable element which will notify this class.
   * @param arg optional parameters (an {@code EmailModel} object, for the case of a {@code
   *     MailSaver} observable) containing all the information about the email.
   */
  @Override
  public void update(Observable o, Object arg) {
    if (o instanceof MailSaver) {
      EmailModel email = (EmailModel) arg;
      String subject;
      try {
        subject = MimeUtility.decodeText(email.getSubject());
      } catch (UnsupportedEncodingException e) {
        LOGGER.error("", e);
        subject = email.getSubject();
      }

      model.addRow(
          new Object[] {
            dateFormat.format(email.getReceivedDate()), email.getFrom(), email.getTo(), subject
          });
      UIModel.INSTANCE.getListMailsMap().put(nbElements++, email.getFilePath());
    } else if (o instanceof ClearAllButton) {
      // Delete information from the map
      UIModel.INSTANCE.getListMailsMap().clear();

      // Remove elements from the list
      try {
        while (nbElements > 0) {
          model.removeRow(--nbElements);
        }
      } catch (ArrayIndexOutOfBoundsException e) {
        LOGGER.error("", e);
      }
    }
  }
 private void clearForm() {
   int tblsize = tblProduct_model.getRowCount();
   for (int i = 0; i < tblsize; i++) {
     tblProduct_model.removeRow(0);
   }
   option.setText("");
 }
 /** Method edit employee on database and edit on employee table */
 private void editEmp() {
   parent.doBlur();
   // Get Id employee selected
   String empID = view.getTblEmp().getValueAt(view.getTblEmp().getSelectedRow(), 0).toString();
   // Get employee from database
   Employee emp = AccessEmp.getInstance().getEmpInfo(new Integer(empID));
   // Create instance of Employee edit dialog and display it
   editEmp = new EditEmployeeController(new EditEmployeeDialog(parent.getView()), emp);
   editEmp.getView().setVisible(true);
   // Update data on database
   if (editEmp.getEmp() != null) {
     if (AccessEmp.getInstance().editEmp(editEmp.getEmp())) {
       JOptionPane.showMessageDialog(
           view,
           Messages.getString("EmployeeController.14"), // $NON-NLS-1$
           Messages.getString("EmployeeController.15"),
           JOptionPane.INFORMATION_MESSAGE);
       // Remove old data on table model
       empModel.removeRow(view.getTblEmp().getSelectedRow());
       // Add new row
       empModel.addRow(emp.toVector());
     } else {
       JOptionPane.showMessageDialog(
           view,
           Messages.getString("EmployeeController.16") // $NON-NLS-1$
               + Messages.getString("EmployeeController.17"),
           Messages.getString("EmployeeController.18"), // $NON-NLS-1$
           JOptionPane.ERROR_MESSAGE);
     }
   }
   parent.doBlur();
   // Set selection to employee book
   view.getTblEmp().changeSelection(view.getTblEmp().getRowCount() - 1, 0, false, false);
 }
Exemple #28
0
 private void removeButtonActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_removeButtonActionPerformed
   if (outputTable.getSelectedRow() != -1) {
     DefaultTableModel model = (DefaultTableModel) this.outputTable.getModel();
     model.removeRow(outputTable.getSelectedRow());
   }
 } // GEN-LAST:event_removeButtonActionPerformed
 /** Delete an employee */
 private void deleteEmp() {
   parent.doBlur();
   int sure =
       JOptionPane.showConfirmDialog(
           parent.getView(),
           Messages.getString("EmployeeController.7"),
           Messages.getString("EmployeeController.8"), // $NON-NLS-1$
           JOptionPane.YES_NO_OPTION,
           JOptionPane.INFORMATION_MESSAGE);
   if (sure == JOptionPane.OK_OPTION) {
     // Get Id employee selected
     String empID = view.getTblEmp().getValueAt(view.getTblEmp().getSelectedRow(), 0).toString();
     if (!AccessEmp.getInstance().deleteEmp(Integer.parseInt(empID))) {
       JOptionPane.showMessageDialog(
           parent.getView(),
           Messages.getString("EmployeeController.9") // $NON-NLS-1$
               + Messages.getString("EmployeeController.10"), // $NON-NLS-1$
           Messages.getString("EmployeeController.11"),
           JOptionPane.ERROR_MESSAGE);
     } else {
       JOptionPane.showMessageDialog(
           parent.getView(),
           Messages.getString("EmployeeController.12"),
           Messages.getString("EmployeeController.13"), // $NON-NLS-1$
           JOptionPane.INFORMATION_MESSAGE);
       empModel.removeRow(view.getTblEmp().getSelectedRow());
     }
   }
   tableFocus();
   parent.doBlur();
 }
  private void listaFacturasMouseClicked(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_listaFacturasMouseClicked
    try {

      if (rsVenta == null || listaFacturas.getSelectedIndex() == -1) {
        return;
      }

      rsVenta.absolute(listaFacturas.getSelectedIndex() + 1);

      lbNumeroVenta.setText(rsVenta.getString("id_venta"));
      lbNombre.setText(
          rsVenta.getString("nombre_cliente") + " " + rsVenta.getString("apellido_cliente"));
      lbCedulaRif.setText(rsVenta.getString("cedula_rif"));
      lbfecha.setText(rsVenta.getDate("fecha_venta").toString());
      lbDireccion.setText(rsVenta.getString("domicilio_cliente"));

      String sql =
          "SELECT venta.id_venta,  detalle_venta.cantidad,detalle_venta.importe, "
              + "producto.nombre_producto,producto.descripcion_producto,  producto.id_producto, producto.precio_producto "
              + "FROM public.venta "
              + "INNER JOIN public.detalle_venta ON venta.id_venta=detalle_venta.id_venta "
              + "INNER JOIN public.producto ON detalle_venta.id_producto=producto.id_producto "
              + "WHERE venta.id_venta ="
              + rsVenta.getInt("id_venta")
              + "ORDER BY id_venta ";

      Statement st =
          Conexion.getConnection()
              .createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
      ResultSet rs = st.executeQuery(sql);

      int cant = modeloTabla.getRowCount();
      for (int i = 0; i < cant; i++) {
        modeloTabla.removeRow(0);
      }

      float subTotal = 0f;

      while (rs.next()) {
        subTotal += rs.getFloat("precio_producto") * rs.getInt("cantidad");
        modeloTabla.addRow(
            new Object[] {
              rs.getInt("id_producto"),
              rs.getString("nombre_producto"),
              rs.getString("descripcion_producto"),
              rs.getInt("cantidad"),
              rs.getFloat("precio_producto"),
              subTotal
            });
      }

      tfSubTotal.setText(subTotal + "");
      tfIva.setText((subTotal * 0.12) + "");
      tfTotal.setText(rsVenta.getFloat("total_venta") + "");
    } catch (SQLException ex) {
      Logger.getLogger(cliente.class.getName()).log(Level.SEVERE, null, ex);
    }
  } // GEN-LAST:event_listaFacturasMouseClicked