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 QuantityAddButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_QuantityAddButtonActionPerformed

    int warehouseindex = getWarehouseIndex();
    if (warehouseindex == -1) return;

    AddQuantityDialog addquantity_dialog =
        new AddQuantityDialog(null, true, st, itemindex, warehouseindex);
    addquantity_dialog.setVisible(true);
    String[] added_value = addquantity_dialog.getReturnValue();

    if (added_value == null) {
      JOptionPane.showMessageDialog(
          null,
          "Error adding quantity and expired date.",
          "Error Dialog",
          JOptionPane.ERROR_MESSAGE);
      return;
    }
    // clicking cancel button
    else if (added_value.length == 0) {
      return;
    }

    int total_row = QuantityTB.getRowCount();
    if (quantity_row_length == total_row) {
      ((DefaultTableModel) QuantityTB.getModel())
          .addRow(
              new Object[] {
                null, null, null, null, null, null, null, null, null, null, null, null, null, null,
                null, null
              });
    }
    QuantityTB.setValueAt(added_value[0], quantity_row_length, 0);
    QuantityTB.setValueAt(added_value[1], quantity_row_length, 1);
    quantity_row_length++;
  } // GEN-LAST:event_QuantityAddButtonActionPerformed