Пример #1
0
    def read_grades(query_key, data):
        if not Utils.check_whitespace(data):
            if query_key == 'Course ID':
                sql = f"""
                select course_name, courses.course_id, user_id, name, students.school, grade 
                from students, courses, grades
                where (user_id,grade) in  (select student_id,grade from grades where course_id ={data} )
                 and courses.course_id = {data}
    
                      """
            else:
                sql = f"""
                select course_name, courses.course_id, user_id, name, students.school, grade 
                from students, courses, grades
                where (courses.course_id, grade) in  
                (select course_id,grade from grades where student_id = '{data}' ) 
                 and students.user_id = '{data}'
    
                    """
            try:
                Database.initialize()
                grades_data = Database.query(sql)
                return grades_data
            except pymysql.Error as error:
                raise error
            finally:
                Database.close()

        else:
            raise ValueError('Please input data!')
Пример #2
0
    def init_teacher_table(self):
        self.teacher_tableWidget.setRowCount(0)
        self.teacher_tableWidget.insertRow(0)

        text = self.teacher_id_lineEdit.text()
        teacher_id = text if text and not Utils.check_whitespace(
            text) else None
        text = self.teacher_name_lineEdit.text()
        teacher_name = text if text and not Utils.check_whitespace(
            text) else None
        text = self.position_lineEdit.text()
        position = text if text and not Utils.check_whitespace(text) else None

        teachers_data = Teacher.read_teachers(
            self.admin_MainWindow.user.school, teacher_id, teacher_name,
            position)

        self.init_table(self.teacher_tableWidget, 'teacher', teachers_data, 8)
Пример #3
0
    def init_student_table(self):
        self.student_tableWidget.setRowCount(0)
        self.student_tableWidget.insertRow(0)

        text = self.department_lineEdit.text()
        department = text if text and not Utils.check_whitespace(
            text) else None
        text = self.class_lineEdit.text()
        class_name = text if text and not Utils.check_whitespace(
            text) else None
        text = self.student_id_lineEdit.text()
        student_id = text if text and not Utils.check_whitespace(
            text) else None
        text = self.student_name_lineEdit.text()
        student_name = text if text and not Utils.check_whitespace(
            text) else None

        students_data = Student.read_students(
            self.admin_MainWindow.user.school, department, class_name,
            student_id, student_name)
        self.init_table(self.student_tableWidget, 'student', students_data, 8)
Пример #4
0
    def init_course_talbe(self):
        self.course_tableWidget.setRowCount(0)
        self.course_tableWidget.insertRow(0)

        text = self.course_id_lineEdit.text()
        course_id = text if text and not Utils.check_whitespace(text) else None
        text = self.course_name_lineEdit.text()
        course_name = text if text and not Utils.check_whitespace(
            text) else None
        text = self.course_teacher_name_lineEdit.text()
        teacher_name = text if text and not Utils.check_whitespace(
            text) else None
        text = self.course_teacher_id_lineEdit.text()
        teacher_id = text if text and not Utils.check_whitespace(
            text) else None

        courses_data = Course.read_courses(self.admin_MainWindow.user.school,
                                           course_id, course_name,
                                           teacher_name, teacher_id)

        self.init_table(self.course_tableWidget, 'course', courses_data, 2)