private void btnSaveActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnSaveActionPerformed // updating information about student if (!(txtPPS.getText().isEmpty()) && !(txtName.getText().isEmpty()) && !(txtSurname.getText().isEmpty()) && !(txtAddress.getText().isEmpty()) && !(txtCity.getText().isEmpty()) && !(txtDOB.getText().isEmpty()) && !(txtPhone.getText().isEmpty()) && !(txtEmail.getText().isEmpty())) { studentList.get(lstPersons.getSelectedIndex()).setPPSNumber(txtPPS.getText()); studentList.get(lstPersons.getSelectedIndex()).setFirstName(txtName.getText()); studentList.get(lstPersons.getSelectedIndex()).setLastName(txtSurname.getText()); studentList.get(lstPersons.getSelectedIndex()).setAddress(txtAddress.getText()); studentList.get(lstPersons.getSelectedIndex()).setCity(txtCity.getText()); studentList.get(lstPersons.getSelectedIndex()).setDateOfBirth(txtDOB.getText()); studentList.get(lstPersons.getSelectedIndex()).setPhone(txtPhone.getText()); studentList.get(lstPersons.getSelectedIndex()).setEmail(txtEmail.getText()); if (cbGender.getSelectedIndex() == 0) { studentList.get(lstPersons.getSelectedIndex()).setGender("true"); } else { studentList.get(lstPersons.getSelectedIndex()).setGender("false"); } newConnection.saveStudent(studentList.get(lstPersons.getSelectedIndex()), STARTME.TESTING); this.setVisible(false); eraseInfo(true, true); } } // GEN-LAST:event_btnSaveActionPerformed
private void formInternalFrameActivated( javax.swing.event.InternalFrameEvent evt) { // GEN-FIRST:event_formInternalFrameActivated // getting a list of all groups groupList = newConnection.getGroupList(STARTME.TESTING); for (int i = 0; i < groupList.size(); i++) { cbGroup.addItem("" + groupList.get(i).getCourseName() + " " + groupList.get(i).getYear()); } } // GEN-LAST:event_formInternalFrameActivated
private void btnSelectGroupActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnSelectGroupActionPerformed // getting students in selected group // groupList.get(cbGroup.getSelectedIndex()).getGroupID(); // retuns the id of selected group eraseInfo(false, true); studentList = newConnection.getStudentsInGroup( groupList.get(cbGroup.getSelectedIndex()).getGroupID(), STARTME.TESTING); for (int i = 0; i < studentList.size(); i++) { lstBox.addElement(studentList.get(i).getFirstName() + " " + studentList.get(i).getLastName()); } } // GEN-LAST:event_btnSelectGroupActionPerformed
private void btnSaveNewActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnSaveNewActionPerformed // add to object if all fields are not empty if (!(txtPPS.getText().isEmpty()) && !(txtName.getText().isEmpty()) && !(txtSurname.getText().isEmpty()) && !(txtAddress.getText().isEmpty()) && !(txtCity.getText().isEmpty()) && !(txtDOB.getText().isEmpty()) && !(txtPhone.getText().isEmpty()) && !(txtEmail.getText().isEmpty())) { studentList.add(new Person()); studentList.get(studentList.size() - 1).setPPSNumber(txtPPS.getText()); studentList.get(studentList.size() - 1).setFirstName(txtName.getText()); studentList.get(studentList.size() - 1).setLastName(txtSurname.getText()); studentList.get(studentList.size() - 1).setAddress(txtAddress.getText()); studentList.get(studentList.size() - 1).setCity(txtCity.getText()); studentList.get(studentList.size() - 1).setDateOfBirth(txtDOB.getText()); studentList.get(studentList.size() - 1).setPhone(txtPhone.getText()); studentList.get(studentList.size() - 1).setEmail(txtEmail.getText()); if (cbGender.getSelectedIndex() == 0) { studentList.get(studentList.size() - 1).setGender("true"); } else { studentList.get(studentList.size() - 1).setGender("false"); } lstBox.addElement( studentList.get(studentList.size() - 1).getFirstName() + " " + studentList.get(studentList.size() - 1).getLastName()); newConnection.insertNewStudent( studentList.get(studentList.size() - 1), groupList.get(cbGroup.getSelectedIndex()), STARTME.TESTING); btnSave.setEnabled(true); btnClose.setEnabled(true); lstPersons.setEnabled(true); btnSaveNew.setVisible(false); btnNew.setVisible(true); } } // GEN-LAST:event_btnSaveNewActionPerformed