Advertisement
JudarnaDansar

Untitled

May 23rd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1. //Update information about a course
  2.     public void setCourseInfo(String iD, JTextField newCourseName, String newCourseStart, String newCourseEnd, JComboBox newTeacher, JComboBox newSubject) {
  3.         try {
  4.             //Name of the new course
  5.             String course = newCourseName.getText();
  6.             //New id
  7.             String tempTeacher = newTeacher.getSelectedItem().toString();
  8.             String[] splitStr = tempTeacher.split("\\s+");
  9.             String teacherId = getIdTeacher(splitStr[0], splitStr[1]);
  10.             //get subject Id for course
  11.             String courseSubject = newSubject.getSelectedItem().toString();
  12.             String subjectId = getSubjectId(courseSubject);
  13.             //The accual command to insert new course
  14.             String command = "UPDATE kurs SET kursnamn= '" + course + "', kursstart= '" + newCourseStart + "', kursslut= '" + newCourseEnd + "', kurslarare= " + teacherId + ", amnestillhorighet= " + subjectId
  15.                     + "WHERE kurs_id=" + iD;
  16.             hwdb.insert(command);
  17.         } catch (InfException e) {
  18.             System.out.println(e.getMessage());
  19.         }
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement