Skip to content

Commit f9658b0

Browse files
authored
added set 4
1 parent 969ec18 commit f9658b0

File tree

1 file changed

+191
-0
lines changed

1 file changed

+191
-0
lines changed

Week-5/Set4-hotelwithdatabase.py

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
from tkinter import *
2+
import sqlite3
3+
import tkinter as tk
4+
from tkinter import messagebox
5+
6+
7+
window = Tk()
8+
window.title("Hotel Room Booking Form")
9+
window.geometry('1500x800')
10+
window.configure(background = "white");
11+
12+
13+
a1=StringVar()
14+
b1=StringVar()
15+
c1=StringVar()
16+
d1=StringVar()
17+
e1=IntVar()
18+
f1=IntVar()
19+
g1=StringVar()
20+
h1=StringVar()
21+
i1=StringVar()
22+
j1=StringVar()
23+
k1=IntVar()
24+
l1=StringVar()
25+
m1=IntVar()
26+
p101=StringVar()
27+
p102=StringVar()
28+
p103=StringVar()
29+
30+
def database():
31+
title=a1.get()
32+
fname=b1.get()
33+
lname=c1.get()
34+
share=d1.get()
35+
busno=e1.get()
36+
mobno=f1.get()
37+
email=g1.get()
38+
doa=h1.get()
39+
dod=i1.get()
40+
nmcred=j1.get()
41+
credno=k1.get()
42+
expd=l1.get()
43+
cvv=m1.get()
44+
sign=p101.get()
45+
date=p102.get()
46+
pname=p103.get()
47+
48+
db = sqlite3.connect('hotel.db')
49+
cursor=db.cursor()
50+
cursor.execute('CREATE TABLE IF NOT EXISTS HOTEL(a1 TEXT,b1 TEXT,c1 TEXT,d1 TEXT,e1 INT,f1 INT,g1 TEXT,h1 TEXT,i1 TEXT,j1 TEXT,k1 INT,l1 TEXT,m1 INT,p101 TEXT,p102 TEXT,p103 TEXT)')
51+
cursor.execute('INSERT INTO HOTEL(a1,b1,c1,d1,e1,f1,g1,h1,i1,j1,k1,l1,m1,p101,p102,p103) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
52+
(title,fname,lname,share,busno,mobno,email,doa,dod,nmcred,credno,expd,cvv,sign,date,pname))
53+
db.commit()
54+
msg = messagebox.showinfo( "DB Demo","SUBMITTED SUCCESSFULLY")
55+
56+
57+
def display():
58+
db=sqlite3.connect('hotel.db')
59+
60+
with db:
61+
cursor=db.cursor()
62+
my_w = tk.Tk()
63+
my_w.geometry("600x250")
64+
65+
r_set=cursor.execute('''SELECT * from HOTEL ''');
66+
i=0
67+
for HOTEL in r_set:
68+
for j in range(len(HOTEL)):
69+
e = Entry(my_w, width=10, fg='blue')
70+
e.grid(row=i, column=j)
71+
e.insert(END, HOTEL[j])
72+
i=i+1
73+
a = Label(window ,text = "Title ").grid(row = 0,column = 0,sticky = "NSEW")
74+
b = Label(window ,text = "First Name ").grid(row = 1,column = 0,sticky = "NSEW")
75+
c = Label(window ,text = "Last Name ").grid(row = 2,column = 0,sticky = "NSEW")
76+
d = Label(window ,text = "Share With ").grid(row = 3,column = 0,sticky = "NSEW")
77+
e = Label(window ,text = "Buisness Number ").grid(row = 4,column = 0,sticky = "NSEW")
78+
f = Label(window ,text = "Mobile Number").grid(row = 5,column = 0,sticky = "NSEW")
79+
g = Label(window ,text = "Email Address ").grid(row = 6,column = 0,sticky = "NSEW")
80+
h = Label(window ,text = "Date of Arrival ").grid(row = 7,column = 0,sticky = "NSEW")
81+
i = Label(window ,text = "Date of Departure ").grid(row = 8,column = 0,sticky = "NSEW")
82+
j = Label(window ,text = "Name on Credit Card ").grid(row = 9,column = 0,sticky = "NSEW")
83+
k = Label(window ,text = "Credit Card Number ").grid(row = 10,column = 0,sticky = "NSEW")
84+
l = Label(window ,text = "Expiry Date ").grid(row = 11,column = 0,sticky = "NSEW")
85+
m = Label(window ,text = "CVV Number ").grid(row = 12,column = 0,sticky = "NSEW")
86+
n = Label(window ,text = "Payment Method ").grid(row = 13,column = 0,sticky = "NSEW")
87+
CheckVar1 = IntVar()
88+
CheckVar2 = IntVar()
89+
C1 = Checkbutton(window, text = "Credit Card ", variable = CheckVar1, \
90+
onvalue = 1, offvalue = 0, height=1, \
91+
width = 20)
92+
C1.grid(row = 13, column = 1 , sticky = "NSEW")
93+
C2 = Checkbutton(window, text = "Debit Bank Transfer ", variable = CheckVar2, \
94+
onvalue = 1, offvalue = 0, height=1, \
95+
width = 20)
96+
C2.grid(row = 13, column = 2 , sticky = "NSEW")
97+
p = Label(window ,text = "Negotiated Rates : ").grid(row = 14,column = 0 , sticky = "NSEW")
98+
g = Label(window ,text = "Deluxe Room Single ").grid(row = 15,column = 0 , sticky = "NSEW")
99+
g1 = Label(window ,text = " R1700 ").grid(row = 15,column = 1 , sticky = "NSEW")
100+
h = Label(window ,text = "Deluxe Room Double ").grid(row = 15,column = 2 , sticky = "NSEW")
101+
h1 = Label(window ,text = " R1700 ").grid(row = 15,column = 3 , sticky = "NSEW")
102+
g = Label(window ,text = "Suites Room Single ").grid(row = 16,column = 0 , sticky = "NSEW")
103+
g1 = Label(window ,text = " R1700 ").grid(row = 16,column = 1 , sticky = "NSEW")
104+
h = Label(window ,text = "Suites Room Double ").grid(row = 16,column = 2,sticky = "NSEW")
105+
h1 = Label(window ,text = " R1700 ").grid(row = 16,column = 3 ,sticky = "NSEW")
106+
p1 = Label(window ,text = "Room Preference : ").grid(row = 17,column = 0,sticky = "NSEW")
107+
CheckVar11 = IntVar()
108+
CheckVar22 = IntVar()
109+
C3 = Checkbutton(window, text = "King Bed ", variable = CheckVar11, \
110+
onvalue = 1, offvalue = 0, height=1, \
111+
width = 20)
112+
C3.grid(row = 18, column = 0)
113+
C4 = Checkbutton(window, text = "Twin - Two Single Beds ", variable = CheckVar22, \
114+
onvalue = 1, offvalue = 0, height=1, \
115+
width = 20)
116+
C4.grid(row = 18, column = 1)
117+
118+
line1 = Label(window, text="The above rates are quoted per room, per night. The rates include breakfast, 14% vat, and Excludes 1% Tourism Levy\n and a voluntary R10 donation to the Arabella Community Trust that will be levies onto your account.", bg="white")
119+
line2 = Label(window, text="Total amount payable ZAR__ x_ nights = ZAR__ due to Arabella\n Hotel and Spa", bg="white")
120+
line3 = Label(window, text="Credit Card will be charged on receipt of this form and details will also be used to settle all incidentals not settle on\n departure. A copy of the final folio will be sent to you should there be any unsettled charges.", bg="white")
121+
line4 = Label(window, text="In order to qualify for the above rates, your booking needs to be made on or before 15th January 2016", bg="white")
122+
line5 = Label(window, text="Terms and conditions can be found on the next page.", bg="white")
123+
line6 = Label(window, text="The rate is valid for seven days before and after the conference dates. Check in time is 14:00 & check out time is 11:00", bg="white")
124+
line7 = Label(window, text="By your signature hereto, you are accepting all terms and conditions specified on this form and confirm that all information\n given is current and accurate.", bg="white")
125+
126+
line1.grid(row=20, column=0,columnspan=4)
127+
line2.grid(row=21, column=0,columnspan=4)
128+
line3.grid(row=22, column=0,columnspan=4)
129+
line4.grid(row=23, column=0,columnspan=4)
130+
line5.grid(row=24, column=0,columnspan=4)
131+
line6.grid(row=25, column=0,columnspan=4)
132+
line7.grid(row=26, column=0,columnspan=4)
133+
134+
p1 = Label(window ,text = "Signature : ").grid(row = 27,column = 0,sticky = "NSEW")
135+
p1 = Label(window ,text = "Print Name: ").grid(row = 27,column = 2,sticky = "NSEW")
136+
p1 = Label(window ,text = "Date : ").grid(row = 28,column = 0,sticky = "NSEW")
137+
138+
a1 = Entry(window)
139+
a1.grid(row = 0,column = 1)
140+
b1 = Entry(window)
141+
b1.grid(row = 1,column = 1)
142+
c1 = Entry(window)
143+
c1.grid(row = 2,column = 1)
144+
d1 = Entry(window)
145+
d1.grid(row = 3,column = 1)
146+
e1 = Entry(window)
147+
e1.grid(row = 4,column = 1)
148+
f1 = Entry(window)
149+
f1.grid(row = 5,column = 1)
150+
g1 = Entry(window)
151+
g1.grid(row = 6,column = 1)
152+
h1 = Entry(window)
153+
h1.grid(row = 7,column = 1)
154+
i1 = Entry(window)
155+
i1.grid(row = 8,column = 1)
156+
j1 = Entry(window)
157+
j1.grid(row = 9,column = 1)
158+
k1 = Entry(window)
159+
k1.grid(row = 10,column = 1)
160+
l1 = Entry(window)
161+
l1.grid(row = 11,column = 1)
162+
m1 = Entry(window)
163+
m1.grid(row = 12,column = 1)
164+
p101 = Entry(window)
165+
p101.grid(row = 27,column = 1,sticky = "NSEW")
166+
p102 = Entry(window)
167+
p102.grid(row = 27,column = 3,sticky = "NSEW")
168+
p103 = Entry(window)
169+
p103.grid(row = 28,column = 1,sticky = "NSEW")
170+
171+
btn = Button(window ,text="SUBMIT",command = database,width=20).grid(row=30,column=2)
172+
btn = Button(window,text="DISPLAY RECORD(s)",command=display,width=20).grid(row=30,column=3)
173+
window.mainloop()
174+
175+
import sqlite3
176+
my_conn = sqlite3.connect('hotel.db')
177+
178+
import tkinter as tk
179+
from tkinter import *
180+
my_w = tk.Tk()
181+
my_w.geometry("1300x250")
182+
183+
r_set=my_conn.execute('''SELECT * from HOTEL ''');
184+
i=0 # row value inside the loop
185+
for HOTEL in r_set:
186+
for j in range(len(HOTEL)):
187+
e = Entry(my_w, width=10, fg='blue')
188+
e.grid(row=i, column=j)
189+
e.insert(END, HOTEL[j])
190+
i=i+1
191+
my_w.mainloop()

0 commit comments

Comments
 (0)