选课系统V1.0
Posted zhangmingda
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了选课系统V1.0相关的知识,希望对你有一定的参考价值。
tree . . ├── bin │ ├── __init__.py │ └── start.py #启动文件 ├── conf │ ├── __init__.py │ └── settings.py #全局配置文件 ├── core#核心代码目录 │ ├── CourseClass.py#课程类 │ ├── GradeClass.py #班级类 │ ├── __init__.py │ ├── main.py #主程序 │ ├── RWdb.py #数据读写功能类 │ ├── SchoolClass.py #学校类 │ ├── SchoolPeopleClass.py #人员父类 │ ├── StudentsClass.py #学生类 │ └── TeacherClass.py #教师类 ├── db #存放各种对象数据 │ ├── course.db │ ├── grade.db │ ├── __init__.py │ ├── school.db │ ├── students.db │ └── teachers.db ├── __init__.py └── test#测试目录 ├── __init__.py └── test.py
#!/usr/bin/env python # Author:Zhangmingdad import os BASER_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__) )) ‘‘‘数据库文件路径/文件名配置‘‘‘ DB_PATH = os.path.join(BASER_DIR,‘db‘) SCHOOL_DB_FILE = os.path.join(DB_PATH,‘school.db‘) COURSE_DB_FILE = os.path.join(DB_PATH,‘course.db‘) TEACHERS_DB_FILE = os.path.join(DB_PATH,‘teachers.db‘) STUDENTS_DB_FILE = os.path.join(DB_PATH,‘students.db‘) GRADE_DB_FILE = os.path.join(DB_PATH,‘grade.db‘) ‘‘‘系统统一入口视图配置‘‘‘ login_sys = { ‘1‘:‘manager_sys()‘, ‘2‘:‘students_sys()‘, ‘3‘:‘teachers_sys()‘ } smg_login_sys = ‘‘‘ 【1】 学校管理系统 【2】 学生注册缴费查询系统 【3】 教师办公系统 ‘‘‘ ‘‘‘后台管理视图配置‘‘‘ manager_sys = { ‘1‘:‘create_course()‘, ‘2‘:‘create_teacher()‘, ‘3‘:‘create_grade()‘, ‘4‘:‘create_school()‘, ‘5‘:‘review_school_info()‘ } smg_manager_sys = ‘‘‘ 【1】 创建课程 【2】 招聘老师 【3】 创建班级 【4】 创建学校 【5】 查看学校详情 ‘‘‘ students_sys = { ‘1‘:‘student_sign_in()‘, ‘2‘:‘stu_paytuition()‘, ‘3‘:‘show_score()‘, ‘4‘:‘show_stu_info()‘ } smg_students_sys = ‘‘‘ 【1】 注册 【2】 缴费 【3】 成绩查询 【4】 查看个人信息 ‘‘‘ teachers_sys = { ‘1‘:‘show_teach_grades()‘, ‘2‘:‘show_grade_students()‘, ‘3‘:‘modify_stu_score()‘, ‘4‘:‘show_teacher_info()‘ } smg_teachers_sys = ‘‘‘ 【1】 查看所教班级 【2】 查看班级学员列表 【3】 修改学生成绩 【4】 查看教师个人信息 ‘‘‘ Manager_user = ‘root‘ Manager_passwd = ‘root‘
#!/usr/bin/env python # Author:Zhangmingda import os,pickle from conf import settings class RWdb(object): ‘‘‘数据读写大类‘‘‘ @staticmethod def readschooldb(): ‘‘‘通过pickle的load方法读取学校信息‘‘‘ if os.path.exists(settings.SCHOOL_DB_FILE): with open(settings.SCHOOL_DB_FILE,‘rb‘) as school_f: school_info = pickle.load(school_f) else: school_info = {} return school_info @staticmethod def writeschooldb(school_info): ‘‘‘通过pickle的dump存入学校信息‘‘‘ with open(settings.SCHOOL_DB_FILE,‘wb‘) as school_f: pickle.dump(school_info,school_f) #################课程读写################################# @staticmethod def readcoursedb(): ‘‘‘通过pickle的load方法读取课程信息‘‘‘ if os.path.exists(settings.COURSE_DB_FILE): with open(settings.COURSE_DB_FILE,‘rb‘) as course_f: course_info = pickle.load(course_f) else: course_info = {} return course_info @staticmethod def writecoursedb(course_info): ‘‘‘通过pickle的dump存入学校信息‘‘‘ with open(settings.COURSE_DB_FILE,‘wb‘) as course_f: pickle.dump(course_info,course_f) #################班级数据读写################################# @staticmethod def readgradedb(): ‘‘‘通过pickle的load方法读取课程信息‘‘‘ if os.path.exists(settings.GRADE_DB_FILE): with open(settings.GRADE_DB_FILE,‘rb‘) as grade_f: grade_info = pickle.load(grade_f) else: grade_info = {} return grade_info @staticmethod def writegradedb(grade_info): ‘‘‘通过pickle的dump存入学校信息‘‘‘ with open(settings.GRADE_DB_FILE,‘wb‘) as grade_f: pickle.dump(grade_info,grade_f) #################教师数据读写################################# @staticmethod def readteachersdb(): ‘‘‘通过pickle的load方法读取课程信息‘‘‘ if os.path.exists(settings.TEACHERS_DB_FILE): with open(settings.TEACHERS_DB_FILE,‘rb‘) as teachers_f: teachers_info = pickle.load(teachers_f) else: teachers_info = {} return teachers_info @staticmethod def writeteachersdb(teachers_info): ‘‘‘通过pickle的dump存入学校信息‘‘‘ with open(settings.TEACHERS_DB_FILE,‘wb‘) as teachers_f: pickle.dump(teachers_info,teachers_f) #################学生数据读写################################# @staticmethod def readstudentsdb(): ‘‘‘通过pickle的load方法读取课程信息‘‘‘ if os.path.exists(settings.STUDENTS_DB_FILE): with open(settings.STUDENTS_DB_FILE,‘rb‘) as students_f: students_info = pickle.load(students_f) else: students_info = {} return students_info @staticmethod def writestudentsdb(students_info): ‘‘‘通过pickle的dump存入学校信息‘‘‘ with open(settings.STUDENTS_DB_FILE,‘wb‘) as students_f: pickle.dump(students_info,students_f)
#!/usr/bin/env python # Author:Zhangmingda import os,sys BASER_DIR = os.path.dirname(os.path.abspath(__file__) ) sys.path.append(BASER_DIR) from .SchoolClass import School from conf import settings def create_school(): ‘‘‘创建一个学校‘‘‘ back_flag = False while not back_flag: school_dict = School.readschooldb() ‘‘‘查看已有学校名字‘‘‘ if len(school_dict): print(‘当前已存在学校如下:‘) for school_name in school_dict: print(school_name) ‘‘‘新建学校名字‘‘‘ new_school_name = input(‘请输入要创建的学校名称(b返回):‘).strip() if new_school_name in school_dict or new_school_name == ‘‘: print(‘