private void addteammemberActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_addteammemberActionPerformed JTextField fname = new JTextField(); JTextField lname = new JTextField(); JTextField position = new JTextField(); Object[] message = { "First Name:", fname, "Last Name:", lname, "Position:", position, }; int option = JOptionPane.showConfirmDialog( this, message, "Enter Team Member Information", JOptionPane.OK_CANCEL_OPTION); if (option == JOptionPane.OK_OPTION) { Person tm = new Person(); tm.setFirstName(fname.getText()); tm.setLastName(lname.getText()); tm.setPosition(position.getText()); currentProject.getTeamMembers().add(tm); teammodel.addElement(tm.getFirstName() + " " + tm.getLastName() + " " + tm.getPosition()); teamlist.setModel(teammodel); } } // GEN-LAST:event_addteammemberActionPerformed
public ViewProject(int id) { initComponents(); currentProject = new Project(); currentProject.setProjectID(id); try { Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection( "jdbc:mysql://127.0.0.1:3306/projectmanagementsystem?zeroDateTimeBehavior=convertToNull", "root", "password"); String query2 = "select * from project where idproject = ?"; PreparedStatement pst2 = con.prepareStatement(query2); int projectid = id + 1; pst2.setInt(1, projectid); ResultSet rs = pst2.executeQuery(); if (rs.next()) { projectname.setText(rs.getString("projectname")); projectdescription.setText(rs.getString("projectdesc")); } String query3 = "select * from teammember where teammember_FK = ?"; PreparedStatement pst3 = con.prepareStatement(query3); pst3.setInt(1, projectid); ResultSet rs2 = pst3.executeQuery(); while (rs2.next()) { Person p = new Person(); p.setFirstName(rs2.getString("firstname")); p.setLastName(rs2.getString("lastname")); p.setPosition(rs2.getString("position")); p.setPersonID(rs2.getInt("idteammember")); teammembers.add(p); teammodel.addElement(p.getFirstName() + " " + p.getLastName() + " " + p.getPosition()); } teamlist.setModel(teammodel); String query4 = "select * from goal where goal_FK = ?"; PreparedStatement pst4 = con.prepareStatement(query4); pst4.setInt(1, projectid); ResultSet rs3 = pst4.executeQuery(); while (rs3.next()) { Goal g = new Goal(); g.setGoalID(rs3.getInt("idgoal")); g.setGoalDesc(rs3.getString("goaldesc")); g.setGoalType(rs3.getString("goaltype")); goals.add(g); goalmodel.addElement(g.getGoalType() + " " + g.getGoalDesc()); } goallist.setModel(goalmodel); String query5 = "select * from requirement where requirement_FK = ?"; PreparedStatement pst5 = con.prepareStatement(query5); pst5.setInt(1, projectid); ResultSet rs4 = pst5.executeQuery(); while (rs4.next()) { Requirement r = new Requirement(); String type; r.setRequirementID(rs4.getInt("idrequirement")); r.setRequirementDescription(rs4.getString("requirementdesc")); if (rs4.getInt("isFunctionalRequirement") == 0) { r.setIsFunctionalRequirement(false); type = "Non-functional"; } else type = "Functional"; requirements.add(r); requirementmodel.addElement(type + " " + r.getRequirementDescription()); } requirementlist.setModel(requirementmodel); String query6 = "select * from risk where risk_FK = ?"; PreparedStatement pst6 = con.prepareStatement(query6); pst6.setInt(1, projectid); ResultSet rs5 = pst6.executeQuery(); while (rs5.next()) { Risk r = new Risk(); r.setRiskID(rs5.getInt("idrisk")); r.setRiskName(rs5.getString("riskname")); r.setRiskStatus(rs5.getString("riskstatus")); risks.add(r); riskmodel.addElement(r.getRiskStatus() + " " + r.getRiskName()); } risklist.setModel(riskmodel); String query7 = "select * from effort join requirement on effort.effort_FK = requirement.idrequirement" + " where requirement.requirement_FK = ?"; PreparedStatement pst7 = con.prepareStatement(query7); pst7.setInt(1, projectid); ResultSet rs6 = pst7.executeQuery(); while (rs6.next()) { Effort e = new Effort(); e.setEffortID(rs6.getInt("ideffort")); e.setEffortDate(rs6.getString("effortdate")); e.setEffortDevPhase(rs6.getString("effortdevphase")); e.setEffortHours(rs6.getInt("efforthours")); e.setRequirementID(rs6.getInt("effort_FK")); e.setRequirementDesc(rs6.getString("requirementdesc")); efforts.add(e); effortmodel.addElement( "For req: " + e.getRequirementDesc() + " " + e.getEffortDevPhase() + " " + e.getEffortDate() + " " + e.getEffortHours()); } effortlist.setModel(effortmodel); } catch (Exception e) { System.out.println(e.toString()); } }