Professional Documents
Culture Documents
Salary Management
Salary Management
What is a Database?
A database is a separate application that stores a collection of data. Each database has one or more
distinct APIs for creating, accessing, managing, searching and replicating the data it holds.
Other kinds of data stores can also be used, such as files on the file system or large hash tables in
memory but data fetching and writing would not be so fast and easy with those type of systems.
Nowadays, we use relational database management systems (RDBMS) to store and manage huge
volume of data. This is called relational database because all the data is stored into different tables
and relations are established using primary keys or other keys known as Foreign Keys.
A Relational DataBase Management System (RDBMS) is a software that −
Enables you to implement a database with tables, columns and indexes.
Guarantees the Referential Integrity between rows of various tables.
Updates the indexes automatically.
Interprets an SQL query and combines information from various tables.
RDBMS Terminology
Before we proceed to explain the MySQL database system, let us revise a few definitions related to
the database.
Database − A database is a collection of tables, with related data.
Table − A table is a matrix with data. A table in a database looks like a simple spreadsheet.
Column − One column (data element) contains data of one and the same kind, for example the
column postcode.
Row − A row (= tuple, entry or record) is a group of related data, for example the data of one
subscription.
Redundancy − Storing data twice, redundantly to make the system faster.
Primary Key − A primary key is unique. A key value can not occur twice in one table. With a key, you
can only find one row.
Foreign Key − A foreign key is the linking pin between two tables.
Compound Key − A compound key (composite key) is a key that consists of multiple columns,
because one column is not sufficiently unique.
Index − An index in a database resembles an index at the back of a book.
Referential Integrity − Referential Integrity makes sure that a foreign key value always points to an
existing row.
MySQL Database
MySQL is a fast, easy-to-use RDBMS being used for many small and big businesses. MySQL is
developed, marketed and supported by MySQL AB, which is a Swedish company. MySQL is becoming
so popular because of many good reasons −
MySQL is released under an open-source license. So you have nothing to pay to use it.
MySQL is a very powerful program in its own right. It handles a large subset of the functionality of
the most expensive and powerful database packages.
MySQL uses a standard form of the well-known SQL data language.
MySQL works on many operating systems and with many languages including PHP, PERL, C, C++,
JAVA, etc.
MySQL works very quickly and works well even with large data sets.
MySQL is very friendly to PHP, the most appreciated language for web development.
MySQL supports large databases, up to 50 million rows or more in a table. The default file size limit
for a table is 4GB, but you can increase this (if your operating system can handle it) to a theoretical
limit of 8 million terabytes (TB).
MySQL is customizable. The open-source GPL license allows programmers to modify the MySQL
software to fit their own specific environments.
''' It is a reserved function in Python class which makes all the function initialize the attributes
inside
the class. It is also called as a constructor is object oriented terminology. '''
self.win = win
self.win.geometry("800x500+300+150")
self.win.title("Salary Manager")
# self.win.configure(bg = "#15350204f")
st = StringVar()
self.intt = IntVar()
def main_table() :
try :
except sql.errors.DatabaseError :
self.db = sql.connect(host = "localhost", user = "root", passwd = "18180612", database =
"salarymanagement")
self.cur = self.db.cursor()
try :
main_table()
except sql.errors.ProgrammingError :
pass
finally :
try :
main_table()
except sql.errors.ProgrammingError :
pass
''' This function coountdown() is used for time interval. I have used this function several time
for
vanishing different frames. '''
if time == -1 :
fab.destroy()
else :
fab.after(500, coountdown, time-1, fab)
basewidth = 300
img = Image.open('logo12.PNG')
# wpercent = (basewidth/float(img.size[0]))
# hsize = int((float(img.size[1])*float(wpercent)))
im = img.resize((90,90), Image.ANTIALIAS)
imgii = ImageTk.PhotoImage(im)
imi = img.resize((150, 130), Image.ANTIALIAS)
imgia = ImageTk.PhotoImage(imi)
varm = IntVar()
st = StringVar()
st1 = StringVar()
self.intt = IntVar()
def mark() :
''' The function mark() is used for hiding password in the first frame or login page. This
function is
embedded inside the Checkbutton widget so that if the button is checked then the password
will bo shown
or for any other case it will be replaced by a star(*). '''
if varm.get() == 1 :
self.password.configure(show = "")
check.configure(text = "Hide")
elif varm.get() == 0 :
self.password.configure(show = "*")
check.configure(text = "Show")
def like(event) :
''' The function like() is used to display the image in the login frame and it also display the
about
section of application by double clicking on the image. I have also packed a button named Out
to exiting
about frame displayed on the main frame. '''
creator_info = Frame(self.home_frame, width = 600, height = 380)
creator_info.place(x = 100, y = 60)
def destrot() :
''' This small function destrot() is packed inside the Button named out for destroying the
about
frame or to clear the about section. '''
creator_info.destroy()
# self.flag = ""
# self.cart = ""
self.constant = False
#self.win.iconbitmap('management_ico.ico')
def options() :
''' The function options() is used for displaying the different genders in the login page. I have
used
the OptionMenu widget for making the Option Button. This options are specified with the four
different
strings. '''
options = [
" None ",
" Male ",
" Female ",
" Others "
]
st = StringVar()
st.set(options[0])
self.optnbtn = OptionMenu(self.home_frame, st, options[0], options[1], options[2],
options[3])
self.optnbtn.configure(bd = 0, height = 1, width = 12, font = "Arial", bg = "#FDFEFE", fg =
"#F02D94",
activebackground = "#B6C1C3")
self.optnbtn.place(x = 385, y = 250)
self.optnbtn1 = "gg"
options()
def service() :
''' This function service() is designed to store the Earnings of a person in a regular basis in the
service sector. I have specified different entry box using the Entry widget to store the data of
their
expenses in our MySql server. '''
self.var5 = IntVar()
self.var6 = IntVar()
self.var5.set(0)
self.var6.set(0)
self.flag = "servi"
# self.day_1.place_forget()
# self.week_1.place_forget()
# self.month_1.place_forget()
self.cur.execute("select * from main where Name = '%s' and Password = '%s'" % (str(user),
str(passwd)))
rud = self.cur.fetchall()
if rud :
if nod :
rd = np.array(nod)
self.var5.set(rd[0])
self.var6.set(rd[1])
self.salary_1.configure(textvariable = self.var5)
self.extra_1.configure(textvariable = self.var6)
def business() :
income in our MySql server. '''
self.var5 = IntVar()
self.var6 = IntVar()
self.var5.set(0)
self.var6.set(0)
self.flag = "busin"
# self.day_2.place_forget()
# self.week_2.place_forget()
# self.month_2.place_forget()
self.cur.execute("select * from main where Name = '%s' and Password = '%s'" % (str(user),
str(passwd)))
rud = self.cur.fetchall()
if rud:
rd = np.array(nod)
self.var5.set(rd[0])
self.var6.set(rd[1])
self.salary_1.configure(textvariable = self.var5)
self.extra_1.configure(textvariable = self.var6)
def expenses() :
if self.salary_1.get() != "" or self.extra_1.get() != "" :
self.frame2 = Frame(self.win, bg = "blue", width = 800, height = 500)
self.frame2.place(x = 0, y = 0)
self.acc = Button(self.win, text = "12", command = account, bd = 0)
self.acc.place(x = 0, y = 240)
self.lab14 = Label(self.frame2, text = "EXPENSES", bd = 0)
self.lab14.configure(fg = "yellow", bg = "blue", font = "agencyfb")
self.lab14.place(x = 375, y = 50)
self.var7 = IntVar()
self.var8 = IntVar()
self.var9 = IntVar()
self.var10 = IntVar()
self.var11 = IntVar()
self.var12 = IntVar()
self.var13 = IntVar()
self.var14 = IntVar()
self.var15 = IntVar()
self.var16 = IntVar()
self.var17 = IntVar()
self.var18 = IntVar()
self.var19 = IntVar()
self.var20 = IntVar()
self.var7.set(0)
self.var8.set(0)
self.var9.set(0)
self.var10.set(0)
self.var11.set(0)
self.var12.set(0)
self.var13.set(0)
self.var14.set(0)
self.var15.set(0)
self.var16.set(0)
self.var17.set(0)
self.var18.set(0)
self.var19.set(0)
self.var20.set(0)
#intt = IntVar()
self.intt .set(0)
user = self.name.get()
passwd = b64encode(bytes(self.password.get(), "utf-16")).decode()
self.cur.execute("select * from main where Name = '%s' and Password = '%s'" % (str(user),
str(passwd)))
rud = self.cur.fetchall()
if rud :
def if_login() :
rd = np.array(rud)
self.var1 = StringVar()
self.var2 = IntVar()
# self.var3 = StringVar()
self.var4 = StringVar()
self.var5 = IntVar()
self.var6 = IntVar()
self.var7 = IntVar()
self.var8 = IntVar()
self.var9 = IntVar()
self.var10 = IntVar()
self.var11 = IntVar()
self.var12 = IntVar()
self.var13 = IntVar()
self.var14 = IntVar()
self.var15 = IntVar()
self.var16 = IntVar()
self.var17 = IntVar()
self.var18 = IntVar()
self.var19 = IntVar()
self.var20 = IntVar()
self.var1.set(rd[0][0])
self.var2.set(rd[0][1])
# self.var3.set(rd[0][2])
self.var4.set(rd[0][3])
self.var5.set(rd[0][6])
self.var6.set(rd[0][7])
self.var7.set(rd[0][8])
self.var8.set(rd[0][9])
self.var9.set(rd[0][10])
self.var10.set(rd[0][11])
self.var11.set(rd[0][12])
self.var12.set(rd[0][13])
self.var13.set(rd[0][14])
self.var14.set(rd[0][15])
self.var15.set(rd[0][16])
self.var16.set(rd[0][17])
self.var17.set(rd[0][18])
self.var18.set(rd[0][19])
self.var19.set(rd[0][20])
self.var20.set(rd[0][21])
self.name.configure(textvariable = self.var1)
self.age.configure(textvariable = self.var2)
# self.optnbtn1.configure(textvariable = self.var3)
self.password.configure(textvariable = self.var4)
self.salary_1.configure(textvariable = self.var5)
self.extra_1.configure(textvariable = self.var6)
self.entry15.configure(textvariable = self.var7)
self.entry16.configure(textvariable = self.var8)
self.entry17.configure(textvariable = self.var9)
self.entry18.configure(textvariable = self.var10)
self.entry19.configure(textvariable = self.var11)
self.entry20.configure(textvariable = self.var12)
self.entry21.configure(textvariable = self.var13)
self.entry22.configure(textvariable = self.var14)
self.entry23.configure(textvariable = self.var15)
self.entry24.configure(textvariable = self.var16)
self.entry25.configure(textvariable = self.var17)
self.entry26.configure(textvariable = self.var18)
self.entry27.configure(textvariable = self.var19)
self.entry28.configure(textvariable = self.var20)
if_login()
self.db.commit()
def click() :
self.lst_total = [
int(self.entry15.get()),
int(self.entry16.get()),
int(self.entry17.get()),
int(self.entry18.get()),
int(self.entry19.get()),
int(self.entry20.get()),
int(self.entry21.get()),
int(self.entry22.get()),
int(self.entry23.get()),
int(self.entry24.get()),
int(self.entry25.get()),
int(self.entry26.get()),
int(self.entry27.get()),
int(self.entry28.get())
]
self.summ = 0
for i in range(0, len(self.lst_total)):
self.summ = self.summ + self.lst_total[i]
coountdown(6, error)
def error_ok() :
error.place_forget()
#sleep(5)
error_btn = Button(error, text = "Ok", command = error_ok, bd = 0)
error_btn.pack()
else :
database()
self.total_print.configure(text = self.summ)
stat()
else :
def stat() :
self.frame2.place_forget()
self.statt = Frame(self.win, bg = "pink", width = 800, height = 500)
self.statt.place (x = 0, y = 0)
def line_graphical() :
self.statt.place_forget()
b = []
a=[
"HOUSE RENT",
"ELECTRIC BILLS",
"FOOD",
"COOKING EMENITIES",
"HEALTH",
"EDUCATION",
"WATER SUPPLY",
"SHOPPING",
"TRAVELLING",
"INTERNET & COMMUNICATION",
"SAVINGS",
"LOAN REPAYMENT",
"EXTRA",
"DONATIONS"
]
for i in self.lst_total :
b.append(i)
graph = fig.add_subplot(122)
graph.plot(b, a, marker = "o")
graph.grid()
get_widz = canv.get_tk_widget()
get_widz.pack()
def bar_graphical() :
self.statt.place_forget()
b = []
a=[
"HOUSE RENT",
"ELECTRIC BILLS",
"FOOD",
"COOKING EMENITIES",
"HEALTH",
"EDUCATION",
"WATER SUPPLY",
"SHOPPING",
"TRAVELLING",
"INTERNET & COMMUNICATION",
"SAVINGS",
"LOAN REPAYMENT",
"EXTRA",
"DONATIONS"
]
for i in self.lst_total:
b.append(i)
graph = fig.add_subplot(122)
graph.barh(a, b)
graph.grid()
get_widz = canv.get_tk_widget()
get_widz.pack()
def pie_graphical() :
self.statt.place_forget()
self.pie_grph = Frame(self.win, bg = "green", width = 800, height = 500)
self.pie_grph.place(x = 0, y = 0)
b = []
a=[
"HOUSE RENT",
"ELECTRIC BILLS",
"FOOD",
"COOKING EMENITIES",
"HEALTH",
"EDUCATION",
"WATER SUPPLY",
"SHOPPING",
"TRAVELLING",
"INTERNET & COMMUNICATION",
"SAVINGS",
"LOAN REPAYMENT",
"EXTRA",
"DONATIONS"
]
for i in self.lst_total :
b.append(i)
graph = fig.add_subplot(111)
graph.pie(b, labels = a)
get_widz = canv.get_tk_widget()
get_widz.pack()
def database() :
user = self.name.get()
passwd = b64encode(bytes(self.password.get(), "utf-16")).decode()
self.cur.execute("select * from main where Name = '%s' and Password = '%s'" % (str(user),
str(passwd)))
rud = self.cur.fetchall()
def inserting() :
self.cur = self.db.cursor()
self.cur.execute("insert into main values"
"("
"'{}', {}, '{}', '{}', '{}', '{}', {}, {}, {}, {}, {},"
" {}, {}, {}, {}, {}, {}, {},{}, {}, {}, {})"
.format
(
str(self.name.get()),
self.age.get(),
str(self.optnbtn1),
b64encode(bytes(self.password.get(), "utf-16")).decode(),
str(self.flag),
str(self.cart),
int(self.salary_1.get()),
int(self.extra_1.get()),
self.entry15.get(),
self.entry16.get(),
self.entry17.get(),
self.entry18.get(),
self.entry19.get(),
self.entry20.get(),
self.entry21.get(),
self.entry22.get(),
self.entry23.get(),
self.entry24.get(),
self.entry25.get(),
self.entry26.get(),
self.entry27.get(),
self.entry28.get()
))
if rud :
print("Welcome")
inserting()
self.db.commit()
else :
inserting()
self.db.commit()
print("Account Created")
self.cur.close()
self.db.close()
def add_income_again() :
self.db = sql.connect(host = "localhost", user = "root", passwd = "18180612", database =
"salarymanagement")
self.cur = self.db.cursor()
user = self.name.get()
passwd = b64encode(bytes(self.password.get(), "utf-16")).decode()
self.cur.execute("select Job from main where Name = '%s' and Password = '%s'" % (str(user),
str(passwd)))
rud = self.cur.fetchall()
try :
if rud[-1][0] == "servi" :
service()
except IndexError :
if self.flag == "servi" :
service()
business()
def account_setting() :
self.frame.pack_forget()
# intt = IntVar()
varm = IntVar()
st = StringVar()
st1 = StringVar()
self.intt.set(self.age.get())
st.set(self.name.get())
st1.set(self.password.get())
self.constant = True
def mark_2() :
if varm.get() == 1 :
password_entry.configure(show = "")
check.configure(text = "Hide")
elif varm.get() == 0 :
password_entry.configure(show = "*")
check.configure(text = "Show")
def update_account() :
self.name = name_entry
self.age = age_entry
self.password = password_entry
def account() :
# self.acc.place_forget()
self.acc.configure(text = "21", command = account_update)
self.acc.place_configure(x = 250, y = 240)
# self.goback = Button(self.win, text = "21", command = account_update)
# self.goback.place(x = 250, y = 240)
self.frame = Frame(self.win, bg = "red", width = 250, height = 500)
self.frame.pack(side = LEFT)
def like() :
creator_info = Frame(self.win, width = 600, height = 380)
creator_info.place(x = 100, y = 60)
def destrot() :
creator_info.destroy()
if self.constant == True :
self.frame1.place_forget()
self.acc.configure(text = "12", command = account)
self.acc.place_configure(x = 0, y = 240)
# self.frame.pack_forget()
# self.frame.place_forget()
# self.goback.place_forget()
self.acc.configure(text = "12", command = account)
self.acc.place_configure(x = 0, y = 240)
def day1() :
self.cart = "Day"
service()
def week1() :
self.cart = "Week"
service()
def month1() :
self.cart = "Month"
service()
def day2():
self.cart = "Day"
business()
def week2() :
self.cart = "Week"
business()
def month2() :
self.cart = "Month"
business()
def interval_service() :
self.lab4.place_forget()
self.service.place_forget()
self.business.place_forget()
def interval_business() :
self.lab4.place_forget()
self.service.place_forget()
self.business.place_forget()
def afterenter() :
if self.name.get() != "" and self.password.get() != "" :
self.home_frame.place_forget()
self.win.configure(bg = "dimgrey")
else :
if __name__ == "__main__" :
window = Tk()
startpage(window)
window.mainloop()