private void jAddActionPerformed(java.awt.event.ActionEvent evt) { String code = jCode.getText(); String registrationNumberText = jRegistrationNumber.getText(); String barcodeText = jBarcode.getText(); String maincharName = jMaincharName.getText(); String title = jTitle.getText(); String version = jVersion.getText(); String size = jSize.getSelectedItem().toString(); if (code.isEmpty() || registrationNumberText.isEmpty() || barcodeText.isEmpty()) { // Handle the case where any of the required fields are empty System.out.println("Please fill in all the required fields."); return; // Exit the method to prevent further execution } int registrationNumber; int barcode; try { registrationNumber = Integer.parseInt(registrationNumberText); barcode = Integer.parseInt(barcodeText); } catch (NumberFormatException e) { // Handle the case where the input strings cannot be parsed as integers System.out.println("Invalid input for registration number or barcode."); e.printStackTrace(); return; // Exit the method to prevent further execution } Collection collect = new Collection(code, registrationNumber, barcode, maincharName, title, version, size); CollectionRepository cr = new CollectionRepository(); cr.insertProduct(collect); jCode.setText(""); jRegistrationNumber.setText(""); jBarcode.setText(""); jMaincharName.setText(""); jTitle.setText(""); jVersion.setText(""); jSize.setSelectedItem(""); view(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)