· 6 years ago · Apr 28, 2019, 06:44 PM
1from tkinter import *
2import sqlite3
3
4root = Tk()
5root.title("Ð¼Ð¾Ñ Ð±Ð°Ð·Ð°")
6root.geometry("1000x700")
7
8
9
10
11def rdm(self):
12
13
14
15 def rdm1(self):
16 mesto =textbox55.get()
17 cena="0"
18 prov = (listbox4.get(listbox4.curselection()))
19 for i in list4:
20 if prov == "ВзроÑлый" and mesto <="36" and mesto >"0" and mesto<="54":
21 cena = "цена 5000 руб"
22 if prov == "ДетÑкий"and mesto <="36" and mesto >"0"and mesto<="54":
23 cena = "цена 3000 руб"
24 if prov == "Льготный"and mesto <="36" and mesto >"0"and mesto<="54":
25 cena = "цена 2500 руб"
26 if prov == "ВзроÑлый" and mesto >="37" and mesto >"0"and mesto<="54":
27 cena = "цена 4000 руб"
28 if prov == "ДетÑкий"and mesto <="37" and mesto >"0"and mesto<="54":
29 cena = "цена 2000 руб"
30 if prov == "Льготный"and mesto <="37" and mesto >"0"and mesto<="54":
31 cena = "цена 1500 руб"
32 else:
33 root3 = Tk()
34 root3.title("Ð¼Ð¾Ñ Ð±Ð°Ð·Ð°")
35 root3.geometry("200x100")
36 lbl1 = Label(root3, text="Error")
37 lbl1.pack()
38 lbl1.configure(font="Arial, 10", fg="black")
39
40 conn = sqlite3.connect('bilet1.db')
41 cursor = conn.cursor()
42 ap = '''insert into bilet2 values(?,?,?,?,?,?,?,?,?,?,?,?)'''
43 cursor.execute(
44 'CREATE TABLE IF NOT EXISTS bilet2(log TEXT, name1 TEXT,name2 TEXT,name3 TEXT,name4 TEXT,name5 TEXT,name6 TEXT,name7 TEXT,name8 TEXT,name9 TEXT,name10 TEXT,name11 TEXT )')
45
46 cursor.execute('''SELECT * FROM bilet2 WHERE log = ?;''', (mesto,))
47 results = cursor.fetchall()
48 if results == []:
49 v1 = []
50 all2 = [mesto, textbox1.get(), textbox22.get(), textbox33.get(), textbox4.get(), textbox5.get(),
51 textbox6.get(), listbox1.get(listbox1.curselection()), listbox2.get(listbox2.curselection()),
52 listbox3.get(listbox3.curselection()), (listbox4.get(listbox4.curselection())), cena]
53 v1.append(all2)
54 for v1_unit in v1:
55 cursor.execute('INSERT INTO bilet2 values(?,?,?,?,?,?,?,?,?,?,?,?)', v1_unit)
56
57 else:
58 root3 = Tk()
59 root3.title("Ð¼Ð¾Ñ Ð±Ð°Ð·Ð°")
60 root3.geometry("200x100")
61 lbl1 = Label(root3, text="МеÑто занÑто!")
62 lbl1.pack()
63 lbl1.configure(font="Arial, 10", fg="black")
64
65
66 conn.commit()
67 conn.close()
68
69 window = Tk()
70 window.title("Ð¼Ð¾Ñ Ð±Ð°Ð·Ð°")
71 window.geometry("1000x700")
72 window.title("Ð¼Ð¾Ñ Ð±Ð°Ð·Ð°")
73 window.geometry("1000x700")
74 lbl2 = Label(window, text="ФамилиÑ")
75 lbl2.grid(column=0, row=0)
76 lbl2.place(relx=0.05, rely=0.2)
77 lbl2.configure(font="Arial, 10", fg="black")
78 textbox1 = Entry(window, width=30)
79 textbox1.focus_set()
80 textbox1.place(relx=0.15, rely=0.2)
81 lbl3 = Label(window, text="имÑ")
82 lbl3.grid(column=0, row=0)
83 lbl3.place(relx=0.05, rely=0.3)
84 lbl3.configure(font="Arial, 10", fg="black")
85 textbox22 = Entry(window, width=30)
86 textbox22.focus_set()
87 textbox22.place(relx=0.15, rely=0.3)
88 lbl4 = Label(window, text="отчеÑтво")
89 lbl4.grid(column=0, row=0)
90 lbl4.place(relx=0.05, rely=0.4)
91 lbl4.configure(font="Arial, 10", fg="black")
92 textbox33 = Entry(window, width=30)
93 textbox33.focus_set()
94 textbox33.place(relx=0.15, rely=0.4)
95 lbl4 = Label(window, text="год рождениÑ")
96 lbl4.grid(column=0, row=0)
97 lbl4.place(relx=0.05, rely=0.5)
98 lbl4.configure(font="Arial, 10", fg="black")
99 textbox4 = Entry(window, width=30)
100 textbox4.focus_set()
101 textbox4.place(relx=0.15, rely=0.5)
102 lbl4 = Label(window, text="номер и ÑÐµÑ€Ð¸Ñ Ð¿Ð°Ñпорта")
103 lbl4.grid(column=0, row=0)
104 lbl4.place(relx=0.05, rely=0.6)
105 lbl4.configure(font="Arial, 10", fg="black")
106 textbox5 = Entry(window, width=10)
107 textbox5.focus_set()
108 textbox5.place(relx=0.2, rely=0.6)
109 textbox6 = Entry(window, width=10)
110 textbox6.focus_set()
111 textbox6.place(relx=0.24, rely=0.6)
112
113 butp1 = Button(window, text="Ok")
114 butp1.place(relx=0.2, rely=0.70)
115 butp1.bind("<Button-1>", rdm1)
116 lbl3 = Label(window, text="Откуда:")
117 lbl3.grid(column=0, row=0)
118 lbl3.place(relx=0.50, rely=0.35)
119 lbl3.configure(font="Arial,16", bg="#00BD58", fg="white")
120 listbox1 = Listbox(window, height=5, width=15, exportselection=0)
121 listbox1.grid(column=0, row=0)
122 listbox1.place(relx=0.50, rely=0.40)
123 list1 = [u"МоÑква", u"Саратов", u"Сочи", u"Клин"]
124 for i in list1:
125 listbox1.insert(END, i)
126 lbl4 = Label(window, text="Куда:")
127 lbl4.grid(column=0, row=0)
128 lbl4.place(relx=0.60, rely=0.35)
129 lbl4.configure(font="Arial,16", bg="#00BD58", fg="white")
130 listbox2 = Listbox(window, height=5, width=15, exportselection=0)
131 listbox2.grid(column=0, row=0)
132 listbox2.place(relx=0.60, rely=0.40)
133 list2 = [u"Санкт-Петербург ", u"ВолоколамÑк", u"Барнаул", u"Владикавказ"]
134 for i in list2:
135 listbox2.insert(END, i)
136 lbl5 = Label(window, text="Когда:")
137 lbl5.grid(column=0, row=0)
138 lbl5.place(relx=0.70, rely=0.35)
139 lbl5.configure(font="Arial,16", bg="#00BD58", fg="white")
140 listbox3 = Listbox(window, height=5, width=15, exportselection=0)
141 listbox3.grid(column=0, row=0)
142 listbox3.place(relx=0.70, rely=0.40)
143 list3 = [u"15.05.19", u"25.05.19", u"05.06.19", u"15.06.19"]
144 for i in list3:
145 listbox3.insert(END, i)
146 listbox4 = Listbox(window, height=5, width=15, exportselection=0)
147 listbox4.grid(column=0, row=0)
148 listbox4.place(relx=0.50, rely=0.20)
149 list4 = [u"ДетÑкий", u"ВзроÑлый", u"Льготный"]
150 for i in list4:
151 listbox4.insert(END, i)
152 lbl31 = Label(window, text="Льготы:")
153 lbl31.grid(column=0, row=0)
154 lbl31.place(relx=0.50, rely=0.1)
155 lbl31.configure(font="Arial,16", bg="#00BD58", fg="white")
156 lbl4 = Label(window, text="Ðомер меÑта")
157 lbl4.grid(column=0, row=0)
158 lbl4.place(relx=0.05, rely=0.65)
159 lbl4.configure(font="Arial, 10", fg="black")
160 textbox55 = Entry(window, width=2)
161 textbox55.focus_set()
162 textbox55.place(relx=0.2, rely=0.65)
163 lbl44 = Label(window, text="Ð’Ñего меÑÑ‚ 54 Ñ 37 идут боковые")
164 lbl44.grid(column=0, row=0)
165 lbl44.place(relx=0.3, rely=0.65)
166 lbl44.configure(font="Arial, 10", fg="black")
167
168
169def append3(event):
170 root3 = Tk()
171 root3.title("Ð¼Ð¾Ñ Ð±Ð°Ð·Ð°")
172 root3.geometry("1000x700")
173 conn = sqlite3.connect('bilet1.db')
174 cursor = conn.cursor()
175 cursor.execute(
176 'CREATE TABLE IF NOT EXISTS bilet2(log TEXT, name1 TEXT,name2 TEXT,name3 TEXT,name4 TEXT,name5 TEXT,name6 TEXT,name7 TEXT,name8 TEXT,name9 TEXT,name10 TEXT,name11 TEXT)')
177 cursor.execute('''SELECT * FROM bilet2 ''')
178 results = cursor.fetchall()
179 for results_unit in results:
180 lbl1 = Label(root3, text="")
181 lbl1.pack()
182 lbl1['text'] = results_unit
183def admin():
184 name3 = 'SASHA'
185 name4 = '123'
186 if textbox2.get() == name3 and textbox3.get() == name4:
187 root3 = Tk()
188 root3.title("Ð¼Ð¾Ñ Ð±Ð°Ð·Ð°")
189 root3.geometry("1000x700")
190 conn = sqlite3.connect('bilet1.db')
191 cursor = conn.cursor()
192 name = textbox2.get()
193 cursor.execute('''SELECT * FROM bilet2 ''')
194 results = cursor.fetchall()
195 for results_unit in results:
196 lbl1 = Label(root3, text="")
197 lbl1.pack()
198 lbl1['text'] = results_unit
199 else:
200 root4 = Tk()
201 root4.title("Ð¼Ð¾Ñ Ð±Ð°Ð·Ð°")
202 root4.geometry("200x200")
203 lbl2 = Label(root4, text="Ð’Ñ‹ не админиÑтратор!")
204 lbl2.pack()
205 lbl2.configure(font="Arial, 10", fg="black")
206 root4.mainloop()
207
208def baza():
209 conn = sqlite3.connect('bilet1.db')
210 cursor = conn.cursor()
211 admin =[]
212 name1='sasha'
213 admin.append(name1)
214 ap = '''insert into Artist2 values(?,?)'''
215 mp = '''delete from Artist2 wheare name= ?'''
216 name1 = textbox2.get()
217 name2 = textbox3.get()
218 cursor.execute('''SELECT * FROM Artist3 WHERE log = ?;''',(name1,))
219 results = cursor.fetchall()
220 if results == []:
221 root3 = Tk()
222 root3.title("Ð¼Ð¾Ñ Ð±Ð°Ð·Ð°")
223 root3.geometry("200x100")
224 lbl1 = Label(root3, text="Вам нужно зарегиÑтрировтÑÑ!")
225 lbl1.pack()
226 lbl1.configure(font="Arial, 10", fg="black")
227 root3.mainloop()
228 if results == ('sasha', '123') :
229 root3 = Tk()
230 root3.title("Ð¼Ð¾Ñ Ð±Ð°Ð·Ð°")
231 root3.geometry("200x100")
232 lbl1 = Label(root3, text="Admin")
233 lbl1.pack()
234 if results != [] and results != admin:
235 root2 = Tk()
236 root2.title("Ð¼Ð¾Ñ Ð±Ð°Ð·Ð°")
237 root2.geometry("1000x700")
238 lbl1 = Label(root2, text="ОКÐО ПОЛЬЗОВÐТЕЛЯ")
239 lbl1.pack()
240 lbl1.configure(font="Arial, 20", fg="black")
241 butp1 = Button(root2, text="Купить билет!")
242 butp1.place(relx=0.2, rely=0.62)
243 butp1.bind("<Button-1>", rdm)
244 butp1 = Button(root2, text="ИÑÑ‚Ð¾Ñ€Ð¸Ñ Ð¿Ð¾ÐµÐ·Ð´Ð¾Ðº")
245 butp1.place(relx=0.2, rely=0.70)
246 butp1.bind("<Button-1>", append3)
247 root2.mainloop()
248 conn.commit()
249 conn.close()
250
251def reg():
252 conn = sqlite3.connect('bilet1.db')
253 cursor = conn.cursor()
254 cursor.execute('CREATE TABLE IF NOT EXISTS Artist3(log TEXT,'
255 'par TEXT)')
256 name_all = []
257 name1 = [textbox2.get(),textbox3.get()]
258 name_all.append(name1)
259 for name_unit in name_all:
260 cursor.execute('INSERT INTO Artist3 VALUES(?,?)', name_unit)
261 conn.commit()
262 conn.close()
263
264
265
266
267
268butappend = Button(root, text="войти", command=baza)
269butappend.grid(column=5, row=5)
270butappend.place(relx=0.4, rely=0.55)
271butappend = Button(root, text="зарегеÑтрироватÑÑ", command=reg)
272butappend.grid(column=5, row=5)
273butappend.place(relx=0.4, rely=0.6)
274butappend = Button(root, text="ÐдминиÑтратор", command=admin)
275butappend.grid(column=5, row=5)
276butappend.place(relx=0.4, rely=0.65)
277textbox2 = Entry(root, width=30)
278textbox2.focus_set()
279textbox2.place(relx=0.35, rely=0.45)
280textbox3 = Entry(root, width=30)
281textbox3.place(relx=0.35, rely=0.50)
282lbl1 = Label(root, text="покупка билетов")
283lbl1.grid(column=0, row=0)
284lbl1.place(relx=0.3, rely=0.3)
285lbl1.configure(font="Arial, 25", fg="blue")
286
287root.mainloop()