Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void addNewCourse(JTextField courseName, String courseStart, String courseEnd, JComboBox teacher, JComboBox subject) {
- try {
- //Name of the new course
- String course = courseName.getText();
- //new Id for the course
- ArrayList<String> count = new ArrayList<String>();
- String getNewId = "SELECT kursnamn FROM kurs";
- count = hwdb.fetchColumn(getNewId);
- int newId = count.size() + 1;
- //Fetch teacher ID
- String tempTeacher = teacher.getSelectedItem().toString();
- String[] splitStr = tempTeacher.split("\\s+");
- String iD = getIdTeacher(splitStr[0], splitStr[1]);
- //get subject Id for course
- String courseSubject = subject.getSelectedItem().toString();
- String subjectId = getSubjectId(courseSubject);
- //The actual command to insert new course
- String command = "INSERT INTO kurs VALUES (" + newId + ", '" + course + "', '" + courseStart + "', '" + courseEnd + "', " + iD + ", " + subjectId + ")";
- hwdb.insert(command);
- } catch (InfException e) {
- System.out.println(e.getMessage());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement