0% found this document useful (0 votes)
80 views

Code Python

The document contains Python code that defines functions for managing employee data in a database. It includes functions for adding, viewing, deleting, and updating employee records stored in a SQLite database table. The code also handles user authentication by checking login credentials stored in a file against user input on a login form.

Uploaded by

Aryan Agney
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views

Code Python

The document contains Python code that defines functions for managing employee data in a database. It includes functions for adding, viewing, deleting, and updating employee records stored in a SQLite database table. The code also handles user authentication by checking login credentials stored in a file against user input on a login form.

Uploaded by

Aryan Agney
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

import sqlite3,sys,os

from PIL import *


from
t1.insert(END,"<>Address is Required<>\n")
f=1
if a==1 or b==1 or c==1 or d==1 or e==1 or f==1:
return 1
else:
return 0

def add_Employee(self):
ret=verifier()
if ret==0:
conn=connection()
cur=conn.cursor()
cur.execute("CREATE TABLE IF NOT EXISTS Employee(NAME TEXT,emp_no
INTEGER,Deptartment TEXT,PHONE_NO INTEGER,Qualifications TEXT,ADDRESS TEXT)")
cur.execute("insert into Employee values(?,?,?,?,?,?)",
(Employee_name.get(),int(emp_no.get()),Deptartment.get(),int(phone.get()),Qualifica
tions.get(),address.get()))
conn.commit()
conn.close()
t1.insert(END,"ADDED SUCCESSFULLY\n")

def view_Employee():
conn=connection()
cur=conn.cursor()
cur.execute("select * from Employee")
data=cur.fetchall()
conn.close()
for i in data:
t1.insert(END,str(i)+"\n")

def delete_Employee():
ret=verifier()
if ret==0:
conn=connection()
cur=conn.cursor()
cur.execute("DELETE FROM Employee WHERE emp_no=?",(int(emp_no.get()),))
conn.commit()
conn.close()
t1.insert(END,"SUCCESSFULLY DELETED THE USER\n")

def update_Employee():
ret=verifier()
if ret==0:
conn=connection()
cur=conn.cursor()
cur.execute("UPDATE Employee SET
NAME=?,emp_no=?,Deptartment=?,PHONE_NO=?,Qualifications=?,ADDRESS=? where
emp_no=?",
(Employee_name.get(),int(emp_no.get()),Deptartment.get(),int(phone.get()),Qualifica
tions.get(),address.get(),int(emp_no.get())))
conn.commit()
conn.close()
t1.insert(END,"UPDATED SUCCESSFULLY\n")
def clse():
root.destroy()

def emp(self):

g="#0a2845"#color
gg='#134e86'#secondary color
gw="white"
root=Toplevel()
root.title("Employee Management System")
root.resizable(width=FALSE, height=FALSE)
root.geometry('1335x720')

# logo = PhotoImage(file="a.gif")
root.configure(background=g)

Image_open=Image.open("a.png")
image=ImageTk.PhotoImage(Image_open)
logo=Label(root,image=image,bg=gg)

b2=Button(root,image=photo2,command=view_Employee)
b2.place(x=55,y=630)
string.
f.write('\n') # Splits the line so both variables are on different lines.

loginB = Button(rootA, text='Login', command=CheckLogin) # This makes the login


button, which will go to the CheckLogin def.
loginB.grid(columnspan=2, sticky=W)

rmuser = Button(rootA, text='Delete User', fg='red', command=DelUser) # This


makes the deluser button. blah go to the deluser def.
rmuser.grid(columnspan=2, sticky=W)
rootA.mainloop()

def CheckLogin():
with open(creds) as f:
data = f.readlines() # This takes the entire document we put the info into
and puts it into the data variable
uname = data[0].rstrip() # Data[0], 0 is the first line, 1 is the second
and so on.
pword = data[1].rstrip() # Using .rstrip() will remove the \n (new line)
word from before when we input it

if nameEL.get() == uname and pwordEL.get() == pword: # Checks to see if you


entered the correct data.
r = Tk() # Opens new window
r.title(':D')
r.geometry('150x50') # Makes the window a certain size
B = Button(r, text ="Hello Click Here To Continue", command=lambda:emp(r))

B.pack()
r.mainloop()
else:
r = Tk()
r.title('D:')
r.geometry('150x50')
rlbl = Label(r, text='\n[!] Invalid Login')
rlbl.pack()
r.mainloop()

def DelUser():
os.remove(creds) # Removes the file
rootA.destroy() # Destroys the login window
Signup() # And goes back to the start!

if os.path.isfile(creds):
Login()
else: # This if else statement checks to see if the file exists. If it does it will
go to Login, if not it will go to Signup :)
Signup()

You might also like