if all text fields are filled up ifsurnameisEmpty

If all text fields are filled up ifsurnameisempty

This preview shows page 61 - 65 out of 67 pages.

String description = updateP.getTdescription().getText(); //if all text fields are filled up if(!surname.isEmpty() && !gender.isEmpty() && !address.isEmpty() && ! description.isEmpty() && !sage.isEmpty()) { try { // set the details of a 'person' int iage=Integer.valueOf(updateP.getTage().getText()); updatePerson.setName(name); updatePerson.setSurname(surname); updatePerson.setGender(gender); updatePerson.setAge(iage); updatePerson.setAddress(address); updatePerson.setDescription(description); } // if the input into 'age' is not numbers catch (NumberFormatException e) { // prompt error message JOptionPane.showConfirmDialog(null, "Please enter numbers only", "error", JOptionPane.CANCEL_OPTION); } } // if form is empty when submit else { //prompt error message JOptionPane.showMessageDialog(updateP, "Please fill in all information."); } // Update the relationship of father if(updateP.getCfather().getSelectedItem() != null && ! updateP.getCfather().getSelectedItem().equals("")) { Person father = new Person(); father = plist.displyPersonByName(updateP.getCfather().getSelectedItem().toString()); updatePerson.addParent(father); } // Update the relationship of mother if(updateP.getCmother().getSelectedItem() != null && ! updateP.getCmother().getSelectedItem().equals(""))
Image of page 61
{ Person mother = new Person(); mother = plist.displyPersonByName(updateP.getCmother().getSelectedItem().toString()); updatePerson.addParent(mother); } // Update the relationship of sibling if(updateP.getCsibling().getSelectedItem() != null && ! updateP.getCsibling().getSelectedItem().equals("")) { Person sibling = new Person(); sibling = plist.displyPersonByName(updateP.getCsibling().getSelectedItem().toString()); updatePerson.addSibling(sibling); } // Update the relationship of spouse if(updateP.getCspouse().getSelectedItem() != null && ! updateP.getCspouse().getSelectedItem().equals("")) { Person spouse = new Person(); spouse = plist.displyPersonByName(updateP.getCspouse().getSelectedItem().toString()); updatePerson.setSpouse(spouse); } // Update the relationship of child if(updateP.getCchild().getSelectedItem() != null && ! updateP.getCchild().getSelectedItem().equals("")) { Person child = new Person(); child = plist.displyPersonByName(updateP.getCchild().getSelectedItem().toString()); updatePerson.addChild(child); } } // delete a 'person' public void DeletePerson() { boolean isDataExist = false; isDataExist = plist.DoesDataExist(); // if there is at least one record of a 'person'
Image of page 62
if(isDataExist) { int row,column; String name; row = ((JTable) editP.getTPerson()).getSelectedRow(); column = 0; // create a table if(row >= 0) { //selected user input to delete name = ((JTable) editP.getTPerson()).getValueAt(row, column).toString(); plist.DeletePerson(name); LoadDataForEditTable(); //prompt succesful message JOptionPane.showMessageDialog(createF, "Successfully Deleted"); } // if user did not select any member else { //prompt error message JOptionPane.showMessageDialog(createF, "Please select a member to delete"); } } // if the record is empty else { // prompt error message JOptionPane.showMessageDialog(createF, "No record to delete"); } } // load data for table (edit) public void LoadDataForEditTable() { // if the table is consist of >0 'person' while (((TableModel) editP.getTPerson().getModel()).getRowCount() > 0) { ((TableModel) editP.getTPerson().getModel()).removeRow(0); } // if the record is not empty if(plist != null) { dataPerson = plist.toStringVector();
Image of page 63
// loop till the end of dataPerson for (int i = 0; i < dataPerson.length; i++)
Image of page 64
Image of page 65

You've reached the end of your free preview.

Want to read all 67 pages?

  • One '14
  • Void type, Ang Wei Ming, public class ICT373

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture