// fill fields on dialog private void fillFields() { SimpleDateFormat mySimpleDateFormat = new SimpleDateFormat("dd/mm/yyyy"); Person person = PersonController.getPerson(selectedID); Date date = new Date(); System.out.println(person.getDay()); String[] arrstr = person.getDay().split("-"); int day = Integer.parseInt(arrstr[0]); int month = Integer.parseInt(arrstr[1]); int year = Integer.parseInt(person.getYear()); day = date.getDay(); month = date.getMonth(); year = date.getYear(); txtId.setText(person.getId()); txtPName.setText(person.getName()); txtBorn.setText(person.getBorn()); if (person.getSex() == "Male") { radMale.setSelected(true); } else { radFemale.setSelected(true); } if (person.getIsdirector().equals("1")) { isDirector.setSelected(true); } else { isDirector.setSelected(false); } if (person.getIsstar().equals("1")) { isStar.setSelected(true); } else { isStar.setSelected(false); } jxDate.setDate(date); }
// update a manager's profile private void btnUpdateActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnUpdateActionPerformed // TODO add your handling code here: JTextComponent[] tcp = {txtId, txtPName, txtBorn}; if (!Validator.validateComponents(tcp)) { return; } String id = txtId.getText(); String name = txtPName.getText(); String born = txtBorn.getText(); String gender = "Male"; boolean male = true; if (radFemale.isSelected()) { male = false; gender = "Female"; } String star = "0"; if (isStar.isSelected()) { star = "1"; } String director = "0"; if (isDirector.isSelected()) { director = "1"; } String day = String.valueOf(jxDate.getDate().getDay()); String month = String.valueOf(jxDate.getDate().getMonth() + 1); String year = String.valueOf(jxDate.getDate().getYear() + 1900); String day1 = day + "-" + month; if (PersonController.update(selectedID, name, gender, day1, year, born, director, star)) { new CustomMessageDialog( null, true, "Done!", "Updated sucessfully!", CustomMessageDialog.DONE); AdminPersonList.reloadTable(); } } // GEN-LAST:event_btnUpdateActionPerformed