Ejemplo n.º 1
0
 def saveCourse(self):
     temp = {}
     db = database.databaseCourse()
     temp["courseID"] = self.course_code.text()
     temp["courseName"] = self.course_name.text()
     temp["credit"] = self.credits.text()
     temp["lecturer"] = self.lecturer.text()
     temp["period"] = self.period.text()
     temp["year"] = self.year.text()
     temp["term"] = self.term.text()
     temp["facultyID"] = self.faculty.text()
     temp["majorID"] = self.major.text()
     temp["student_limit"] = self.student_limit.text()
     temp["building"] = self.building.text()
     temp["room"] = self.room.text()
     temp["pre"] = self.pre.text()
     status = db.addCourse(temp)
     if (status == 1):
         self.parent.showOK("Course Saved",
                            "The course has been saved successfully")
         self.clearField()
     elif (status[0] == "22P02"):
         self.parent.showERROR(
             "Data Integrity Error" + status[0],
             "Invalid DataType or Incomplete Form.\nPlease check your fields."
         )
     elif (status[0] == "23505"):
         self.parent.showERROR("Data Duplication Error" + status[0],
                               "CourseID already exists.")
     elif (status[0] == "23503"):
         self.parent.showERROR(
             "Data Consistency Error" + status[0],
             "Either Professor ID, FacultyID, or Major ID is incorrect.")
Ejemplo n.º 2
0
    def UIinit(self):
        loader = QUiLoader()
        form = loader.load("resources/UI/assignCourseToProf.ui", None)
        self.setCentralWidget(form)

        #QPushButton
        self.search_button = form.findChild(QPushButton, "searchButton")
        self.cancel_button = form.findChild(QPushButton, "closeButton")
        self.assign_button = form.findChild(QPushButton, "assignButton")

        #LineEdit
        self.courseID = form.findChild(QLineEdit, "courseID")
        self.prof_name = form.findChild(QLineEdit, "profName")

        #Label
        self.course_id = form.findChild(QLabel, "courseID_2")
        self.course_name = form.findChild(QLabel, "courseName")
        self.major = form.findChild(QLabel, "major")
        self.year = form.findChild(QLabel, "year")
        self.time = form.findChild(QLabel, "time")
        self.location = form.findChild(QLabel, "location")
        self.crs = form.findChild(QLabel, "crs")
        self.pre_requisite = form.findChild(QLabel, "preRequisite")

        #Connect
        self.search_button.clicked.connect(self.search)
        self.cancel_button.clicked.connect(self.close)
        self.assign_button.clicked.connect(self.assignProf)

        self.db = database.databaseCourse()
Ejemplo n.º 3
0
 def search(self):
     self.db = database.databaseCourse()
     data = self.db.findProfessorbyCourseID(self.search_course_id.text())
     if (data != None):
         self.user_id.setText(data.user_id)
         self.first_name.setText(data.name)
         self.surname.setText(data.surname)
         self.email.setText(data.email)
         self.faculty_id.setText(data.facultyID)
         status = data.status
         if (status == 0):
             self.type.setText("Lecturer")
         elif (status == 1):
             self.type.setText("Assist. Prof.")
         elif (status == 2):
             self.type.setText("Assoc. Prof.")
         elif (status == 3):
             self.type.setText("Professor.")
         elif (status == 4):
             self.type.setText("Suspend")
         elif (status == 5):
             self.type.setText("Retired")
         else:
             self.type.setText("Unknown")
     else:
         self.parent.showERROR("Invalid CourseID",
                               "Invalid CourseID, Please Try Again.")
Ejemplo n.º 4
0
 def updatePage(self):
     data = self.parent.getCurrentUser()
     db = database.databaseCourse()
     temp = db.getCourseProfessor(data.getID())
     allCourse = self.createBulk(temp)
     self.course_table.setRowCount(len(allCourse))
     i = 0
     for course in allCourse:
         self.course_table.setItem(i, 0, QTableWidgetItem(course.getCourseID()))
         self.course_table.setItem(i, 1, QTableWidgetItem(course.getCourseName()))
         self.course_table.setItem(i, 2, QTableWidgetItem(course.getCredit()))
         i = i + 1
Ejemplo n.º 5
0
 def __init__(self, parent=None):
     QMainWindow.__init__(self, None)
     self.setMinimumSize(900, 600)
     self.setWindowTitle("Courses")
     palette = QPalette()
     palette.setBrush(
         QPalette.Background,
         QBrush(QPixmap("resources/images/programBackground.png")))
     self.bar = QPixmap("resources/images/topBarBackground.png")
     self.setPalette(palette)
     self.parent = parent
     self.rowUP = 0
     self.rowDN = 0
     self.db = database.databaseCourse()
     self.courseAvailable = []
     self.currentCourse = []
     self.allTakenCourse = []
     self.parent = parent
     self.data = None
     self.UIinit()
Ejemplo n.º 6
0
 def search(self):
     self.db = database.databaseCourse()
     data = self.db.getCourseProfessor(self.professor_ID.text())
     allCourse = self.createBulk(data)
     self.course_table.setRowCount(len(allCourse))
     i = 0
     for course in allCourse:
         self.course_table.setItem(i, 0,
                                   QTableWidgetItem(course.getCourseID()))
         self.course_table.setItem(i, 1,
                                   QTableWidgetItem(course.getCourseName()))
         self.course_table.setItem(i, 2,
                                   QTableWidgetItem(course.getMajorID()))
         self.course_table.setItem(i, 3, QTableWidgetItem(course.getYear()))
         self.course_table.setItem(i, 4, QTableWidgetItem(course.getTime()))
         self.course_table.setItem(i, 5,
                                   QTableWidgetItem(course.getLocation()))
         self.course_table.setItem(i, 6,
                                   QTableWidgetItem(course.getCredit()))
         self.course_table.setItem(i, 7,
                                   QTableWidgetItem(course.getMaxStud()))
         self.course_table.setItem(i, 8, QTableWidgetItem(course.getPre()))
         i = i + 1
Ejemplo n.º 7
0
    def UIinit(self):
        loader = QUiLoader()
        form = loader.load("resources/UI/findCourse.ui", None)
        self.setCentralWidget(form)

        #QPushButton
        self.search_button = form.findChild(QPushButton, "searchButton")
        self.cancel_button = form.findChild(QPushButton, "closeButton")
        self.addSelected_button = form.findChild(QPushButton, "add_selected")
        self.addSelected_button.setEnabled(False)

        #LineEdit
        self.faculty_name = form.findChild(QLineEdit, "facultyID")

        #Table
        self.course_table = form.findChild(QTableWidget, "tableWidget")
        self.course_table.setSelectionMode(QAbstractItemView.SingleSelection)
        self.course_table.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.course_table.setEditTriggers(QAbstractItemView.NoEditTriggers)

        self.course_table_header = self.course_table.horizontalHeader()
        self.course_table_header.setResizeMode(0, QHeaderView.ResizeToContents)
        self.course_table_header.setResizeMode(1, QHeaderView.ResizeToContents)
        self.course_table_header.setResizeMode(2, QHeaderView.ResizeToContents)
        self.course_table_header.setResizeMode(3, QHeaderView.ResizeToContents)
        self.course_table_header.setResizeMode(4, QHeaderView.ResizeToContents)
        self.course_table_header.setResizeMode(5, QHeaderView.Stretch)
        self.course_table_header.setResizeMode(7, QHeaderView.ResizeToContents)
        self.course_table_header.setResizeMode(8, QHeaderView.ResizeToContents)

        #Connect
        self.faculty_name.returnPressed.connect(self.search)
        self.search_button.clicked.connect(self.search)
        self.cancel_button.clicked.connect(self.close)
        self.addSelected_button.clicked.connect(self.add_selected)

        self.db = database.databaseCourse()