Advertisement
JudarnaDansar

Untitled

May 23rd, 2018
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. public void addNewCourse(JTextField courseName, String courseStart, String courseEnd, JComboBox teacher, JComboBox subject) {
  2. try {
  3. //Name of the new course
  4. String course = courseName.getText();
  5. //new Id for the course
  6. ArrayList<String> count = new ArrayList<String>();
  7. String getNewId = "SELECT kursnamn FROM kurs";
  8. count = hwdb.fetchColumn(getNewId);
  9. int newId = count.size() + 1;
  10. //Fetch teacher ID
  11. String tempTeacher = teacher.getSelectedItem().toString();
  12. String[] splitStr = tempTeacher.split("\\s+");
  13. String iD = getIdTeacher(splitStr[0], splitStr[1]);
  14. //get subject Id for course
  15. String courseSubject = subject.getSelectedItem().toString();
  16. String subjectId = getSubjectId(courseSubject);
  17. //The actual command to insert new course
  18. String command = "INSERT INTO kurs VALUES (" + newId + ", '" + course + "', '" + courseStart + "', '" + courseEnd + "', " + iD + ", " + subjectId + ")";
  19. hwdb.insert(command);
  20. } catch (InfException e) {
  21. System.out.println(e.getMessage());
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement