def admin_add_b(): # Add Record of Sport sport = {} sport_list = f.sport_read() flag = 0 while flag == 0: print( "\n*** Add Records of Sport ***\n\n\tPlease Fill in the Sport Code and Sport Name" ) sport_code = input("\tSport Code: ") sport_name = input("\tSport Name: ") # Check if the sport.txt already had input or not for sport in sport_list: if sport["Sport Code"] == sport_code or sport[ "Sport Name"] == sport_name: print("\n\t" + sport_code, "or", sport_name, " are already stored") flag = 1 if flag == 1: continue else: sport["Sport Code"] = sport_code sport["Sport Name"] = sport_name sport["Description"] = input("\tDescribe the sport: ") sport_list.append(sport) f.sport_write(sport_list) print("\n\t★★★ Complete ★★★\n") print_records(sport) break
def admin_search_c(): # Search Specific Records of Sport by Sport ID print("\n*** Search Specific Records of Sport by Sport ID ***") sport_list = f.sport_read() dict_key = "Sport Code" while 1: sport_id = input("\n\tEnter Sport ID: ") if search_print(sport_list, sport_id, dict_key): return
def view_details_a(): # View Datail of Sport print("\n*** View Detail of Sport ***\n\n\t") sport_list = f.sport_read() for sport in sport_list: print("\tSport: "+str(sport["Sport Name"])) print("\t"+str(sport["Description"])) print()
def view_details_b(): # View Datail of Sport Schedule print("\n*** View Detail of Sport Schedule ***\n\n\t") sport_list = f.sport_read() schedule_list = f.schedule_read() for schedule in schedule_list: for sport in sport_list: if schedule["Sport Code"] == sport["Sport Code"]: print("\tSport: "+str(sport["Sport Name"])) print("\tDate: "+schedule["Date"]) print("\tStart Time: "+schedule["Start Time"]) print("\tEnd Time: "+schedule["End Time"]) print()
def admin_modify_b(): # Modify Sport print("\n*** Modify Record of Sport ***") while 1: sport_id = input("\n\tEnter Sport ID to modify: ") sport_list = f.sport_read() for sport in sport_list: # check coach id if sport_id == sport["Sport Code"]: sport["Sport Name"] = input("\n\tPlease Enter Sport Name: ") f.sport_write(sport_list) print("\n\t★★★Complete★★★") print_records(sport) return print("\n\tThere is no " + sport_id + " in this sysmtem")
def modify_coach(num, coach, coach_id): # modify coaches try: num = int(num) if num == 1: coach["Name"] = input("\n\tPlease Enter Name: ") elif num == 2: # modify dates check_date(coach) elif num == 3: while 1: hourly_rate = input("\tPlease Enter Horly Rate (RM/h): ") try: hourly_rate = int(hourly_rate) if hourly_rate >= 100 and hourly_rate <= 500: coach["Horly Rate (RM/h)"] = hourly_rate break else: print( "\n\tHorly Rate should be 100(RM/h)-500RM(RM/h).Please try again." ) continue except: print("\n\tPlease Enter the number") continue elif num == 4: coach["Phone"] = input("\n\tPlease Enter Phone: ") elif num == 5: coach["Adress"] = input("\n\tPlease Enter Adress: ") elif num == 6: # Check whether the input of Sport center code exits or not flag = 0 while flag == 0: sport_center_code = input("\tSport Center Code: ") sport_center_list = f.sport_center_read() for sport_center in sport_center_list: if sport_center["Sport Center Code"] == sport_center_code: coach["Sport Center Code"] = sport_center_code coach["Sport Center Name"] = sport_center[ "Sport Center Name"] flag = 1 break if flag == 1: break else: print("\n\tThere is no", sport_center_code, "in this system") elif num == 7: # Check whether the input of sport code exits or not flag = 0 while flag == 0: sport_code = input("\tSport Code: ") sport_list = f.sport_read() for sport_center in sport_list: if sport_center["Sport Code"] == sport_code: coach["Sport Code"] = sport_code coach["Sport Name"] = sport_center["Sport Name"] # we need to change sport code in the schedule file schedule_list = f.schedule_read() for schedule in schedule_list: if schedule["Coach ID"] == coach_id: schedule["Sport Code"] = sport_code f.schedule_write(schedule_list) flag = 1 break if flag == 1: break else: print("\n\tThere is no", sport_code, "in this system") else: print("\n\tPlease enter 1 ~ 7") except: print("\n\tWrong Input")
def admin_add_a(): # Add Record of Coach coach = {} print( "\n*** Add Records of Coach ***\n\n\tPlease Fill in your information below" ) coach["Coach ID"] = input("\n\tCoach ID: ") coach["Name"] = input("\tName: ") # Add Date check_date(coach) # check whether Horly Rate (RM/h) is number or not while 1: hourly_rate = input("\tHorly Rate (RM/h): ") try: hourly_rate = int(hourly_rate) if hourly_rate >= 100 and hourly_rate <= 500: coach["Horly Rate (RM/h)"] = hourly_rate break else: print( "\n\tHorly Rate should be 100(RM/h)-500RM(RM/h).Please try again." ) continue except: print("\n\tPlease Enter the number") continue coach["Phone"] = input("\tPhone: ") coach["Adress"] = input("\tAdress: ") # Check whether the input of Sport center code exits or not flag = 0 while flag == 0: sport_center_code = input("\tSport Center Code: ") sport_center_list = f.sport_center_read() for sport_center in sport_center_list: if sport_center["Sport Center Code"] == sport_center_code: coach["Sport Center Code"] = sport_center_code coach["Sport Center Name"] = sport_center["Sport Center Name"] flag = 1 if flag == 1: break else: print("\n\tThere is no", sport_center_code, "in this system") continue # Check whether the input of sport code exits or not flag = 0 while flag == 0: sport_code = input("\tSport Code: ") sport_list = f.sport_read() for sport in sport_list: if sport["Sport Code"] == sport_code: coach["Sport Code"] = sport_code coach["Sport Name"] = sport["Sport Name"] flag = 1 if flag == 1: break else: print("\n\tThere is no", sport_code, "in this system") continue coach["Rating"] = 0 # add records coach_list = f.coach_read() coach_list.append(coach) f.coach_write(coach_list) # print records print("\n\t★★★ Complete ★★★\n") print_records(coach)
def admin_display_b(): # Display All Records Sports sport_list = f.sport_read() print("\n*** Here are all records of sport ***\n") for sport in sport_list: print_records(sport)