private void QuantityEditButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_QuantityEditButtonActionPerformed
    int warehouseindex = getWarehouseIndex();
    if (warehouseindex == -1) return;

    int selected_row = QuantityTB.getSelectedRow();
    if (selected_row == -1 || QuantityTB.getValueAt(selected_row, 1) == null) return;
    String date = (String) QuantityTB.getValueAt(selected_row, 0);

    EditQuantityDialog editquantity_dialog =
        new EditQuantityDialog(null, true, st, itemindex, warehouseindex, date);
    editquantity_dialog.setVisible(true);
    String added_value = editquantity_dialog.getReturnValue();

    // error in database operation
    if (added_value.equals("-1")) {
      JOptionPane.showMessageDialog(
          null, "Error editing quantity.", "Error Dialog", JOptionPane.ERROR_MESSAGE);
      return;
    }
    // clicking cancel button
    else if (added_value.equals("-2")) {
      return;
    }

    QuantityTB.setValueAt(added_value, selected_row, 1);
  } // GEN-LAST:event_QuantityEditButtonActionPerformed
  private void QuantityDeleteButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_QuantityDeleteButtonActionPerformed
    int warehouseindex = getWarehouseIndex();
    if (warehouseindex == -1) return;

    int selected_row = QuantityTB.getSelectedRow();
    if (selected_row == -1 || QuantityTB.getValueAt(selected_row, 1) == null) return;
    String date = (String) QuantityTB.getValueAt(selected_row, 0);

    int answer =
        JOptionPane.showConfirmDialog(
            null,
            "Do you really want to delete it?",
            "Confirmation Dialog",
            JOptionPane.YES_NO_OPTION);

    if (answer == JOptionPane.YES_OPTION) {
      if (st.deleteQuantityAndExpiredDate(itemindex, warehouseindex, date)) {
        WarehouseCBActionPerformed(null);
      }
    }
  } // GEN-LAST:event_QuantityDeleteButtonActionPerformed