Advertisement
Guest User

Untitled

a guest
Feb 8th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.31 KB | None | 0 0
  1.  
  2. def mainMenu():
  3.  
  4. print("""
  5.  
  6. ################################################################################
  7.  
  8. # #
  9.  
  10. # Clive's Carpets #
  11.  
  12. # Please Login Below! #
  13.  
  14. # #
  15.  
  16. ################################################################################
  17.  
  18. """)
  19.  
  20. validateUser()
  21.  
  22. def adminMenu():
  23.  
  24. while True:
  25.  
  26. print("""
  27.  
  28. ################################################################################
  29.  
  30. # #
  31.  
  32. # Clive's Carpets #
  33.  
  34. # Admin Menu #
  35.  
  36. # #
  37.  
  38. # 1 - Add a New User #
  39.  
  40. # 2 - Exit #
  41.  
  42. # #
  43.  
  44. ################################################################################
  45.  
  46. """)
  47.  
  48. adminMenu = input("What option would you like to choose? '1'or '2': ")
  49.  
  50. if adminMenu == '1':
  51.  
  52. newUser()
  53.  
  54. break
  55.  
  56. elif adminMenu == '2':
  57.  
  58. exit()
  59.  
  60. break
  61.  
  62.  
  63.  
  64. def userMenu():
  65.  
  66. print("User Menu")
  67.  
  68. exit()
  69.  
  70.  
  71.  
  72. def newUser():
  73.  
  74. userType, username, password1, password2 = "","","",""
  75.  
  76. while True:
  77.  
  78. userType = input("what type of user are you?\n(1) Admin\n(2) User\nType '-1' to exit to the main menu")
  79.  
  80. if userType == "-1":
  81.  
  82. mainMenu()
  83.  
  84. if len(userType) > 1:
  85.  
  86. print("\nInvalid Input!\n")
  87.  
  88. elif usertype.isdigit() != True:
  89.  
  90. print("\nPlease enter a number!")
  91.  
  92. elif int(userType) <1:
  93.  
  94. print("\nInvalid Input\n")
  95.  
  96. else:
  97.  
  98. break
  99.  
  100. while True:
  101.  
  102. username = input("\nPlease enter the username of the new user: ")
  103.  
  104. if username == "-1":
  105.  
  106. mainMenu()
  107.  
  108. if len(username) > 10:
  109.  
  110. print("\nUsername must be less than 11 characters!\n")
  111.  
  112. elif username.isalpha() == False:
  113.  
  114. print("\nThe username must only contain alpha!\n")
  115.  
  116. else:
  117.  
  118. break
  119.  
  120. while True:
  121.  
  122. password1 = input("\nPlease enter the password for the user: ")
  123.  
  124. if password1 == '-1':
  125.  
  126. mainMenu()
  127.  
  128. if len(password1) >10:
  129.  
  130. print("\nPassword must be less than 11 characters!\n")
  131.  
  132. password2 = input("\nPlease enter the password again: ")
  133.  
  134. if password2 == '-1':
  135.  
  136. mainMenu()
  137.  
  138. if len(password2) >10:
  139.  
  140. print("\nPassword must be less than 11 characters!\n")
  141.  
  142. if passwrod1 != password2:
  143.  
  144. print("\nThe passwords do not match!\n")
  145.  
  146. else:
  147.  
  148. break
  149.  
  150.  
  151.  
  152. username = username.lower()
  153.  
  154. password1 = password1.lower()
  155.  
  156. password2 = password2.lower()
  157.  
  158. userTypeStore = str(userType).ljust(1)
  159.  
  160. usernameStore = username.ljust(10)
  161.  
  162. passwordStore = password1.ljust(10)
  163.  
  164. store = open("users.txt","a")
  165.  
  166. iStore = usernameStore + passwordStore + userTypeStore + "\n"
  167.  
  168. store.write(iStore)
  169.  
  170. store.close()
  171.  
  172. print("\nNew User Created: ")
  173.  
  174. print("\nUsertype: "+userType+"\nUsername: "+username)
  175.  
  176. print("Password: **********")
  177.  
  178. mainMenu()
  179.  
  180. def validateUser():
  181.  
  182. validateUserType, validateUsername, validatePassword = "","",""
  183.  
  184. username = str(input("\nPlease enter your username: \n"))
  185.  
  186. password = str(input("\nPlease enter your password: \n"))
  187.  
  188. while True:
  189.  
  190. try:
  191.  
  192. readUsers = open("users.txt","r")
  193.  
  194. validateCounter = 0
  195.  
  196. while True:
  197.  
  198. location = readUsers.readline()
  199.  
  200. validateUserType = location[20:21]
  201.  
  202. validateUserType = validateUserType.strip()
  203.  
  204. validateUsername = location[0:10]
  205.  
  206. validateUsername = validateUsername.lower()
  207.  
  208. username = username.lower()
  209.  
  210. validatePassword = location[10:20]
  211.  
  212. validatePassword = validatePassword.lower()
  213.  
  214. if location == "":
  215.  
  216. readUsers.close()
  217.  
  218. break
  219.  
  220. if validateUserType == str(1) and validateUsername == username and validatePassword == password:
  221.  
  222. validateCounter = validateCounter + 1
  223.  
  224. userMenu()
  225.  
  226. break
  227.  
  228. if validateUserType == str(2) and validateUsername == username and validatePassword == password:
  229.  
  230. validateCounter = validateCounter + 1
  231.  
  232. userMenu()
  233.  
  234. break
  235.  
  236. if validateCounter == 0:
  237.  
  238. print("\nNo user in the file with those login details.\n")
  239.  
  240. validateUser()
  241.  
  242. except FileNotFoundError:
  243.  
  244. 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")
  245.  
  246. newUser()
  247.  
  248. def main():
  249.  
  250. mainMenu()
  251.  
  252. main()
  253.  
  254. def newQuote():
  255.  
  256. CARPET = 22.50
  257.  
  258. carpetCost = 0
  259.  
  260. GRIPPER = 1.10
  261.  
  262. gripperCost = 0
  263.  
  264. RATE = 65
  265.  
  266. labour = 0
  267.  
  268. underlayPicker = 0
  269.  
  270. underlay = 0
  271.  
  272. underlayCost = 0
  273.  
  274. width = 0
  275.  
  276. length = 0
  277.  
  278. periMeter = 0
  279.  
  280. squareMeter = 0
  281.  
  282. rawMaterialsCost = 0
  283.  
  284. totalcost = 0
  285.  
  286. quotationCount = len(open("quotations.txt","r").readlines( ))
  287.  
  288. quotationID = "CC"+str(quotationCount+1)
  289.  
  290. while True:
  291.  
  292. customerID = input("\nInput the customer ID: ")
  293.  
  294. if len(customerID)>12:
  295.  
  296. print("\nCustomer ID has to be less than 12 characters (5 characters House Number + 7 Characters Postcode")
  297.  
  298. else:
  299.  
  300. break
  301.  
  302. while True:
  303.  
  304. length = float(input("\nInput the total length of the room (m): "))
  305.  
  306. if length>30:
  307.  
  308. print("\nRoom is too long!")
  309.  
  310. else:
  311.  
  312. break
  313.  
  314. while True:
  315.  
  316. width = float(input("\nInput the total width of the room (m): "))
  317.  
  318. if width>30:
  319.  
  320. print("\nRoom is too wide!")
  321.  
  322. else:
  323.  
  324. break
  325.  
  326. while True:
  327.  
  328. periMeter = float(input("\nInput the total perimeter of the room (m): "))
  329.  
  330. if periMeter>300:
  331.  
  332. print("\nYou had better double check!")
  333.  
  334. else:
  335.  
  336. break
  337.  
  338. while True:
  339.  
  340. print("""
  341.  
  342. #################################################################################
  343.  
  344. # #
  345.  
  346. # Clive's Carpets #
  347.  
  348. # Underlay Picker #
  349.  
  350. # #
  351.  
  352. # Which underlay would the customer like: #
  353.  
  354. # 1 - First Step: £5.99 per square meter #
  355.  
  356. # 2 - Monarch: £7.99 per squere meter #
  357.  
  358. # 3 - Royal: £60.00 per square meter #
  359.  
  360. # #
  361.  
  362. # 4 - Exit #
  363.  
  364. # #
  365.  
  366. #################################################################################
  367.  
  368. """)
  369.  
  370. underlayPicker = input("Which underlay would the customer like? Option '1', '2', '3' or '4': ")
  371.  
  372. if underlayPicker == "1":
  373.  
  374. underlay = 5.99
  375.  
  376. break
  377.  
  378. elif underlayPicker == "2":
  379.  
  380. underlay = 7.99
  381.  
  382. break
  383.  
  384. elif underlayPicker == "3":
  385.  
  386. underlay = 60
  387.  
  388. break
  389.  
  390. elif underlayPicker == "4":
  391.  
  392. quit()
  393.  
  394. else:
  395.  
  396. print("\nThat is not a valid entry, you must select '1', '2', '3' or '4'")
  397.  
  398. squareMeter = length * width
  399.  
  400. squareMeter = float(str(round(squareMeter, 2)))
  401.  
  402. perimeter = round(perimeter + 0.49)
  403.  
  404. carpetCost = squareMeter * CARPET
  405.  
  406. carpetCost = float(str(round(carpetCost, 2)))
  407.  
  408. gripperCost = perimeter * GRIPPER
  409.  
  410. gripperCost = float(str(round(gripperCost, 2)))
  411.  
  412. underlayCost = squareMeter * underlay
  413.  
  414. underlayCost = float(str(round(underlayCost, 2)))
  415.  
  416. if squareMeter < 17:
  417.  
  418. labour = RATE
  419.  
  420. elif squareMeter > 16:
  421.  
  422. labour = (squareMeter / 16) * RATE
  423.  
  424. labour = float(str(round(labour, 2)))
  425.  
  426. rawMaterialsCost = carpetCost + gripperCost + underlayCost
  427.  
  428. rawMaterialsCost = float(str(round(rawMaterialsCost, 2)))
  429.  
  430. totalCost = rawMaterialsCost + labour
  431.  
  432. totalCost = float(str(round(totalCost, 2)))
  433.  
  434. print("\nQuotation "+str(quotationID)+" for Customer "+str(customerID))
  435.  
  436. print("\nRoom size in Sq.M: "+str(squareMeter))
  437.  
  438. print("Room perimeter in M: "+str(perimeter))
  439.  
  440. print("\nCarpetCost: £"+"{:.2f}".format(carpetCost))
  441.  
  442. print("Gripper Cost: £"+"{:.2f}".format(gripperCost))
  443.  
  444. print("Underlay Cost: £"+"{:.2f}".format(underlayCost))
  445.  
  446. print("\nRaw Materials Cost: £"+"{:.2f}".format(rawMaterialsCost))
  447.  
  448. print("Labour Cost: £"+"{:.2f}".format(labour))
  449.  
  450. print("\nTotal Cost: £"+"{:.2f}".format(totalCost))
  451.  
  452. quotationIDStore = quotationID.1just(10)
  453.  
  454. customerID = customerID.lower()
  455.  
  456. customerID = customerID.replace(" ", "")
  457.  
  458. customerIDStore = customerID.1just(12)
  459.  
  460. squareMeter = str(squareMeter)
  461.  
  462. squareMeterStore = squareMeter.1just(10)
  463.  
  464. perimeter = str(perimeter)
  465.  
  466. perimeterStore = perimeter.1just(10)
  467.  
  468. carpetCost = str(carpetStore)
  469.  
  470. carpetCostStore = carpetCost.1just(10)
  471.  
  472. gripperCost = str(gripperCost)
  473.  
  474. gripperCostStore = gripperCost.1just(10)
  475.  
  476. underlayCost = str(underlayCost)
  477.  
  478. underlayCostStore = underlayCost.1just(10)
  479.  
  480. rawMaterialsCost = str(rawMaterialsCost)
  481.  
  482. rawMaterialsCostStore = rawMaterialsCost.1just(10)
  483.  
  484. labour = str(labour)
  485.  
  486. labourStore = labour.1just(10)
  487.  
  488. totalCost = str(totalCost)
  489.  
  490. totalCostStore = totalCostStore.1just(10)
  491.  
  492. store = open("quotations.txt","a")
  493.  
  494. istore = quotationIDStore + customerIDStore + squareMeterStore + perimeterStore + carpetCostStore + gripperCostStore +underlayCostStore + rawMaterialsCostStore +"\n"
  495.  
  496. store.write(istore)
  497.  
  498. store.close()
  499.  
  500. print("\nQuotation saved to Customer Records")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement