Ejemplo n.º 1
0
def stu_registration():
    """学生注册"""
    print("欢迎来到学生注册系统!")
    for index, i in enumerate(school_func.school_list):
        print(index, i.name)
    school_id = int(input("请选择您要注册学校的序号:"))
    school_func.show_grades()
    file_name_res = setting.file_name(setting.GRADE_PATH)
    tmp_grades = []
    for i in file_name_res:
        course_str = i
        suffix = re.search("\.+[a-z]{4}", course_str).group()
        course_str = course_str.replace(suffix, "")
        tmp_grades.append(course_str)
    for index, i in enumerate(tmp_grades):
        print(index, i)
    choose_grade = int(input("请输入您的班级序号:"))
    stu_tmp_list = setting.file_name(setting.STUDENTDB_PATH)
    while True:
        stu_name = input("请输入您的姓名:")
        stu_file_name = setting.file_name(setting.STUDENTDB_PATH)
        tmp_stu = []
        for i in stu_file_name:
            stu_str = i
            suffix_stu = re.search("\.+[a-z]{4}", stu_str).group()
            course_str = stu_str.replace(suffix_stu, "")
            tmp_stu.append(course_str)
        if stu_name in tmp_stu:
            print("您输入的学生姓名已经存在,如果重名请联系管理员")
            break
        else:
            stu_age = input("请输入您的年龄:")
            stu_sex = input("请输入您的性别:")
            tmp_stu_id = setting.file_name(setting.STUDENTDB_PATH)
            stu_num = len(tmp_stu_id)
            stu_id = 1001 + stu_num
            pay_status = 0
            student = BasicLogic.Students(
                stu_name, stu_age, stu_sex,
                school_func.school_list[school_id].name, stu_id,
                tmp_grades[choose_grade], pay_status)
            school_func.school_list[school_id].enroll(student)
            stu_info = {
                "school": school_func.school_list[school_id].name,
                "name": stu_name,
                "age": stu_age,
                "sex": stu_sex,
                "id": stu_id,
                "grade": tmp_grades[choose_grade],
                "pay_status": pay_status,
            }
            file_path = "%s\%s.text" % (setting.STUDENTDB_PATH, stu_name)
            with open(file_path, "ab") as f:
                pickle.dump(stu_info, f)
Ejemplo n.º 2
0
def add_grade():
    '''创建班级,用户输入选择班级的信息进行创建'''
    for index,i in enumerate(school_list):
        print(index,i.name)
    school_id = int(input("请选择班级所在学校的序号:"))
    add_grade_name = input("请输入班级名称:")
    teacher_tmp_list = setting.file_name(setting.TEACHERDB_PATH)
    teacher_list = []
    for teachers in teacher_tmp_list:
        suffix = re.search("\.+[a-z]{4}", teachers).group()
        course_str = teachers.replace(suffix, "")
        teacher_list.append(course_str)
    while True:
        if len(teacher_list):
            for index,i in enumerate(teacher_list):
                print(index,i)
            break
        else:
            print("还没有创建老师,请先创建讲师!")
            add_teacher()
    add_grade_teacher = int(input("请选择班级老师的序号:"))
    course_tmp_list = setting.file_name(setting.COURSE_PATH)
    course_list = []
    for coures in course_tmp_list:
        suffix = re.search("\.+[a-z]{4}", coures).group()
        course_str = coures.replace(suffix, "")
        course_list.append(course_str)
    while True:
        if len(course_list):
            for index,i in enumerate(course_list):
                print(index,i)
            break
        else:
            print("还没有创建课程,请先创建课程!")
            add_course()
    add_grade_course = int(input("请选择班级课程的序号:"))
    grade = BasicLogic.Grade(add_grade_name,teacher_list[add_grade_teacher],course_list[add_grade_course])
    school_list[school_id].creat_grade(grade)
    grade_info = {"school":school_list[school_id].name,
                   "name":add_grade_name,
                   "teacher":teacher_list[add_grade_teacher],
                   "course":course_list[add_grade_course],
                   }
    file_path = "%s\%s.text" %(setting.GRADE_PATH,add_grade_name)
    with open(file_path,"ab") as f:
        pickle.dump(grade_info, f)
Ejemplo n.º 3
0
def show_courses():
    '''查看课程列表,反序列化课程文件'''
    file_name_res = setting.file_name(setting.COURSE_PATH)
    for i in file_name_res:
        file_path = "%s\%s" %(setting.COURSE_PATH,i)
        with open(file_path,"rb") as f:
            res = pickle.load(f)
            print("""
            -----------------info of Course:%s
            学校名称:%s
            课程名称:%s
            课程周期:%s
            课程价格:%s
            """ %( res["course"],res["school"], res["course"], res["time"], res["price"]))
Ejemplo n.º 4
0
def show_stu():
    """查看学生信息"""
    file_name_res = setting.file_name(setting.STUDENTDB_PATH)
    for i in file_name_res:
        file_path = "%s\%s" % (setting.STUDENTDB_PATH, i)
        with open(file_path, "rb") as f:
            res = pickle.load(f)
        print("""
        ---------info of Student:%s ---------
        学生姓名:%s
        学生性别:%s
        学生年龄:%s
        所属学校:%s
        学生ID:%s
        所属班级:%s
        缴费状态:%s
        """ % (res["name"], res["name"], res["sex"], res["age"], res["school"],
               res["id"], res["grade"], res["pay_status"]))
Ejemplo n.º 5
0
def show_grades():
    """查看班级信息"""
    file_name_res = setting.file_name(setting.GRADE_PATH)
    for i in file_name_res:
        file_path = "%s\%s" %(setting.GRADE_PATH,i)
        with open(file_path,"rb") as f:
            res = pickle.load(f)
            # course_str = res["course"]
            # suffix = re.search("\.+[a-z]{4}",course_str).group()
            # course_str = course_str.replace(suffix,"")
            # teacher_str = res["teacher"]
            # teacher_str = teacher_str.replace(suffix,"")
        print("""
        ---------info of Grade:%s ---------
        学校名称:%s
        班级名称:%s
        班级讲师:%s
        班级课程:%s
        """ % (res["name"],res["school"],res["name"],res["teacher"],res["course"]))
Ejemplo n.º 6
0
def show_teachers():
    '''查看老师列表,反序列化老师的数据文件'''
    file_name_res = setting.file_name(setting.TEACHERDB_PATH)
    for i in file_name_res:
        file_path = "%s\%s" %(setting.TEACHERDB_PATH,i)
        with open(file_path,"rb") as f:
            res = pickle.load(f)
            # course_str = res["course"]
            # suffix = re.search("\.+[a-z]{4}",course_str).group()
            # course_str = course_str.replace(suffix,"")
        print("""
        ---------info of Teacher:%s ---------
        学校名称:%s
        老师姓名:%s
        老师年龄:%s
        老师性别:%s
        老师所授课程:%s
        老师薪资:%s
        """ % (res["name"],res["school"],res["name"],res["age"],res["sex"],res["course"],res["salary"]))
Ejemplo n.º 7
0
def add_teacher():
    '''创建老师,管理员输入老师的信息,由school类进行创建'''
    for index,i in enumerate(school_list):
        print(index,i.name)
    school_id = int(input("请选择老师所在学校的序号:"))
    add_teacher_name = input("请输入老师的姓名:")
    add_teacher_age = input("请输入老师的年龄:")
    add_teacher_sex = input("请输入老师的性别:")
    add_teacher_salary = int(input("请输入老师的薪资:"))
    # add_teacher_course = input("请输入老师主讲课程:")
    course_tmp_list = setting.file_name(setting.COURSE_PATH)
    course_list = []
    for coures in course_tmp_list:
        suffix = re.search("\.+[a-z]{4}", coures).group()
        course_str = coures.replace(suffix, "")
        course_list.append(course_str)
    while True:
        if len(course_list):
            for index,i in enumerate(course_list):
                print(index,i)
            break
        else:
            print("学校还没有创建课程,请先创建课程!")
            add_course()
            #return
    add_teacher_course = int(input("请选择讲师所授课程的序号:"))
    teacher = BasicLogic.Teacher(add_teacher_name,add_teacher_age,add_teacher_sex,school_list[school_id].name,add_teacher_salary,course_list[add_teacher_course])
    school_list[school_id].hire(teacher)
    teacher_info = {"school":school_list[school_id].name,
                   "name":add_teacher_name,
                   "age":add_teacher_age,
                   "sex":add_teacher_sex,
                    "salary":add_teacher_salary,
                    "course":course_list[add_teacher_course],
                   }
    file_path = "%s\%s.text" %(setting.TEACHERDB_PATH,add_teacher_name)
    with open(file_path,"ab") as f:
        pickle.dump(teacher_info, f)
Ejemplo n.º 8
0
def pay_tuition():
    """学生缴费,修改支付状态"""
    while True:
        stu_name = input("请输入您的姓名:")
        stu_file_name = setting.file_name(setting.STUDENTDB_PATH)
        tmp_stu = []
        for i in stu_file_name:
            stu_str = i
            suffix_stu = re.search("\.+[a-z]{4}", stu_str).group()
            course_str = stu_str.replace(suffix_stu, "")
            tmp_stu.append(course_str)
        if stu_name in tmp_stu:
            stu_db_path = "%s\%s.text" % (setting.STUDENTDB_PATH, stu_name)
            with open(stu_db_path, "rb") as f_stu:
                res = pickle.load(f_stu)
            pay_status = res["pay_status"]
            stu_grade = res["grade"]
            grade_db_path = "%s\%s.text" % (setting.GRADE_PATH, stu_grade)
            with open(grade_db_path, "rb") as f_grade:
                res_grade = pickle.load(f_grade)
            grade_course = res_grade["course"]
            if pay_status == 0:
                print("您当前的缴费状态:未缴费")
                course_db_path = "%s\%s.text" % (setting.COURSE_PATH,
                                                 grade_course)
                with open(course_db_path, "rb") as f_course:
                    course_res = pickle.load(f_course)
                course_price = course_res["price"]
                i = 0
                while i < 3:
                    print("您所需要缴费的金额为:%s" % course_price)
                    stu_pay = int(input("请输入您要缴费的金额:"))
                    if stu_pay == course_price:
                        print("缴费成功!")
                        res["pay_status"] = 1
                        with open(stu_db_path, "wb") as f_in:
                            pickle.dump(res, f_in)
                        with open(stu_db_path, "rb") as f_out:
                            show_stu = pickle.load(f_out)
                            print("""
                                    ---------info of Student:%s ---------
                                    学生姓名:%s
                                    学生性别:%s
                                    学生年龄:%s
                                    所属学校:%s
                                    学生ID:%s
                                    所属班级:%s
                                    缴费状态:%s
                                    """ %
                                  (show_stu["name"], show_stu["name"],
                                   show_stu["sex"], show_stu["age"],
                                   show_stu["school"], show_stu["id"],
                                   show_stu["grade"], show_stu["pay_status"]))
                            # show_stu()
                        break
                    else:
                        print("您输入的金额不正确!重新输入")
                        i += 1
                break
            if pay_status == 1:
                print("您当前的缴费状态:已缴费")
                break
        else:
            exit("您尚未注册,请先办理学员注册手续!")