Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import*
- import sqlite3,pickle
- conn = sqlite3.connect('Base1.db')
- cursor = conn.cursor()
- sql ='create table if not exists Base1 (fio TEXT, passport TEXT, place TEXT, data TEXT, lg TEXT)'
- cursor.execute(sql)
- count = cursor.execute("SELECT COUNT(*) FROM Base1").fetchone()[0]
- print(count)
- cursor.execute("SELECT * FROM Base1")
- print(cursor.fetchall())
- def fbuy():
- def adultb():
- def buynext():
- fio = textbox1.get()
- passport = textbox2.get()
- place = textbox3.get()
- data = textbox4.get()
- lg = '---'
- cursor.execute("SELECT * FROM Base1")
- result=cursor.fetchall()
- if result == []:
- sql = '''insert into Base1 values(?,?,?,?,?)'''
- cursor.execute(sql, (fio,passport,place,data,lg))
- count = cursor.execute("SELECT COUNT(*) FROM Base1").fetchone()[0]
- print(count)
- elif result != []:
- cursor.execute('''SELECT * FROM Base1 WHERE place = ?;''',(place,))
- result=cursor.fetchall()
- print(result)
- if result!=[]:
- error = Tk()
- error.title("Ошибка")
- error.geometry("500x200")
- lbl = Label(error, text = "Место уже занято, оформите билет заново")
- lbl.grid(row = 0, column = 4)
- print("Место уже занято")
- def back():
- error.destroy()
- butback = Button(error, text = "Назад", command = back)
- butback.grid(row = 2, column = 0, pady=10, sticky = W + E)
- else:
- sql = '''insert into Base1 values(?,?,?,?,?)'''
- cursor.execute(sql, (fio,passport,place,data,lg))
- conn.commit()
- frame2.grid_remove()
- frame3.grid_remove()
- lbl2 = Label(frame1, text = "Введите информацию:")
- lbl2.grid(row = 0, column = 1)
- lbl2 = Label(frame1, text = "Фио")
- lbl2.grid(row = 1, column = 0)
- lbl2 = Label(frame1, text = "Серия и номер паспорта")
- lbl2.grid(row = 2, column = 0)
- lbl2 = Label(frame1, text = "Место")
- lbl2.grid(row = 3, column = 0)
- lbl2 = Label(frame1, text = "Дата рождения")
- lbl2.grid(row = 4, column = 0)
- textbox1 = Entry(frame1, width = 50)
- textbox1.focus_set()
- textbox1.grid(row = 1, column = 1)
- textbox2 = Entry(frame1, width = 50)
- textbox2.grid(row = 2, column = 1)
- textbox3 = Entry(frame1, width = 50)
- textbox3.grid(row = 3, column = 1)
- textbox4 = Entry(frame1, width = 50)
- textbox4.grid(row = 4, column = 1)
- frame1.grid(row = 2, column = 1, columnspan = 3)
- butbuynext = Button(frame1, text = "Ввести данные", command = buynext)
- butbuynext.grid(row = 5, column = 1, pady=10, sticky = W + E)
- def lgb():
- def buynext():
- fio = textbox1.get()
- passport = textbox2.get()
- place = textbox3.get()
- data = textbox4.get()
- lg = textbox5.get()
- cursor.execute("SELECT * FROM Base1")
- result=cursor.fetchall()
- if result == []:
- sql = '''insert into Base1 values(?,?,?,?,?)'''
- cursor.execute(sql, (fio,passport,place,data,lg))
- count = cursor.execute("SELECT COUNT(*) FROM Base1").fetchone()[0]
- print(count)
- elif result != []:
- cursor.execute('''SELECT * FROM Base1 WHERE place = ?;''',(place,))
- result=cursor.fetchall()
- print(result)
- if result!=[]:
- error = Tk()
- error.title("Ошибка")
- error.geometry("500x200")
- lbl = Label(error, text = "Место уже занято, оформите билет заново")
- lbl.grid(row = 0, column = 4)
- print("Место уже занято")
- def back():
- error.destroy()
- butback = Button(error, text = "Назад", command = back)
- butback.grid(row = 2, column = 0, pady=10, sticky = W + E)
- else:
- sql = '''insert into Base1 values(?,?,?,?,?)'''
- cursor.execute(sql, (fio,passport,place,data,lg))
- conn.commit()
- frame1.grid_remove()
- frame3.grid_remove()
- lbl2 = Label(frame2, text = "Введите информацию:")
- lbl2.grid(row = 0, column = 1, )
- lbl2 = Label(frame2, text = "Фио")
- lbl2.grid(row = 1, column = 0)
- lbl2 = Label(frame2, text = "Серия и номер паспорта")
- lbl2.grid(row = 2, column = 0)
- lbl2 = Label(frame2, text = "Место")
- lbl2.grid(row = 3, column = 0)
- lbl2 = Label(frame2, text = "Дата рождения")
- lbl2.grid(row = 4, column = 0)
- lbl2 = Label(frame2, text = "Номер льготной карты")
- lbl2.grid(row = 5, column = 0)
- textbox1 = Entry(frame2,width = 50)
- textbox1.focus_set()
- textbox1.grid(row = 1, column = 1)
- textbox2 = Entry(frame2,width = 50)
- textbox2.grid(row = 2, column = 1)
- textbox3 = Entry(frame2,width = 50)
- textbox3.grid(row = 3, column = 1)
- textbox4 = Entry(frame2,width = 50)
- textbox4.grid(row = 4, column = 1)
- textbox5 = Entry(frame2,width = 50)
- textbox5.grid(row = 5, column = 1)
- frame2.grid(row = 2, column = 1, columnspan = 3)
- butbuynext = Button(frame2, text = "Ввести данные", command = buynext)
- butbuynext.grid(row = 6, column = 1, pady=10, sticky = W + E)
- def childb():
- def buynext():
- fio = textbox1.get()
- passport = textbox2.get()
- place = textbox3.get()
- data = textbox4.get()
- lg = '---'
- cursor.execute("SELECT * FROM Base1")
- result=cursor.fetchall()
- if result == []:
- sql = '''insert into Base1 values(?,?,?,?,?)'''
- cursor.execute(sql, (fio,passport,place,data,lg))
- count = cursor.execute("SELECT COUNT(*) FROM Base1").fetchone()[0]
- print(count)
- elif result != []:
- cursor.execute('''SELECT * FROM Base1 WHERE place = ?;''',(place,))
- result=cursor.fetchall()
- print(result)
- if result!=[]:
- error = Tk()
- error.title("Ошибка")
- error.geometry("500x200")
- lbl = Label(error, text = "Место уже занято, оформите билет заново")
- lbl.grid(row = 0, column = 4)
- print("Место уже занято")
- def back():
- error.destroy()
- butback = Button(error, text = "Назад", command = back)
- butback.grid(row = 2, column = 0, pady=10, sticky = W + E)
- cursor.execute('''SELECT * FROM Base1 WHERE passport = ?;''',(passport,))
- result=cursor.fetchall()
- print(result)
- if result == []:
- error = Tk()
- error.title("Ошибка")
- error.geometry("500x200")
- lbl = Label(error, text = "Родитель не найден, оформите билет заново")
- lbl.grid(row = 0, column = 4)
- print("Место уже занято")
- def back():
- error.destroy()
- butback = Button(error, text = "Назад", command = back)
- butback.grid(row = 2, column = 0, pady=10, sticky = W + E)
- else:
- sql = '''insert into Base1 values(?,?,?,?,?)'''
- cursor.execute(sql, (fio,passport,place,data,lg))
- conn.commit()
- frame1.grid_remove()
- frame2.grid_remove()
- lbl2 = Label(frame3, text = "Введите информацию:")
- lbl2.grid(row = 0, column = 1)
- lbl2 = Label(frame3, text = "Фио")
- lbl2.grid(row = 1, column = 0)
- lbl2 = Label(frame3, text = "Серия и номер паспорта родителя")
- lbl2.grid(row = 2, column = 0)
- lbl2 = Label(frame3, text = "Место")
- lbl2.grid(row = 3, column = 0)
- lbl2 = Label(frame3, text = "Дата рождения")
- lbl2.grid(row = 4, column = 0)
- textbox1 = Entry(frame3,width = 50)
- textbox1.focus_set()
- textbox1.grid(row = 1, column = 1)
- textbox2 = Entry(frame3,width = 50)
- textbox2.grid(row = 2, column = 1)
- textbox3 = Entry(frame3,width = 50)
- textbox3.grid(row = 3, column = 1)
- textbox4 = Entry(frame3,width = 50)
- textbox4.grid(row = 4, column = 1)
- frame3.grid(row = 2, column = 1, columnspan = 3)
- butbuynext = Button(frame3, text = "Ввести данные", command = buynext)
- butbuynext.grid(row = 5, column = 1, pady=10, sticky = W + E)
- buy = Tk()
- buy.title("Меню")
- buy.geometry("800x500")
- frame1=Frame(buy,bg='green',bd=5)
- frame2=Frame(buy,bg='red',bd=5)
- frame3=Frame(buy,bg='blue',bd=5)
- check = IntVar()
- rbtn1 = Radiobutton(buy, text = "Полный", value = 1, variable = check, command = adultb)
- rbtn2 = Radiobutton(buy, text = "Льготный", value = 2, variable = check, command = lgb)
- rbtn3 = Radiobutton(buy, text = "Детский", value = 3, variable = check, command = childb)
- lbl2 = Label(buy, text = "Выберите тип билета:")
- lbl2.grid(row = 0, column = 0, padx=30, pady=20)
- rbtn1.grid(row = 0, column = 1, padx=10, pady=20)
- rbtn2.grid(row = 0, column = 2, padx=10, pady=20)
- rbtn3.grid(row = 0, column = 3, padx=10, pady=20)
- def printt():
- pr = Tk()
- pr.title("Печать билетов")
- pr.geometry("500x500")
- lbl=Label(pr, text = "Для возможности печати билетов нужно иметь права администратора!")
- lbl1=Label(pr, text = "Введите логин и пароль.")
- lbl.grid(row = 0, column = 0,columnspan=2)
- lbl1.grid(row = 1, column = 0)
- lbl2 = Label(pr, text = "login")
- lbl2.grid(row = 2, column = 0, sticky = W)
- lbl2 = Label(pr, text = "password")
- lbl2.grid(row = 3, column = 0, sticky = W)
- textbox1 = Entry(pr,width = 50)
- textbox1.focus_set()
- textbox1.grid(row = 2, column = 1)
- textbox2 = Entry(pr,width = 50)
- textbox2.grid(row = 3, column = 1)
- def admin():
- login = 'admin'
- password = '1111'
- login1=textbox1.get()
- password1=textbox2.get()
- if login1==login and password1==password:
- print("\nБаза данных:")
- cursor.execute("SELECT * FROM Base1")
- result=cursor.fetchall()
- print(result)
- else:
- error = Tk()
- error.title("Ошибка")
- error.geometry("500x200")
- lbl = Label(error, text = "Неверный пароль или логин, попробуйте снова")
- lbl.grid(row = 0, column = 4)
- def back():
- error.destroy()
- butback = Button(error, text = "Назад", command = back)
- butback.grid(row = 2, column = 0, pady=10, sticky = W + E)
- butadmin = Button(pr, text = "ОК",command = admin)
- butadmin.grid(row = 4, column = 1,columnspan = 2, padx=30, pady=30, sticky = W + E)
- window = Tk()
- window.title("Меню")
- window.geometry("500x500")
- butbuy = Button(window, text = "Оформить билет", command = fbuy)
- butprint = Button(window, text = "Вывести билеты",command = printt)
- butbuy.grid(row = 2, column = 2, padx=200, pady=100, sticky = W + E)
- butprint.grid(row = 4, column = 2, padx=200, pady=100, sticky = W + E)
- conn.commit()
- window.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement