shivansh-28

point of sale system

May 3rd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.59 KB | None | 0 0
  1. from tkinter import *
  2. import random
  3. import time
  4. from PyQt5 import QtGui
  5. #===================DAT BASE=================================
  6. import sqlite3
  7.  
  8. conn = sqlite3.connect('inventory .db')
  9.  
  10. c= conn.cursor()
  11. print ("Opened database successfully");
  12. #==========================================
  13. root = Tk()
  14. root.geometry("1600x700+0+0")
  15. root.title("POINT OF SALE SYSTEM JAMIA MILLIA ISLAMIA ")
  16.  
  17. Tops = Frame(root,bg="white",width = 1600,height=50,relief=SUNKEN)
  18. Tops.pack(side=TOP)
  19.  
  20. f1 = Frame(root,width = 900,height=700,relief=SUNKEN)
  21. f1.pack(side=LEFT)
  22.  
  23. f2 = Frame(root ,width = 400,height=700,relief=SUNKEN)
  24. f2.pack(side=RIGHT)
  25. #------------------TIME--------------
  26. localtime=time.asctime(time.localtime(time.time()))
  27. #-----------------INFO TOP-----------------
  28. lblinfo = Label(Tops, font=( 'aria' ,30, 'bold' ),text="POINT OF SALE SYSTEM JAMIA MILLIA ISLAMIA " ,fg="GREEN",bd=10,anchor='w')
  29. lblinfo.grid(row=0,column=0)
  30. lblinfo = Label(Tops, font=( 'aria' ,20, ),text=localtime,fg="GREEN",anchor=W)
  31. lblinfo.grid(row=0,column=1)
  32. #=================================================================log in ====================================================================
  33. creds = 'tempfile.temp'
  34.  
  35. def Signup(): # This is the signup definition,
  36. global pwordE # These globals just make the variables global to the entire script, meaning any definition can use them
  37. global nameE
  38. global roots
  39.  
  40. roots = Tk() # This creates the window, just a blank one.
  41. roots.title('Signup') # This renames the title of said window to 'signup'
  42. intruction = Label(roots, text='JAMIA MILLIA ISLAMIA \n') # This puts a label, so just a piece of text saying 'please enter blah'
  43. intruction.grid(row=0, column=0, sticky=E) # This just puts it in the window, on row 0, col 0. If you want to learn more look up a tkinter tutorial :)
  44.  
  45. nameL = Label(roots, text='New Username: ') # This just does the same as above, instead with the text new username.
  46. pwordL = Label(roots, text='New Password: ') # ^^
  47. nameL.grid(row=1, column=0, sticky=W) # Same thing as the instruction var just on different rows. :) Tkinter is like that.
  48. pwordL.grid(row=2, column=0, sticky=W) # ^^
  49.  
  50. nameE = Entry(roots) # This now puts a text box waiting for input.
  51. pwordE = Entry(roots, show='*') # Same as above, yet 'show="*"' What this does is replace the text with *, like a password box :D
  52. nameE.grid(row=1, column=1) # You know what this does now :D
  53. pwordE.grid(row=2, column=1) # ^^
  54.  
  55. signupButton = Button(roots, text='Signup', command=FSSignup) # This creates the button with the text 'signup', when you click it, the command 'fssignup' will run. which is the def
  56. signupButton.grid(columnspan=2, sticky=W)
  57. roots.mainloop() # This just makes the window keep open, we will destroy it soon
  58.  
  59. def FSSignup():
  60. with open(creds, 'w') as f: # Creates a document using the variable we made at the top.
  61. f.write(nameE.get()) # nameE is the variable we were storing the input to. Tkinter makes us use .get() to get the actual string.
  62. f.write('\n') # Splits the line so both variables are on different lines.
  63. f.write(pwordE.get()) # Same as nameE just with pword var
  64. f.close() # Closes the file
  65.  
  66. roots.destroy() # This will destroy the signup window. :)
  67. Login() # This will move us onto the login definition :D
  68.  
  69. def Login():
  70. global nameEL
  71. global pwordEL # More globals :D
  72. global rootA
  73.  
  74. rootA = Tk() # This now makes a new window.
  75. rootA.title('Login') # This makes the window title 'login'
  76.  
  77. intruction = Label(rootA, text='Please Login\n') # More labels to tell us what they do
  78. intruction.grid(sticky=E) # Blahdy Blah
  79.  
  80. nameL = Label(rootA, text='Username: ') # More labels
  81. pwordL = Label(rootA, text='Password: ') # ^
  82. nameL.grid(row=1, insertwidth=4,sticky=W)
  83. pwordL.grid(row=2, sticky=W)
  84.  
  85. nameEL = Entry(rootA) # The entry input
  86. pwordEL = Entry(rootA, show='*')
  87. nameEL.grid(row=1, column=1)
  88. pwordEL.grid(row=2, column=1)
  89.  
  90. # loginB = Button(rootA, text='Login', command=CheckLogin) # This makes the login button, which will go to the CheckLogin def.
  91. #loginB.grid(columnspan=8, sticky=W)
  92.  
  93. rmuser = Button(rootA, text='Delete User', fg='red', command=DelUser) # This makes the deluser button. blah go to the deluser def.
  94. rmuser.grid(columnspan=8, sticky=W)
  95. rootA.mainloop()
  96.  
  97. def CheckLogin():
  98. with open(creds) as f:
  99. data = f.readlines() # This takes the entire document we put the info into and puts it into the data variable
  100. uname = data[0].rstrip() # Data[0], 0 is the first line, 1 is the second and so on.
  101. pword = data[1].rstrip() # Using .rstrip() will remove the \n (new line) word from before when we input it
  102.  
  103. if nameEL.get() == uname and pwordEL.get() == pword: # Checks to see if you entered the correct data.
  104. r = Tk() # Opens new window
  105. r.title(':D')
  106. r.geometry("600x700+0+0") # Makes the window a certain size
  107. rlbl = Label(r, text='\n[+] Logged In') # "logged in" label
  108. rlbl.pack() # Pack is like .grid(), just different
  109. r.mainloop()
  110. else:
  111. r = Tk()
  112. r.title('D:')
  113. r.geometry("600x700+0+0")
  114. rlbl = Label(r, text='\n[!] Invalid Login')
  115. rlbl.pack()
  116. r.mainloop()
  117.  
  118. def DelUser():
  119. os.remove(creds) # Removes the file
  120. rootA.destroy() # Destroys the login window
  121. Signup() # And goes back to the start!
  122. def os():
  123. if os.path.isfile(creds):
  124. Login()
  125. else: # This if else statement checks to see if the file exists. If it does it will go to Login, if not it will go to Signup :)
  126. Signup()
  127.  
  128.  
  129.  
  130. #=======================================================================================
  131. def __init__(self, pos):
  132.  
  133. super(Application, self).__init__(pos)
  134. self.task = ""
  135. self.UserIn = StringVar()
  136. self.grid()
  137. self.create_widgets()
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154. text_Input=StringVar()
  155. operator =""
  156.  
  157. txtdisplay = Entry(f2,font=('ariel' ,390,'bold'), textvariable=text_Input, bd=4 ,insertwidth=24 ,bg="white",justify='right')
  158. txtdisplay.grid(columnspan=40 )
  159.  
  160. def btnclick(numbers):
  161. global operator
  162. operator=operator + str(numbers)
  163. text_Input.set(operator)
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173. def clrdisplay():
  174. global operator
  175. operator=""
  176. text_Input.set("")
  177.  
  178. def eqals():
  179. global operator
  180. sumup=str(eval(operator))
  181.  
  182. text_Input.set(sumup)
  183. operator = ""
  184.  
  185. def Ref():
  186. x=random.randint(12980, 50876)
  187. randomRef = str(x)
  188. rand.set(randomRef)
  189.  
  190. cof =float(Fries.get())
  191. colfries= float(Largefries.get())
  192. cob= float(Burger.get())
  193. cofi= float(Filet.get())
  194. cochee= float(Cheese_burger.get())
  195. codr= float(Drinks.get())
  196.  
  197. costoffries = cof*25
  198. costoflargefries = colfries*40
  199. costofburger = cob*35
  200. costoffilet = cofi*50
  201. costofcheeseburger = cochee*50
  202. costofdrinks = codr*35
  203.  
  204. costofmeal = "Rs.",str('%.2f'% (costoffries + costoflargefries + costofburger + costoffilet + costofcheeseburger + costofdrinks))
  205. PayTax=((costoffries + costoflargefries + costofburger + costoffilet + costofcheeseburger + costofdrinks)*0.33)
  206. Totalcost=(costoffries + costoflargefries + costofburger + costoffilet + costofcheeseburger + costofdrinks)
  207. Ser_Charge=((costoffries + costoflargefries + costofburger + costoffilet + costofcheeseburger + costofdrinks)/99)
  208. Service="Rs.",str('%.2f'% Ser_Charge)
  209. OverAllCost="Rs.",str( PayTax + Totalcost + Ser_Charge)
  210. PaidTax="Rs.",str('%.2f'% PayTax)
  211.  
  212. Service_Charge.set(Service)
  213. cost.set(costofmeal)
  214. Tax.set(PaidTax)
  215. Subtotal.set(costofmeal)
  216. Total.set(OverAllCost)
  217.  
  218.  
  219.  
  220.  
  221. #btnTotal=Button(f1,padx=16,pady=8, bd=10 ,fg="black",font=('Helvetica' ,16,'bold'),width=10, text="TOTAL", bg="#E6D72A",command=Ref)
  222. #btnTotal.grid(row=7, column=1)
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232. def qexit():
  233. root.destroy()
  234.  
  235. def reset():
  236. rand.set("")
  237. Fries.set("")
  238. Largefries.set("")
  239. Burger.set("")
  240. Filet.set("")
  241. Subtotal.set("")
  242. Total.set("")
  243. Service_Charge.set("")
  244. Drinks.set("")
  245. Tax.set("")
  246. cost.set("")
  247. Cheese_burger.set("")
  248.  
  249. def __init__(self, master):
  250.  
  251. super(Application, self).__init__(master)
  252. self.task = ""
  253. self.UserIn = StringVar()
  254. self.grid()
  255. self.create_widgets()
  256.  
  257.  
  258. def displayText(self, value):
  259. self.user_input.delete(0, END)
  260. self.user_input.insert(0, value)
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274. #---------------------------------------------------------------------------------------
  275. rand = StringVar()
  276. Fries = StringVar()
  277. Largefries = StringVar()
  278. Burger = StringVar()
  279. Filet = StringVar()
  280. Subtotal = StringVar()
  281. Total = StringVar()
  282. Service_Charge = StringVar()
  283. Drinks = StringVar()
  284. Tax = StringVar()
  285. cost = StringVar()
  286. Cheese_burger = StringVar()
  287.  
  288.  
  289.  
  290. def create_widgets(self):
  291.  
  292. # self.button2 = Button(self, bg = "#98DBC6", bd = 12,
  293. # text = "Fries Meal", padx = 35, pady = 8,
  294. #command = lambda: self.buttonClick("Lunch"), font = ("Helvetica", 20, "bold"))
  295. #self.button2.grid(row = 2, column = 1, sticky = W)
  296.  
  297.  
  298. #self.button1 = Button(self, bg = "#98DBC6", bd = 12,
  299. #text = "samosa", padx = 33, pady = 7, font = ("Helvetica", 20, "bold"),
  300. #command = lambda : self.buttonClick("samosa"))
  301. #self.button1.grid(row = 2, column = 0, sticky = W)
  302.  
  303.  
  304. #self.button1 = Button(f1, font=( 'Helvetica' ,16, 'bold' ),text="Lunch Meal",fg="steel blue",bd=10,anchor='w')
  305. #self.button1.grid(row=2,column=0)
  306.  
  307.  
  308.  
  309. #lblfries = Button(f1, font=( 'aria' ,16, 'bold' ),text="Fries Meal",fg="steel blue",bd=10,anchor='w')
  310. #lblfries.grid(row=1,column=0)
  311. #txtfries = Entry(f1,font=('ariel' ,16,'bold'), textvariable=Fries , bd=6,insertwidth=4,bg="powder blue" ,justify='right')
  312. #txtfries.grid(row=1,column=1)
  313.  
  314.  
  315.  
  316. lblreference = Label(f1, font=( 'aria' ,16, 'bold' ),text="Order No.",fg="steel blue",bd=10,anchor='w')
  317. lblreference.grid(row=0,column=0)
  318. txtreference = Entry(f1,font=('ariel' ,16,'bold'), textvariable=rand , bd=6,insertwidth=4,bg="powder blue" ,justify='right')
  319. txtreference.grid(row=0,column=1)
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341. #def(self):
  342. # lblLargefries = Button(f1, font=( 'Helvetica' ,16, 'bold' ),text="Lunch Meal",fg="steel blue",bd=10,anchor='w',command=self.Lunch )
  343. # lblLargefries.grid(row=9,column=0)
  344.  
  345.  
  346.  
  347. lblburger = Button(f1, font=( 'aria' ,16, 'bold' ),text="Burger Meal",fg="steel blue",bd=10,anchor='w')
  348. lblburger.grid(row=3,column=0)
  349. txtburger = Entry(f1,font=('ariel' ,16,'bold'), textvariable=Burger , bd=6,insertwidth=4,bg="powder blue" ,justify='right')
  350. txtburger.grid(row=3,column=1)
  351.  
  352. lblFilet = Button(f1, font=( 'aria' ,16, 'bold' ),text="Pizza Meal",fg="steel blue",bd=10,anchor='w')
  353. lblFilet.grid(row=4,column=0)
  354. txtFilet = Entry(f1,font=('ariel' ,16,'bold'), textvariable=Filet , bd=6,insertwidth=4,bg="powder blue" ,justify='right')
  355. txtFilet.grid(row=4,column=1)
  356.  
  357. lblCheese_burger = Button(f1, font=( 'aria' ,16, 'bold' ),text="Cheese burger",fg="steel blue",bd=10,anchor='w')
  358. lblCheese_burger.grid(row=5,column=0)
  359. txtCheese_burger = Entry(f1,font=('ariel' ,16,'bold'), textvariable=Cheese_burger , bd=6,insertwidth=4,bg="powder blue" ,justify='right')
  360. txtCheese_burger.grid(row=5,column=1)
  361.  
  362. #--------------------------------------------------------------------------------------
  363. #lblDrinks = Button(f1, font=( 'Helvetica' ,16, 'bold' ),text="Drinks",fg="steel blue",bd=10,anchor='w')
  364. #lblDrinks.grid(row=0,column=2)
  365. #txtDrinks = buttonClick
  366. #lblDrinks.grid(row=0,column=4)
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380. #btn7=Button(f2,padx=16,pady=16,bd=4, fg="black", font=('ariel', 20 ,'bold'),text="7",bg="powder blue", command=lambda: btnclick(7) )
  381. #btn7.grid(row=2,column=0)
  382.  
  383.  
  384.  
  385. lblcost = Label(f1, font=( 'Helvetica' ,16, 'bold' ),text="cost",fg="steel blue",bd=10,anchor='w')
  386. lblcost.grid(row=9,column=7)
  387.  
  388.  
  389. lblService_Charge = Label(f1, font=( 'Helvetica' ,16, 'bold' ),text="Service Charge",fg="steel blue",bd=10,anchor='w')
  390. lblService_Charge.grid(row=5,column=4)
  391.  
  392.  
  393. #lblTax = Label(f1, font=( 'Helvetica' ,16, 'bold' ),text="Tax",fg="steel blue",bd=10,anchor='w')
  394. #lblTax.grid(row=5,column=2)
  395. #txtTax = buttonClick
  396.  
  397.  
  398. lblSubtotal = Label(f1, font=( 'Helvetica' ,16, 'bold' ),text="Subtotal",fg="steel blue",bd=10,anchor='w')
  399. lblSubtotal.grid(row=9,column=3)
  400.  
  401.  
  402. lblTotal = Label(f1, font=( 'Helvetica' ,16, 'bold' ),text="Total",fg="steel blue",bd=10,anchor='w')
  403. lblTotal.grid(row=10,column=10)
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410. #btn=Button(f2,padx=16,pady=16,bd=4, fg="black", font=('Helvetica', 20 ,'bold'),text="Lunch ",bg="powder blue", command=lambda: btnclick(Lunch ) )
  411. #btn.grid(row=8,column=0)
  412.  
  413.  
  414. #-----------------------------------------buttons------------------------------------------
  415. lblTotal = Label(f1,text="---------------------",fg="white")
  416. lblTotal.grid(row=8,columnspan=3)
  417.  
  418. btnTotal=Button(f1,padx=16,pady=8, bd=10 ,fg="black",font=('Helvetica' ,16,'bold'),width=10, text="TOTAL", bg="#E6D72A",command=Ref)
  419. btnTotal.grid(row=7, column=1)
  420.  
  421. btnreset=Button(f1,padx=16,pady=8, bd=10 ,fg="black",font=('Helvetica' ,16,'bold'),width=10, text="RESET", bg="#E6D72A",command=reset)
  422. btnreset.grid(row=7, column=2)
  423.  
  424. btnexit=Button(f1,padx=16,pady=8, bd=10 ,fg="black",font=('ariel' ,16,'bold'),width=10, text=" LOG-IN ", bg="#E6D72A",command='CheckLogin')
  425. btnexit.grid(row=7, column=0)
  426.  
  427.  
  428. def price():
  429. roo = Tk()
  430. roo.geometry("600x220+0+0")
  431. roo.title("Price List")
  432. lblinfo = Label(roo, font=('aria', 15, 'bold'), text="ITEM", fg="black", bd=5)
  433. lblinfo.grid(row=0, column=0)
  434. lblinfo = Label(roo, font=('aria', 15,'bold'), text="_____________", fg="white", anchor=W)
  435. lblinfo.grid(row=0, column=2)
  436. lblinfo = Label(roo, font=('aria', 15, 'bold'), text="PRICE", fg="black", anchor=W)
  437. lblinfo.grid(row=0, column=3)
  438. lblinfo = Label(roo, font=('aria', 15, 'bold'), text="Fries Meal", fg="steel blue", anchor=W)
  439. lblinfo.grid(row=1, column=0)
  440. lblinfo = Label(roo, font=('aria', 15, 'bold'), text="25", fg="steel blue", anchor=W)
  441. lblinfo.grid(row=1, column=3)
  442. lblinfo = Label(roo, font=('aria', 15, 'bold'), text="Lunch Meal", fg="steel blue", anchor=W)
  443. lblinfo.grid(row=2, column=0)
  444. lblinfo = Label(roo, font=('aria', 15, 'bold'), text="40", fg="steel blue", anchor=W)
  445. lblinfo.grid(row=2, column=3)
  446. lblinfo = Label(roo, font=('aria', 15, 'bold'), text="Burger Meal", fg="steel blue", anchor=W)
  447. lblinfo.grid(row=3, column=0)
  448. lblinfo = Label(roo, font=('aria', 15, 'bold'), text="35", fg="steel blue", anchor=W)
  449. lblinfo.grid(row=3, column=3)
  450. lblinfo = Label(roo, font=('aria', 15, 'bold'), text="Pizza Meal", fg="steel blue", anchor=W)
  451. lblinfo.grid(row=4, column=0)
  452. lblinfo = Label(roo, font=('aria', 15, 'bold'), text="50", fg="steel blue", anchor=W)
  453. lblinfo.grid(row=4, column=3)
  454. lblinfo = Label(roo, font=('aria', 15, 'bold'), text="Cheese Burger", fg="steel blue", anchor=W)
  455. lblinfo.grid(row=5, column=0)
  456. lblinfo = Label(roo, font=('aria', 15, 'bold'), text="30", fg="steel blue", anchor=W)
  457. lblinfo.grid(row=5, column=3)
  458. lblinfo = Label(roo, font=('aria', 15, 'bold'), text="Drinks", fg="steel blue", anchor=W)
  459. lblinfo.grid(row=6, column=0)
  460. lblinfo = Label(roo, font=('aria', 15, 'bold'), text="35", fg="steel blue", anchor=W)
  461. lblinfo.grid(row=6, column=3)
  462.  
  463. roo.mainloop()
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.  
  471. root.mainloop()
Add Comment
Please, Sign In to add comment