-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.py
85 lines (78 loc) · 3.68 KB
/
Main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
from tkinter import *
from tkinter import messagebox
import sqlite3
from sqlite3 import Error
import os
import sys
py=sys.executable
#creating window
class Lib(Tk):
def __init__(self):
super().__init__()
self.a = StringVar()
self.b = StringVar()
self.maxsize(1366, 768)
self.minsize(1366, 768)
self.state("zoomed")
self.iconbitmap(r'libico.ico')
self.canvas = Canvas(width=1366, height=768, bg='blue')
self.canvas.pack()
self.photo = PhotoImage(file='output-onlinejpgtools1.png')
self.canvas.create_image(-20, -20, image=self.photo, anchor=NW)
self.title("Library Administration")
#verifying input
def chex():
if len(self.user_text.get()) < 0:
messagebox.showinfo("Oop's","Please Enter Your User Id")
elif len(self.pass_text.get()) < 0:
messagebox.showinfo("Oop's","Please Enter Your Password")
else:
try:
self.conn = sqlite3.connect('library_administration.db')
self.myCursor = self.conn.cursor()
self.myCursor.execute("Select * from admin where id=? AND password =?",[self.user_text.get(),self.pass_text.get()])
self.pc = self.myCursor.fetchall()
self.myCursor.close()
self.conn.close()
if self.pc:
self.destroy()
os.system('%s %s' % (py, 'options.py'))
else:
messagebox.showinfo('Error', 'Username and password not found')
self.user_text.delete(0, END)
self.pass_text.delete(0, END)
except Error:
messagebox.showinfo('Error',"Something Goes Wrong,Try restarting")
def fp():
os.system('%s %s' % (py, 'f_passwd.py'))
def check():
try:
conn = sqlite3.connect('library_administration.db')
mycursor = conn.cursor()
mycursor.execute("Select * from admin")
z = mycursor.fetchone()
mycursor.close()
conn.close()
if not z:
messagebox.showinfo("Error", "Please Register A user")
x = messagebox.askyesno("Confirm","Do you want to register a user")
if x:
self.destroy()
os.system('%s %s' % (py, 'Reg.py'))
else:
self.label = Label(self, text="Admin Login", font=("Algerian", 35, 'bold'))
self.label.place(x=530, y=30)
self.label1 = Label(self, text="User-Id", font=("Times New roman", 25, 'bold'))
self.label1.place(x=450, y=200)
self.user_text = Entry(self, textvariable=self.a, width=45)
self.user_text.place(x=650, y=215)
self.label2 = Label(self, text="Password", font=("Times new roman", 25, 'bold'))
self.label2.place(x=450, y=250)
self.pass_text = Entry(self, show='*', textvariable=self.b, width=45)
self.pass_text.place(x=650, y=265)
self.butt = Button(self, text="Login", font=10, width=15, command=chex).place(x=650, y=315)
self.butt2 = Button(self, text="Forgot Password", font=10, width=18, command=fp).place(x=830, y=313)
except Error:
messagebox.showinfo("Error", "Something Goes Wrong")
check()
Lib().mainloop()