Tuesday, 24 February 2015

PAYROLL PROCESSING PROJECT IN C



#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<dos.h>
#include<io.h>
#include<ctype.h>
#include<string.h>

struct add
{

char empname[25];
long int empno;
char sex[6];
char address[50];
char city[25];
long int pin;
char department[25];
char joindate[25];
char dob[25];
char category[1];
char designation[20];
int l;
int year;

};

struct permenentstaff
{

float basicpay;
float da;
float hrd;
float pf;
float lic;

};





struct managementstaff
{

float basicpay;
float da;
float hra;
float pf;
float lic;
};

struct apprentices
{

float basicpay;

};

main()
{

char yes,c,c0,c1,m,p,a,c2,c4,c41,rm,rp,ra;
char ma,pa,aa;
static int i;
clrscr();

mainmenu();

fflush(stdin);
yes=getche();

if(yes=='1'||yes=='2'||yes=='3')

{

while(i==0)

{






switch(yes)

{

case '1':
clrscr();
database();
c=getche();

if(c=='1')

{
mparecord();
ma=getche();
switch(ma)

{
case '1':
mrecord();
c41=getche();
switch(c41)
{
 case '1':
  maddrecord();
  break;
 case '2':
  mmodifyrecord();
  break;
 case '3':
  mdeleterecord();
  break;
 case '4':
  mretrieverecord();
  break;
 case '5':
  continue;
  //break;
}
break;





case '2':
 precord();
 switch(c41)
 {
 case '1':
  paddrecord();
  break;
 case '2':
  pmodifyrecord();
  break;
 case '3':
  pdeleterecord();
  break;
 case '4':
  pretrieverecord();
  break;
 case '5':
  continue;
  //break;
 }
     break;

case '3':
 arecord();
 c41=getche();
 switch(c41)
 {
 case '1':
  aaddrecord();
  break;
 case '2':
  amodifyrecord();
  break;
 case '3':
  adeleterecord();
  break;
 case '4':
  aretrieverecord();
  break;




 case '5':
  continue;
  //break;
}
break;

case '4':
continue;
//break;
}
}

else if(c=='2')
{
staff();
c2=getche();
switch(c2)
{
case '1':
     clrscr();
 managementstaff();
 m=getche();
 switch(m)
 {
  case '1':
addmrecord();
break;
case '2':
modifymrecord();
break;
case '3':
retrievemrecord();
break;
case '4':
staff();
break;
 }
 break;





case '2':
clrscr();
permenentstaff();
  p=getche();
switch(p)
{
case '1':
  addprecord();
    break;
case '2':
    modifyprecord();
  break;
case '3':
    retrieveprecord();
    break;
case '4':
  staff();
    break;
    }
    break;
case '3':
clrscr();
apprenticesstaff();
a=getche();
  switch(a)
{
case '1':
 addarecord();
   break;
case '2':
 modifyarecord();
   break;
case '3':
 retrievearecord();
 break;
case '4':
 staff();
 break;
}
break;



case '4':
 mainmenu();
 break;
}
break;
}

else if(c=='3')
{
mainmenu();
break;
}
break;
case '2':
switch(yes)
{
case '2':
 clrscr();
 rstaff();
 rm=getche();
   if(rm=='1')
     {
  mreportsmenu();
c1=getche();
if(c1=='1')
{
mlabels();
}
else if(c1=='2')
{
mpayrollledger();
}
else if(c1=='3')
{
mpfdeduction();
}
else if(c1=='4')
{
mlicdeduction();
}
else if(c1=='5')

{
rstaff();
}
 
 }

 else if(rm=='2')
 {
  preportsmenu();
rp=getche();
if(rp=='1')
{
plabels();
}
else if(rp=='2')
{
ppayrollledger();
}
else if(rp=='3')
{
ppfdeduction();
}
else if(rp=='4')
{
plicdeduction();
}
else if(rp=='5')
{
rstaff();
}
   else if(rm=='3')
   {
  areportsmenu();
ra=getche();
if(ra=='1')
{
alabels();
}
else if(ra=='2')
{
apayrollledger();
}

else if(ra=='3')
{
rstaff();
}
   }

   else if(rm=='4')
   {
mainmenu();
 }
 break;
}
break;
case '3':
exit(1);
break;
}
}
}
return;
}


printline()
{
int i;
printf("\n");
for(i=0;i<80;i++)
{
printf("%c",'÷');
}
return;
}

staff()
{
char c0,m,p,a;
clrscr();
printline();
printf("\n\t\t\t\tPAYROLL DATA BASE OPERATIONS ");




printline();
printf("\n\n\n\n\n\t\t\t\t 1...MANAGEMENT STAFF ");
printf("\n\n\t\t\t\t 2...PERMENENT STAFF ");
printf("\n\n\t\t\t\t 3...APPRENTICES STAFF ");
printf("\n\n\t\t\t\t 4...RETURN TO MAIN MENU");
printf("\n\n\n\n\n\n\t\t\t\t YOUR CHOICE");

c0=getche();
switch(c0)
{
case '1':
 clrscr();
 managementstaff();
 m=getche();
 switch(m)
   {
  case '1':
  addmrecord();
break;
case '2':
  modifymrecord();
  break;
case '3':
  retrievemrecord();
  break;
case '4':
  staff();
  break;
   }
   break;

case '2':
 clrscr();
 permenentstaff();
   p=getche();
       switch(p)
{
  case '1':
  addprecord();
  break;


case '2':
  modifyprecord();
  break;
case '3':
  retrieveprecord();
  break;
case '4':
  staff();
  break;
}
        break;

case '3':
clrscr();
apprenticesstaff();
a=getche();
switch(a)
{
case '1':
    addarecord();
  break;
case '2':
modifyarecord();
break;
case '3':
retrievearecord();
  break;
case '4':
    staff();
  break;
}
break;

case '4':
  mainmenu();
  break;
}
return;
}





mparecord()

{
char yes,c,c0,c1,m,p,a,c2,c4,c41,rm,rp,ra;
char ma,pa,aa;
clrscr();
printline();
printf("\n\t\t\t\tPAYROLL DATA BASE OPERATIONS ");
printline();
printf("\n\n\n\n\n\t\t\t\t 1...MANAGEMENT STAFF ");
printf("\n\n\t\t\t\t 2...PERMENENT STAFF ");
printf("\n\n\t\t\t\t 3...APPRENTICES STAFF ");
printf("\n\n\t\t\t\t 4...RETURN TO MAIN MENU");
printf("\n\n\n\n\n\n\t\t\t\t YOUR CHOICE");
fflush(stdin);
ma=getche();
if(ma=='1')
{
mrecord();
c41=getche();
switch(c41)
{
case '1':
  maddrecord();
  break;
case '2':
  mmodifyrecord();
  break;
case '3':
  mdeleterecord();
  break;
case '4':
  mretrieverecord();
  break;
case '5':
  mparecord();
  break;
}
}




else if(ma=='2')
{
precord();
pa=getche();
switch(pa)
{
case '1':
 paddrecord();
 break;
case '2':
 pmodifyrecord();
 break;
case '3':
 pdeleterecord();
   break;
case '4':
 pretrieverecord();
 break;
case '5':
 mparecord();
 break;
}
}
else if(ma=='3')
{
arecord();
a=getche();
switch(aa)
{
case '1':
aaddrecord();
  break;
case '2':
amodifyrecord();
break;
case '3':
    adeleterecord();
    break;
case '4':
    aretrieverecord();
    break;


case '5':
    mparecord();
  break;
}
}
else if(ma=='4')
{
mainmenu();
}
return;
}

rstaff()
{
char rm,c1,rp,ra;
clrscr();
printline();
printf("\n\t\t\t\tPAYROLL DATA BASE OPERATIONS                   ");
printline();
printf("\n\n\n\n\n\t\t\t\t 1...MANAGEMENT STAFF ");
printf("\n\n\t\t\t\t 2...PERMENENT STAFF ");
printf("\n\n\t\t\t\t 3...APPRENTICES STAFF ");
printf("\n\n\t\t\t\t 4...RETURN TO MAIN MENU");
printf("\n\n\n\n\n\n\t\t\t\t YOUR CHOICE");

rm=getche();
if(rm=='1')
{
mreportsmenu();
c1=getche();

if(c1=='1')
{
mlabels();
}
else if(c1=='2')
{
mpayrollledger();
}
else if(c1=='3')
{
mpfdeduction();
}
else if(c1=='4')
{
mlicdeduction();
}
else if(c1=='5')
{
rstaff();
}
}
else if(rm=='2')
{
preportsmenu();

rp=getche();

if(rp=='1')
{
plabels();
}
else if(rp=='2')
{
ppayrollledger();
}
else if(rp=='3')
{
ppfdeduction();
}
else if(rp=='4')
{
plicdeduction();
}
else if(rp=='5')
{
rstaff();
}
}
else if(rm=='3')
{
areportsmenu();
ra=getche();
if(ra=='1')
{
alabels();
}
else if(ra=='2')
{
apayrollledger();
}
else if(ra=='3')
{
rstaff();
}
}
else if(rm=='4')
{
mainmenu();
}
return;
}

mainmenu()
{
char yes,c,c0,c1,m,p,a,c2,c4,c41,rm,rp,ra;
char ma,pa,aa,t;
static int i;
clrscr();
printline();
printf("\n\n\n\t\t\t\tPAYROLL PROJECT");
printline();
printf("\n\n\n\n\n\t\t\t\t 1...DATABASE OPERATIONS ");
printf("\n\n\t\t\t\t 2...REPORTS           ");
printf("\n\n\t\t\t\t 3...EXIT             ");
printf("\n\n\n\n\n\n\n\t\t\t\t YOUR CHOICE       ");

fflush(stdin);
yes=getche();

if(yes=='1'||yes=='2'||yes=='3')
{
while(i==0)
{
switch(yes)
{
case '1':
clrscr();
database();
c=getche();
if(c=='1')
{
mparecord();
ma=getche();
switch(ma)
{
case '1':
mrecord();
c41=getche();
switch(c41)
{
case '1':
 maddrecord();
 break;
case '2':
 mmodifyrecord();
 break;
case '3':
 mdeleterecord();
 break;
case '4':
 mretrieverecord();
 break;
case '5':
 continue;
//break;
}
break;
case '2':
 precord();
 switch(c41)
 {
case '1':
 paddrecord();
 break;
case '2':
 pmodifyrecord();
 break;
case '3':
 pdeleterecord();
 break;
case '4':
 pretrieverecord();
 break;
case '5':
 continue;
 // break;
 }
 break;

case '3':
 arecord();
 c41=getche();
 switch(c41)
 {
case '1':
 aaddrecord();
 break;
case '2':
 amodifyrecord();
 break;
case '3':
 adeleterecord();
 break;
case '4':
 aretrieverecord();
 break;
case '5':
 continue;
 //break;
 }
 break;
case '4':
 continue;
 //break;
}
}
else if(c=='2')
{
staff();
c2=getche();
switch(c2)
{
case '1':
 clrscr();
 managementstaff();
 m=getche();
 switch(m)
 {
case '1':
 addmrecord();
 break;
case '2':
 modifymrecord();
 break;
case '3':
 retrievemrecord();
 break;
case '4':
 staff();
 break;
 }
 break;

case '2':
 clrscr();
 permenentstaff();
 p=getche();
 switch(p)
 {
case '1':
 addprecord();
 break;
case '2':
 modifyprecord();
 break;
case '3':
 retrieveprecord();
 break;
case '4':
 staff();
 break;
 }
 break;
case '3':
 clrscr();
 apprenticesstaff();
 a=getche();
 switch(a)
 {
case '1':
 addarecord();
 break;
case '2':
 modifyarecord();
 break;
case '3':
 retrievearecord();
 break;
case '4':
 staff();
 break;
 }
 break;

case '4':
 mainmenu();
 break;
}
break;
}
else if(c=='3')
{
mainmenu();
break;
}
break;
case '2':
 switch(yes)
 {
case '2':
 clrscr();
 rstaff();
 rm=getche();
 if(rm=='1')
 {
mreportsmenu();
c1=getche();
if(c1=='1')
{
mlabels();
}
else if(c1=='2')
{
mpayrollledger();
}
else if(c1=='3')
{
mpfdeduction();
}
else if(c1=='4')
{
mlicdeduction();
}
else if(c1=='5')
{
rstaff();
}
}
else if(rm=='2')
{
preportsmenu();
rp=getche();
if(rp=='1')
{
plabels();
}
else if(rp=='2')
{
ppayrollledger();
}
else if(rp=='3')
{
ppfdeduction();
}
else if(rp=='4')
{
plicdeduction();
}
else if(rp=='5')
{
rstaff();
}
}
else if(rm=='3')
{
areportsmenu();
ra=getche();
if(ra=='1')
{
alabels();
}
else if(ra=='2')
{
apayrollledger();
}
else if(ra=='3')
{
rstaff();
}
 }
 else if(rm=='4')
 {
mainmenu();
 }
 break;
 }
 break;
case '3':
 exit(1);
 break;
}
}
}
i=1;
return;
}

mrecord()
{
char c;
clrscr();
printline();
printf("\n\t\t\t\tMASTER DATA ENTRY");
printline();
printf("\n\n\t\t\t\t 1...ADD RECORD ");
printf("\n\n\t\t\t\t 2...MODIFY RECORD");
printf("\n\n\t\t\t\t 3...DELETE RECORD ");
printf("\n\n\t\t\t\t 4...RETRIEVE RECORD");
printf("\n\n\t\t\t\t 5...RETURN TO MAIN MENU");
printf("\n\n\n\n\t\t\t\t YOUR CHOICE");
c=getche();
if(c=='1')
{
maddrecord();
}
else if(c=='2')
{
mmodifyrecord();
}
if(c=='3')
{
mdeleterecord();
}
else if(c=='4')
{
mretrieverecord();
}
else if(c=='5')
{
mparecord();
}
return;
}


precord()
{
char c;
clrscr();
printline();
printf("\n\t\t\t\tMASTER DATA ENTRY");
printline();
printf("\n\n\t\t\t\t 1...ADD RECORD ");
printf("\n\n\t\t\t\t 2...MODIFY RECORD");
printf("\n\n\t\t\t\t 3...DELETE RECORD ");
printf("\n\n\t\t\t\t 4...RETRIEVE RECORD");
printf("\n\n\t\t\t\t 5...RETURN TO MAIN MENU");
printf("\n\n\n\n\t\t\t\t YOUR CHOICE");
c=getche();
if(c=='1')
{
paddrecord();
}
else if(c=='2')
{
pmodifyrecord();
}
if(c=='3')
{
pdeleterecord();
}
else if(c=='4')
{
pretrieverecord();
}
else if(c=='5')
{
mparecord();
}
return;
}


arecord()
{
char c;
clrscr();
printline();
printf("\n\t\t\t\tMASTER DATA ENTRY");
printline();
printf("\n\n\t\t\t\t 1...ADD RECORD ");
printf("\n\n\t\t\t\t 2...MODIFY RECORD");
printf("\n\n\t\t\t\t 3...DELETE RECORD ");
printf("\n\n\t\t\t\t 4...RETRIEVE RECORD");
printf("\n\n\t\t\t\t 5...RETURN TO MAIN MENU");
printf("\n\n\n\n\t\t\t\t YOUR CHOICE");
c=getche();
if(c=='1')
{
aaddrecord();
}
else if(c=='2')
{
amodifyrecord();
}
if(c=='3')
{
adeleterecord();
}
else if(c=='4')
{
aretrieverecord();
}
else if(c=='5')
{
mparecord();
}
return;
}


permenentstaff()
{
char c;
clrscr();
printline();
printf("\n\t\t\t\tPERMENENT STAFF DATA ENTRY");
printline();
printf("\n\n\t\t\t\t 1...ADD RECORD ");
printf("\n\n\t\t\t\t 2...MODIFY RECORD");
printf("\n\n\t\t\t\t 3...RETRIEVE RECORD");
printf("\n\n\t\t\t\t 4...RETURN TO MAIN MENU");
printf("\n\n\n\n\t\t\t\t YOUR CHOICE");

c=getche();
if(c=='1')
{
addprecord();
}
else if(c=='2')
{
modifyprecord();
}
else if(c=='3')
{
retrieveprecord();
}
else if(c=='4')
{
staff();
}
return;
}


managementstaff()
{
char c;
clrscr();
printline();
printf("\n\t\t\t\tMANAGEMENT STAFF DATA ENTRY");
printline();
printf("\n\n\t\t\t\t 1...ADD RECORD ");
printf("\n\n\t\t\t\t 2...MODIFY RECORD");
printf("\n\n\t\t\t\t 3...RETRIEVE RECORD");
printf("\n\n\t\t\t\t 4...RETURN TO MAIN MENU");
printf("\n\n\n\n\t\t\t\t YOUR CHOICE");

c=getche();
if(c=='1')
{
addmrecord();
}
else if(c=='2')
{
modifymrecord();
}
else if(c=='3')
{
retrievemrecord();
}
else if(c=='4')
{
staff();
}
return;
}


apprenticesstaff()
{
char c;
clrscr();
printline();
printf("\n\t\t\t\tAPPRENTICES STAFF DATA ENTRY");
printline();
printf("\n\n\t\t\t\t 1...ADD RECORD ");
printf("\n\n\t\t\t\t 2...MODIFY RECORD");
printf("\n\n\t\t\t\t 3...RETRIEVE RECORD");
printf("\n\n\t\t\t\t 4...RETURN TO MAIN MENU");
printf("\n\n\n\n\t\t\t\t YOUR CHOICE");

c=getche();
if(c=='1')
{
addarecord();
}
else if(c=='2')
{
modifyarecord();
}
else if(c=='3')
{
retrievearecord();
}
else if(c=='4')
{
staff();
}
return;
}


database()
{
clrscr();
printline();
printf("\n\t\t\t\tPAYROLL DATA BASE OPERATIONS ");
printline();
printf("\n\n\n\n\n\t\t\t\t 1...MASTER FILE DATA ENTRY ");
printf("\n\n\t\t\t\t 2...TRANSACTION DATA ENTRY ");
printf("\n\n\t\t\t\t 3...RETURN TO MAIN MENU ");
printf("\n\n\n\n\n\n\t\t\t\t YOUR CHOICE ");
return;
}

maddrecord()
{
struct add a;
FILE *ad,*pd;
char flag;
ad=fopen("mpay.dat","ab+");
pd=fopen("pay.dat","ab+");

clrscr();
printline();
printf("\nTHE EMPLOYEE NUMBER\t\t\t:");
fflush(stdin);
scanf("%ld",&a.empno);
printf("\n ENTER THE EMPLOYEE NAME\t\t:");
fflush(stdin);
gets(a.empname);
printf("\n ENTER THE EMPLOYEE SEX\t\t\t:");
fflush(stdin);
gets(a.sex);
printf("\n ENTER THE EMPLOYEE ADDRESS\t\t:");
fflush(stdin);
gets(a.address);
printf("\n ENTER THE EMPLOYEE CITY\t\t: ");
fflush(stdin);
gets(a.city);
printf("\n ENTER THE EMPLOYEE PIN CODE\t\t:");
fflush(stdin);
scanf("%ld",&a.pin);
printf("\n ENTER THE EMPLOYEE DEPARTMENT\t\t:");
fflush(stdin);
gets(a.department);
printf("\n ENTER THE EMPLOYEE JOIN DATE\t\t:");
fflush(stdin);
gets(a.joindate);
printf("\n ENTER THE EMPLOYEE DATE OF BIRTH\t:");
fflush(stdin);
gets(a.dob);
printf("\n ENTER THE EMPLOYEE CATEGORY\t\t:");
fflush(stdin);
gets(a.category);
printf("\n ENTER THE EMPLOYEE DESIGNATION\t\t:");
fflush(stdin);
gets(a.designation);
printf("\n ENTER THE CURRENT YEAR\t\t\t:");
fflush(stdin);
scanf("%d",&a.l);
printf("\n ENTER THE CURRENT YEAR\t\t\t:");
fflush(stdin);
scanf("%d",&a.year);
printline();

fwrite(&a,sizeof(a),1,ad);
fwrite(&a,sizeof(a),1,pd);

fflush(stdin);
puts("\n\n\n\t\t RECORDS  ARE SUCCESSFULLY ADDED");
getche();

fclose(ad);
fclose(pd);
mparecord();
return;
}


paddrecord()
{
struct add a;
FILE *ad,*pd;
char flag;
ad=fopen("ppay.dat","ab+");
pd=fopen("pay.dat","ab+");

clrscr();
printline();
printf("\n  THE EMPLOYEE NUMBER   : ");
fflush(stdin);
scanf("%ld",&a.empno);
printf("\n ENTER THE EMPLOYEE NAME   : ");
fflush(stdin);
gets(a.empname);
printf("\n ENTER THE EMPLOYEE SEX\t\t      : ");
fflush(stdin);
gets(a.sex);
printf("\n ENTER THE EMPLOYEE ADDRESS      : ");
fflush(stdin);
gets(a.address);
printf("\n ENTER THE EMPLOYEE CITY         : ");
fflush(stdin);
gets(a.city);
printf("\n ENTER THE EMPLOYEE PIN CODE     : ");
fflush(stdin);
scanf("%ld",&a.pin);
printf("\n ENTER THE EMPLOYEE DEPARTMENT   : ");
fflush(stdin);
gets(a.department);
printf("\n ENTER THE EMPLOYEE JOIN DATE    : ");
fflush(stdin);
gets(a.joindate);
printf("\n ENTER THE EMPLOYEE DATE OF BIRTH: ");
fflush(stdin);
gets(a.dob);
printf("\n ENTER THE EMPLOYEE CATEGORY     : ");
fflush(stdin);
gets(a.category);
printf("\n ENTER THE EMPLOYEE DESIGNATION  : ");
fflush(stdin);
gets(a.designation);
printf("\n ENTER THE CURRENT YEAR   : ");
fflush(stdin);
scanf("%d",&a.l);
printf("\n ENTER THE CURRENT YEAR   :");
fflush(stdin);
scanf("%d",&a.year);
printline();

fwrite(&a,sizeof(a),1,ad);
fwrite(&a,sizeof(a),1,pd);
fflush(stdin);

puts("\n\n\n\t\t RECORDS  ARE SUCCESSFULLY ADDED           :");
getche();

fclose(ad);
fclose(pd);
mparecord();
return;
}
aaddrecord()
{
struct add a;
FILE *ad,*pd;
char flag;
ad=fopen("apay.dat","ab+");
pd=fopen("pay.dat","ab+");
clrscr();

printline();
printf("\n  THE EMPLOYEE NUMBER   : ");
fflush(stdin);
scanf("%ld",&a.empno);
printf("\n ENTER THE EMPLOYEE NAME   : ");
fflush(stdin);
gets(a.empname);
printf("\n ENTER THE EMPLOYEE SEX\t\t      : ");
fflush(stdin);
gets(a.sex);
printf("\n ENTER THE EMPLOYEE ADDRESS      : ");
fflush(stdin);
gets(a.address);
printf("\n ENTER THE EMPLOYEE CITY         : ");
fflush(stdin);
gets(a.city);
printf("\n ENTER THE EMPLOYEE PIN CODE     : ");
fflush(stdin);
scanf("%ld",&a.pin);
printf("\n ENTER THE EMPLOYEE DEPARTMENT   : ");
fflush(stdin);
gets(a.department);
printf("\n ENTER THE EMPLOYEE JOIN DATE    : ");
fflush(stdin);
gets(a.joindate);
printf("\n ENTER THE EMPLOYEE DATE OF BIRTH: ");
fflush(stdin);
gets(a.dob);
printf("\n ENTER THE EMPLOYEE CATEGORY     : ");
fflush(stdin);
gets(a.category);
printf("\n ENTER THE EMPLOYEE DESIGNATION  : ");
fflush(stdin);
gets(a.designation);
printf("\n ENTER THE CURRENT YEAR   : ");
fflush(stdin);
scanf("%d",&a.l);
printf("\n ENTER THE CURRENT YEAR   : ");
fflush(stdin);
scanf("%d",&a.year);
printline();

fwrite(&a,sizeof(a),1,ad);
fwrite(&a,sizeof(a),1,pd);
fflush(stdin);

puts("\n\n\n\t\t RECORDS  ARE SUCCESSFULLY ADDED");
getche();

fclose(ad);
fclose(pd);
mparecord();
return;
}


mmodifyrecord()
{
FILE *ad;
char flag;
long int no;
struct add a;
ad=fopen("mpay.dat","rb+");

clrscr();
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t ENTER EMPLOYEE NUMBER   :");
scanf("%ld",&no);
while(fread(&a,sizeof(a),1,ad)!=NULL)
{
clrscr();
if(a.empno==no)
{
printline();
printf("\n NUMBER               :%ld",a.empno);
printf("\n NAME :%s",a.empname);
printf("\n SEX\t\t       :%s",a.sex);
printf("\n ADDRESS       :%s",a.address);
printf("\n CITY         :%s",a.city);
printf("\n PIN CODE     :%ld",a.pin);
printf("\n DEPARTMENT   :%s",a.department);
printf("\n JOIN DATE     :%s",a.joindate);
printf("\n DATE OF BIRTH :%s",a.dob);
printf("\n CATEGORY     :%s",a.category);
printf("\n DESIGNATION   :%s",a.designation);
printf("\n CURRENT MONTH LEAVE  :%d",a.l);
printf("\n CURRENT YEAR        :%d",a.year);
getch();

fflush(stdin);
printf("\n  THE EMPLOYEE NUMBER           : ");
fflush(stdin);
scanf("%ld",&a.empno);
printf("\n ENTER THE EMPLOYEE NAME   : ");
fflush(stdin);
gets(a.empname);
printf("\n ENTER THE EMPLOYEE SEX\t\t      : ");
fflush(stdin);
gets(a.sex);
printf("\n ENTER THE EMPLOYEE ADDRESS      : ");
fflush(stdin);
gets(a.address);
printf("\n ENTER THE EMPLOYEE CITY         : ");
fflush(stdin);
gets(a.city);
printf("\n ENTER THE EMPLOYEE PIN CODE     : ");
fflush(stdin);
scanf("%ld",&a.pin);
printf("\n ENTER THE EMPLOYEE DEPARTMENT   : ");
fflush(stdin);
gets(a.department);
printf("\n ENTER THE EMPLOYEE JOIN DATE    : ");
fflush(stdin);
gets(a.joindate);
printf("\n ENTER THE EMPLOYEE DATE OF BIRTH: ");
fflush(stdin);
gets(a.dob);
printf("\n ENTER THE EMPLOYEE CATEGORY     : ");
fflush(stdin);
gets(a.category);
printf("\n ENTER THE EMPLOYEE DESIGNATION  : ");
fflush(stdin);
gets(a.designation);
printf("\n ENTER THE CURRENT MONTH LEAVE   : ");
fflush(stdin);
scanf("%d",&a.l);
printf("\n ENTER THE CURRENT MONTH LEAVE   : ");
fflush(stdin);
scanf("%d",&a.l);
printf("\n ENTER THE CURRENT YEAR   : ");
fflush(stdin);
scanf("%d",&a.year);

fflush(stdin);
fseek(ad,-214L,1);
fwrite(&a,sizeof(a),1,ad);
puts("\n\n\t  RECORDS UPDATED SUCCESSFULLY ");
getch();
fclose(ad);
mparecord();
return;
}
}
printf("\n\n\n\n\n\n\n\n\t\t\t\t INVALID EMPLOYEE NUMBER" );
fflush(stdin);
getche();
mparecord();
printline();
return;
}


pmodifyrecord()
{
FILE *ad;
char flag;
long int no;
struct add a;
ad=fopen("ppay.dat","rb+");
clrscr();
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t ENTER EMPLOYEE NUMBER: ");
scanf("%ld",&no);
while(fread(&a,sizeof(a),1,ad)!=NULL)
{
clrscr();
if(a.empno==no)
{
printline();
printf("\n NUMBER        :%ld",a.empno);
printf("\n NAME        :%s",a.empname);
printf("\n SEX\t\t       :%s",a.sex);
printf("\n ADDRESS              :%s",a.address);
printf("\n CITY                 :%s",a.city);
printf("\n PIN CODE             :%ld",a.pin);
printf("\n DEPARTMENT           :%s",a.department);
printf("\n JOIN DATE            :%s",a.joindate);
printf("\n DATE OF BIRTH        :%s",a.dob);
printf("\n CATEGORY             :%s",a.category);
printf("\n DESIGNATION          :%s",a.designation);
printf("\n CURRENT MONTH LEAVE  :%d",a.l);
printf("\n CURRENT YEAR        :%d",a.year);
getch();
fflush(stdin);
printline();
printf("\n  THE EMPLOYEE NUMBER   : ");
fflush(stdin);
scanf("%ld",&a.empno);
printf("\n ENTER THE EMPLOYEE NAME   : ");
fflush(stdin);
gets(a.empname);
printf("\n ENTER THE EMPLOYEE SEX\t\t      : ");
fflush(stdin);
gets(a.sex);
printf("\n ENTER THE EMPLOYEE ADDRESS      : ");
fflush(stdin);
gets(a.address);
printf("\n ENTER THE EMPLOYEE CITY         : ");
fflush(stdin);
gets(a.city);
printf("\n ENTER THE EMPLOYEE PIN CODE     : ");
fflush(stdin);
scanf("%ld",&a.pin);
printf("\n ENTER THE EMPLOYEE DEPARTMENT   : ");
fflush(stdin);
gets(a.department);
printf("\n ENTER THE EMPLOYEE JOIN DATE    : ");
fflush(stdin);
gets(a.joindate);
printf("\n ENTER THE EMPLOYEE DATE OF BIRTH: ");
fflush(stdin);
gets(a.dob);
printf("\n ENTER THE EMPLOYEE CATEGORY     :");
fflush(stdin);
gets(a.category);
printf("\n ENTER THE EMPLOYEE DESIGNATION  :");
fflush(stdin);
gets(a.designation);
printf("\n ENTER THE CURRENT MONTH LEAVE   :");
fflush(stdin);
scanf("%d",&a.l);
printf("\n ENTER THE CURRENT YEAR   :");
fflush(stdin);
scanf("%d",&a.l);
printf("\n ENTER THE CURRENT YEAR   :");
fflush(stdin);
scanf("%d",&a.year);

fflush(stdin);
fseek(ad,-214L,1);
fwrite(&a,sizeof(a),1,ad);
puts("\n\n\t  RECORDS UPDATED SUCCESSFULLY" );
getch();
fclose(ad);
mparecord();
return;
}
}
printline();
printf("\n\n\n\n\n\n\n\n\t\t\t\t INVALID EMPLOYEE NUMBER" );
fflush(stdin);
getche();
mparecord();
printline();
return;
}


amodifyrecord()
{
FILE *ad;
char flag;
long int no;
struct add a;
ad=fopen("apay.dat","rb+");
clrscr();
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t ENTER EMPLOYEE NUMBER   :");
scanf("%ld",&no);
while(fread(&a,sizeof(a),1,ad)!=NULL)
{
clrscr();
if(a.empno==no)
{
printline();
printf("\n NUMBER        :%ld",a.empno);
printf("\n NAME        :%s",a.empname);
printf("\n SEX\t\t       :%s",a.sex);
printf("\n ADDRESS              :%s",a.address);
printf("\n CITY                 :%s",a.city);
printf("\n PIN CODE             :%ld",a.pin);
printf("\n DEPARTMENT           :%s",a.department);
printf("\n JOIN DATE            :%s",a.joindate);
printf("\n DATE OF BIRTH        :%s",a.dob);
printf("\n CATEGORY             :%s",a.category);
printf("\n DESIGNATION          :%s",a.designation);
printf("\n CURRENT MONTH LEAVE  :%d",a.l);
printf("\n CURRENT YEAR        :%d",a.year);
getch();

fflush(stdin);
printline();

printf("\n  THE EMPLOYEE NUMBER            :");
fflush(stdin);
scanf("%ld",&a.empno);
printf("\n ENTER THE EMPLOYEE NAME    :");
fflush(stdin);
gets(a.empname);
printf("\n ENTER THE EMPLOYEE SEX\t\t       :");
fflush(stdin);
gets(a.sex);
printf("\n ENTER THE EMPLOYEE ADDRESS       :");
fflush(stdin);
gets(a.address);
printf("\n ENTER THE EMPLOYEE CITY          :");
fflush(stdin);
gets(a.city);
printf("\n ENTER THE EMPLOYEE PIN CODE      :");
fflush(stdin);
scanf("%ld",&a.pin);
printf("\n ENTER THE EMPLOYEE DEPARTMENT    :");
fflush(stdin);
gets(a.department);
printf("\n ENTER THE EMPLOYEE JOIN DATE     :");
fflush(stdin);
gets(a.joindate);
printf("\n ENTER THE EMPLOYEE DATE OF BIRTH : ");
fflush(stdin);
gets(a.dob);
printf("\n ENTER THE EMPLOYEE CATEGORY      :");
fflush(stdin);
gets(a.category);
printf("\n ENTER THE EMPLOYEE DESIGNATION   :");
fflush(stdin);
gets(a.designation);
printf("\n ENTER THE CURRENT MONTH LEAVE    :");
fflush(stdin);
scanf("%d",&a.l);
printf("\n ENTER THE CURRENT YEAR    :");
fflush(stdin);
scanf("%d",&a.year);

fflush(stdin);
fseek(ad,-214L,1);
fwrite(&a,sizeof(a),1,ad);

puts("\n\n\t  RECORDS UPDATED SUCCESSFULLY" );
getch();

fclose(ad);
mparecord();
return;
}
}
printline();
printf("\n\n\n\n\n\n\n\n\t\t\t\t INVALID EMPLOYEE NUMBER" );
fflush(stdin);
getche();
mparecord();
printline();
return;
}


mretrieverecord()
{
FILE *ad;
char flag;
struct add a;
ad=fopen("mpay.dat","rb+");
while((fread(&a,sizeof(a),1,ad))!=NULL)
{
clrscr();
printline();
printf("\n EMPLOYEE NUMBER :%ld",a.empno);
printf("\n NAME           :%s",a.empname);
printf("\n SEX\t\t       :%s",a.sex);
printf("\n ADDRESS              :%s",a.address);
printf("\n CITY                 :%s",a.city);
printf("\n PIN CODE             :%ld",a.pin);
printf("\n DEPARTMENT           :%s",a.department);
printf("\n JOIN DATE            :%s",a.joindate);
printf("\n DATE OF BIRTH        :%s",a.dob);
printf("\n CATEGORY             :%s",a.category);
printf("\n DESIGNATION          :%s",a.designation);
printf("\n MONTH LEAVE   :%d",a.l);
printf("\n CURRENT YEAR        :%d",a.year);
printline();
getch();
}
fclose(ad);
mparecord();
return;
}


pretrieverecord()
{
FILE *ad;
char flag;
struct add a;
ad=fopen("ppay.dat","rb+");
while((fread(&a,sizeof(a),1,ad))!=NULL)
{
clrscr();
printline();
printf("\n EMPLOYEE NUMBER :%ld",a.empno);
printf("\n NAME           :%s",a.empname);
printf("\n SEX\t\t       :%s",a.sex);
printf("\n ADDRESS              :%s",a.address);
printf("\n CITY                 :%s",a.city);
printf("\n PIN CODE             :%ld",a.pin);
printf("\n DEPARTMENT           :%s",a.department);
printf("\n JOIN DATE            :%s",a.joindate);
printf("\n DATE OF BIRTH        :%s",a.dob);
printf("\n CATEGORY             :%s",a.category);
printf("\n DESIGNATION          :%s",a.designation);
printf("\n MONTH LEAVE   :%d",a.l);
printf("\n CURRENT YEAR        :%d",a.year);
printline();
getch();
}
fclose(ad);
mparecord();
return;
}


aretrieverecord()
{
FILE *ad;
char flag;
struct add a;
ad=fopen("apay.dat","rb+");
while((fread(&a,sizeof(a),1,ad))!=NULL)
{
clrscr();
printline();
printf("\n EMPLOYEE NUMBER :%ld",a.empno);
printf("\n NAME           :%s",a.empname);
printf("\n SEX\t\t       :%s",a.sex);
printf("\n ADDRESS              :%s",a.address);
printf("\n CITY                 :%s",a.city);
printf("\n PIN CODE             :%ld",a.pin);
printf("\n DEPARTMENT           :%s",a.department);
printf("\n JOIN DATE            :%s",a.joindate);
printf("\n DATE OF BIRTH        :%s",a.dob);
printf("\n CATEGORY             :%s",a.category);
printf("\n DESIGNATION          :%s",a.designation);
printf("\n MONTH LEAVE   :%d",a.l);
printf("\n CURRENT YEAR        :%d",a.year);
printline();
getch();
}
fclose(ad);
mparecord();
return;
}


mdeleterecord()
{
FILE *ad,*temp;
char flag;
long int no;
struct add a;
temp=fopen("temp.dat","wb+");
ad=fopen("mpay.dat","rb+");
clrscr();
printf("\n\n\n\n\n\n\n\n\n\t\t\t\t ENTER EMPLOYEE NUMBER: ");
scanf("%ld",&no);

while((fread(&a,sizeof(a),1,ad)!=NULL))
{
if(a.empno==no)
{
clrscr();
printline();
printf("\n EMPLOYEE NUMBER :%ld",a.empno);
printf("\n NAME           :%s",a.empname);
printf("\n SEX\t\t       :%s",a.sex);
printf("\n ADDRESS              :%s",a.address);
printf("\n CITY                 :%s",a.city);
printf("\n PIN CODE             :%ld",a.pin);
printf("\n DEPARTMENT           :%s",a.department);
printf("\n JOIN DATE            :%s",a.joindate);
printf("\n DATE OF BIRTH        :%s",a.dob);
printf("\n CATEGORY             :%s",a.category);
printf("\n DESIGNATION          :%s",a.designation);
printf("\n CURRENT MONTH LEAVE  :%d",a.l);
printf("\n CURRENT YEAR        :%d",a.year);
printline();
getch();

printf("\n CONFIRM TO DELETE THIS RECORD  [Y/N]: ");
fflush(stdin);

flag=getche();
if(toupper(flag)!='Y')
{
fwrite(&a,sizeof(a),1,temp);
continue;
}
}
else
{
fwrite(&a,sizeof(a),1,temp);
}
}
remove("mpay.dat");
rename("temp.dat","mpay.dat");
remove("temp.dat");
fclose(ad);
fclose(temp);
mparecord();
return;
}


pdeleterecord()
{
FILE *ad,*temp;
char flag;
long int no;
struct add a;
temp=fopen("temp.dat","wb+");
ad=fopen("ppay.dat","rb+");

clrscr();
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t ENTER EMPLOYEE NUMBER   :");
scanf("%ld",&no);
while((fread(&a,sizeof(a),1,ad)!=NULL))
{
if(a.empno==no)
{
clrscr();
printline();
printf("\n EMPLOYEE NUMBER :%ld",a.empno);
printf("\n NAME           :%s",a.empname);
printf("\n SEX\t\t       :%s",a.sex);
printf("\n ADDRESS              :%s",a.address);
printf("\n CITY                 :%s",a.city);
printf("\n PIN CODE             :%ld",a.pin);
printf("\n DEPARTMENT           :%s",a.department);
printf("\n JOIN DATE            :%s",a.joindate);
printf("\n DATE OF BIRTH        :%s",a.dob);
printf("\n CATEGORY             :%s",a.category);
printf("\n DESIGNATION          :%s",a.designation);
printf("\n CURRENT MONTH LEAVE  :%d",a.l);
printf("\n CURRENT YEAR        :%d",a.year);
printline();
getch();

printf("\n CONFIRM TO DELETE THIS RECORD  [Y/N]: ");
fflush(stdin);

flag=getche();
if(toupper(flag)!='Y')
{
fwrite(&a,sizeof(a),1,temp);
continue;
}
}
else
{
fwrite(&a,sizeof(a),1,temp);
}
}
remove("ppay.dat");
rename("temp.dat","ppay.dat");
remove("temp.dat");
fclose(ad);
fclose(temp);
mparecord();
return;
}


adeleterecord()
{
FILE *ad,*temp;
char flag;
long int no;
struct add a;
temp=fopen("temp.dat","wb+");
ad=fopen("apay.dat","rb+");
clrscr();
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t ENTER EMPLOYEE NUMBER   :");
scanf("%ld",&no);

while((fread(&a,sizeof(a),1,ad)!=NULL))
{
if(a.empno==no)
{
clrscr();
printline();
printf("\n EMPLOYEE NUMBER :%ld",a.empno);
printf("\n NAME           :%s",a.empname);
printf("\n SEX\t\t       :%s",a.sex);
printf("\n ADDRESS              :%s",a.address);
printf("\n CITY                 :%s",a.city);
printf("\n PIN CODE             :%ld",a.pin);
printf("\n DEPARTMENT           :%s",a.department);
printf("\n JOIN DATE            :%s",a.joindate);
printf("\n DATE OF BIRTH        :%s",a.dob);
printf("\n CATEGORY             :%s",a.category);
printf("\n DESIGNATION          :%s",a.designation);
printf("\n CURRENT MONTH LEAVE  :%d",a.l);
printf("\n CURRENT YEAR        :%d",a.year);
printline();
getch();

printf("\n CONFIRM TO DELETE THIS RECORD  [Y/N]  :");
fflush(stdin);

flag=getche();
if(toupper(flag)!='Y')
{
fwrite(&a,sizeof(a),1,temp);
continue;
}
}
else
{
fwrite(&a,sizeof(a),1,temp);
}
}
remove("apay.dat");
rename("temp.dat","apay.dat");
remove("temp.dat");
fclose(ad);
fclose(temp);
mparecord();
return;
}

//-----------------MANAGEMENT STAFF REPORTS----------------------------
mreportsmenu()
{
char c;
clrscr();
printline();
printf("\n\n\n\t\t\t\t MANGEMENT STAFF REPORTS MENU ");
printline();
printf("\n\n\t\t\t\t 1...PAY SLIP");
printf("\n\n\t\t\t\t 2...PAY ROLL LEDGER");
printf("\n\n\t\t\t\t 3...PF DEDUCTION LIST");
printf("\n\n\t\t\t\t 4...LIC DEDUCTION LIST");
printf("\n\n\t\t\t\t 5...RETURN TO MAINMENU");
printf("\n\n\n\n\t\t\t\t YOUR CHOICE :");
fflush(stdin);
c=getche();
if(c=='1')
{
mlabels();
}
else if(c=='2')
{
mpayrollledger();
}
else if(c=='3')
{
mpfdeduction();
}
else if(c=='4')
{
mlicdeduction();
}
else if(c=='5')
{
rstaff();
}
return;
}
//PAY_SLIP:
mlabels()
{
FILE *ad;
struct add a;
ad=fopen("mpay.dat","rb+");
while((fread(&a,sizeof(a),1,ad))!=NULL)
{
clrscr();
printline();
printf("\n NUMBER :%ld",a.empno);
printf("\n NAME\t :%s",a.empname);
printf("\n SEX\t\t      :%s",a.sex);
printf("\n ADDRESS      :%s",a.address);
printf("\n CITY         :%s",a.city);
printf("\n PIN CODE     :%ld",a.pin);
printf("\n DEPARTMENT :%ld",a.department);
printline();
getch();
}
fclose(ad);
rstaff();
getch();
return;
}


//PAYROLL LEDGER
mpayrollledger()
{
float dud1,dud2,hhra,td1,bp,dda,sal,npay;
long int no;
int leave;
FILE *ad,*md;
struct add a;
struct managementstaff m;
ad=fopen("mpay.dat","rb+");
md=fopen("management.dat","rb+");
clrscr();
printf("\n\n\n\n\n\n\t\t\t\t ENTER EMPLOYEE NUMBER: ");
scanf("%ld",&no);
while(fread(&a,sizeof(a),1,ad)!=NULL)
{
clrscr();
if(a.empno==no)
{
printline();
printf("\n EMPLOYEE NUMBER :%ld",a.empno);
printf("\n NAME           :%s",a.empname);
printf("\n SEX\t\t         :%s",a.sex);
printf("\n ADDRESS         :%s",a.address);
printf("\n CITY            :%s",a.city);
printf("\n PIN CODE        :%ld",a.pin);
printf("\n DEPARTMENT      :%s",a.department);
printf("\n MONTH LEAVE     :%d",a.l);
leave=a.l;
printline();
fflush(stdin);
getche();

fread(&m,sizeof(m),1,md);
printline();
bp=m.basicpay;
printf("\n BASIC PAY :%.2f",m.basicpay);

dda=m.da;
printf("\n DA     :%.2f",m.da);

hhra=m.hra;
printf("\n HRA       :%.2f",m.hra);

dud1=m.pf;
printf("\n PF        :%.2f",m.pf);

leave=a.l;
printf("\n LEAVE     :%d",leave);

dud2=m.lic;
printf("\n LIC       :%.2f",m.lic);

td1=(float)dud1+dud2;
sal=(float)bp+dda+hhra;
npay=(float)sal-td1;

printf("\n\n TOTAL SALARY :%.2f",sal);
printf("\n\n TOTAL DUDUCTION     :%.2f",td1);
printf("\n TOTAL DUT FOR LEAVE   :%d",mleave(leave));
printf("\n\n NET_PAY         :%.2f",npay-(float)mleave(leave));
printline();
fflush(stdin);
getche();
}
}
fclose(ad);
fclose(md);
fflush(stdin);
getche();
mreportsmenu();
getch();
return;
}
// P_F DEDUCTION REPORT:
mpfdeduction()
{
FILE *ad;
FILE *md;
char flag;
struct add a;
struct managementstaff m;
float h;
float sal,sub1,sub2,sub3,sup1,sup2;
long int no;
ad=fopen("pay.dat","rb+");
md=fopen("management.dat","rb+");
clrscr();
printf("\n ENTER EMPLOYEE NO :");
scanf("%ld",&no);

while(fread(&a,sizeof(a),1,ad)!=NULL)
{
if(a.empno==no)
{
printline();
printf("\n EMPLOYEE NUMBER      :%ld",a.empno);
printf("\n NAME         :%s",a.empname);
printf("\n DEPARTMENT           :%s",a.department);
printf("\n JOIN DATE            :%s",a.joindate);
printf("\n CATEGORY             :%s",a.category);
fread(&m,sizeof(m),1,md);

printf("\n\n\n PF (DEDUCTION)   :%.2f",m.pf);
fflush(stdin);

getche();
fclose(ad);
fclose(md);
rstaff();
return;
}
}
fclose(ad);
fclose(md);
mreportsmenu();
getch();
return;
}

//LIC DEDUCTION REPORT:

mlicdeduction()
{
FILE *ad;
FILE *md;
char flag;
struct add a;
struct managementstaff m;
float h;
float sal,sub1,sub2,sub3,sup1,sup2;
long int no;
ad=fopen("pay.dat","rb+");
md=fopen("management.dat","rb+");
clrscr();
printf("\n ENTER EMPLOYEE NO: ");
scanf("%ld",&no);

while(fread(&a,sizeof(a),1,ad)!=NULL)
{
if(a.empno==no)
{
printline();
printf("\n EMPLOYEE NUMBER :%ld",a.empno);
printf("\n NAME           :%s",a.empname);
printf("\n DEPARTMENT           :%s",a.department);
printf("\n JOIN DATE            :%s",a.joindate);
printf("\n CATEGORY             :%s",a.category);
fread(&m,sizeof(m),1,md);

printf("\n\n\n LIC DEDUCTION        :%.2f",m.lic);

fflush(stdin);
getche();
rstaff();
return;
}
}
printline();
printf("\n\n\n\t\t\t\t INVALID EMPLOYEE NUMBER ");
fflush(stdin);
getche();
mreportsmenu();
printline();
fclose(ad);
fclose(md);
return;
}


//------------------ PERMENENT STAFF REPORTS MENU --------------------
preportsmenu()
{
char c;
clrscr();
printline();
printf("\n\n\n\t\t\t\t PERMENENT STAFF REPORTS MENU                   ");
printline();
printf("\n\n\t\t\t\t 1...PAY SLIP              ");
printf("\n\n\t\t\t\t 2...PAY ROLL LEDGER         ");
printf("\n\n\t\t\t\t 3...HOUSE RENT DEDUCTION  LIST         ");
printf("\n\n\t\t\t\t 4...PF DEDUCTION LIST       ");
printf("\n\n\t\t\t\t 5...LIC DEDUCTION LIST       ");
printf("\n\n\t\t\t\t 6...RETURN TO MAINMENU          ");
printf("\n\n\n\n\n\n\n\t\t\t\t YOUR CHOICE ?         ");
fflush(stdin);
c=getche();
if(c=='1')
{
plabels();
}
else if(c=='2')
{
ppayrollledger();
}
if(c=='3')
{
phouserentdeduction();
}
else if(c=='4')
{
ppfdeduction();
}
else if(c=='5')
{
plicdeduction();
}
else if(c=='6')
{
rstaff();
}
return;
}


plabels()
{
FILE *ad;
struct add a;
ad=fopen("ppay.dat","rb+");
while((fread(&a,sizeof(a),1,ad))!=NULL)
{
clrscr();
printline();
printf("\n NUMBER :%ld",a.empno);
printf("\n NAME\t :%s",a.empname);
printf("\n SEX\t\t      :%s",a.sex);
printf("\n ADDRESS      :%s",a.address);
printf("\n CITY         :%s",a.city);
printf("\n PIN CODE     :%ld",a.pin);
printf("\n DEPARTMENT :%ld",a.department);
printline();
getch();
}
fclose(ad);
rstaff();
getch();
return;
}

ppayrollledger()
{
int leave;
float dud1,dud2,dud3,td,bp,dda,sal,npay;
long int no;
FILE *ad,*pd;
struct add a;
struct permenentstaff p;
ad=fopen("ppay.dat","rb+");
pd=fopen("per.dat","rb+");
clrscr();
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t ENTER EMPLOYEE NUMBER   :");
scanf("%ld",&no);
while(fread(&a,sizeof(a),1,ad)!=NULL)
{
clrscr();
if(a.empno==no)
{
printline();
printf("\n EMPLOYEE NUMBER  :%ld",a.empno);
printf("\n NAME            :%s",a.empname);
printf("\n SEX\t\t      :%s",a.sex);
printf("\n ADDRESS          :%s",a.address);
printf("\n CITY             :%s",a.city);
printf("\n PIN CODE         :%ld",a.pin);
printf("\n DEPARTMENT       :%s",a.department);
leave=a.l;
printline();
fflush(stdin);
getche();
fread(&p,sizeof(p),1,pd);

printline();
bp=p.basicpay;
printf("\n BASIC PAY  :%.2f",p.basicpay);
dda=p.da;
printf("\n DA      :%.2f",p.da);
dud1=p.hrd;
printf("\n HRD        :%.2f",p.hrd);
dud2=p.pf;
printf("\n PF         :%.2f",p.pf);

printf("\n LEAVE      :%d",leave);
dud3=p.lic;
printf("\n LIC        :%.2f",p.lic);

td=(float)dud1+dud2+dud3;
sal=(float)bp+dda;
npay=(float)sal-td;

printf("\n\n TOTAL SALARY            :%.2f",sal);
printf("\n\n TOTAL DUDUCTION/t/t            :%.2f",td);
printf("\n TOTAL DEDUCTION FOR LEAVE        :%d",pleave(leave));
printf("\n\n NET_PAY/t/t            :%.2f",npay-(float)pleave(leave));
printline();
fflush(stdin);
getche();
}
}
fclose(ad);
fclose(pd);
fflush(stdin);
getche();
preportsmenu();
getch();
return;
}


phouserentdeduction()
{
FILE *ad;
FILE *md;
char flag;
struct add a;
struct permenentstaff m;
float h;
float sal,sub1,sub2,sub3,sup1,sup2;
long int no;
ad=fopen("pay.dat","rb+");
md=fopen("per.dat","rb+");
clrscr();
printf("\n ENTER EMPLOYEE NO :");
scanf("%ld",&no);

while(fread(&a,sizeof(a),1,ad)!=NULL)
{
if(a.empno==no)
{
printline();
printf("\n EMPLOYEE NUMBER :%ld",a.empno);
printf("\n NAME     :%s",a.empname);
printf("\n DEPARTMENT      :%s",a.department);
printf("\n JOIN DATE       :%s",a.joindate);
printf("\n CATEGORY        :%s",a.category);
fread(&m,sizeof(m),1,md);
printf("\n\n HRD (DEDUCTION) :%.2f",m.hrd);
fflush(stdin);
getche();
rstaff();
return;
}
}
fclose(ad);
fclose(md);
preportsmenu();
getch();
return;
}


plicdeduction()
{
FILE *ad;
FILE *md;
char flag;
struct add a;
struct permenentstaff m;
float h;
float sal,sub1,sub2,sub3,sup1,sup2;
long int no;
ad=fopen("pay.dat","rb+");
md=fopen("per.dat","rb+");
clrscr();
printf("\n ENTER EMPLOYEE NO :");
scanf("%ld",&no);

while(fread(&a,sizeof(a),1,ad)!=NULL)
{
if(a.empno==no)
{
printline();
printf("\n EMPLOYEE NUMBER      :%ld",a.empno);
printf("\n NAME        :%s",a.empname);
printf("\n DEPARTMENT           :%s",a.department);
printf("\n JOIN DATE            :%s",a.joindate);
printf("\n CATEGORY             :%s",a.category);
fread(&m,sizeof(m),1,md);

printf("\n\n LIC DEDUCTION        :%.2f",m.lic);

fflush(stdin);
getche();
rstaff();
return;
}
}
printf("\n\n\n\t\t\t\t INVALID EMPLOYEE NUMBER ");
fflush(stdin);
getche();
preportsmenu();
printline();
fclose(ad);
fclose(md);
return;
}
//PERMENENT STAFF P_F
ppfdeduction()
{
FILE *ad;
FILE *md;
char flag;
struct add a;
struct permenentstaff m;
float h;
float sal,sub1,sub2,sub3,sup1,sup2;
long int no;
ad=fopen("pay.dat","rb+");
md=fopen("per.dat","rb+");
clrscr();
printf("\n ENTER EMPLOYEE NO: ");
scanf("%ld",&no);
while(fread(&a,sizeof(a),1,ad)!=NULL)
{
if(a.empno==no)
{
printline();
printf("\n EMPLOYEE NUMBER :%ld",a.empno);
printf("\n NAME           :%s",a.empname);
printf("\n DEPARTMENT           :%s",a.department);
printf("\n JOIN DATE            :%s",a.joindate);
printf("\n CATEGORY             :%s",a.category);

fread(&m,sizeof(m),1,md);
printf("\n\n PF (DEDUCTION)       :%.2f",m.pf);
fflush(stdin);
getche();
fclose(ad);
fclose(md);
rstaff();
return;
}
}
fclose(ad);
fclose(md);
preportsmenu();
getch();
return;
}
//-------------------------- APPRENTICES STAFF REPORTS MENU ------------------------

areportsmenu()
{
char c;
clrscr();
printline();
printf("\n\n\n\t\t\t\t APPRENTICES STAFF REPORTS MENU                   ");
printline();
printf("\n\n\t\t\t\t 1...PAY SLIP              ");
printf("\n\n\t\t\t\t 2...PAY ROLL LEDGER         ");
printf("\n\n\t\t\t\t 3...RETURN TO MAINMENU          ");
printf("\n\n\n\n\n\n\n\t\t\t\t YOUR CHOICE ?         ");
fflush(stdin);
c=getche();
if(c=='1')
{
alabels();
}
else if(c=='2')
{
apayrollledger();
}
else if(c=='3')
{
rstaff();
}
return;
}

/*------------------------------------PAYSLIP--------------------------------*/
alabels()
{
FILE *ad;
struct add a;

ad=fopen("apay.dat","rb+");

while((fread(&a,sizeof(a),1,ad))!=NULL)
{
clrscr();
printline();
printf("\n NUMBER :%ld",a.empno);
printf("\n NAME\t :%s",a.empname);
printf("\n SEX\t\t      :%s",a.sex);
printf("\n ADDRESS      :%s",a.address);
printf("\n CITY         :%s",a.city);
printf("\n PIN CODE     :%ld",a.pin);
printf("\n DEPARTMENT :%ld",a.department);
printline();
getch();
}
fclose(ad);
rstaff();
getch();
return;
}

apayrollledger()
{
FILE *ad,*apd;
struct add a;
struct apprentices ap;
long int no;
int leave;
ad=fopen("apay.dat","rb+");
apd=fopen("app.dat","rb+");
clrscr();
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t ENTER EMPLOYEE NUMBER   :");
scanf("%ld",&no);
while(fread(&a,sizeof(a),1,ad)!=NULL)
{
clrscr();
if(a.empno==no)
{
printline();
printf("\n EMPLOYEE NUMBER :%ld",a.empno);
printf("\n NAME                :%s",a.empname);
printf("\n SEX\t\t       :%s",a.sex);
printf("\n ADDRESS              :%s",a.address);
printf("\n CITY                 :%s",a.city);
printf("\n PIN CODE             :%ld",a.pin);
printf("\n DEPARTMENT           :%s",a.department);
printf("\n CURRENT MONTH LEAVE :%d",a.l);
leave=a.l;
fflush(stdin);
getche();
printline();
fread(&ap,sizeof(ap),1,apd);
printline();
printf("\n\n BASIC PAY            :%.2f",ap.basicpay);
printf("\n\n DEDUCTION FOR LEAVE  :%d",aleave(leave));
printf("\n\n NET_PAY  :%.2f",ap.basicpay-(float)aleave(leave));
printline();
fflush(stdin);
getche();
}
}
fclose(ad);
fclose(apd);
fflush(stdin);
getche();
areportsmenu();
fflush(stdin);
getche();
return;
}


/* ----------------------TRANSACTION REPORT---------------------*/
/* ----------------MANAGEMENT STAFF (TRANSACTION)--------------*/
// ADD RECORD
addmrecord()
{
struct managementstaff a;
FILE *ad;
char flag;
clrscr();
ad=fopen("management.dat","w");
clrscr();

printline();
printf("\n ENTER THE BASIC PAY :");
fflush(stdin);
scanf("%f",&a.basicpay);
printf("\n ENTER THE DA        :");
fflush(stdin);
scanf("%f",&a.da);
printf("\n ENTER THE HRA        :");
fflush(stdin);
scanf("%f",&a.hra);
printf("\n ENTER THE PF         :");
fflush(stdin);
scanf("%f",&a.pf);
printf("\n ENTER THE LIC        :");
fflush(stdin);
scanf("%f",&a.lic);
printline();
fwrite(&a,sizeof(a),1,ad);
fflush(stdin);
puts("\n\n\n\t\t RECORDS  ARE SUCCESSFULLY ADDED" );
getche();
fclose(ad);
managementstaff();
return;
}


// MODIFY RECORD
modifymrecord()
{
FILE *ad;
long int no;
struct managementstaff a;
ad=fopen("management.dat","rb+");

clrscr();
printline();
printf("\n ENTER THE DA         :%.2f",a.da);
printf("\n ENTER THE HRA         :%.2f",a.hra);
printf("\n ENTER THE PF          :%.2f",a.pf);
printf("\n ENTER THE BASIC PAY   :%.2f",a.basicpay);
printf("\n ENTER THE LIC         :%.2f",a.lic);
getch();
printline();

printline();
printf("\n ENTER THE BASIC PAY:");
fflush(stdin);
scanf("%ld",&a.basicpay);
printf("\n ENTER THE DA:");
fflush(stdin);
scanf("%f",&a.da);
printf("\n ENTER THE HRA:");
fflush(stdin);
scanf("%f",&a.hra);
printf("\n ENTER THE PF:");
fflush(stdin);
scanf("%f",&a.pf);
printf("\n ENTER THE LIC:");
fflush(stdin);
scanf("%f",&a.lic);

fflush(stdin);
fseek(ad,-20L,1);
fwrite(&a,sizeof(a),1,ad);
puts("\n\n\t  RECORDS UPDATED SUCCESSFULLY");
getch();
fclose(ad);

fflush(stdin);
getche();
managementstaff();
printline();
return;
}

// VIEW RECORD
retrievemrecord()
{
FILE *ad;
char flag;
struct managementstaff a;
ad=fopen("management.dat","rb+");
clrscr();

while((fread(&a,sizeof(a),1,ad))!=NULL)
{
clrscr();
printline();
printf("\n ENTER THE DA        :%.2f",a.da);
printf("\n ENTER THE HRA        :%.2f",a.hra);
printf("\n ENTER THE PF         :%.2f",a.pf);
printf("\n ENTER THE BASIC PAY  :%.2f",a.basicpay);
printf("\n ENTER THE LIC        :%.2f",a.lic);
getch();
printline();
getch();
}
fclose(ad);
managementstaff();
return;
}


//--------------------------PERMANENT STAFF (TRANSACTION)----------------
// ADD RECORD
addprecord()
{
struct permenentstaff a;
FILE *ad;
char flag;
clrscr();
ad=fopen("per.dat","w");
clrscr();
printline();
printf("\n BASIC PAY       :");
fflush(stdin);
scanf("%f",&a.basicpay);
printf("\n ENTER THE DA   :");
fflush(stdin);
scanf("%f",&a.da);
printf("\n ENTER THE HRD   :");
fflush(stdin);
scanf("%f",&a.hrd);
printf("\n ENTER THE PF    :");
fflush(stdin);
scanf("%f",&a.pf);
printf("\n ENTER THE LIC   :");
fflush(stdin);
scanf("%f",&a.lic);
fwrite(&a,sizeof(a),1,ad);
fflush(stdin);
puts("\n\n\n\t\t RECORDS ARE SUCCESSFULLY ADDED" );
getche();
fclose(ad);
permenentstaff();
return;
}

// MODIFY RECORD
modifyprecord()
{
FILE *ad;
struct permenentstaff a;
ad=fopen("per.dat","rb+");

clrscr();
printline();
printf("\n BASIC PAY     :%.2f",a.basicpay);
printf("\n DA   :%.2f",a.da);
printf("\n HRD :%.2f",a.hrd);
printf("\n PF   :%.2f",a.pf);
printf("\n LIC :%.2f",a.lic);
printline();

fflush(stdin);
getche();
printline();
printf("\n BASIC PAY    :");
fflush(stdin);
scanf("%f",&a.basicpay);
printf("\n ENTER THE DA :");
fflush(stdin);
scanf("%f",&a.da);
printf("\n ENTER THE HRD:");
fflush(stdin);
scanf("%f",&a.hrd);
printf("\n ENTER THE PF :");
fflush(stdin);
scanf("%f",&a.pf);
printf("\n ENTER THE LIC:");
fflush(stdin);
scanf("%f",&a.lic);
fflush(stdin);
fseek(ad,-20L,1);
fwrite(&a,sizeof(a),1,ad);
puts("\n\n\t  RECORDS UPDATED SUCCESSFULLY" );
fflush(stdin);
getche();
fclose(ad);
permenentstaff();
return;
}

// VIEW RECORD
retrieveprecord()
{
FILE *ad;
char flag;
struct permenentstaff a;
ad=fopen("per.dat","rb+");
clrscr();

while((fread(&a,sizeof(a),1,ad))!=NULL)
{
clrscr();
printline();
printf("\n BASIC PAY       :%.2f",a.basicpay);
printf("\n ENTER THE DA   :%.2f",a.da);
printf("\n ENTER THE HRD   :%.2f",a.hrd);
printf("\n ENTER THE PF    :%.2f",a.pf);
printf("\n ENTER THE LIC   :%.2f",a.lic);
printline();
getch();
}
fclose(ad);
permenentstaff();
return;
}

/*--------------------APPRENTICE STAFF (TRANSACTION)-------------*/
//ADD RECORD
addarecord()
{
struct apprentices a;
FILE *ad;
char flag;
clrscr();
ad=fopen("app.dat","w");
clrscr();
printline();
printf("\n BASIC PAY    :");
fflush(stdin);
scanf("%f",&a.basicpay);
fwrite(&a,sizeof(a),1,ad);
fflush(stdin);

puts("\n\n\n\t\t RECORDS  ARE SUCCESSFULLY ADDED" );
getche();

fclose(ad);
apprenticesstaff();
return;
}
//MODIFY RECORD
modifyarecord()
{
FILE *ad;
struct apprentices a;
ad=fopen("app.dat","rb+");

clrscr();
printline();
printf("\n BASIC PAY       :%.2f",a.basicpay);
getch();
fflush(stdin);
printline();
printf("\n ENTER BASIC PAY :");
fflush(stdin);
scanf("%f",&a.basicpay);
fflush(stdin);

fseek(ad,-4L,1);
fwrite(&a,sizeof(a),1,ad);
puts("\n\n\t  RECORDS UPDATED SUCCESSFULLY" );
getch();

fclose(ad);
apprenticesstaff();
return;
}

// VIEW RECORD
retrievearecord()
{
FILE *ad;
char flag;
struct apprentices a;
ad=fopen("app.dat","rb+");
clrscr();

while((fread(&a,sizeof(a),1,ad))!=NULL)
{
clrscr();
printf("\n\n\n\n\n\n\n\n\n\n\n");
printline();
printf("\n BASIC PAY      :%.2f",a.basicpay);
printline();
getch();
}
fclose(ad);
apprenticesstaff();
return;
}

//-----------------------CALCULATION LEAVE-------------------
//MANAGEMENT STAFF:
int mleave(int a)
{
static int leave;
switch(a)
{
case 1:
leave=33;
break;
case 2:
leave=66;
break;
case 3:
leave=99;
break;
case 4:
leave=132;
break;
case 5:
leave=165;
break;
case 6:
leave=198;
break;
case 7:
leave=231;
break;
case 8:
leave=264;
break;
case 9:
leave=1;
break;
case 10:
leave=1;
break;
case 11:
leave=1;
break;
case 12:
leave=1;
break;
case 13:
leave=1;
break;
case 14:
leave=1;
break;
case 15:
leave=1;
break;
case 16:
leave=1;
break;
case 17:
leave=1;
break;
case 18:
leave=1;
break;
case 19:
leave=1;
break;
case 20:
leave=1;
break;
case 21:
leave=1;
break;
case 22:
leave=1;
break;
case 23:
leave=1;
break;
case 24:
leave=1;
break;
case 25:
leave=1;
break;
case 26:
leave=1;
break;
case 27:
leave=1;
break;
case 28:
leave=1;
break;
case 29:
leave=1;
break;
case 30:
leave=1;
break;
case 31:
leave=1;
break;
}
return leave;
}


//PERMANENT STAFF:
int pleave(int a)
{
static int leave;
switch(a)
{
case 1:
leave=33;
break;
case 2:
leave=66;
break;
case 3:
leave=99;
break;
case 4:
leave=132;
break;
case 5:
leave=165;
break;
case 6:
leave=198;
break;
case 7:
leave=231;
break;
case 8:
leave=264;
break;
case 9:
leave=1;
break;
case 10:
leave=1;
break;
case 11:
leave=1;
break;
case 12:
leave=1;
break;
case 13:
leave=1;
break;
case 14:
leave=1;
break;
case 15:
leave=1;
break;
case 16:
leave=1;
break;
case 17:
leave=1;
break;
case 18:
leave=1;
break;
case 19:
leave=1;
break;
case 20:
leave=1;
break;
case 21:
leave=1;
break;
case 22:
leave=1;
break;
case 23:
leave=1;
break;
case 24:
leave=1;
break;
case 25:
leave=1;
break;
case 26:
leave=1;
break;
case 27:
leave=1;
break;
case 28:
leave=1;
break;
case 29:
leave=1;
break;
case 30:
leave=1;
break;
case 31:
leave=1;
break;
}
return leave;
}
// APPRENTICES STAFF:
int aleave(int a)
{
static int leave;
switch(a)
{
case 1:
leave=18;
break;
case 2:
leave=1;
break;
case 3:
leave=1;
break;
case 4:
leave=1;
break;
case 5:
leave=1;
break;
case 6:
leave=1;
break;
case 7:
leave=1;
break;
case 8:
leave=1;
break;
case 9:
leave=1;
break;
case 10:
leave=1;
break;
case 11:
leave=1;
break;
case 12:
leave=1;
break;
case 13:
leave=1;
break;
case 14:
leave=1;
break;
case 15:
leave=1;
break;
case 16:
leave=1;
break;
case 17:
leave=1;
break;
case 18:
leave=1;
break;
case 19:
leave=1;
break;
case 20:
leave=1;
break;
case 21:
leave=1;
break;
case 22:
leave=1;
break;
case 23:
leave=1;
break;
case 24:
leave=1;
break;
case 25:
leave=1;
break;
case 26:
leave=1;
break;
case 27:
leave=1;
break;
case 28:
leave=1;
break;
case 29:
leave=1;
break;
case 30:
leave=1;
break;
case 31:
leave=1;
break;
}
return leave;
}

No comments:

Post a Comment