Skip to content

Commit a02863d

Browse files
Merge pull request #10 from sandip2224/main
Week-5 Tkinter Program [Set-5] + SQL
2 parents a7db758 + f276be5 commit a02863d

File tree

1 file changed

+232
-0
lines changed

1 file changed

+232
-0
lines changed

Week-5/Set-5.py

Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
from tkinter import *
2+
import sqlite3
3+
root=Tk()
4+
root.title("CAR RENTAL RECEIPT")
5+
root.geometry('700x800')
6+
7+
#Databases
8+
conn=sqlite3.connect('address_book.db');
9+
c=conn.cursor()
10+
11+
#Create Table
12+
c.execute("""CREATE TABLE addresses (
13+
VIN integer,
14+
Make text,
15+
Year integer,
16+
Color text,
17+
Registration integer,
18+
Model text,
19+
Mileage integer
20+
)""")
21+
22+
#Create submit function for db
23+
def submit():
24+
conn=sqlite3.connect('address_book.db');
25+
c=conn.cursor()
26+
27+
#Insert into table
28+
c.execute("INSERT INTO addresses VALUES (:VIN, :Make, :Year, :Color,
29+
:Registration, :Model, :Mileage)",
30+
{
31+
'VIN':e5_1.get(),
32+
'Make':e5_2.get(),
33+
'Year':e5_3.get(),
34+
'Color':e5_4.get(),
35+
'Registration':e6_1.get(),
36+
'Model':e6_2.get(),
37+
'Mileage':e6_3.get()
38+
})
39+
e5_1.delete(0, END);
40+
e5_2.delete(0, END);
41+
e5_3.delete(0, END);
42+
e5_4.delete(0, END);
43+
e6_1.delete(0, END);
44+
e6_2.delete(0, END);
45+
e6_3.delete(0, END);
46+
conn.commit()
47+
conn.close()
48+
#Labels
49+
g1=Label(root, text="CAR RENTAL RECEIPT", font="Calibri 18 bold")
50+
l1=Label(root, text="Date: ")
51+
e1=Entry(root,width=30, borderwidth=2)
52+
l2=Label(root, text="Receipt #: ")
53+
e2=Entry(root,width=30, borderwidth=2)
54+
l3=Label(root, text="Rental Company Info", font="Calibri 12 bold")
55+
l3_1=Label(root, text="Company: ")
56+
e3_1=Entry(root,width=30, borderwidth=2)
57+
l3_2=Label(root, text="Representative: ")
58+
e3_2=Entry(root,width=30, borderwidth=2)
59+
l3_3=Label(root, text="Location: ")
60+
e3_3=Entry(root,width=30, borderwidth=2)
61+
l3_4=Label(root, text="City/State/ZIP: ")
62+
e3_4=Entry(root,width=30, borderwidth=2)
63+
l3_5=Label(root, text="Phone: ")
64+
e3_5=Entry(root,width=30, borderwidth=2)
65+
66+
l4=Label(root, text="Lessee Info", font="Calibri 12 bold")
67+
l4_1=Label(root, text="License: ")
68+
e4_1=Entry(root,width=30, borderwidth=2)
69+
l4_2=Label(root, text="Representative: ")
70+
e4_2=Entry(root,width=30, borderwidth=2)
71+
l4_3=Label(root, text="Address: ")
72+
e4_3=Entry(root,width=30, borderwidth=2)
73+
l4_4=Label(root, text="City/State/ZIP: ")
74+
e4_4=Entry(root,width=30, borderwidth=2)
75+
l4_5=Label(root, text="Phone: ")
76+
e4_5=Entry(root,width=30, borderwidth=2)
77+
g2=Label(root, text="Vehicle Information", font="Calibri 18 bold")
78+
l5_1=Label(root, text="VIN: ")
79+
e5_1=Entry(root,width=30, borderwidth=2)
80+
l5_2=Label(root, text="Make: ")
81+
e5_2=Entry(root,width=30, borderwidth=2)
82+
l5_3=Label(root, text="Year: ")
83+
e5_3=Entry(root,width=30, borderwidth=2)
84+
l5_4=Label(root, text="Color: ")
85+
e5_4=Entry(root,width=30, borderwidth=2)
86+
l6_1=Label(root, text="Registration: ")
87+
e6_1=Entry(root,width=30, borderwidth=2)
88+
l6_2=Label(root, text="Model: ")
89+
e6_2=Entry(root,width=30, borderwidth=2)
90+
l6_3=Label(root, text="Mileage: ")
91+
e6_3=Entry(root,width=30, borderwidth=2)
92+
h1=Label(root, text="VIN", font="Calibri 12 bold")
93+
h1_1=Entry(root,width=14, borderwidth=2)
94+
h1_2=Entry(root,width=14, borderwidth=2)
95+
h1_3=Entry(root,width=14, borderwidth=2)
96+
h2=Label(root, text="Cost/Day", font="Calibri 12 bold")
97+
h2_1=Entry(root,width=12, borderwidth=2)
98+
h2_2=Entry(root,width=12, borderwidth=2)
99+
h2_3=Entry(root,width=12, borderwidth=2)
100+
h3=Label(root, text="# of Days", font="Calibri 12 bold")
101+
102+
h3_1=Entry(root,width=19, borderwidth=2)
103+
h3_2=Entry(root,width=19, borderwidth=2)
104+
h3_3=Entry(root,width=19, borderwidth=2)
105+
h4=Label(root, text="Additional Costs", font="Calibri 12 bold")
106+
h4_1=Entry(root,width=18, borderwidth=2)
107+
h4_2=Entry(root,width=18, borderwidth=2)
108+
h4_3=Entry(root,width=18, borderwidth=2)
109+
h4l1=Label(root, text="Subtotal: ")
110+
h4l2=Label(root, text="Tax (%): ")
111+
h4l3=Label(root, text="Total: ")
112+
h4l4=Label(root, text="Amount paid: ")
113+
h4e1=Entry(root,width=8, borderwidth=2)
114+
h4e2=Entry(root,width=9, borderwidth=2)
115+
h4e3=Entry(root,width=10, borderwidth=2)
116+
h4e4=Entry(root,width=4, borderwidth=2)
117+
h5=Label(root, text="Line Total", font="Calibri 12 bold")
118+
h5_1=Entry(root,width=16, borderwidth=2)
119+
h5_2=Entry(root,width=16, borderwidth=2)
120+
h5_3=Entry(root,width=16, borderwidth=2)
121+
h5_4=Entry(root,width=16, borderwidth=2)
122+
h5_5=Entry(root,width=16, borderwidth=2)
123+
h5_6=Entry(root,width=16, borderwidth=2)
124+
h5_7=Entry(root,width=16, borderwidth=2)
125+
xl1=Label(root, text="Payment Method: ")
126+
ck1=Checkbutton(root, text='Cash. ', onvalue=1, offvalue=0)
127+
ck2=Checkbutton(root, text='Check No.: ', onvalue=1, offvalue=0)
128+
ent1=Entry(root,width=31, borderwidth=2)
129+
ck3=Checkbutton(root, text='Credit No.: ', onvalue=1, offvalue=0)
130+
ent3=Entry(root,width=41, borderwidth=2)
131+
ck4=Checkbutton(root, text='Other.: ', onvalue=1, offvalue=0)
132+
ent4=Entry(root,width=44, borderwidth=2)
133+
lasl1=Label(root, text="Authorized Signature: ", font="Calibri 10 bold")
134+
lasl2=Label(root, text="Representative Name: ", font="Calibri 10")
135+
lase1=Entry(root,width=22, borderwidth=2)
136+
lase2=Entry(root,width=20, borderwidth=2)
137+
#Create Submit Button
138+
submit_btn=Button(root, text="Add Record to Database", command=submit)
139+
140+
submit_btn.place(x=140, y=720)
141+
#Positioning
142+
l1.place(x=10, y=45)
143+
e1.place(x=50, y=45)
144+
l2.place(x=10, y=75)
145+
e2.place(x=73, y=75)
146+
l3.place(x=10, y=110)
147+
l3_1.place(x=10, y=150)
148+
l3_2.place(x=10, y=180)
149+
l3_3.place(x=10, y=210)
150+
l3_4.place(x=10, y=240)
151+
l3_5.place(x=10, y=270)
152+
e3_1.place(x=110, y=150)
153+
e3_2.place(x=110, y=180)
154+
e3_3.place(x=110, y=210)
155+
e3_4.place(x=110, y=240)
156+
e3_5.place(x=110, y=270)
157+
l4.place(x=320, y=110)
158+
l4_1.place(x=320, y=150)
159+
l4_2.place(x=320, y=180)
160+
l4_3.place(x=320, y=210)
161+
l4_4.place(x=320, y=240)
162+
l4_5.place(x=320, y=270)
163+
e4_1.place(x=420, y=150)
164+
e4_2.place(x=420, y=180)
165+
e4_3.place(x=420, y=210)
166+
e4_4.place(x=420, y=240)
167+
e4_5.place(x=420, y=270)
168+
g1.place(x=240, y=0)
169+
g2.place(x=240, y=300)
170+
l5_1.place(x=10, y=360)
171+
l5_2.place(x=10, y=390)
172+
l5_3.place(x=10, y=420)
173+
l5_4.place(x=10, y=450)
174+
e5_1.place(x=60, y=360)
175+
e5_2.place(x=60, y=390)
176+
e5_3.place(x=60, y=420)
177+
178+
e5_4.place(x=60, y=450)
179+
l6_1.place(x=320, y=360)
180+
l6_2.place(x=320, y=390)
181+
l6_3.place(x=320, y=420)
182+
e6_1.place(x=420, y=360)
183+
e6_2.place(x=420, y=390)
184+
e6_3.place(x=420, y=420)
185+
h1.place(x=70, y=490)
186+
h2.place(x=160, y=490)
187+
h3.place(x=290, y=490)
188+
h4.place(x=400, y=490)
189+
h5.place(x=560, y=490)
190+
h1_1.place(x=40, y=520)
191+
h1_2.place(x=40, y=545)
192+
h1_3.place(x=40, y=570)
193+
h2_1.place(x=150, y=520)
194+
h2_2.place(x=150, y=545)
195+
h2_3.place(x=150, y=570)
196+
h3_1.place(x=260, y=520)
197+
h3_2.place(x=260, y=545)
198+
h3_3.place(x=260, y=570)
199+
h4_1.place(x=400, y=520)
200+
h4_2.place(x=400, y=545)
201+
h4_3.place(x=400, y=570)
202+
h4l1.place(x=400, y=595)
203+
h4l2.place(x=400, y=620)
204+
h4l3.place(x=400, y=645)
205+
h4l4.place(x=400, y=670)
206+
h4e1.place(x=460, y=595)
207+
h4e2.place(x=454, y=620)
208+
h4e3.place(x=447, y=645)
209+
h4e4.place(x=483, y=670)
210+
h5_1.place(x=540, y=520)
211+
h5_2.place(x=540, y=545)
212+
h5_3.place(x=540, y=570)
213+
h5_4.place(x=540, y=595)
214+
h5_5.place(x=540, y=620)
215+
h5_6.place(x=540, y=645)
216+
217+
h5_7.place(x=540, y=670)
218+
xl1.place(x=40, y=595)
219+
ck1.place(x=40, y=620)
220+
ck2.place(x=100, y=620)
221+
ck3.place(x=40, y=645)
222+
ck4.place(x=40, y=670)
223+
ent1.place(x=188, y=623)
224+
ent3.place(x=128, y=649)
225+
ent4.place(x=110, y=675)
226+
lasl1.place(x=380, y=710)
227+
lasl2.place(x=390, y=735)
228+
lase1.place(x=505, y=710)
229+
lase2.place(x=518, y=735)
230+
conn.commit()
231+
conn.close()
232+
root.mainloop()

0 commit comments

Comments
 (0)