Payroll Management
Payroll Management
PROPOSED SYSTEM
1. MySQL connector:
This is used to connect MySQL database with python.
2. Datetime:
Using datetime module, current date and time will be
displayed in the project.
3. Tabulate:
Using tabulate module, we can design the structure of
table. Format of the table can be altered with this
module.
4. Inflect:
Using inflect module we can convert number into
words.
SYSTEM DESIGN OF PAYROLL
MANAGEMENT SYSTEM
The general tasks involved in the design process are the following:
1. Design various blocks for overall system processes.
2. Design smaller, compact and workable modules in each block.
3. Design various database structures.
4. Specify details of programs to achieve desired functionality,
5. Design the form of Inputs, and outputs of the system.
6. Perform documentation of the design.
7. System reviews.
USER INTERFACE DESIGN
mydb=mysql.connector.connect(host="localhost",
user='root',
password='12345')
mycursor=mydb.cursor()
while True:
print("\n\n\n")
print("*"*95)
print("\t\t\t\t\tMAIN MENU")
print("*"*95)
print("\t\t\t\t1. For Adding Employee records")
print("\t\t\t\t2. For Displaying Record of All the
Employees")
print("\t\t\t\t3. For displaying Record of a particular
Employee")
print("\t\t\t\t4. For deleting Records of all the Employees")
print("\t\t\t\t5. For Deleting a Record of a particular
employee")
print("\t\t\t\t6. For Modification in a record")
print("\t\t\t\t7. For displaying payroll")
print("\t\t\t\t8. For displaying Salary Slip for all the
Employees")
print("\t\t\t\t9. For displaying Salary Slip for a particular
Employee")
print("\t\t\t\t10.For Exit")
print("Enter Choice...",end=' ')
choice=int(input())
if choice==1:
try:
print('Enter employee information........')
mempno=int(input('Enter employee no:'))
mname=input('Enter employee name:')
mjob=input("Enter employee job:")
mbasic=float(input("Enter basic salary:"))
if mjob.upper()=='OFFICER':
mda=mbasic*0.5
mhra=mbasic*0.35
mtax=mbasic*0.2
elif mjob.upper()=='MANAGER':
mda=mbasic*0.45
mhra-mbasic*0.38
mtax=mbasic*0.15
else:
mda=mbasic*0.48
mhra=mbasic*0.25
mtax=mbasic*0.1
mgross=mbasic+mda+mhra
mnet=mgross-mtax
rec=(mempno, mname, mjob, mbasic, mda, mhra,
mgross, mtax, mnet)
query="insert into "+TableName+"
values(%s,%s,%s,%s,%s,%s,%s,%s,%s)"
mycursor.execute(query,rec)
mydb.commit()
print('Record added successfully....')
except Exception as e:
print('Something went wrong',e)
elif choice==2:
try:
query= 'select*from '+TableName
mycursor.execute(query)
print(tabulate(mycursor,headers=['EmpNo', 'Name',
'Job', 'Basic Salary', 'DA', 'HRA', 'gross Salary', 'Tax',
'NetSalary', 'Tax', 'Net Salary'], tablefmt='psql'))
'''myrecords=mycursor.fetchall()
for rec in myrecords:
print (rec)'''
except:
print('Something went wrong')
elif choice==3:
try:
en=input('Enter employee no. of the record to be
displayed...')
query="select * from "+TableName+" where
empno="+en
mycursor.execute(query)
myrecord=mycursor.fetchone()
print("\n\nRecord of Employee No:"+en)
print(myrecord)
c=mycursor.rowcount
if c==-1:
print('Nothing to display')
except:
print('Something went wrong')
elif choice==4:
try:
ch=input('Do you want to delete all the records (y/n)')
if ch.upper()=='Y':
mycursor.execute('delete from'+TableName)
mydb.commit()
print('All the records are deleted...')
except:
print('Something went wrong')
elif choice==5:
try:
en=input("Enter employee no. of the record to be
deleted...")
query='delete from '+TableName+' where empno='+en
mycursor.execute(query)
mydb.commit()
c=mycursor.rowcount
if c>0:
print('Deletion done')
else:
print('Employee no ',en,' not found')
except:
print('Something went wrong')
elif choice == 6:
try:
en=input("Enter employee no. of the record to be
modified...")
query='select * from '+TableName+' where
empno='+en
mycursor.execute(query)
myrecord=mycursor.fetchone()
c=mycursor.rowcount
if c==-1:
print('Empno '+en+' does not exist')
else:
mname=myrecord[1]
mjob=myrecord[2]
mbasic=myrecord[3]
print('empno :',myrecord[0])
print('name :',myrecord[1])
print('job :',myrecord[2])
print("basic :",myrecord[3])
print('da :',myrecord[4])
print("hra :",myrecord[5])
print('gross :',myrecord[6])
print('tax :',myrecord[7])
print('net :',myrecord[8])
print("-------------------------")
print("Type Value to modify below or just press
Enter for no change")
x=input("Enter name :")
if len(x)>0:
mname=x
x=input("Enter job :")
if len(x)>0:
mjob = x
x=input("Enter basic salary :")
if len(x)>0:
mbasic=float(x)
query='update '+TableName+ ' set
name='+"'"+mname+"'"+','+'job='+"'"+mjob+"'"+','+'basicsala
ry='+"'"+str(mbasic)+"'" ' where empno='+en
print(query)
mycursor.execute(query)
mydb.commit()
print("Record modified")
except:
print('Something went wrong')
elif choice==9:
try:
en=input("Enter employee number whose pay slip
you want to retreive:")
query='select * from '+TableName+' where
empno='+en
mycursor.execute(query)
now = datetime.datetime.now()
print("\n\n\n\t\t\t\tSALARY SLIP ")
print("Current Date and Time:", end=' ')
print(now.strftime("%Y-%m-%d %H:%M:%S"))
print(tabulate (mycursor, headers = ['EmpNo',
'Name', 'Job', 'Basic Salary', 'Da', 'Salary', 'Tax', 'Net Salary'],
tablefmt='psql'))
except Exception as e:
print('Something went wrong', e)
elif choice==10:
break
else:
print('wrong Choice')