private void jButton3ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton3ActionPerformed
    // TODO add your handling code here:
    String firstName = jTextField1.getText();
    String middleName = jTextField2.getText();
    String lastName = jTextField3.getText();
    String birthDate = jTextField4.getText();
    String position = jTextField5.getText();
    String gender = jComboBox1.getSelectedItem().toString();
    int salary = Integer.parseInt(jTextField6.getText());
    String nationality = jComboBox2.getSelectedItem().toString();
    String dateEmployed = jTextField8.getText();
    String qualifications = jTextArea1.getText();

    Staff neo =
        new Staff(
            firstName,
            middleName,
            lastName,
            birthDate,
            position,
            gender,
            salary,
            nationality,
            dateEmployed,
            qualifications);
    StaffData x = new StaffData();
    File newFile = imgch.getFile();
    x.addImage(newFile, newFile.getAbsolutePath());
    x.addStaff(neo);
    this.dispose();
  } // GEN-LAST:event_jButton3ActionPerformed
  public void doRentDVD(StaffData staff_data, CustomerData customer_data, DVDData DVD_data) {
    if (staff_data.getID() == 0 || customer_data.getID() == 0 || DVD_data.getID() == 0) {
      setMessage("Enter staff, customer and DVD IDs first");
      return;
    }

    try {
      // populate objects
      staff_data = getStaffManager().findStaff(staff_data.getID());
      customer_data = getCustomerManager().findCustomer(customer_data.getID());
      DVD_data = getDVDManager().findDVD(DVD_data.getID());

      // has customer asked for this DVD??
      RentalData rental =
          getRentalManager().findRental(customer_data.getID(), DVD_data.getID(), null);
      if (rental != null) {
        if (rental.getDispatched() != null && !rental.getDispatched().equals("null")) {
          setMessage("Already dispatched to customer on " + rental.getDispatched());
          return;
        }

        try {

          // need to do begin transaction...
          DVDStoreFactory.getInstance().begin();

          // indicate sent to customer & by whom
          rental.setStaffID(staff_data.getID());
          rental.setDispatched(DVDStoreFactory.getTodayDate());
          getRentalManager().dispatchDVD(rental);

          // indicate number of copies available now reduced by 1 - should change to do on REQUEST
          // !!!

          DVD_data.setNumCopies(DVD_data.getNumCopies() - 1);
          getDVDManager().updateDVD(DVD_data);

          // need to do commit transaction...
          DVDStoreFactory.getInstance().commit();

          setMessage("Rented DVD");

        } catch (Exception e) {
          setMessage("Couldn't rent DVD: exception: " + e);
          try {
            // need to do rollback of transaction...
            DVDStoreFactory.getInstance().rollback();

          } catch (Exception e2) {
            setMessage("*** Couldn't roll back transaction: " + e);
          }
        }
      } else setMessage("This DVD not requested by customer!");
    } catch (Exception e) {
      setMessage("Couldn't check DVD: exception:" + e);
    }
  }
  public void doReturnDVD(StaffData staff_data, CustomerData customer_data, DVDData DVD_data) {
    if (staff_data.getID() == 0 || customer_data.getID() == 0 || DVD_data.getID() == 0) {
      setMessage("Enter staff, customer and DVD IDs first");
      return;
    }

    try {
      // populate objects...
      staff_data = getStaffManager().findStaff(staff_data.getID());
      customer_data = getCustomerManager().findCustomer(customer_data.getID());
      DVD_data = getDVDManager().findDVD(DVD_data.getID());

      // has customer rented this DVD?
      RentalData rental_data =
          getRentalManager().findRental(customer_data.getID(), DVD_data.getID(), null);
      if (rental_data == null || !rental_data.getReturned().equals("null"))
        setMessage("This DVD not rented by this customer!");
      else {
        try {
          // begin transaction...
          DVDStoreFactory.getInstance().begin();

          rental_data.setReturned(DVDStoreFactory.getTodayDate());
          getRentalManager().returnDVD(rental_data);
          DVD_data.setNumCopies(DVD_data.getNumCopies() + 1);
          getDVDManager().updateDVD(DVD_data);

          // need to commit transaction...

          DVDStoreFactory.getInstance().commit();

          setMessage("Returned DVD");

        } catch (Exception e) {
          setMessage("Couldn't return DVD: exception " + e);
          try {
            // need to rollback transaction
            DVDStoreFactory.getInstance().rollback();
          } catch (Exception e2) {
            setMessage("Couldn't rollback transaction: exception " + e);
          }
        }
      }
    } catch (Exception e) {
      setMessage("couldn't check DVD record: " + e);
    }
  }
  public void doFindStaff(StaffData staff_data) {
    try {
      if (staff_data.getID() == 0) {
        setMessage("Enter your staff ID");
        staff_data.setID(0);
        return;
      }

      if (staff_data.getPassword().equals("")) {
        setMessage("Enter your password");
        staff_data.setID(0);
        return;
      }

      StaffData s2 = getStaffManager().findStaff(staff_data.getID());

      if (s2 != null) {
        if (s2.matchesPassword(staff_data.getPassword())) {
          setMessage("Found staff member");
          staff_data.setName(s2.getName());
        } else setMessage("That password is incorrect");

      } else setMessage("Can't find that staff record");
    } catch (Exception e) {
      setMessage("Error finding staff: " + e.toString());
      staff_data.setID(0);
    }
  }