#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<graphics.h>
struct emp
{
char eid[30];
char ename[30];
char egen[10];
char edoj[20];
char edes[30];
char eday[30];
char ecom[30];
char ebac[30];
char eext[30];
};
void main()
{
int gd=DETECT,gm;
clrscr();
initgraph(&gd,&gm,"");
outtextxy(430,0,"");
setcolor(RED);
settextstyle(1,0,6);
outtextxy(60,20,"EMPLOYEE DATABASE");
setcolor(YELLOW);
outtextxy(50,120,"MANAGEMENT SYSTEM");
setcolor(WHITE);
outtextxy(130,220,"(DAILY REPORT)");
setcolor(LIGHTCYAN);
settextstyle(1,0,4);
outtextxy(50,320,"DEVELOPED BY--->>>");
setcolor(BLUE);
outtextxy(300,400,"R.N.Patel");
getche();
closegraph();
menu();
getche();
}
menu()
{
int i,ch;
clrscr();
textcolor(GREEN);
for(i=1;i<=79;i++)
{
gotoxy(i,1);
printf("*");
gotoxy(i,25);
printf("*");
}
for(i=1;i<=24;i++)
{
gotoxy(1,i);
printf("*");
gotoxy(79,i);
printf("*");
}
for(i=25;i<=55;i++)
{
gotoxy(i,5);
printf("*");
gotoxy(i,20);
printf("*");
}
for(i=5;i<=20;i++)
{
gotoxy(25,i);
printf("*");
gotoxy(55,i);
printf("*");
}
gotoxy(34,6);
printf("# MAIN MENU #");
gotoxy(30,8);
printf("1. ADD NEW EMPLOYEE");
gotoxy(30,10);
printf("2. LIST OF EMPLOYEE");
gotoxy(30,12);
printf("3. DELETE A EMPLOYEE");
gotoxy(30,14);
printf("4. DAILY REPORT");
gotoxy(30,16);
printf("5. EXIT");
gotoxy(28,18);
printf("Enter Your Choice: ");
scanf("%d",&ch);
switch(ch)
{
case 1: add_emp(); break;
case 2: list_emp(); break;
case 3: delete_emp(); break;
case 4: daily(); break;
case 5: exit(0); break;
default:
gotoxy(30,19);
printf("WRONG CHOICE!!!");
getch();
clrscr();
menu();
}
return;
}
add_emp()
{
struct emp e;
char ch;
FILE *fp;
clrscr();
printf("\t\t\t# Employee Registration Form #\n\n");
printf("Enter Employee ID: ");
scanf("%s",e.eid);
fflush(stdin);
printf("Enter Employee Name: ");
scanf("%s",e.ename);
fflush(stdin);
printf("Enter Employee Gender (M/F): ");
scanf("%s",e.egen);
fflush(stdin);
printf("Enter Date Of Joining: ");
scanf("%s",e.edoj);
fflush(stdin);
printf("Enter Employee Designation: ");
scanf("%s",e.edes);
fflush(stdin);
printf("\n-------------------------------------------------------------------------");
printf("Enter Today's Date: ");
scanf("%s",e.eday);
fflush(stdin);
printf("Enter Coming Time of Employee: ");
scanf("%s",e.ecom);
fflush(stdin);
printf("Enter Going Time of Employee: ");
scanf("%s",e.ebac);
fflush(stdin);
printf("Enter Extra Hours of Working: ");
scanf("%s",e.eext);
fflush(stdin);
printf("Do You Want to Save This Record (y/n): ");
scanf("%c",&ch);
if(ch=='Y'||ch=='y')
{
fp=fopen("EMP.TXT","ab+");
if(fp==NULL)
{
printf("Error in File Opening");
return;
}
fwrite(&e,sizeof(e),1,fp);
printf("RECORD ADDED SUCCESSFULLY");
fclose(fp);
}
getche();
menu();
return;
}
list_emp()
{
struct emp e;
int i=0,j=0;
FILE *fp;
clrscr();
printf("\t\t\t# LIST OF EMPLOYEES #\n");
printf("-------------------------------------------------------------------------------\n");
printf(" ID\t\tNAME\t\tGENDER\t\tDOJ\t\tDESIGNATION\n");
printf("-------------------------------------------------------------------------------\n");
fp=fopen("EMP.TXT","rb");
if(fp==NULL)
{
printf("Error in File Opening");
return;
}
while(!feof(fp))
{
fread(&e,sizeof(e),1,fp);
i++;
}
if(i==1)
{
printf("No Record is Found");
}
rewind(fp);
while(!feof(fp))
{
fread(&e,sizeof(e),1,fp);
printf("%s\t\t%s\t\t%s\t\t%s\t\t%s\n",e.eid,e.ename,e.egen,e.edoj,e.edes);
j++;
if(j==i-1)
break;
}
getche();
menu();
return;
}
delete_emp()
{
int i=0,j=0,k;
struct emp e;
char id[30];
FILE *fp,*temp;
clrscr();
printf("\t\t\t # DELETION OF A EMPLOYEE #\n");
printf("-------------------------------------------------------------------------------\n");
printf(" ID\t\tNAME\t\tGENDER\t\tDOJ\t\tDESIGNATION\n");
printf("-------------------------------------------------------------------------------\n");
fp=fopen("EMP.TXT","rb");
if(fp==NULL)
{
printf("Error in File Opening");
return;
}
while(!feof(fp))
{
fread(&e,sizeof(e),1,fp);
i++;
}
rewind(fp);
while(!feof(fp))
{
fread(&e,sizeof(e),1,fp);
printf("%s\t\t%s\t\t%s\t\t%s\t\t%s\n",e.eid,e.ename,e.egen,e.edoj,e.edes);
j++;
if(j==i-1)
break;
}
printf("\n");
printf("Enter Employee ID For Deleting: ");
scanf("%s",id);
rewind(fp);
temp=fopen("EMP1.TXT","wb");
j=0;
k=0;
while(!feof(fp))
{
fread(&e,sizeof(e),1,fp);
if(strcmp(e.eid,id)==0)
{
k=1;
}
else
{
fwrite(&e,sizeof(e),1,temp);
}
j++;
if(j==i-1)
break;
}
if(k==0)
{
printf("No Record Found");
return;
}
remove("EMP.TXT");
rename("EMP1.TXT","EMP.TXT");
printf("Record Deleted Successfully");
getche();
menu();
return;
}
daily()
{
char id[30];
int k=0;
struct emp e;
FILE *fp;
clrscr();
printf("Enter Employee ID for See Daily Report: ");
scanf("%s",id);
printf("===============================================\n");
fp=fopen("EMP.TXT","rb");
while(!feof(fp))
{
fread(&e,sizeof(e),1,fp);
if(strcmp(e.eid,id)==0)
{
printf("ID: %s",e.eid);
printf("\nName: %s",e.ename);
printf("\nGender: %s",e.egen);
printf("\nDate Of Joining: %s",e.edoj);
printf("\nDesignation: %s",e.edes);
printf("\n-------------------------------------------------------------------------");
printf("\nToday's Date: %s",e.eday);
printf("\nComing Time: %s",e.ecom);
printf("\nGoing Time: %s",e.ebac);
printf("\nExtra Hours: %s",e.eext);
k=1;
break;
}
}
if(k==0)
printf("No Record Found");
return;
}
#include<conio.h>
#include<string.h>
#include<graphics.h>
struct emp
{
char eid[30];
char ename[30];
char egen[10];
char edoj[20];
char edes[30];
char eday[30];
char ecom[30];
char ebac[30];
char eext[30];
};
void main()
{
int gd=DETECT,gm;
clrscr();
initgraph(&gd,&gm,"");
outtextxy(430,0,"
setcolor(RED);
settextstyle(1,0,6);
outtextxy(60,20,"EMPLOYEE DATABASE");
setcolor(YELLOW);
outtextxy(50,120,"MANAGEMENT SYSTEM");
setcolor(WHITE);
outtextxy(130,220,"(DAILY REPORT)");
setcolor(LIGHTCYAN);
settextstyle(1,0,4);
outtextxy(50,320,"DEVELOPED BY--->>>");
setcolor(BLUE);
outtextxy(300,400,"R.N.Patel");
getche();
closegraph();
menu();
getche();
}
menu()
{
int i,ch;
clrscr();
textcolor(GREEN);
for(i=1;i<=79;i++)
{
gotoxy(i,1);
printf("*");
gotoxy(i,25);
printf("*");
}
for(i=1;i<=24;i++)
{
gotoxy(1,i);
printf("*");
gotoxy(79,i);
printf("*");
}
for(i=25;i<=55;i++)
{
gotoxy(i,5);
printf("*");
gotoxy(i,20);
printf("*");
}
for(i=5;i<=20;i++)
{
gotoxy(25,i);
printf("*");
gotoxy(55,i);
printf("*");
}
gotoxy(34,6);
printf("# MAIN MENU #");
gotoxy(30,8);
printf("1. ADD NEW EMPLOYEE");
gotoxy(30,10);
printf("2. LIST OF EMPLOYEE");
gotoxy(30,12);
printf("3. DELETE A EMPLOYEE");
gotoxy(30,14);
printf("4. DAILY REPORT");
gotoxy(30,16);
printf("5. EXIT");
gotoxy(28,18);
printf("Enter Your Choice: ");
scanf("%d",&ch);
switch(ch)
{
case 1: add_emp(); break;
case 2: list_emp(); break;
case 3: delete_emp(); break;
case 4: daily(); break;
case 5: exit(0); break;
default:
gotoxy(30,19);
printf("WRONG CHOICE!!!");
getch();
clrscr();
menu();
}
return;
}
add_emp()
{
struct emp e;
char ch;
FILE *fp;
clrscr();
printf("\t\t\t# Employee Registration Form #\n\n");
printf("Enter Employee ID: ");
scanf("%s",e.eid);
fflush(stdin);
printf("Enter Employee Name: ");
scanf("%s",e.ename);
fflush(stdin);
printf("Enter Employee Gender (M/F): ");
scanf("%s",e.egen);
fflush(stdin);
printf("Enter Date Of Joining: ");
scanf("%s",e.edoj);
fflush(stdin);
printf("Enter Employee Designation: ");
scanf("%s",e.edes);
fflush(stdin);
printf("\n-------------------------------------------------------------------------");
printf("Enter Today's Date: ");
scanf("%s",e.eday);
fflush(stdin);
printf("Enter Coming Time of Employee: ");
scanf("%s",e.ecom);
fflush(stdin);
printf("Enter Going Time of Employee: ");
scanf("%s",e.ebac);
fflush(stdin);
printf("Enter Extra Hours of Working: ");
scanf("%s",e.eext);
fflush(stdin);
printf("Do You Want to Save This Record (y/n): ");
scanf("%c",&ch);
if(ch=='Y'||ch=='y')
{
fp=fopen("EMP.TXT","ab+");
if(fp==NULL)
{
printf("Error in File Opening");
return;
}
fwrite(&e,sizeof(e),1,fp);
printf("RECORD ADDED SUCCESSFULLY");
fclose(fp);
}
getche();
menu();
return;
}
list_emp()
{
struct emp e;
int i=0,j=0;
FILE *fp;
clrscr();
printf("\t\t\t# LIST OF EMPLOYEES #\n");
printf("-------------------------------------------------------------------------------\n");
printf(" ID\t\tNAME\t\tGENDER\t\tDOJ\t\tDESIGNATION\n");
printf("-------------------------------------------------------------------------------\n");
fp=fopen("EMP.TXT","rb");
if(fp==NULL)
{
printf("Error in File Opening");
return;
}
while(!feof(fp))
{
fread(&e,sizeof(e),1,fp);
i++;
}
if(i==1)
{
printf("No Record is Found");
}
rewind(fp);
while(!feof(fp))
{
fread(&e,sizeof(e),1,fp);
printf("%s\t\t%s\t\t%s\t\t%s\t\t%s\n",e.eid,e.ename,e.egen,e.edoj,e.edes);
j++;
if(j==i-1)
break;
}
getche();
menu();
return;
}
delete_emp()
{
int i=0,j=0,k;
struct emp e;
char id[30];
FILE *fp,*temp;
clrscr();
printf("\t\t\t # DELETION OF A EMPLOYEE #\n");
printf("-------------------------------------------------------------------------------\n");
printf(" ID\t\tNAME\t\tGENDER\t\tDOJ\t\tDESIGNATION\n");
printf("-------------------------------------------------------------------------------\n");
fp=fopen("EMP.TXT","rb");
if(fp==NULL)
{
printf("Error in File Opening");
return;
}
while(!feof(fp))
{
fread(&e,sizeof(e),1,fp);
i++;
}
rewind(fp);
while(!feof(fp))
{
fread(&e,sizeof(e),1,fp);
printf("%s\t\t%s\t\t%s\t\t%s\t\t%s\n",e.eid,e.ename,e.egen,e.edoj,e.edes);
j++;
if(j==i-1)
break;
}
printf("\n");
printf("Enter Employee ID For Deleting: ");
scanf("%s",id);
rewind(fp);
temp=fopen("EMP1.TXT","wb");
j=0;
k=0;
while(!feof(fp))
{
fread(&e,sizeof(e),1,fp);
if(strcmp(e.eid,id)==0)
{
k=1;
}
else
{
fwrite(&e,sizeof(e),1,temp);
}
j++;
if(j==i-1)
break;
}
if(k==0)
{
printf("No Record Found");
return;
}
remove("EMP.TXT");
rename("EMP1.TXT","EMP.TXT");
printf("Record Deleted Successfully");
getche();
menu();
return;
}
daily()
{
char id[30];
int k=0;
struct emp e;
FILE *fp;
clrscr();
printf("Enter Employee ID for See Daily Report: ");
scanf("%s",id);
printf("===============================================\n");
fp=fopen("EMP.TXT","rb");
while(!feof(fp))
{
fread(&e,sizeof(e),1,fp);
if(strcmp(e.eid,id)==0)
{
printf("ID: %s",e.eid);
printf("\nName: %s",e.ename);
printf("\nGender: %s",e.egen);
printf("\nDate Of Joining: %s",e.edoj);
printf("\nDesignation: %s",e.edes);
printf("\n-------------------------------------------------------------------------");
printf("\nToday's Date: %s",e.eday);
printf("\nComing Time: %s",e.ecom);
printf("\nGoing Time: %s",e.ebac);
printf("\nExtra Hours: %s",e.eext);
k=1;
break;
}
}
if(k==0)
printf("No Record Found");
return;
}
No comments:
Post a Comment