Page

Faculty Information Management System in C/C++

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<math.h>
#include<dos.h>
struct address
{
 int hno;
 int streetno;
 char city[15];
 char state[15];
 char country[15];
};
struct work_details
{
 char fid[5];
 char dept[15];
 char desig[15];
 float basic;
};
struct gen_details
{
 char fid[5];
 char name[25];
 struct address present_add;
 struct address permanent_add;
};
struct payroll{
 char fid[5];
 float TA;
 float DA;
 float HRA;
 float MALL;
 float bonus;
};
void wgen_det();
void rgen_det();
void wwork_det();
void rwork_det(char id[],int len);
void menu();
FILE * fp;
void main()
{
 clrscr();
 menu();
 getch();
}
void menu()
{
 char iid[5];
 int ch;
 clrscr();
 printf("\n-----------------------------------------------------------\n");
 printf("\n-----------------FACULTY MANAGEMENT SYSTEM-----------------\n");
 printf("\n1. ADD GENERAL DETAILS OF FACULTY\n");
 printf("\n2. READ GENERAL DETAILS OF FACULTY\n");
 printf("\n3. ADD WORKING DETAILS OF FACULTY\n");
 printf("\n4. READ WORKING DETAILS OF FACULTY\n"); printf("\n5. EXIT");
 printf("\n-----------------------------------------------------------\n");
 printf("\nEnter your Choice\n");
 scanf("%d",&ch);
 printf("\n-----------------------------------------------------------\n");
 switch(ch)
 {
 case 1:
 wgen_det();
 break;
 case 2:
 rgen_det();
 break;
 case 3:
 wwork_det();
 break;
 case 4:
 printf("\nEnter the FACULTY ID no.\n");
 scanf("%s",iid);
 rwork_det(iid,5);
 break;
 default:
 printf("\nYou have Entered wrong choice");
 menu();
 }
 }
void rwork_det(char id[],int len)
{
 struct work_details work;
 long cnt=0;
 int n; fp=fopen("wrk_det.txt","r");
 fread(&work,sizeof(work)+1,1,fp);
 while(fp)
 {
 if((strcmp(work.fid,id)==0))
 {
n=1;
cnt=ftell(fp);
break;
 }
 else
 {
 n=0;
 // cnt++;
 }
 }
 if(n==0)
 {
 printf("Record Not Found");
 exit(1);
 }
 else
 {
 rewind(fp);
 fseek(fp,cnt,0);
 printf("\n-----------DETAILS OF FACULTY ID No.:- %s------------",id);
 printf("\nDEPARTMENT\t: %s",work.dept);
 printf("\nDESIGNATION\t: %s",work.desig);
 printf("\nBASIC SALARY\t: %.2f",work.basic);
 printf("\nLENGTH=%d",len);
 } fclose(fp);
}
void wwork_det()
{
 struct work_details work;
 fp=fopen("wrk_det.txt","a+");
 printf("\n----------ENTER FACULTY WORKING DETAILS----------\n");
 printf("\nEnter the Faculty Identity Number\n");
 scanf("%s",work.fid);
 printf("\nEnter the Department for this Faculty\n");
 scanf("%s",work.dept);
 printf("\nEnter the Designation for this Faculty\n");
 scanf("%s",work.desig);
 printf("\nEnter the Basic Salary of this Faculty\n");
 scanf("%.2f",&work.basic);
 fwrite(&work,sizeof(work),1,fp);
 fclose(fp);
 }
void wgen_det()
{
 struct gen_details gen;
 fp=fopen("general.txt","a+");
 printf("\n-----------------ENTER FACULTY DETAILS------------------\n");
 printf("\nEnter the Faculty Identity Number\n");
 scanf("%s",gen.fid);
 printf("\nEnter the Name of the Faculty\n");
 scanf("%s",gen.name);
 printf("\n---Enter The Present Address Details of Faculty---\n");
 printf("\nEnter the House Number\n");
 scanf("%d",&gen.present_add.hno); printf("\nEnter the Street Number\n");
 scanf("%d",&gen.present_add.streetno);
 printf("\nEnter the Name of the city\n");
 scanf("%s",gen.present_add.city);
 printf("\nEnter the Name of the State\n");
 scanf("%s",gen.present_add.state);
 printf("\nEnter the Name of the Country\n");
 scanf("%s",gen.present_add.country);
 printf("\n---Enter The Permanent Address Details of Faculty---\n");
 printf("\nEnter the House Number\n");
 scanf("%d",&gen.permanent_add.hno);
 printf("\nEnter the Street Number\n");
 scanf("%d",&gen.permanent_add.streetno);
 printf("\nEnter the Name of the city\n");
 scanf("%s",gen.permanent_add.city);
 printf("\nEnter the Name of the State\n");
 scanf("%s",gen.permanent_add.state);
 printf("\nEnter the Name of the Country\n");
 scanf("%s",gen.permanent_add.country);
 fwrite(&gen,sizeof(gen),1,fp);
 fclose(fp);
 }
void rgen_det()
{
 struct gen_details genn;
 fp=fopen("general.txt","r");
 fread(&genn,sizeof(genn)+1,1,fp);
 printf("\n--------------------DETAILS OF FACULTY---------------------\n");
 printf("\nFID\t\t :%s",genn.fid);
 printf("\nNAME\t\t :%s",genn.name);
 printf("\nPRESENT ADDRESS---\n"); printf("\nHouse No :%d",genn.present_add.hno);
 printf("\nStreet No :%d",genn.present_add.streetno);
 printf("\nCity\t\t :%s",genn.present_add.city);
 printf("\nState\t\t :%s",genn.present_add.state);
 printf("\nCountry\t\t :%s",genn.present_add.country);
 printf("\nPERMANENT ADDRESS---\n");
 printf("\nHouse No :%d",genn.permanent_add.hno);
 printf("\nStreet No :%d",genn.permanent_add.streetno);
 printf("\nCity\t\t :%s",genn.permanent_add.city);
 printf("\nState\t\t :%s",genn.permanent_add.state);
 printf("\nCountry\t\t :%s",genn.permanent_add.country);
 fclose(fp);
}

No comments:

Post a Comment