Вы находитесь на странице: 1из 30

The Employee Attendance System

Learning Objectives
The designing of the Employee Attendance project enable the students to: Create a simple C++ application using the concept of Object-oriented programming Use pointers extensively Explore the use of date and time functions Perform validation to execute the program effectively Create, store, update and retrieve data in files

Understanding the Employee Attendance System


The project is about tracking the employee leave information, which is required during the payroll processing. The project specifies the default leave availability for the employees and updates their leave information depending on the leave mode specified. The leave mode should be CL, ML and EL, where each employee is allowed to take 10, 20, and 20 days respectively for CL, ML and EL. The project provides the facility for displaying monthly attendance for all employees. It also contains the provision to view the leave status for a particular employee or for all employees.

Creating the Employee Attendance System


To create the employee attendance application, a C++ source file and a C++ header file is created. The source file is named as EmpLeave.cpp and the header file is named as EmpAttendance.h.

Creating the Header File EmpAttendance.h


The EmpAttendance.h header file includes the following classes: Attendance check date_Validation close_Attend Employee EmployeeLeaveUpdation Leave ShowLeaveData StoreEmployeeData

The Attendance Class


The Attendance class receives the attendance information for each employee and stores them into the file called Attendance.dat. The Attendance class includes the following functions:

attend_mark (): Receives the absentee employee number, validates the employee number and passes the values to the WriteAttendance () function. It also identifies the employees, who are present in the organization for a particular day. WriteAttendance (): Writes the data received from attend_mark() function into the Attendance.dat file.

The check Class


The check class is used for validating the character data in the application. For this purpose, the check class includes a function called check_All(), which receives the data, validates it, and returns to the point of invocation.

The date_Validation Class


The date_Validation class validates the date entries in the application. The date_Validation class includes the following functions: Functions calculatedays(int) date_Validation(char *, char *) DateExtract(string) Description Calculates the number of days in a month Validates the from and to date entries Extracts only the date value from the given date. dateInput() MonthExtract(string ) (Ex: 18 from 05/18/04) Receives the date input Extracts only the month value from the given date. (Ex: 05 from 05/18/04)

The close_Attend Class


This close_Attend class is used to display the monthly attendance of the employees. The member functions of the class are tabulated below: Functions display_attend() DateExtract(string) Description Used to display the monthly attendance of the employees from the Attendance.dat file. Used to extract the date of a particular employee from the Attendance.dat file.

The Employee Class

The employee class receives the employee information from the user. It also takes care of validating the user entries such as name and address validation (accepting white space) and phone number validation. Functions get_InputName() getEmpInfo() Description Receives the name from the user by accepting the white space. Receives complete information of the employees by making necessary validations.

The Leave Class


The Leave class accepts the employee leave information, such as employee number, from date, to date, and reason. It calculates the number of days leave taken and correspondingly, updates CL, ML, or EL. The member functions of the Leave class are shown in the following table: Functions getleave_Info() leave_validate() Description Receives the leave information for an employee Checks for valid entry of CL, ML or EL.

The EmployeeLeaveUpdation Class


The EmployeeLeaveUpdation class updates the employee leave information in the file called LeaveInformation.dat. It accepts information from the Leave class. It calculates the number of days, total leave available (consolidation of CL, ML, and EL), and updates the status of CL, ML, and EL respectively. It contains a member function called UpdateEmployeeData.

The ShowLeaveData Class


The ShowLeaveData class is used to display the leave information of the employees. It can display the information for a single employee or for all employees from the LeaveUpdation.dat file. The member functions of this class are shown in the following table: Functions ShowData() AllEmployees() SingleEmployee() StoreUpdatedData (EmployeeLeaveUpdation) Description Permits the display of leave information for a single employee or for all employees Displays the leave information for all employees in the organization Displays the leave information for a single employee Stores the leave information into the file called LeaveUpdation.dat

The StoreEmployeeData Class


The StoreEmployeeData class automates the generation of employee numbers and stores the complete employee information into the file called EmployeeInformation.dat. The member functions of this class are shown in the following table: Functions GenerateEmpNo() Description Generates the employee number. While entering the first employee data, the file will be created and the employee number is initialized to 1. Otherwise, the employee number is read from the file EmployeeInformation.dat and it is putemp(Employee) incremented for the subsequent employees. Stores the employee information into the EmployeeInformation.dat file.

Creating the Source File EmpLeave.cpp


The EmpLeave.cpp file includes the EmpAttendance.h header file. The source file is responsible for displaying the main menu of the application. The classes defined in the header file are instantiated in this source file. The main menu of the employee attendance application is shown in Fig. A.2:

Code for the Employee Attendance System


EmpLeave.cpp /*Main menu*/
#ifndef __abc #define __abc #include <iostream> #include<conio.h> #include <fstream> #include<string> #include <vector> #include "EmpAttendance.h" using namespace std; void GetUserData() { fstream out; Employee *emp,*emp1; emp = new Employee(); emp1 = new Employee(); StoreEmployeeData storeemp; system("cls"); cout<<"\n\n\n"; cout<<" EMPLOYEE INFORMATION\n"; cout<< ********************\n\n\n"; int no=storeemp.GenerateEmpNo(); cout<<" \t EMPLOYEE NUMBER : "<<no<<"\n";

"

emp->empno = no; emp->getEmpInfo(); storeemp.putemp(emp); } int main() { int opt; char ch; do { system("cls"); cout<<"\n\n\n\n\n\n"; cout<<" cout<<"

EMPLOYEE ATTENDANCE FORM\n"; ************************\n\n\n";

cout<<" cout<<" cout<<" cout<<" cout<<" cout<<" cout<<" cin>>opt;

EMPLOYEE INFORMATION ------------------- 1\n\n\n"; EMPLOYEE LEAVE FORM ------------------- 2\n\n\n"; EMPLOYEE ATTENDANCE ------------------- 3\n\n\n"; CLOSE MONTHLY ATTENDANCE ------------------- 4\n\n\n"; EMPLOYEE LEAVE STATUS ------------------- 5\n\n\n"; EXIT ------------------- 6\n\n\n"; ENTER THE OPTION (1-6): ";

switch(opt) { case 1: GetUserData(); break; case 2: { Leave *leave; leave = new Leave(); leave->getleave_Info(); // Updating the leave information in a file EmployeeLeaveUpdation *up1; up1 = new EmployeeLeaveUpdation(); up1->UpdateEmployeeData(leave); ShowLeaveData *show; show = new ShowLeaveData(); show->StoreUpdatedData(up1); break; } case 3: { Attendance *attend; attend = new Attendance(); attend->attend_mark(); break; } case 4:{ close_Attend *ca; ca = new close_Attend(); ca->display_Attend(); break; } case 5: { ShowLeaveData *show; show = new ShowLeaveData(); show->ShowData(); break; } case 6: goto a; default:{ cout<<"\n\t\t\tINVALID ENTRY (ENTER BETWEEN 1 AND 6)"; break; } }

cout<<"\n\n\n"; cout<<" RETURN TO MAIN MENU? (Y/N) "; cin>> ch; }while (ch=='Y' || ch == 'y'); a: if (ch!='y' || ch!='Y') { cout<<"\n\n\n"; cout<<" } getch(); return 0; } #endif

THANK YOU!!!";

EmpAttendance.h
#include<iostream> #include<istream> #include<string> #include<conio.h> #include<time.h> #include <cctype> #include <algorithm> #include <time.h> #include<stdlib.h> using namespace std; vector <int> v_emp;

/*The Check Class*/


int CheckEmployeeNumber(int); //The check class is used for validation. class check { public: void check_All(string p) { cout<<" ENTER VALID DATA FOR "<<p; } };

/*The Date Validation Class*/


//The date_Validation class validates the date entries. class date_Validation { char strdate1[11],strdate2[11]; int date1,date2; int month1,month2; int year1,year2; int days; int datecount1,datecount2; int special; int temp1,temp2; int count1; int count2; public: /*int DateExtract(string stdate); int MonthExtract(string stdate); int YearExtract(string stdate); int calculatedays(int months);*/

date_Validation(char *from, char *to) { strcpy(strdate1,from); strcpy(strdate2,to); } int dateInput() { int flag=0; date1=DateExtract(strdate1); month1=MonthExtract(strdate1); year1=YearExtract(strdate1); date2=DateExtract(strdate2); month2=MonthExtract(strdate2); year2=YearExtract(strdate2); if(month1 > 12 || month2 >12 || date1 >31 || date2 > 31) { flag=1; }

if (year1 == year2) { if (month1 == month2) { days=date2-date1+1; } else { temp1=month1; temp2=month2; if(month1<=month2) { if(month1 == 02) { if (year1%4 == 0) datecount1 = 29 - date1 +1; else datecount1 = 28 -date1 +1; } else { count1 = calculatedays(temp1); count2= calculatedays(temp2); datecount1=count1-date1+1; } datecount2 = date2; days = datecount1 + datecount2+1; days<<endl; } else//month1<month2 { cout<<"Enter valid date\n\n"; flag=1; } } } else { cout<<"\n\nEnter the date of the same calender year" <<"\n\n"; flag=1; } if (flag==1) return -1;

else return days; return days; }

int DateExtract(string stdate) { int l=0; int iDate; string strDate=stdate; strDate=strDate.substr(3,2); char aDate[2]; while(strDate[l]!='\0') { aDate[l] = strDate[l]; l++; } iDate = atoi(aDate); return iDate; } int MonthExtract(string stdate) { int l=0; int iMonth; string strMonth=stdate; strMonth=strMonth.substr(0,2); char aMonth[2]; while(strMonth[l]!='\0') { aMonth[l] = strMonth[l]; l++; } iMonth = atoi(aMonth); return iMonth; } int YearExtract(string stdate) {

int l=0; int iYear; string strYear=stdate; strYear=strYear.substr(6,4); char aYear[2]; while(strYear[l]!='\0') { aYear[l] = strYear[l]; l++; } iYear = atoi(aYear); return iYear; } int calculatedays(int months) { int count; switch(months) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: { count = 31; cout<<endl<<"I am in function. Days in month is " << count; break; } case 4: case 6: case 9: case 11: { count = 30; break; } }//switch return count; }// calculate days };

/*The Employee Class*/


// The Employee class is used to retrieve the employee information from the users. class Employee:public check { int bb,CL,EL,ML; string sex; char *addr; char empname[100]; char age[2]; string phno1,phno2; double salary; public: int empno; check ch; Employee() { empno=0; addr = new char[100]; } int getCL() { return CL; } int getML() { return ML; } int getEL() { return EL; } void setCL(int cl) { CL=cl; } void setML(int ml) { ML=ml; } void setEL(int el) { EL=el; }

// Retrieves the name from the user with white spaces void get_InputName() { char *emp_name; emp_name=new char[100]; cin.ignore(); cin.get(emp_name,100,'\n'); } //Prompts the user to enter the employee information void getEmpInfo() { CL=10; ML=20; EL=20; cout<<"\n\n"; cout<<"\t EMPLOYEE NAME : "; get_InputName(); cout<<"\n\n"; cout<<" \t AGE (21 to 58) : "; bb: cin>>age; int age_len = strlen(age); //Checking for valid age entry. //Age should be between 21 and 58. //Age should not involve and alphabets. if(age_len<=2) { int k=0; for(k=0;k<2;k++) { if((age[k] >='a' && age[k]<='z') ||(age[k] >='A' && age[k]<='Z')) { cout<<"ENTER VALID AGE: "; goto bb; } } int age_int = atoi(age); if(age_int <21 || age_int >58) { cout<<"\nENTER VALID AGE (21 to 58): "; goto bb; } } else {

cout <<"\nENTER VALID AGE (21 to 58)"; goto bb; } cout<<"\n\n"; cout<<" cc: cin>>sex; transform (sex.begin(), sex.end(), sex.begin(), toupper); if((sex.compare("FEMALE")!=0)&& (sex.compare("MALE")!=0)) { ch.check_All("GENDER: "); goto cc; } cout<<"\n\n"; cout<<" ADDRESS : "; cin.ignore(); cin.get(addr,100); cout<<"\n\n"; cout<<" PHONE NUMBER :\n "; cout<<" CODE : "; cin>>phno1; int i=0,flag=0; //Checking for valid phone number entry while(phno1[i]!='\0') { if (!(phno1[i] >='0') || !(phno1[i] <='9')) { flag=2; } i++; } if(flag==2) { cout<<"\nENTER VALID CODE: "; goto dd; } cout<<"\n"; cout<<" NUMBER : "; cin>>phno2; i=0; flag=0; while(phno2[i]!='\0') { if (!(phno2[i] >='0') || !(phno2[i] <='9')) { flag=3; } i++; } if(flag==3) GENDER (MALE/FEMALE) : ";

dd:

kk:

{ cout<<"ENTER VALID PHONE NO: "; goto kk; } cout<<"\n\n"; cout<<" cin>>salary; if(salary<=0) { cout<<" goto mm; } cout<<"\n\n"; cout<<" cout<<" cout<<" cout<<" } }; Employee *emp1 = new Employee; SALARY : Rs.";

mm:

ENTER VALID SALARY: ";

LEAVE ELIGIBLE :\n\n"; CASUAL LEAVE (CL) : "<<CL<<"\n\n"; MEDICAL LEAVE (ML) : "<<ML<<"\n\n"; EARNED LEAVE (EL) : "<<EL<<"\n\n";

/*The StoreEmployeeData Class*/


// The class StoreEmployeeData is used for storing the employee information class StoreEmployeeData { public: // Retrieving the data from employee object to auto generate the employee numbers int GenerateEmpNo() { ofstream out; ifstream in; out.open("EmployeeInformation.dat",ios::app); out.close(); int eno=0; int i=0; in.open("EmployeeInformation.dat",ios::in); in.seekg(0,ios::end); //Finding the length of the file int len = in.tellg(); // If length is zero, then the employee number should be 1.

if (len==0) { eno+=1; } // If not, then retrieve the last employee number and increment it by 1 and insert it for the new //employee. else { int c; in.seekg(0,ios::beg); while (in) { in.read((char*) emp1, sizeof(Employee)); c =emp1->empno; } eno=c + 1; in.close(); } return eno; } // Storing the employee data void putemp(Employee *emp) { emp1=emp; ofstream out; out.open("EmployeeInformation.dat",ios::app); out.write ((char*) emp1, sizeof(Employee)); out.close(); } };

/*The Leave Class*/


// The Leave class retrieves the leave information of the employees class Leave { int eno; char *reason; string lmode; char from_date[11],to_date[11],cdate[11]; public: int days, entry; Leave() { reason=new char[100]; }

int getEno() { return eno; } string getLmode() { return lmode; } //Receiving leave information void getleave_Info() { system("cls"); Employee *emp; emp= new Employee; cout<<"\n\n\n"; cout<<" EMPLOYEE LEAVE INFORMATION\n"; cout<<" ***************************\n\n\n"; _strdate(cdate); cout<<" Date: "<<cdate; cout<<"\n\n"; cout<<"EMPLOYEE NUMBER: "; cin>>eno; int ret = CheckEmployeeNumber(eno); if (ret==1) goto a2; else cout<<"\nENTER VALID EMPLOYEE NUMBER : "; goto a1; cout<<"\n\n\n"; cout<<" LEAVE PARTICULARS :"; cout<<"\n\n"; cout<<" FROM DATE (MM/DD/YYYY) : "; cin>> from_date; int fdate=atoi(from_date); cout<<"\n\n"; cout<<" TO DATE (MM/DD/YYYY) : "; cin>> to_date; date_Validation dat(from_date, to_date); days=dat.dateInput(); if (days==-1 ) goto entry; cout<<"\n\n"; cout<<" REASON : "; cin.ignore(); cin.get(reason,100); cout<<"\n\n"; cout<<" cout<<"\n\n\n"; NUMBER OF DAYS : "<<days;

a1:

a2:

entry:

leave_validate(); } // This method is used to check whether mode of leave is CL or ML or EL. void leave_validate() { cout<<" aa: cin>>lmode; MODE OF LEAVE(CL/ML/EL) : ";

transform (lmode.begin(), lmode.end(), lmode.begin(), toupper); int a=lmode.length(); if((a>2) || ((lmode.compare("CL")!=0)&&(lmode.compare("ML")! =0)&&(lmode.compare("EL")!=0))) { check_All(" goto aa; } } void check_All(string p) { system("cls"); cout<<"\n\n\n\n"; cout<<" ENTER VALID DATA FOR "<<p; } MODE OF LEAVE(CL/ML/EL) : ");

};

/*The EmployeeLeaveUpdation Class*/


class EmployeeLeaveUpdation { // Updating Employee leave information public: int EmpNo,NoOfDays; int TotalLeave; int CL,ML,EL; void UpdateEmployeeData(Leave *lv) { TotalLeave=0; int cl,ml,el;

vector <int> vemp,vcl,vml,vel; string mode = lv->getLmode(); int days = lv->days; int eno = lv->getEno(); NoOfDays = lv->days; Employee *emp1 = new Employee(); ifstream in; in.open("EmployeeInformation.dat",ios::in); int flag =0; in.seekg(0,ios::beg); while (in) { in.read((char*) emp1, sizeof(Employee)); vemp.push_back(emp1->empno); vcl.push_back(emp1->getCL()); vml.push_back(emp1->getML()); vel.push_back(emp1->getEL()); } for(int i=0;i<vemp.size();i++) { if(eno == vemp[i]) { EmpNo = eno; CL = vcl[i]; ML = vml[i]; EL = vel[i]; if(mode == "CL") { flag=1; cl=vcl[i]-days; CL=cl; } if(mode=="ML") { flag=2; ml=vml[i]-days; ML=ml; } if(mode=="EL") { flag=3; el=vel[i]-days; EL=el; } TotalLeave = CL+ML+EL;

} } in.clear(); } };

/*The Attendance Class*/


//The Attendance class is used to store the employees day-to-day attendance. class Attendance { public: int empno; char date[9]; char PA; void attend_mark () { system("cls"); vector <int> v1; vector <int> v2,v3,v4; Employee *emp; emp= new Employee; Leave *leave; leave = new Leave(); int eno,i; ifstream in; in.open("EmployeeInformation.dat",ios::in); i=0; in.seekg(0,ios::end); int len = in.tellg(); int rec = len/sizeof(Employee); cout<<"\n\n\n\n\n"; cout<<" EMPLOYEE ATTENDANCE\n"; cout<<" ********************\n\n\n"; cout<<"ABSENTEES EMPLOYEE PARTICULARS (ENTER 0 to EXIT)\n\n\n"; int n=0; for(int j=1;j<=rec+1;j++) { cout<<"ENTER THE ABSENTEE EMPLOYEE "<<j<<" : ";

aa1:

cin>>eno; cout<<"\n\n"; if(eno!= 0) { int ret = CheckEmployeeNumber(eno); if (ret==1) goto aa2; else { cout<<"\nENTER VALID EMPLOYEE NUMBER : "; goto aa1; } n++; v1.push_back(eno); PA='A'; //Inserting absentee data WriteAttendance(eno,PA); } else goto ll; }

aa2:

ll:

in.close(); Employee *emp1; emp1 = new Employee; //Inserting P for other employees in.open("EmployeeInformation.dat",ios::in); in.seekg(0,ios::beg); while(in) { in.read((char *) emp1, sizeof(Employee)); v2.push_back(emp1->empno); } cout<<"\n\n"; v3.clear(); // Identifying the employees for whom present needs to be marked for(j=0; j<v1.size() ;j++) { for(int s=0;s<v2.size()-1;s++) { if(v2[s] != v1[j]) { // The vector v3 contains the employee (with duplicate values)

v3.push_back(v2[s]); } } } //Removing duplication from vector v3 int half = v3.size()/2; for(int s=half;s<v3.size();s++) { v4.push_back(v3[s]); } if(v1.size()==1) { for( j=0;j<v2.size()-1;j++) { if( v1[0] != v2[j]) WriteAttendance(v2[j],'P'); } } else { for(j=0; j<half ;j++) { for(s=0;s<v4.size();s++) { char P_A; if(v3[j] == v4[s]) { P_A='P'; WriteAttendance(v3[j],P_A); } }//for s loop }//for j loop } in.close(); } void WriteAttendance(int eno,char cc) { Attendance *att; att = new Attendance(); att->empno = eno; att->PA = cc; _strdate(att->date); ofstream out; out.open ("Attendance.dat",ios::app); out.write((char *) att, sizeof(Attendance)); out.close(); delete att; } };

/*The Close Attendance Class*/


// The close_Attend displays the Attendance information of the employees. class close_Attend { string month; int date, year; public: void display_Attend() { system("cls"); ifstream iemp; iemp.open("EmployeeInformation.dat",ios::in); iemp.seekg(0,ios::end); int ilen = iemp.tellg(); int irec = ilen/sizeof(Employee); iemp.close(); Attendance *att; att = new Attendance(); vector <int> v_empno; vector <char> v_attend; ifstream in; in.open("Attendance.dat",ios::in); in.seekg(0,ios::end); int len=in.tellg(); int rec = len/sizeof(Attendance); in.seekg(0,ios::beg); cout<<"\n\n\n"; cout<<" cout<<"\n"; cout<<" cout<<"\n\n\n"; cout<<" ";

EMPLOYEE ATTENDANCE FORM"; *************************";

for(int i=1;i<=31;i++) // Displaying the no of the days in a month { cout<<i<<" "; } cout<<"\n\n"; int l=3; int p=1; string str1,str; vector <int> vempno ; //Retrieving the Employee numbers in a vector vempno

ifstream in1; in1.open("EmployeeInformation.dat", ios::in); Employee *e = new Employee; while(in1) { in1.read((char*) e, sizeof(Employee)); vempno.push_back(e->empno); } vector <int> vatt; vector <char> vpa; vector <string> vdate; int eno; char PA; string strdt; for(int u=0;u<vempno.size()-1;u++) { in.seekg(0,ios::beg); while(in) { in.read((char*) att, sizeof(Attendance)); eno = att->empno; PA=att->PA; strdt=att->date; if(vempno[u] == eno) { vatt.push_back(eno); vpa.push_back(PA); vdate.push_back(strdt); } } in.clear(); } cout<<endl; for(u=0;u<vempno.size()-1;u++) { cout<<vempno[u]; int first=0; for (int h=0;h<vdate.size();h++) { if(vempno[u] == vatt[h]) { int retDate = DateExtract(vdate[h]); if(retDate<=9) { for(i=1;i<retDate;i++) { cout<<" "; } cout<<vpa[h]<<" "; }

else { first+=1; if(first==1) { retDate = retDate-7.5; retDate = (retDate*2)+2.5; for(i=1;i<=retDate;i++) { cout<<" "; } cout<<vpa[h]<<" "; } else { cout<<vpa[h]<<""; } } } } cout<<"\n\n"; } getch(); } int DateExtract(string strdate) { int iDate; int l=0; string strDate= strdate; strDate = strDate.substr(3,2); char aDate[2]; while (strDate[l]!='\0') { aDate[l] = strDate[l]; l++; } iDate = atoi(aDate); return iDate; } };

/*The Show Leave Status Class*/


// The class ShowLeaveData displays leave information for a set of employees or //single employee class ShowLeaveData

{ public: void StoreUpdatedData(EmployeeLeaveUpdation *up) { ofstream out; out.open("LeaveUpdation.dat",ios::app); out.write((char*) up,sizeof(EmployeeLeaveUpdation)); } void ShowData() { system("cls"); char ch='y'; int retrieve; do { system("cls"); cout<<"\n\n\n\n"; cout<<" EMPLOYEE LEAVE STATUS\n"; cout<<" **********************\n\n\n"; cout<<" 1. RETRIEVE DATA FOR A PARTICULAR EMPLOYEE \n\n\n"; cout<<" 2. RETRIEVE DATA FOR ALL EMPLOYEES \n\n\n"<<endl; cout<<" ENTER 1 OR 2 : "; cin>>retrieve; switch(retrieve) { case 1: SingleEmployee();break; case 2: AllEmployees();break; default : cout<<"\n\nENTER EITHER 1 OR 2 "; break; } cout<<"\n\n\n"; cout<<" ENTER 'Y' TO ACCESS EMPLOYEE LEAVE STATUS AND 'N' TO QUIT: "; cin>>ch; }while (ch=='Y' ||ch=='y'); } //ShowData(); void SingleEmployee() { int no; cout<<"\n\n\n\n"; cout<<" ENTER THE EMPLOYEE NUMBER : "; cin>>no; int ret = CheckEmployeeNumber(no); if (ret==1) goto a12; else { cout<<"\nENTER VALID EMPLOYEE NUMBER : "; goto a11;

a11:

} a12: cout<<endl<<endl; EmployeeLeaveUpdation *up; up = new EmployeeLeaveUpdation; ifstream in; in.open("LeaveUpdation.dat",ios::in); in.seekg(0,ios::beg); int cnt =0; while(in) { in.read((char*) up, sizeof(EmployeeLeaveUpdation)); if(no == up->EmpNo) { cnt+=1; break; } else { goto ab; } }//while // Displaying the latest leave record of the employee cout<<"\n\n\n\n\n"; cout<<"EMPLOYEE NUMBER : " << up->EmpNo <<"\n\n\n"; cout<<"TOTAL LEAVE ELIGIBLE : 50"<<"\n\n\n"; cout<<"TOTAL LEAVE AVAILABLE : "<<up->TotalLeave<<"\n\n\n"; cout<<"CASUAL LEAVE : "<<up->CL<<"\n\n\n"; cout<<"MEDICAL LEAVE : "<<up->ML<<"\n\n\n"; cout<<"EARN LEAVE : "<<up->EL<<"\n\n\n"; cout<<"\n\n\n\n"; goto bb; in.clear(); cout<<"\n EMPLOYEE HAS NOT TAKEN LEAVE SO FAR!\n\n\n"; cout<<"Press Enter to continue....\n"; getch(); } void AllEmployees() { system("cls"); EmployeeLeaveUpdation *up; up = new EmployeeLeaveUpdation; ifstream in; in.open("LeaveUpdation.dat",ios::in); in.seekg(0,ios::beg); while(in) {

ab: bb:

in.read((char*) up, sizeof(EmployeeLeaveUpdation)); cout<<"\n\n\n\n\n"; cout<<"EMPLOYEE NUMBER : " << up->EmpNo <<"\n\n\n"; cout<<"TOTAL LEAVE ELIGIBLE : 50"<<"\n\n\n"; cout<<"TOTAL LEAVE AVAILABLE : "<<up->TotalLeave<<"\n\n\n"; cout<<"CASUAL LEAVE : "<<up->CL<<"\n\n\n"; cout<<"MEDICAL LEAVE : "<<up->ML<<"\n\n\n"; cout<<"EARN LEAVE : "<<up->EL<<"\n\n\n"; cout<<"\n\n\n\n"; getch(); cout<<"Press Enter to continue....."; } in.clear(); getch(); }//AllEmployees(); }; // Validating the employee number entered by the user. int CheckEmployeeNumber(int eno) { Employee *emp; emp=new Employee(); int cnt=0; ifstream in; in.open("EmployeeInformation.dat", ios::in); while (in) { in.read((char*) emp, sizeof(Employee)); if(eno == emp->empno) { cnt=1; break; } else { cnt=2; continue; } } if(cnt==1) return 1; else return 0; }

Exercises:
1. Write the C++ code to display the close yearly attendance of the Employee Attendance system. 2. Write the C++ code to view the employee leave status based on date / month.

Вам также может понравиться