Payroll Management system project
//Project on Pay Roll System#include<stdio.h>
///for input output functions like printf, scanf
#include<stdlib.h>#include<conio.h>)
#include<string.h>
#include<dos.h>
#include<graphics.h> ///string operations
#include<conio.h>
#include<iostream.h>
#include<fstream.h>
class banner
{
char *str,ch;
public: banner()
{
str="program to text animation……….";
}
void alternate();
};
void banner::alternate()
{
int i,j,flag=0,c1=10;
strcpy(str,"PROJECT WORK");
for(i=0;!kbhit();i++)
{
//cleardevice();
/********for clearing part of the screen by drawing lines*/
setfillstyle(SOLID_FILL,BLACK);
bar(50,200,700,400);
//////multicolor banner
if(ch==14)
c1=10;
else c1++;
setcolor(c1);
//////
settextstyle(TRIPLEX_FONT,HORIZ_DIR,8);
if(flag==0)
{
i++;
if(i==200)
flag=1;
}
else
{
i--;
if(i==0)
flag=0;
}
outtextxy(50+i,200,str);
delay(3);
}
}
void main()
{
int gd=DETECT,gm;
banner obj;
initgraph(&gd,&gm,"c://TC//BGI");
obj.alternate();
closegraph();
clrscr();
int gdriver=DETECT,gmode,i,j,location,n,c1=10;
char *str,ch;
initgraph(&gdriver,&gmode,"C://TC//BGI");
setcolor(MAGENTA);
setcolor(YELLOW);
setfillstyle(SOLID_FILL,BLUE);
floodfill(50,100,BLUE);
rectangle(10,10,630,470);
settextstyle(7,0,6);
setcolor(WHITE);
outtextxy(20,40,"*******************");
setcolor(WHITE);
outtextxy(160,100,"WELCOME");
setcolor(RED);
outtextxy(230,180,"IN");
setcolor(WHITE);
outtextxy(200,250,"THE");
setcolor(RED);
outtextxy(10,330,"w.w.w onlinestudy.xyz");
setcolor(WHITE); outtextxy(100,430,"*********************");
sleep(3); clearviewport();
setcolor(BLACK); setcolor(YELLOW);
circle(300,280,280); settextstyle(7,0,6);
outtextxy(150,100,"MADE BY");
outtextxy(30,180,"OnlineStudy");
settextstyle(7,0,6);
for(i=0;!kbhit();i++)
setfillstyle(SOLID_FILL,BLACK);
bar(10,20,100,20);
if(ch==14) c1=10;
else
c1++;
setcolor(c1);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);
outtextxy(100,300,str);
delay(350);
ch=str[0];
n=strlen(str);
location=0;
for(j=location;j<n;j++)
{
str[j]=str[j+1];
}
str[n-1]=ch;
str[n]=NULL;
sleep(3);
clearviewport();
setcolor(BLACK);
setcolor(BLUE);
rectangle(8,8,630,470);
setcolor(BLUE);
settextstyle(7,0,6);
outtextxy(100,80,"WELCOME");
outtextxy(200,150,"TO");
outtextxy(300,200,"PAYROLL");
outtextxy(380,300,"SYSTEM");
sleep(3);
clearviewport();
/** structure that represent a employee */
struct emp
{
char name[20],des[20];
int co,sal;
float tax,hra,gr,da,np;
};
struct emp e;
/// structure variable creation
FILE *fp,*ft;
char choice,another;
fstream pay;
char empname[40];
/// string to store name of the employee
long int recsize;
/// size of each record of employee
/** open the file in binary read and write mode * if the file STU.DAT already exists then it open that file in read write mode * if the file doesn’t exit it simply create a new copy */
fp = fopen("EMP.DAT","rb+");
if(fp == NULL)
{
fp = fopen("emp.DAT","wb+");
if(fp == NULL)
{
printf("Connot open file");
exit(1);
}
}
/// sizeo of each record i.e. size of structure variable e
recsize = sizeof(e);
/// infinite loop continues untile the break statement encounter
while(1)
{
system("cls");
///clear the console window
gotoxy(30,10);
/// move the cursor to postion 30, 10 from top-left corner
printf("1. Add Record");
/// option for add record
gotoxy(30,12);
printf("2. List Records");
/// option for showing existing record
gotoxy(30,14);
printf("3. Modify Records");
/// option for editing record
gotoxy(30,16);
printf("4. Delete Records");
/// option for deleting record
gotoxy(30,18);
printf("5. Search Record");
/// option for search record
gotoxy(30,20);
printf("6. Exit");
/// exit from the program
gotoxy(30,22);
printf("Your Choice: ");
/// enter the choice 1, 2, 3, 4, 5
fflush(stdin);
/// flush the input buffer
choice = getche();
/// get the input from keyboard
switch(choice)
{
case '1':
/// if user press 1
system("cls");
int ch;
fseek(fp,0,SEEK_END);
/// search the file and move cursor to end of the file
/// here 0 indicates moving 0 distance from the end of the file
another = 'y';
while(another == 'y')
{
/// if user want to add another record printf(“\nEnter Name: “);
scanf("%s",e.name);
printf("\nEnter Code: ");
scanf("%d", &e.co);
printf("\nEnter Designation: ");
int ch;
printf("\n1.SUBSTAFF");
printf("\n2.CLERK");
printf("\n3.MANAGER");
printf("\n ENTER YOUR CHOICE:(1/2/3)");
scanf("%d",&ch);
switch(ch)
{
case 1: e.sal=1000;
e.hra=100;
e.da=e.sal*1.10;
e.tax=2*(e.sal)/100.0;
strcpy(e.des,"SUBSTAFF");
break;
case 2: e.sal=2000;
e.hra=200;
e.da=200;
e.tax=10*(e.sal)/100.0;
strcpy(e.des,"CLERK");
break;
case 3: e.sal=14000;
e.hra=400;
e.da=400;
e.tax=20*(e.sal)/100.0;
strcpy(e.des,"MANAGER");
break;
default:cout<<"\n INPUT IS INVALID";
break;
}
e.gr=e.sal+e.hra+e.da;
e.np=e.gr-e.tax;
pay.write((char*)&e,sizeof(e));
fwrite(&e,recsize,1,fp);
/// write the record in the file
printf("\nAdd another record(y/n) ");
fflush(stdin);
another = getche();
}
break;
case '2': system("cls");
rewind(fp);
///this moves file cursor to start of the file printf(“EMPLOYEE LIST");
while(fread(&e,recsize,1,fp)==1)
{
/// read the file and fetch the record one record per fetch
//printf(“\nname=%s\nco=%d \npost=%s \nsalary=%d \nDearness Allowance=%f \nHouse rent allowance=%f \n gross pay=%f\n \ntax=%f \nNetpay=%f",e.name,e.co,e.des,e.sal,e.da,e.hra,e.tax,e.np);
//0R
cout<<"\n*********************************************";
cout<<"\n RAHUL ENTERPRISES ";
cout<<"\n*********************************************";
cout<<"\nEMPLOYEE NAME :"<<e.name;
cout<<"\nCODE OF EMPLOYEE :"<<e.co;
cout<<"\nEMPLOYEE DESIGNATION :"<<e.des;
cout<<"\nBASIC SALARY :"<< e.sal;
cout<<"\nDEARNESS ALLOWANCE :"<<e.da;
cout<<"\nHOUSE RENT ALLOWANCE :"<<e.hra;
cout<<"\nGROSS PAY :"<<e.gr;
cout<<"\nTAX :"<<e.tax;
cout<<"\nNET PAY :"<<e.np;
cout<<"\n*********************************************";
}
getch();
break;
case '3':
/// if user press 3 then do editing existing record
system("cls");
another = 'y';
while(another == 'y')
{
printf("Enter the student name to modify: ");
scanf("%s", empname);
rewind(fp);
while(fread(&e,recsize,1,fp)==1)
{
/// fetch all record from file
if(strcmp(e.name,empname) == 0)
{
///if entered name matches with that in file printf(“\nEnter new entery “);
printf("\n enter employee name=");
scanf("%s",&e.name);
printf("enter employee code=");
scanf("%d",&e.co);
printf("\nEnter Designation: ");
int ch;
printf("\n1.SUBSTAFF");
printf("\n2.CLERK");
printf("\n3.MANAGER");
printf("\n ENTER YOUR CHOICE:(1/2/3)");
scanf("%d",&ch);
switch(ch)
{
case 1: e.sal=1000;
e.hra=100;
e.da=e.sal*1.10;
e.tax=2*(e.sal)/100.0;
strcpy(e.des,"SUBSTAFF");
break;
case 2:
e.sal=2000;
e.hra=200;
e.da=200;
e.tax=10*(e.sal)/100.0;
strcpy(e.des,"CLERK");
break;
case 3:
e.sal=14000;
e.hra=400;
e.da=400;
e.tax=20*(e.sal)/100.0;
strcpy(e.des,"MANAGER");
break;
default:cout<<"\n INPUT IS INVALID"; break;
}
e.gr=e.sal+e.hra+e.da;
e.np=e.gr-e.tax;
pay.write((char*)&e,sizeof(e));
//
fwrite(&e,recsize,1,fp);
/// write the record in the file
fseek(fp,-recsize,SEEK_CUR);
/// move the cursor 1 step back from current position
fwrite(&e,recsize,1,fp);
/// override the record break;
}
}
printf("\nModify another record(y/n)");
fflush(stdin);
another = getche();
} break;
case '4':
system("cls");
another = 'y';
while(another == 'y')
{
printf("\nEnter name of employee to delete: ");
scanf("%s",empname);
ft = fopen("Temp.dat","wb");
/// create a intermediate file for temporary storage
rewind(fp);
/// move record to starting of file
while(fread(&e,recsize,1,fp) == 1)
{
/// read all records from file
if(strcmp(e.name,empname) != 0)
{
/// if the entered record match
fwrite(&e,recsize,1,ft);
/// move all records except the one that is to be deleted to temp file
}
}
fclose(fp);
fclose(ft);
remove("EMP.DAT");
/// remove the orginal file rename(“Temp.dat","EMP.DAT");
/// rename the temp file to original file name
fp = fopen("EMP.DAT", "rb+");
printf("Delete another record(y/n)");
fflush(stdin);
another = getche();
} break;
case '5': cleardevice();
int eno,flag=0;
cout<<"\n Enter employee number to be searched :";
cin>>eno;
pay.open("emp.dat",ios::in);
if(!pay)
{
cout<<"\n\nFile Not Found..\nProgram Terminated!";
exit(0);
} pay.seekg(0);
while(!pay.eof())
{
pay.read((char*)&e,sizeof(e));
if(!pay.eof())
{
if(e.co==eno)
{
printf("\n*********************************************");
printf("\n RAHUL ENTERPRISES ");
printf("\n*********************************************");
cout<<"\nEMPLOYEE NAME :"<<e.name;
cout<<"\nCODE OF EMPLOYEE :"<<e.co;
cout<<"\nEMPLOYEE DESIGNATION :"<<e.des;
cout<<"\nBASIC SALARY :"<< e.sal;
cout<<"\nDEARNESS ALLOWANCE :"<<e.da;
cout<<"\nHOUSE RENT ALLOWANCE :"<<e.hra;
cout<<"\nGROSS PAY :"<<e.gr;
cout<<"\nTAX :"<<e.tax;
cout<<"\nNET PAY :"<<e.np;
printf("\n*********************************************");
flag=1;
getch();
break;
}
}
}
if(flag==0)
{
cleardevice();
cout<<"\n\n\n\n\n\n\t\t\tNo such employee";
getch();
}
cleardevice();
pay.close();
break;
case '6': fclose(fp);
/// close the file
exit(0);
/// exit from the program
}
}
}
Output
Request: - Be sure to share it with your friends and ask them any questions you can through the comments. Thank you.
advanced c project ideas, database project for bca, bca project topics in vb, bca project documentation, 1000 projects in c with source code, practical c projects, innovative c projects, c industrial projects,
No comments:
Post a Comment