Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def mainMenu():
- print("""
- ################################################################################
- # #
- # Clive's Carpets #
- # Please Login Below! #
- # #
- ################################################################################
- """)
- validateUser()
- def adminMenu():
- while True:
- print("""
- ################################################################################
- # #
- # Clive's Carpets #
- # Admin Menu #
- # #
- # 1 - Add a New User #
- # 2 - Exit #
- # #
- ################################################################################
- """)
- adminMenu = input("What option would you like to choose? '1'or '2': ")
- if adminMenu == '1':
- newUser()
- break
- elif adminMenu == '2':
- exit()
- break
- def userMenu():
- print("User Menu")
- exit()
- def newUser():
- userType, username, password1, password2 = "","","",""
- while True:
- userType = input("what type of user are you?\n(1) Admin\n(2) User\nType '-1' to exit to the main menu")
- if userType == "-1":
- mainMenu()
- if len(userType) > 1:
- print("\nInvalid Input!\n")
- elif usertype.isdigit() != True:
- print("\nPlease enter a number!")
- elif int(userType) <1:
- print("\nInvalid Input\n")
- else:
- break
- while True:
- username = input("\nPlease enter the username of the new user: ")
- if username == "-1":
- mainMenu()
- if len(username) > 10:
- print("\nUsername must be less than 11 characters!\n")
- elif username.isalpha() == False:
- print("\nThe username must only contain alpha!\n")
- else:
- break
- while True:
- password1 = input("\nPlease enter the password for the user: ")
- if password1 == '-1':
- mainMenu()
- if len(password1) >10:
- print("\nPassword must be less than 11 characters!\n")
- password2 = input("\nPlease enter the password again: ")
- if password2 == '-1':
- mainMenu()
- if len(password2) >10:
- print("\nPassword must be less than 11 characters!\n")
- if passwrod1 != password2:
- print("\nThe passwords do not match!\n")
- else:
- break
- username = username.lower()
- password1 = password1.lower()
- password2 = password2.lower()
- userTypeStore = str(userType).ljust(1)
- usernameStore = username.ljust(10)
- passwordStore = password1.ljust(10)
- store = open("users.txt","a")
- iStore = usernameStore + passwordStore + userTypeStore + "\n"
- store.write(iStore)
- store.close()
- print("\nNew User Created: ")
- print("\nUsertype: "+userType+"\nUsername: "+username)
- print("Password: **********")
- mainMenu()
- def validateUser():
- validateUserType, validateUsername, validatePassword = "","",""
- username = str(input("\nPlease enter your username: \n"))
- password = str(input("\nPlease enter your password: \n"))
- while True:
- try:
- readUsers = open("users.txt","r")
- validateCounter = 0
- while True:
- location = readUsers.readline()
- validateUserType = location[20:21]
- validateUserType = validateUserType.strip()
- validateUsername = location[0:10]
- validateUsername = validateUsername.lower()
- username = username.lower()
- validatePassword = location[10:20]
- validatePassword = validatePassword.lower()
- if location == "":
- readUsers.close()
- break
- if validateUserType == str(1) and validateUsername == username and validatePassword == password:
- validateCounter = validateCounter + 1
- userMenu()
- break
- if validateUserType == str(2) and validateUsername == username and validatePassword == password:
- validateCounter = validateCounter + 1
- userMenu()
- break
- if validateCounter == 0:
- print("\nNo user in the file with those login details.\n")
- validateUser()
- except FileNotFoundError:
- print("\nThere is no Users file for you to search! How about making your first account?\n Top Tip, make it a system administrator account!!\n")
- newUser()
- def main():
- mainMenu()
- main()
- def newQuote():
- CARPET = 22.50
- carpetCost = 0
- GRIPPER = 1.10
- gripperCost = 0
- RATE = 65
- labour = 0
- underlayPicker = 0
- underlay = 0
- underlayCost = 0
- width = 0
- length = 0
- periMeter = 0
- squareMeter = 0
- rawMaterialsCost = 0
- totalcost = 0
- quotationCount = len(open("quotations.txt","r").readlines( ))
- quotationID = "CC"+str(quotationCount+1)
- while True:
- customerID = input("\nInput the customer ID: ")
- if len(customerID)>12:
- print("\nCustomer ID has to be less than 12 characters (5 characters House Number + 7 Characters Postcode")
- else:
- break
- while True:
- length = float(input("\nInput the total length of the room (m): "))
- if length>30:
- print("\nRoom is too long!")
- else:
- break
- while True:
- width = float(input("\nInput the total width of the room (m): "))
- if width>30:
- print("\nRoom is too wide!")
- else:
- break
- while True:
- periMeter = float(input("\nInput the total perimeter of the room (m): "))
- if periMeter>300:
- print("\nYou had better double check!")
- else:
- break
- while True:
- print("""
- #################################################################################
- # #
- # Clive's Carpets #
- # Underlay Picker #
- # #
- # Which underlay would the customer like: #
- # 1 - First Step: £5.99 per square meter #
- # 2 - Monarch: £7.99 per squere meter #
- # 3 - Royal: £60.00 per square meter #
- # #
- # 4 - Exit #
- # #
- #################################################################################
- """)
- underlayPicker = input("Which underlay would the customer like? Option '1', '2', '3' or '4': ")
- if underlayPicker == "1":
- underlay = 5.99
- break
- elif underlayPicker == "2":
- underlay = 7.99
- break
- elif underlayPicker == "3":
- underlay = 60
- break
- elif underlayPicker == "4":
- quit()
- else:
- print("\nThat is not a valid entry, you must select '1', '2', '3' or '4'")
- squareMeter = length * width
- squareMeter = float(str(round(squareMeter, 2)))
- perimeter = round(perimeter + 0.49)
- carpetCost = squareMeter * CARPET
- carpetCost = float(str(round(carpetCost, 2)))
- gripperCost = perimeter * GRIPPER
- gripperCost = float(str(round(gripperCost, 2)))
- underlayCost = squareMeter * underlay
- underlayCost = float(str(round(underlayCost, 2)))
- if squareMeter < 17:
- labour = RATE
- elif squareMeter > 16:
- labour = (squareMeter / 16) * RATE
- labour = float(str(round(labour, 2)))
- rawMaterialsCost = carpetCost + gripperCost + underlayCost
- rawMaterialsCost = float(str(round(rawMaterialsCost, 2)))
- totalCost = rawMaterialsCost + labour
- totalCost = float(str(round(totalCost, 2)))
- print("\nQuotation "+str(quotationID)+" for Customer "+str(customerID))
- print("\nRoom size in Sq.M: "+str(squareMeter))
- print("Room perimeter in M: "+str(perimeter))
- print("\nCarpetCost: £"+"{:.2f}".format(carpetCost))
- print("Gripper Cost: £"+"{:.2f}".format(gripperCost))
- print("Underlay Cost: £"+"{:.2f}".format(underlayCost))
- print("\nRaw Materials Cost: £"+"{:.2f}".format(rawMaterialsCost))
- print("Labour Cost: £"+"{:.2f}".format(labour))
- print("\nTotal Cost: £"+"{:.2f}".format(totalCost))
- quotationIDStore = quotationID.1just(10)
- customerID = customerID.lower()
- customerID = customerID.replace(" ", "")
- customerIDStore = customerID.1just(12)
- squareMeter = str(squareMeter)
- squareMeterStore = squareMeter.1just(10)
- perimeter = str(perimeter)
- perimeterStore = perimeter.1just(10)
- carpetCost = str(carpetStore)
- carpetCostStore = carpetCost.1just(10)
- gripperCost = str(gripperCost)
- gripperCostStore = gripperCost.1just(10)
- underlayCost = str(underlayCost)
- underlayCostStore = underlayCost.1just(10)
- rawMaterialsCost = str(rawMaterialsCost)
- rawMaterialsCostStore = rawMaterialsCost.1just(10)
- labour = str(labour)
- labourStore = labour.1just(10)
- totalCost = str(totalCost)
- totalCostStore = totalCostStore.1just(10)
- store = open("quotations.txt","a")
- istore = quotationIDStore + customerIDStore + squareMeterStore + perimeterStore + carpetCostStore + gripperCostStore +underlayCostStore + rawMaterialsCostStore +"\n"
- store.write(istore)
- store.close()
- print("\nQuotation saved to Customer Records")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement