BANKING SYSTEM PROJECT IN C++
//Declaration of header files
#include<iostream.h>
#include<fstream.h>
#include<process.h>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
#include<conio.h>
#include<dos.h>
#include<stdlib.h>
#include<iomanip.h>
#include<graphics.h>
//This file includes from your library directory or compiler to support
//the graphics mode
//#include"d:\arun\gh.cpp"
class BOX_CLASS
{
public:
void DRAW_LINE(int,int,int,char);
void DRAW_VER(int,int,int,char);
void DRAW_BOX(int,int,int,int,char);
};
//Class for main control
class control
{
private:
void MENU_EDIT(void);
public:
void MAIN_SCREEN(void);
void help(void);
};
//Details class for employee address section
class details
{
private:
//Function to modify the customer employee
void modify_employee(int,char t_name[30],char t_address[30],int tdd,
int tmm,int tyy,char t_city[10],char t_state[3],char t_zip[10]);
int emp_no;
char name[30],address[30];
int dd,mm,yy;
char city[10],state[3],zip[10];
public:
void EMP_APPEND(int,char t_name[30],char t_address[30],int tdd,
int tmm,int tyy,char t_city[10],char t_state[3],char t_zip[10]);
void display_emp_list(void); //Displaying customers employee list
void delete_employee(int); //Deleting customers employee
void modify(void); //To modify customers employee information
int last_emp_no(void); //To know the last employee number
int found_employee(int); //To find employee in DETAILS.dat
char *return_name(int); //Function for validation entry of customer name
char *return_address(int); //Function for validation entry of customer address
//Function for displaying all the details from DETAILS.dat data file
void display_from_details(int);
int recordno(int);
void display(int);//To display customer employee
void send_DATA(int);//Send details information to salary report
};
//Employee class for salary and designation
class employee
{
private:
void EMP_APPEND(int,int,int,int,char t_grade[2],char t_emp_job[12],
float,int); //Function to add change_salary records
void delete_employee(int); //Function to delete a change_salary record
void box_for_display(int); //Function for displaying box;
int emp_no;
int dd,mm,yy; //To store system date/Enter date
char grade[2];
char emp_job[12];
float salary;
int deptno;
public:
void new_employee(void); //Function to create a new employee
void close_employee(void); //Function to close an employee
void display_employee(void); //Function to display the employees
//Function to perform a left clear on specified row from specified column
void Left_clear(int,int);
//Function to perform a right clear on specified row from specified column
void Right_clear(int,int);
void month_salary(void);//Function to list monthwise change_salary report
void display(int); //Function to display a change_salary employee
//Function to modify other informations related to employee
void modify_salary(int,int,int,int,char t_grade[2],char t_emp_job[12],
float,int);
int recordno(int);
float found_salary(int); //Function to find salary from EMP.dat file
//Function to find the employee job for displaying a total list
char *found_job(int);
void change_salary(void); //Function to change the employee salary
};
//Function for horizontal line draw
void BOX_CLASS::DRAW_LINE(int column1,int column2,int row,char c)
{
for(column1;column1<=column2;column1++)
{
gotoxy(column1,row);
cout<<c;
}
}
//Function for vertical line draw
void BOX_CLASS::DRAW_VER(int row1,int row2,int column,char c)
{
for(row1;row1<=row2;row1++)
{
gotoxy(column,row1);
cout<<c;
}
}
void BOX_CLASS::DRAW_BOX(int column1,int row1,int column2,int row2,char c)
{
char ch=218;
char c1,c2,c3,c4;
char l1=196,l2=179;
if(c==ch)
{
c1=218;
c2=191;
c3=217;
c4=192;
l1=196;
l2=179;
}
else
{
c1=c;
c2=c;
c3=c;
c4=c;
l1=c;
l2=c;
}
gotoxy(column1,row1);
cout<<c1;
gotoxy(column2,row1);
cout<<c2;
gotoxy(column1,row2);
cout<<c3;
gotoxy(column2,row2);
cout<<c4;
column1++;
column2--;
DRAW_LINE(column1,column2,row1,l1); //Horizontal line
DRAW_LINE(column1,column2,row2,l1);
column1--;
column2++;
row1++;
row2--;
DRAW_VER(row1,row2,column1,l2); //Vertical line
DRAW_VER(row1,row2,column2,l2);
}
//Function for main menu
void control::MAIN_SCREEN(void)
{
char ch;
//request auto detection of graph driver
int gdriver=DETECT,gmode,errorcode;
while(ch<='6')
{
//Initialises graphics system
initgraph(&gdriver,&gmode,"c:\\tc");
BOX_CLASS s;
//setbkcolor sets the current background color using the palette
setbkcolor(10);
//setcolor sets the current drawing color
setcolor(RED);
//Sets the current text characterstics
settextstyle(0,HORIZ_DIR,1); //Changes the text style(font)
//outtextxy displays a string at the specified location(graphics mode)
outtextxy(420,90,"<0>=Exit");
setcolor(5);
settextstyle(1,HORIZ_DIR,2);
outtextxy(170,350,"Developed By SHAHID");
outtextxy(220,80,"EMPLOYEE MENU");
settextstyle(3,HORIZ_DIR,1);
setcolor(RED);
outtextxy(220,140,"1. Open New employee");
outtextxy(220,160,"2. List of employees");
outtextxy(220,180,"3. See Individual employee");
outtextxy(220,200,"4. EmpChange_Salary");
outtextxy(220,220,"5. Salary Slip");
outtextxy(220,240,"6. Edit Employee");
outtextxy(230,300,"Enter Your Choice ");
//Draws a rectangle(graphics mode)
rectangle(200,120,455,277);
rectangle(400,307,450,327);
ch=getche();
//Shuts down the graphics mode
closegraph();
switch(ch)
{
case '0':
clrscr();
exit(0); //Option to exit from main menu
break;
case '1':
{
employee a;
a.new_employee(); //New employee member function
break;
}
case '2':
{
details EMP_ADD;
EMP_ADD.display_emp_list(); //Global list of employee function
break;
}
case '3':
{
employee a;
//Displaying individual employees all change_salary
a.display_employee();
break;
}
case '4':
{
employee a;
a.change_salary(); //Daily change_salary for individual employee
break;
}
case '5':
{
employee a;
a.month_salary(); //Monthly report for any employee
break;
}
case '6':
{
initgraph(&gdriver,&gmode,"c:\\tc");
MENU_EDIT(); //Sub menu for modifying or deleting any employee
break;
}
}
}
for(int i=25;i>=1;i--)
{
delay(2);
gotoxy(1,i);
clrscr();
}
}
//Function for modify record & delete record menu
void control::MENU_EDIT(void)
{
char ch;
while(1)
{
setbkcolor(7);
setcolor(5);
settextstyle(1,HORIZ_DIR,2);
outtextxy(260,80,"EDIT MENU");
setcolor(4);
rectangle(200,120,455,277);
settextstyle(3,HORIZ_DIR,1);
outtextxy(220,130,"1. Modify employee");
outtextxy(220,160,"2. Close employee");
outtextxy(220,190,"0. Quit");
outtextxy(230,220,"Enter your choice : ");
ch=getche();
closegraph();
if(ch==27)
break;
else
{
if(ch=='1')
{
details EMP_ADD;
EMP_ADD.modify();
break;
}
else
{
if(ch=='2')
{
employee a;
a.close_employee();
break;
}
else
if(ch=='0')
break;
}
}
}
}
//Function for help menu
void control::help(void)
{
//getch gets a character from console but does not echo to the screen
getch();
clrscr();
BOX_CLASS s;
s.DRAW_BOX(2,1,79,25,218);
s.DRAW_BOX(25,2,54,4,219);
gotoxy(27,3);
//cprintf sends formatted output to the text window on the screen
cprintf("Welcome to Employee Project");
//textcolor select a new character color in text mode
textcolor(LIGHTGRAY);
delay(13);
gotoxy(5,6);
cout<<"This project is used to handle the employees in an organisation and";
delay(13);
gotoxy(5,7);
cout<<"for keeping the employee detailed information in computerized manner.";
delay(13);
gotoxy(5,9);
cout<<"And also handles the information as follows: ";
delay(13);
gotoxy(6,11);
cout<<"-In first option you append new employee.";
delay(13);
gotoxy(6,12);
cout<<"-In second option you can list out all the employees with basic salary.";
delay(13);
gotoxy(6,13);
cout<<"-In third option you can get an individual employee status.";
delay(13);
gotoxy(6,14);
cout<<"-In fourth option you can change any employee basic salary.";
delay(13);
gotoxy(6,15);
cout<<"-The fifth option helps you to generate a monthwise salary slip.";
delay(13);
gotoxy(7,16);
cout<<"of individual employee.";
delay(13);
gotoxy(6,17);
cout<<"-In sixth option you can modify or delete any employee.";
delay(13);
gotoxy(7,18);
cout<<"Where it will display two another prompts in the sub menu.";
delay(13);
gotoxy(6,19);
cout<<" 1->Modification, 2->Deleltion, 3->Quit";
delay(13);
gotoxy(6,21);
cout<<"Note-:For Exit from any menu press 0(Zero) at any point then you will";
delay(13);
gotoxy(13,22);
cout<<"simply came back to the previous menu or to the source program.";
textcolor(BLACK+BLINK);
textbackground(WHITE);
gotoxy(26,25);
cprintf("Press any key to continue...");
textcolor(LIGHTGRAY);
textbackground(BLACK);
gotoxy(25,2);
getch();
for(int i=25;i>=1;i--)
{
delay(5);
gotoxy(1,i);
clrscr();
}
}
//Function for modifying data record
void details::modify(void)
{
clrscr();
int j;
char t_acc[10];
int t,t_emp_no;
gotoxy(17,1);
cout<<"<0>=Exit";
gotoxy(5,5);
cout<<"Enter the employee no. ";
gets(t_acc);
t=atoi(t_acc);
t_emp_no=t;
if(t_emp_no==0)
return;
clrscr();
if(!found_employee(t_emp_no))
{
gotoxy(5,5);
cout<<"\7Employee not found";
getch();
return;
}
gotoxy(71,1);
cout<<"<0>=Exit";
textbackground(WHITE);
gotoxy(3,3);
for(j=1;j<=76;j++)
cprintf(" ");
textbackground(BLACK);
textcolor(BLACK+BLINK);
textbackground(WHITE);
gotoxy(30,3);
cprintf("Modify Employee Screen");
textcolor(LIGHTGRAY);
textbackground(BLACK);
int d1,m1,y1;
struct date d; //For extracting system date
getdate(&d);
d1=d.da_day;
m1=d.da_mon;
y1=d.da_year;
gotoxy(4,2);
cout<<"Date: "<<d1<<"/"<<m1<<"/"<<y1;
char ch;
//Displaying from DETAILS.dat data file
display(t_emp_no);
employee a;
//Displaying from EMP.dat data file
a.display(t_emp_no);
do
{
a.Left_clear(5,15);
gotoxy(2,13);
for(j=1;j<=76;j++)
cprintf("=");
textbackground(WHITE);
textbackground(BLACK);
textcolor(BLACK);
textbackground(WHITE);
gotoxy(20,14);
cprintf("Modify This Employee<y/n>? ");
ch=getch();
textcolor(LIGHTGRAY);
textbackground(BLACK);
gotoxy(2,15);
for(j=1;j<=76;j++)
cprintf("=");
if(ch=='0')
return;
ch=toupper(ch);
}while(ch != 'N' && ch != 'Y');
if(ch=='N')
return;
//Declared the temporary feilds for modifying data again
int valid;
char t_name[30],t_address[30];
char t_city[10],t_state[3],t_zip[10];
char t_emp_job[12];
int tdd,tmm,tyy;
int t_deptno;
float t_salary;
char t_grade[2];
//Displays the headings
gotoxy(5,16);
cout<<"Name: ";
gotoxy(5,17);
cout<<"Address: ";
gotoxy(5,18);
cout<<"Date of Birth: ";
gotoxy(5,19);
cout<<"City: ";
gotoxy(5,20);
cout<<"State: ";
gotoxy(5,21);
cout<<"Zip: ";
gotoxy(40,16);
cout<<"Designation: ";
gotoxy(40,17);
cout<<"Date of Joining: ";
gotoxy(40,18);
cout<<"Department no.: ";
gotoxy(40,19);
cout<<"Basic Salary: ";
gotoxy(40,20);
cout<<"Grade: ";
do
{
a.Left_clear(12,16);
a.Left_clear(5,23);
gotoxy(5,23);
cout<<"Enter Name or Press Enter for No Change";
valid=1;
gotoxy(12,16);
gets(t_name);
strupr(t_name);
if(t_name[0]=='0')
return;
if(strlen(t_name)>25)
{
valid=0;
gotoxy(5,23);
cprintf("\7Name should not greater than 25");
getch();
}
}while(!valid);
do
{
a.Left_clear(15,17);
a.Left_clear(5,23);
gotoxy(5,23);
cout<<"Enter Address or Press Enter for No Change";
valid=1;
gotoxy(15,17);
gets(t_address);
strupr(t_address);
if(t_address[0]=='0')
return;
if(strlen(t_address)>25)
{
valid=0;
gotoxy(5,23);
cprintf("\7Address should not greater than 25");
getch();
}
}while(!valid);
a.Left_clear(21,18);
gotoxy(5,23);
cout<<"Enter Date of Birth";
gotoxy(21,18);
cin>>tdd;
gotoxy(23,18);
cout<<"-";
gotoxy(24,18);
cin>>tmm;
gotoxy(26,18);
cout<<"-";
gotoxy(27,18);
cin>>tyy;
a.Left_clear(5,23);
do
{
a.Left_clear(12,19);
a.Left_clear(5,23);
gotoxy(5,23);
cout<<"Enter City and press enter for no change";
valid=1;
gotoxy(12,19);
gets(t_city);
if(t_city[0]=='0')
return;
if(strlen(t_city)>9)
{
valid=0;
gotoxy(5,23);
cprintf("\7City should not greater than 9");
getch();
}
}while(!valid);
a.Left_clear(5,23);
do
{
a.Left_clear(14,20);
a.Left_clear(5,23);
gotoxy(5,23);
cout<<"Enter State and press enter for no change";
valid=1;
gotoxy(14,20);
gets(t_state);
strupr(t_state);
if(t_state[0]=='0')
return;
if(strlen(t_state)==0 || strlen(t_state)>2)
{
valid=0;
gotoxy(5,23);
cprintf("\7State should not greater than 2");
getch();
}
}while(!valid);
a.Left_clear(5,23);
do
{
a.Left_clear(15,21);
a.Left_clear(5,23);
gotoxy(5,23);
cout<<"Enter Zip Code and enter for no change";
valid=1;
gotoxy(15,21);
gets(t_zip);
strupr(t_zip);
if(t_zip[0]=='0')
return;
if(strlen(t_zip)==0 || strlen(t_zip)>9)
{
valid=0;
gotoxy(5,23);
cprintf("\7Zip should not greater than 9");
getch();
}
}while(!valid);
a.Left_clear(5,23);
do
{
a.Right_clear(59,16);
a.Left_clear(5,23);
gotoxy(5,23);
cout<<"Enter Designation and enter for no change";
valid=1;
gotoxy(59,16);
gets(t_emp_job);
strupr(t_emp_job);
if(t_emp_job[0]=='0')
return;
if(strlen(t_emp_job)==0 || strlen(t_emp_job)>11)
{
valid=0;
gotoxy(5,23);
cprintf("\7Designation should not greater than 9");
getch();
}
}while(!valid);
a.Right_clear(59,17);
gotoxy(59,17);
cin>>d1;
gotoxy(61,17);
cout<<"-";
gotoxy(62,17);
cin>>m1;
gotoxy(64,17);
cout<<"-";
gotoxy(65,17);
cin>>y1;
gotoxy(59,18);
cin>>t_deptno;
do
{
a.Right_clear(59,19);
a.Left_clear(5,23);
gotoxy(5,23);
cout<<"Basic Salary not less than 2500";
valid=1;
//Declares as character type & will convert into float type using atof() function
char t[10];
gotoxy(59,19);
gets(t);
t_salary=atof(t);
if(t[0]=='0')
{
valid=0;
gotoxy(5,23);
cprintf("\7Should not less than 2500");
getch();
}
}while(!valid);
if(t_salary>=2500 && t_salary<=3000)
strcpy(t_grade,"C");
else if(t_salary>=3001 && t_salary<=4000)
strcpy(t_grade,"B");
else if(t_salary>=4001 && t_salary<=5000)
strcpy(t_grade,"A");
else if(t_salary>5000)
strcpy(t_grade,"O");
else
return;
gotoxy(59,20);
cout<<t_grade; //Calculate a grade function at here
do
{
a.Left_clear(5,23);
gotoxy(5,22);
cout<<"Do you want to save changes<Y/N>? ";
ch=getche();
if(ch=='0')
return;
ch=toupper(ch);
}while(ch!='N' && ch!='Y');
if(ch=='N')
return;
//Function to rewrite the name and address details into DETAILS.dat
modify_employee(t_emp_no,t_name,t_address,tdd,tmm,tyy,t_city,t_state,t_zip);
//Function to rewrite the salary and job details into EMP.dat
a.modify_salary(t_emp_no,d1,m1,y1,t_grade,t_emp_job,t_salary,t_deptno);
gotoxy(5,23);
cout<<"\7Record modified ";
gotoxy(25,23);
cout<<"Press any key to continue...";
getch();
}
//Displays the record from DETAILS.dat data file for modifying display
void details::display(int t_emp_no)
{
fstream file;
int d1,m1,y1;
file.open("DETAILS.dat",ios::in);
file.seekg(0,ios::beg);
while(file.read((char *)this, sizeof(details)))
{
if(t_emp_no==emp_no)
{
gotoxy(8,4);
cout<<"Employee no. "<<emp_no;
gotoxy(10,6);
cout<<"Name: ";
puts(name);
gotoxy(10,7);
cout<<"Address: ";
puts(address);
gotoxy(10,8);
d1=dd;
m1=mm;
y1=yy;
cout<<"Date of Birth: "<<d1<<"-"<<m1<<"-"<<y1;
gotoxy(10,9);
cout<<"City: ";
puts(city);
gotoxy(10,10);
cout<<"State: ";
puts(state);
gotoxy(10,11);
cout<<"Zip: ";
puts(zip);
getch();
break;
}
}
file.close();
}
//Displays the record from EMP.dat data file for modifying display
void employee::display(int t_emp_no)
{
fstream sfile;
sfile.open("EMP.dat",ios::in);
sfile.seekg(0,ios::beg);
while(sfile.read((char *)this, sizeof(employee)))
{
if(t_emp_no==emp_no)
{
gotoxy(40,6);
cout<<"Designation: ";
puts(emp_job);
gotoxy(40,7);
cout<<"Joining Date: ";
gotoxy(59,7);
cout<<dd<<"-"<<mm<<"-"<<yy;
gotoxy(40,8);
cout<<"Dept. No.: "<<deptno;
gotoxy(40,9);
cout<<"Basic Salary Rs. "<<setw(15) //setwidth
<<setprecision(2) //set position of decimal point
<<setiosflags(ios::left) //set left justified output
<<setiosflags(ios::showpoint) //always show decimal point
<<setiosflags(ios::fixed) //set fixed notation for display
<<salary;
gotoxy(40,10);
cout<<"Grade: "<<grade;
break;
}
}
sfile.close();
}
//Function to insert modified data into DETAILS.dat data file
void details::modify_employee(int t_emp_no,char t_name[30],char t_address[30],
int tdd,int tmm,int tyy,char t_city[10],char t_state[3],char t_zip[10])
{
int recno;
recno=recordno(t_emp_no);
fstream file;
file.open("DETAILS.dat",ios::out|ios::ate);
emp_no=t_emp_no;
strcpy(name,t_name);
strcpy(address,t_address);
dd=tdd;
mm=tmm;
yy=tyy;
strcpy(city,t_city);
strcpy(state,t_state);
strcpy(zip,t_zip);
//Finding the location in file
int location=0;
location=(recno-1)*sizeof(details);
file.seekg(0,ios::beg);
//Search the position in file
file.seekp(location);
//Rewrite the contents in DETAILS.dat data file
file.write((char *)this, sizeof(details));
file.close();
return;
}
//Function to modify data related to salary in EMP.dat
void employee::modify_salary(int t_emp_no,int d1,int m1,int y1,char t_grade[2],
char t_emp_job[12],float t_salary,int t_deptno)
{
int recno=0;
recno=recordno(t_emp_no);
fstream sfile;
sfile.open("EMP.dat",ios::out|ios::ate);
emp_no=t_emp_no;
dd=d1;
mm=m1;
yy=y1;
strcpy(grade,t_grade);
strcpy(emp_job,t_emp_job);
salary=t_salary;
deptno=t_deptno;
//Find the location in file
int location=0;
location=(recno-1)*sizeof(employee);
sfile.seekg(0,ios::beg);
//Search the position in file
sfile.seekp(location);
//Rewrite the contents in EMP.dat data file
sfile.write((char *)this, sizeof(employee));
sfile.close();
return;
}
//Function to find last employee no. from DETAILS.dat data file
int details::last_emp_no(void)
{
fstream file;
file.open("DETAILS.dat",ios::in);
file.seekg(0,ios::beg);
int count=0;
//Searches the last record no. in file
while(file.read((char*)this, sizeof(details)))
count=emp_no;
file.close();
return count;
}
//Function to append record into DETAILS.dat data file
void details::EMP_APPEND(int t_emp_no,char t_name[30],char t_address[30],int tdd,
int tmm,int tyy,char t_city[10],char t_state[3],char t_zip[10])
{
emp_no=t_emp_no;
strcpy(name,t_name);
strcpy(address,t_address);
dd=tdd;
mm=tmm;
yy=tyy;
strcpy(city,t_city);
strcpy(state,t_state);
strcpy(zip,t_zip);
//Appends the record into file
fstream file;
file.open("DETAILS.dat",ios::out|ios::app);
file.write((char *)this, sizeof(details));
file.close();
}
//Function to delete a selected record from DETAILS.dat data file
void details::delete_employee(int t_emp_no)
{
fstream file;
file.open("DETAILS.dat",ios::in);
fstream temp;
temp.open("TEMP.dat",ios::out);
file.seekg(0,ios::beg);
//Deletes the record using copy method into temporary file
while(!file.eof())
{
file.read((char *)this, sizeof(details));
if(file.eof())
break;
if(emp_no != t_emp_no)
temp.write((char *)this, sizeof(details));
}
file.close();
temp.close();
file.open("DETAILS.dat",ios::out);
temp.open("TEMP.dat",ios::in);
temp.seekg(0,ios::beg);
//Overwrite the temporary contents into original DETAILS.dat data file
while(!temp.eof())
{
temp.read((char *)this, sizeof(details));
if(temp.eof())
break;
if(emp_no != t_emp_no)
file.write((char *)this, sizeof(details));
}
file.close();
temp.close();
}
//Function to append a record into EMP.dat data file
void employee::EMP_APPEND(int t_emp_no,int d1,int m1,int y1,char t_grade[2],
char t_emp_job[12],float t_salary,int t_deptno)
{
emp_no=t_emp_no;
dd=d1;
mm=m1;
yy=y1;
strcpy(grade,t_grade);
strcpy(emp_job,t_emp_job);
salary=t_salary;
deptno=t_deptno;
fstream sfile;
//Append the new record into EMP.dat data file
sfile.open("EMP.dat",ios::out|ios::app);
sfile.write((char *)this, sizeof(employee));
sfile.close();
}
//Function to delete a selected record from EMP.dat data file
void employee::delete_employee(int t_emp_no)
{
fstream file;
file.open("EMP.dat",ios::in);
fstream temp;
temp.open("TEMP.dat",ios::out);
file.seekg(0,ios::beg);
//Delete record using copy method into temperory file
while(!file.eof())
{
file.read((char *)this, sizeof(employee));
if(file.eof())
break;
if(emp_no != t_emp_no)
temp.write((char *)this, sizeof(employee));
}
file.close();
temp.close();
file.open("EMP.dat",ios::out);
temp.open("TEMP.dat",ios::in);
temp.seekg(0,ios::beg);
//Overwrites the temporary contents into original EMP.dat data file
while(!temp.eof())
{
temp.read((char *)this, sizeof(employee));
if(temp.eof())
break;
if(emp_no != t_emp_no)
file.write((char *)this, sizeof(employee));
}
file.close();
temp.close();
}
//Function to find the basic salary of an employee from EMP.dat for display_emp_list() function
float employee::found_salary(int t_emp_no)
{
float t_salary=0.0;
int xemp_no;
fstream sfile;
sfile.open("EMP.dat",ios::in);
sfile.seekg(0,ios::beg);
//Searches the record inEMP.dat data file
while(sfile.read((char *)this, sizeof(employee)))
{
xemp_no=emp_no;
if(xemp_no==t_emp_no)
{
t_salary=salary;
break;
}
}
sfile.close();
return(t_salary);
}
//Function to find the designation of an employee from EMP.dat for display_emp_list() function
char *employee::found_job(int t_emp_no)
{
char t_emp_job[12];
int xemp_no;
fstream sfile;
sfile.open("EMP.dat",ios::in);
sfile.seekg(0,ios::beg);
//Searches the emp_job in EMP.dat data file
while(sfile.read((char *)this, sizeof(employee)))
{
xemp_no=emp_no;
if(xemp_no==t_emp_no)
{
strcpy(t_emp_job,emp_job);
break;
}
}
sfile.close();
return(t_emp_job);
}
//Function to change the employee salary either to increase or decrease according to emp_no.
void employee::change_salary(void)
{
clrscr();
char t_acc[10];
int t,t_emp_no,j;
char t_grade[2],t_emp_job[12];
int d1,m1,y1;
float t_salary=0.0,x_salary;
int t_deptno;
gotoxy(17,1);
cout<<"<0>=Exit";
gotoxy(5,5);
cout<<"Enter the employee no. ";
gets(t_acc);
t=atoi(t_acc);
t_emp_no=t;
if(t_emp_no==0)
return;
clrscr();
details EMP_ADD;
if(!EMP_ADD.found_employee(t_emp_no))
{
gotoxy(5,5);
cout<<"\7Employee not found";
getch();
return;
}
gotoxy(71,1);
cout<<"<0>=Exit";
textbackground(WHITE);
gotoxy(3,3);
for(j=1;j<=76;j++)
cprintf(" ");
textbackground(BLACK);
textcolor(BLACK+BLINK);
textbackground(WHITE);
gotoxy(30,3);
cprintf("Salary Change Screen");
//Change to normal color mode
textcolor(LIGHTGRAY);
textbackground(BLACK);
fstream sfile;
sfile.open("EMP.dat",ios::in);
sfile.seekg(0,ios::beg);
//Change salary & modify details in Emp.dat data file
while(sfile.read((char *)this, sizeof(employee)))
{
if(t_emp_no==emp_no)
{
strcpy(t_grade,grade);
strcpy(t_emp_job,emp_job);
d1=dd;
m1=mm;
y1=yy;
t_salary=salary;
t_deptno=deptno;
gotoxy(30,10);
cout<<"Designation: ";
puts(t_emp_job);
gotoxy(30,12);
cout<<"Joining Date: ";
gotoxy(49,12);
cout<<d1<<"-"<<m1<<"-"<<y1;
gotoxy(30,14);
cout<<"Dept. No.: "<<t_deptno;
gotoxy(30,16);
cout<<"Basic Salary RS. "<<setw(15)
<<setprecision(2)
<<setiosflags(ios::left)
<<setiosflags(ios::showpoint)
<<setiosflags(ios::fixed)
<<t_salary;
gotoxy(30,18);
cout<<"Grade: "<<grade;
gotoxy(30,20);
cout<<"Enter New Salary: ";
cin>>x_salary;
break;
}
}
sfile.close();
if(x_salary>=2500 && x_salary<=3000)
{
t_salary=x_salary;
strcpy(t_grade,"C");
}
else if(x_salary>=3001 && x_salary<=4000)
{
t_salary=x_salary;
strcpy(t_grade,"B");
}
else if(x_salary>=4001 && x_salary<=5000)
{
t_salary=x_salary;
strcpy(t_grade,"A");
}
else if(x_salary>5000)
{
t_salary=x_salary;
strcpy(t_grade,"O");
}
else
{
gotoxy(25,22);
cout<<"Press any key to continue...";
getch();
return;
}
//Passes all the parameters for modifying salary(overwriting)
modify_salary(t_emp_no,d1,m1,y1,t_grade,t_emp_job,t_salary,t_deptno);
gotoxy(20,22);
cout<<"Salary Changed !!! Press Any key to continue ... ";
getch();
}
//Function to display all the employee lists including basic salary.
void details::display_emp_list(void)
{
employee a;
clrscr();
int flag;
fstream file;
int memp_no,xemp_no;
float x_salary=0.0;
char xemp_job[12];
gotoxy(25,2);
cout<<"Employee List";
gotoxy(25,3);
cout<<"===============";
int d1,m1,y1;
struct date d; //For extracting system date
getdate(&d);
d1=d.da_day;
m1=d.da_mon;
y1=d.da_year;
gotoxy(62,3);
cout<<"Date :"<<d1<<"-"<<m1<<"-"<<y1;
gotoxy(1,4);
for(int j=1;j<=79;j++)
cout<<"=";
gotoxy(1,5);
cout<<"Emp_no#";
gotoxy(10,5);
cout<<"Name";
gotoxy(30,5);
cout<<"Address";
gotoxy(55,5);
cout<<"Designation";
gotoxy(70,5);
cout<<"Salary";
gotoxy(1,6);
for(j=1;j<=79;j++)
cout<<"=";
file.open("DETAILS.dat",ios::in);
file.seekg(0,ios::beg);
int row=7;
//Displaying the employee salary and designation details from EMP.dat data file
while(file.read((char *)this, sizeof(details)))
{
flag=0;
delay(2);
gotoxy(3,row);
cout<<emp_no;
memp_no=emp_no;
gotoxy(10,row);
puts(name);
gotoxy(30,row);
puts(address);
//Calls to print the employee designation
strcpy(xemp_job,a.found_job(memp_no)); //Function to copy designation
gotoxy(55,row);
cout<<xemp_job;
//Calls to print employee salary
x_salary=a.found_salary(memp_no);
if(x_salary>0)
{
gotoxy(70,row);
cout<<setw(15)
<<setprecision(2)
<<setiosflags(ios::left)
<<setiosflags(ios::showpoint)
<<setiosflags(ios::fixed)
<<x_salary;
}
row++;
if(row==23)
{
flag=1;
row=6;
gotoxy(4,24);
cout<<"Press any key to continue ...";
getch();
clrscr();
}
}
gotoxy(1,row);
for(j=1;j<=79;j++)
cout<<"=";
file.close();
if(!flag)
{
gotoxy(25,24);
cout<<"Press any key to continue...";
getch();
}
getch();
}
//Function to clear a row from left of the screen
void employee::Left_clear(int col,int row)
{
for(int j=col;j<=40;j++)
{
gotoxy(j,row);
cout<<" ";
}
}
//Function to clear a row from right of the screen
void employee::Right_clear(int col,int row)
{
for(int j=col;j<=79;j++)
{
gotoxy(j,row);
cout<<" ";
}
}
//Function to search a record found in DETAILS.dat data file
int details::found_employee(int t_emp_no)
{
fstream file;
file.open("DETAILS.dat",ios::in);
file.seekg(0,ios::beg);
int found=0;
//Checks the employeeis there in DETAILS.dat data file or not
while(file.read((char *)this, sizeof(details)))
{
if(emp_no==t_emp_no)
{
found=1;
break;
}
}
file.close();
return found;
}
//Function for returning the name of employee from DETAILS.dat data file
char *details::return_name(int t_emp_no)
{
fstream file;
file.open("DETAILS.dat",ios::in);
file.seekg(0,ios::beg);
char t_name[30];
//Returns the name of employee from DETAILS.dat data file
while(file.read((char *)this, sizeof(details)))
{
if(emp_no==t_emp_no)
{
strcpy(t_name,name);
break;
}
}
file.close();
return t_name;
}
//Function for returning the address of employee from DETAILS.dat data file
char *details::return_address(int t_emp_no)
{
fstream file;
file.open("DETAILS.dat",ios::in);
file.seekg(0,ios::beg);
char t_address[30];
//Returns the employee address
while(file.read((char *)this, sizeof(details)))
{
if(emp_no==t_emp_no)
{
strcpy(t_address,address);
break;
}
}
file.close();
return t_address;
}
//Function for displaying name and address details from DETAILS.dat data file
void details::display_from_details(int t_emp_no)
{
fstream file;
file.open("DETAILS.dat",ios::in);
file.seekg(0,ios::beg);
char t_zip[10];
while(file.read((char *)this, sizeof(details)))
{
if(emp_no==t_emp_no)
{
gotoxy(10,8);
cout<<"Name: "<<name;
gotoxy(10,10);
cout<<"Address: "<<address;
gotoxy(10,12);
cout<<"Date of Birth: "<<dd<<"-"<<mm<<"-"<<yy;
gotoxy(10,14);
cout<<"City: "<<city;
gotoxy(10,16);
cout<<"State: "<<state;
gotoxy(10,18);
cout<<"Zip Code: "<<zip;
break;
}
}
file.close();
}
//Function for displaying data from DETAILS.dat data file
void employee::box_for_display(int t_emp_no)
{
int d1,m1,y1;
struct date d;
getdate(&d);
d1=d.da_day;
m1=d.da_mon;
y1=d.da_year;
gotoxy(10,6);
cout<<"Employee No. "<<t_emp_no;
gotoxy(55,6);
cout<<"Date: "<<d1<<"/"<<m1<<"/"<<y1;
gotoxy(8,7);
for(int i=1;i<=64;i++)
cout<<"=";
details EMP_ADD;
EMP_ADD.display_from_details(t_emp_no);
}
//Function for displaying details from EMP.dat data file
void employee::display_employee(void)
{
clrscr();
char t_acc[10];
int j;
int t,t_emp_no;
gotoxy(71,1);
cout<<"<0>=Exit";
gotoxy(5,5);
cout<<"Enter employee no. ";
gets(t_acc);
t=atoi(t_acc);
t_emp_no=t;
if(t_emp_no==0)
return;
clrscr();
details EMP_ADD;
if(!EMP_ADD.found_employee(t_emp_no))
{
gotoxy(5,5);
cout<<"\7Employee not found";
getch();
return;
}
gotoxy(30,4);
cout<<"Individual Employee";
gotoxy(30,5);
cout<<"=======================";
box_for_display(t_emp_no);
fstream file;
file.open("EMP.dat",ios::in);
//Displays the employee salary and designation details
while(file.read((char *)this, sizeof(employee)))
{
if(emp_no==t_emp_no)
{
gotoxy(40,8);
cout<<"Designation: "<<emp_job;
gotoxy(40,10);
cout<<"Date of Joining: "<<dd<<"-"<<mm<<"-"<<yy;
gotoxy(40,12);
cout<<"Salary: "<<setw(15)
<<setprecision(2)
<<setiosflags(ios::left)
<<setiosflags(ios::showpoint)
<<setiosflags(ios::fixed)
<<salary;
gotoxy(40,14);
cout<<"Department No.: "<<deptno;
gotoxy(40,16);
cout<<"Grade: "<<grade;
delay(2);
break;
}
}
file.close();
gotoxy(8,19);
for(int i=1;i<=64;i++)
cout<<"=";
gotoxy(25,20);
cout<<"Press any key to continue ...";
getch();
}
void employee::month_salary(void)
{
clrscr();
char t_acc[10];
char *cmonth;
int j;
int t,t_emp_no;
gotoxy(71,1);
cout<<"<0>=Exit";
gotoxy(5,5);
cout<<"Enter employee no. ";
gets(t_acc);
t=atoi(t_acc);
t_emp_no=t;
if(t_emp_no==0)
return;
clrscr();
details EMP_ADD;
if(!EMP_ADD.found_employee(t_emp_no))
{
gotoxy(5,5);
cout<<"\7Employee not found";
getch();
return;
}
gotoxy(30,3);
cout<<"Salary Slip";
gotoxy(30,4);
cout<<"=============";
int d1,m1,y1;
struct date d;
getdate(&d);
d1=d.da_day;
m1=d.da_mon;
y1=d.da_year;
gotoxy(10,5);
cout<<"Employee No. "<<t_emp_no;
//To print the month in character form
switch (m1)
{ //get month name
case 1:
strcpy(cmonth,"January");
break;
case 2:
strcpy(cmonth,"February");
break;
case 3:
strcpy(cmonth,"March");
break;
case 4:
strcpy(cmonth,"April");
break;
case 5:
strcpy(cmonth,"May");
break;
case 6:
strcpy(cmonth,"June");
break;
case 7:
strcpy(cmonth,"July");
break;
case 8:
strcpy(cmonth,"August");
break;
case 9:
strcpy(cmonth,"September");
break;
case 10:
strcpy(cmonth,"October");
break;
case 11:
strcpy(cmonth,"November");
break;
case 12:
strcpy(cmonth,"December");
break;
}
gotoxy(45,5);
cout<<cmonth;
gotoxy(55,5);
cout<<"Date: "<<d1<<"/"<<m1<<"/"<<y1;
gotoxy(8,6);
for(int i=0;i<=64;i++)
cout<<"=";
//Displays name and salary part of the employee
EMP_ADD.send_DATA(t_emp_no);
fstream file;
file.open("EMP.dat",ios::in);
//Displays the designation and salary part of employee
while(file.read((char *)this, sizeof(employee)))
{
if(emp_no==t_emp_no)
{
gotoxy(45,8);
cout<<"Date of Joining: "<<dd<<"-"<<mm<<"-"<<yy;
gotoxy(45,9);
cout<<"Designation: "<<emp_job;
gotoxy(45,10);
cout<<"Department No.: "<<deptno;
gotoxy(45,11);
cout<<"Grade: "<<grade;
delay(2);
break;
}
}
file.close();
gotoxy(8,12);
for(i=0;i<=64;i++)
cout<<"-";
gotoxy(10,13);
cout<<"Salary";
gotoxy(35,13);
cout<<"Earning";
gotoxy(62,13);
cout<<"Deduction";
gotoxy(8,14);
for(i=0;i<=64;i++)
cout<<"-";
//Steps to calculate the da,hra,pf,esi,conveyence etc.
float EPF = 0.0; //Employee provident fund(deduction)
float DA = 0.0; //Employee Dearness allowance(earnings)
float ESI = 0.0; //Employee state insurance(deduction)
float HRA = 0.0; //Employee house rent allowance(earnings)
float CANTEEN = 0.0; //Employee canteen facility(deduction)
float CONV = 0.0; //Employee conveyance(earnings)
float ANN_GROSS = 0.0; //Employee annual income
float ITAX = 0.0; //Employee income tax
float NET_INCOME = 0.0; //Employee monthly income
float TOTAL_EARN = 0.0; //Employee total earnings
float TOTAL_DEDU = 0.0; //Employee total deductions
float PFTAX = 0.0; //Provident fund tax
float TAXABLE = 0.0; //Employee taxable amount
//Steps to calculate DA,HRA, and CONV according to the table of above description
if(salary>=2500 && salary<=3000)
{
DA=salary * 0.9;
HRA=salary * 0.2;
CONV=salary * 0.1;
}
else if(salary>=3001 && salary<=4000)
{
DA=salary * 0.12;
HRA=salary * 0.3;
CONV=salary * 0.15;
}
else if(salary>=4001 && salary<=5000)
{
DA=salary * 0.14;
HRA=salary * 0.35;
CONV=salary * 0.2;
}
else if(salary>=5001)
{
DA=salary * 0.16;
HRA=salary * 0.4;
CONV=salary * 0.25;
}
TOTAL_EARN=salary+DA+HRA+CONV; //Calculates the total monthly gross
ANN_GROSS=TOTAL_EARN * 12; //Annual gross
//Calculates for deduction as pf(12%),esi(0.07%),csf(Rs.350/-)
EPF=(salary+DA) * 0.12; //Calculates 12% as provident fund
//Calculates 0.7% as employee state insurance
ESI=salary * 0.07;
CANTEEN=350; //Canteen charges
//Note:As the employee provides 12% as PF,10% is exempted,and
//remaining 2% is taxable
//Anually taxable from PF side
PFTAX=((salary + DA) * 0.2) * 12;
//Annual Gross including Provident Fund tax
ANN_GROSS=ANN_GROSS + PFTAX;
//Tax calculation steps
//After less standard deduction, the annual gross is:
if(ANN_GROSS<=60000)
ANN_GROSS=40000 - 20000;
else
ANN_GROSS=ANN_GROSS - 20000;
//Calculation of taxable amount
if(ANN_GROSS>40000)
TAXABLE=ANN_GROSS - 40000;
else
TAXABLE=0;
//Steps to calculate the tax
if(TAXABLE<=20000)
ITAX=TAXABLE * 0.1;
else if(TAXABLE>20000 && TAXABLE<=110000)
ITAX=2000 + ((TAXABLE-20000) * 0.2);
else if(TAXABLE>110000)
ITAX=20000 + ((TAXABLE-110000) * 0.3);
ITAX=ITAX/12;
//The total deduction
TOTAL_DEDU=EPF + ESI + CANTEEN + ITAX;
NET_INCOME=TOTAL_EARN - TOTAL_DEDU;
gotoxy(11,15);
cout<<"Basic: ";
gotoxy(22,15);
cout<<setw(15)
<<setprecision(2)
<<setiosflags(ios::left)
<<setiosflags(ios::showpoint)
<<setiosflags(ios::fixed)
<<salary;
gotoxy(35,15);
cout<<setw(15)
<<setprecision(2)
<<setiosflags(ios::left)
<<setiosflags(ios::showpoint)
<<setiosflags(ios::fixed)
<<salary;
gotoxy(50,15);
cout<<"E.P.F.:";
gotoxy(63,15);
cout<<setw(15)
<<setprecision(2)
<<setiosflags(ios::left)
<<setiosflags(ios::showpoint)
<<setiosflags(ios::fixed)
<<EPF;
gotoxy(11,16);
cout<<"D.A.";
gotoxy(22,16);
cout<<setw(15)
<<setprecision(2)
<<setiosflags(ios::left)
<<setiosflags(ios::showpoint)
<<setiosflags(ios::fixed)
<<DA;
gotoxy(35,16);
cout<<setw(15)
<<setprecision(2)
<<setiosflags(ios::left)
<<setiosflags(ios::showpoint)
<<setiosflags(ios::fixed)
<<DA;
gotoxy(50,16);
cout<<"E.S.I.:";
gotoxy(63,16);
cout<<setw(15)
<<setprecision(2)
<<setiosflags(ios::left)
<<setiosflags(ios::showpoint)
<<setiosflags(ios::fixed)
<<ESI;
gotoxy(11,17);
cout<<"H.R.A.:";
gotoxy(22,17);
cout<<setw(15)
<<setprecision(2)
<<setiosflags(ios::left)
<<setiosflags(ios::showpoint)
<<setiosflags(ios::fixed)
<<HRA;
gotoxy(35,17);
cout<<setw(15)
<<setprecision(2)
<<setiosflags(ios::left)
<<setiosflags(ios::showpoint)
<<setiosflags(ios::fixed)
<<HRA;
gotoxy(50,17);
cout<<"CANTEEN:";
gotoxy(63,17);
cout<<setw(15)
<<setprecision(2)
<<setiosflags(ios::left)
<<setiosflags(ios::showpoint)
<<setiosflags(ios::fixed)
<<CANTEEN;
gotoxy(11,18);
cout<<"CONV.:";
gotoxy(22,18);
cout<<setw(15)
<<setprecision(2)
<<setiosflags(ios::left)
<<setiosflags(ios::showpoint)
<<setiosflags(ios::fixed)
<<CONV;
gotoxy(35,18);
cout<<setw(15)
<<setprecision(2)
<<setiosflags(ios::left)
<<setiosflags(ios::showpoint)
<<setiosflags(ios::fixed)
<<CONV;
gotoxy(50,18);
cout<<"INCOME TAX:";
gotoxy(63,18);
cout<<setw(15)
<<setprecision(2)
<<setiosflags(ios::left)
<<setiosflags(ios::showpoint)
<<setiosflags(ios::fixed)
<<ITAX;
gotoxy(8,19);
for(i=0;i<=64;i++)
cout<<"-";
gotoxy(11,20);
cout<<"Total Earnings:";
gotoxy(34,20);
cout<<setw(15)
<<setprecision(2)
<<setiosflags(ios::left)
<<setiosflags(ios::showpoint)
<<setiosflags(ios::fixed)
<<TOTAL_EARN;
gotoxy(48,20);
cout<<"Total Deduct:";
gotoxy(63,20);
cout<<setw(15)
<<setprecision(2)
<<setiosflags(ios::left)
<<setiosflags(ios::showpoint)
<<setiosflags(ios::fixed)
<<TOTAL_DEDU;
gotoxy(8,21);
for(i=0;i<=64;i++)
cout<<"=";
gotoxy(11,22);
cout<<"Net Pay:";
gotoxy(34,22);
cout<<setw(15)
<<setprecision(2)
<<setiosflags(ios::left)
<<setiosflags(ios::showpoint)
<<setiosflags(ios::fixed)
<<NET_INCOME;
gotoxy(55,23);
cout<<"Signature";
gotoxy(10,24);
cout<<"Press any key to Continue ...";
getch();
}
//Function to provide data into salary report
void details::send_DATA(int t_emp_no)
{
fstream file;
file.open("DETAILS.dat",ios::in);
file.seekg(0,ios::beg);
char t_zip[10];
//Sending data into month_salary function
while(file.read((char *)this, sizeof(details)))
{
if(emp_no==t_emp_no)
{
gotoxy(10,7);
cout<<"Name: "<<name;
gotoxy(10,8);
cout<<"Address: "<<address;
gotoxy(10,9);
cout<<"City: "<<city;
gotoxy(10,10);
cout<<"State: "<<state;
gotoxy(10,11);
cout<<"Zip Code: "<<zip;
gotoxy(45,7);
cout<<"Date of Birth: "<<dd<<"-"<<mm<<"-"<<yy;
break;
}
}
file.close();
}
//Function for main menu to append new record into both DETAILS.dat & EMP.dat files
void employee::new_employee(void)
{
char ch;
int i,valid;
clrscr();
details EMP_ADD;
gotoxy(65,4);
cout<<"<0>=Exit";
gotoxy(3,3);
for(i=1;i<=76;i++)
cprintf(" ");
textbackground(BLACK);
textcolor(BLACK+BLINK);
textbackground(WHITE);
gotoxy(30,4);
cprintf("Open New Employee");
textcolor(LIGHTGRAY);
textbackground(BLACK);
int d1,m1,y1;
struct date d; //For extracting system date
getdate(&d);
d1=d.da_day;
m1=d.da_mon;
y1=d.da_year;
int t_emp_no;
t_emp_no=EMP_ADD.last_emp_no();
t_emp_no++;
//Appends & deletes a false record to create primary position in data file
if(t_emp_no==1)
{
EMP_ADD.EMP_APPEND(t_emp_no,"abc","xyz",0,0,0,"aaa","a","aaaa");
EMP_ADD.delete_employee(t_emp_no);
EMP_APPEND(t_emp_no,1,1,1997,"D","details",1.1,0);
delete_employee(t_emp_no);
}
char t_name[30],t_address[30];
char t_grade[2],t_emp_job[12];
int tdd,tmm,tyy;
char P_city[10],t_state[3],t_zip[10];
float t_salary=0.0;
int t_deptno;
gotoxy(5,6);
cout<<"Date: "<<d1<<"-"<<m1<<"-"<<y1;
gotoxy(5,8);
cout<<"Employee No# "<<t_emp_no;
gotoxy(40,8);
cout<<"Name: ";
gotoxy(5,10);
cout<<"Address: ";
gotoxy(5,12);
cout<<"Date of Birth: ";
gotoxy(5,13);
cout<<"City: ";
gotoxy(5,14);
cout<<"State: ";
gotoxy(5,15);
cout<<"Zip: ";
gotoxy(40,15);
cout<<"Designation: ";
gotoxy(40,16);
cout<<"Date of Joining: ";
gotoxy(40,17);
cout<<"Department no.: ";
gotoxy(40,18);
cout<<"Basic Salary: ";
gotoxy(40,19);
cout<<"Grade: ";
do
{
Right_clear(48,8);
Left_clear(5,23);
gotoxy(5,23);
cout<<"Enter name of Person";
valid=1;
gotoxy(48,8);
gets(t_name);
strupr(t_name);
if(t_name[0]=='0')
return;
if(strlen(t_name)==0 || strlen(t_name)>25)
{
valid=0;
gotoxy(5,23);
cprintf("\7Name should not greater than 25");
getch();
}
}while(!valid);
do
{
Left_clear(20,10);
Left_clear(5,23);
gotoxy(5,23);
cout<<"Enter Address of the Person";
valid=1;
gotoxy(20,10);
gets(t_address);
strupr(t_address);
if(t_address[0]=='0')
return;
if(strlen(t_address)==0 || strlen(t_address)>25)
{
valid=0;
gotoxy(5,23);
cprintf("\7Address should not greater than 25");
getch();
}
}while(!valid);
Left_clear(23,12);
gotoxy(23,12);
cin>>tdd;
gotoxy(25,12);
cout<<"-";
gotoxy(26,12);
cin>>tmm;
gotoxy(28,12);
cout<<"-";
gotoxy(29,12);
cin>>tyy;
do
{
Left_clear(13,13);
Left_clear(5,23);
gotoxy(5,23);
cout<<"Enter City";
valid=1;
gotoxy(15,13);
gets(P_city);
strupr(P_city);
if(P_city[0]=='0')
return;
if(strlen(P_city)==0 || strlen(P_city)>10)
{
valid=0;
gotoxy(5,23);
cprintf("\7City should not Space");
getch();
}
}while(!valid);
do
{
Left_clear(15,14);
Left_clear(5,23);
gotoxy(5,23);
cout<<"Enter State";
valid=1;
gotoxy(15,14);
gets(t_state);
strupr(t_state);
if(t_state[0]=='0')
return;
if(strlen(t_state)==0 || strlen(t_state)>2)
{
valid=0;
gotoxy(5,23);
cprintf("\7State should not greater than 2");
getch();
}
}while(!valid);
do
{
Left_clear(15,15);
Left_clear(5,23);
gotoxy(5,23);
cout<<"Enter Zip Code";
valid=1;
gotoxy(15,15);
gets(t_zip);
strupr(t_zip);;
if(t_zip[0]=='0')
return;
if(strlen(t_zip)==0 || strlen(t_zip)>9)
{
valid=0;
gotoxy(5,23);
cprintf("\7Zip should not greater than 9");
getch();
}
}while(!valid);
do
{
Right_clear(59,15);
Left_clear(5,23);
gotoxy(5,23);
cout<<"Enter Designation";
valid=1;
gotoxy(59,15);
gets(t_emp_job);
strupr(t_emp_job);
if(t_emp_job[0]=='0')
return;
if(strlen(t_emp_job)==0 || strlen(t_emp_job)>11)
{
valid=0;
gotoxy(5,23);
cprintf("\7Designation should not greater than 9");
getch();
}
}while(!valid);
Right_clear(59,16);
gotoxy(59,16);
cin>>d1;
gotoxy(61,16);
cout<<"-";
gotoxy(62,16);
cin>>m1;
gotoxy(64,16);
cout<<"-";
gotoxy(65,16);
cin>>y1;
gotoxy(59,17);
cin>>t_deptno;
do
{
Right_clear(59,18);
Left_clear(5,23);
gotoxy(5,23);
cout<<"Basic Salary not less than 900";
valid=1;
//Declares as character type & will convert into float type using atof()
char t[10];
gotoxy(59,18);
gets(t);
t_salary=atof(t);
if(t[0]=='0')
{
valid=0;
gotoxy(5,23);
cprintf("\7Should not less than 900");
getch();
}
}while(!valid);
if(t_salary>=2500 && t_salary<=3000)
strcpy(t_grade,"C");
else if(t_salary>=3001 && t_salary<=4000)
strcpy(t_grade,"B");
else if(t_salary>=4001 && t_salary<=5000)
strcpy(t_grade,"A");
else if(t_salary>5000)
strcpy(t_grade,"O");
else
return;
gotoxy(59,19);
cout<<t_grade;
Left_clear(5,23);
do
{
Left_clear(5,17);
valid=1;
gotoxy(5,22);
cout<<"Do you want to save the record<Y/N>: ";
ch=getche();
if(ch=='0')
return;
ch=toupper(ch);
}while(ch!='N' && ch!='Y');
if(ch=='N')
return;
clrscr();
//Appends the new employee record into DETAILS.dat data file
EMP_ADD.EMP_APPEND(t_emp_no,t_name,t_address,tdd,tmm,tyy,
P_city,t_state,t_zip);
//Appends the new employee and designation in EMP.dat data file
EMP_APPEND(t_emp_no,d1,m1,y1,t_grade,t_emp_job,t_salary,t_deptno);
}
//Function to count the total number of records in DETAILS.dat data file
// for generating automatic employee number
int details::recordno(int t_emp_no)
{
fstream file;
file.open("DETAILS.dat",ios::in);
file.seekg(0,ios::beg);
int count=0;
//Counts the total records in DETAILS.dat data file
while(file.read((char *)this, sizeof(details)))
{
count++;
if(t_emp_no==emp_no)
break;
}
file.close();
return count;
}
//Function to count the total number of record in EMP.dat data file for
//regenerating automatic employee number
int employee::recordno(int t_emp_no)
{
fstream sfile;
sfile.open("EMP.dat",ios::in);
sfile.seekg(0,ios::beg);
int count=0;
//Counts the total record in EMP.dat data file
while(sfile.read((char *)this, sizeof(employee)))
{
count++;
if(t_emp_no==emp_no)
break;
}
sfile.close();
return count;
}
//Function to close the employee account in organisation
void employee::close_employee(void)
{
clrscr();
char ch;
char t_acc[10];
int t,t_emp_no;
gotoxy(71,1);
cout<<"<0>=Exit";
gotoxy(5,5);
cout<<"Enter the employee no. ";
gets(t_acc);
t=atoi(t_acc);
t_emp_no=t;
if(t_emp_no==0)
return;
clrscr();
gotoxy(30,4);
cout<<"Individual Employee to Delete";
gotoxy(30,5);
cout<<"=====================================";
details EMP_ADD;
box_for_display(t_emp_no);
fstream file;
file.open("EMP.dat",ios::in);
//Displays the record which will be deleted
while(file.read((char *)this, sizeof(employee)))
{
if(emp_no==t_emp_no)
{
gotoxy(40,8);
cout<<"Designation: "<<emp_job;
gotoxy(40,10);
cout<<"Date of Joining: "<<dd<<"-"<<mm<<"-"<<yy;
gotoxy(40,12);
cout<<"Salary: "<<setw(15)
<<setprecision(ios::left)
<<setiosflags(ios::showpoint)
<<setiosflags(ios::fixed)
<<setiosflags(ios::fixed)
<<salary;
gotoxy(40,14);
cout<<"Department No.: "<<deptno;
gotoxy(40,16);
cout<<"Grade: "<<grade;
delay(2);
break;
}
}
file.close();
gotoxy(8,19);
for(int i=1;i<=64;i++)
cout<<"=";
gotoxy(10,20);
do
{
Left_clear(5,15);
gotoxy(5,20);
cout<<"Close this employee<y/n>? ";
ch=getche();
if(ch=='0')
return;
ch=toupper(ch);
}while(ch!='N' && ch!='Y');
if(ch=='N')
return;
//Function to delete the record from DETAILS.dat data file
EMP_ADD.delete_employee(t_emp_no);
//Function to delete the record from EMP.dat data file
delete_employee(t_emp_no);
gotoxy(5,20);
cout<<"\7Employee Deleted";
gotoxy(5,23);
cout<<"Press any key to Continue..";
getch();
}
//Main program starts here
void INTRO();
void main(void)
{
control c;
//Calling function from GH.CPP file
INTRO();
closegraph();
c.help();
c.MAIN_SCREEN();
}
//Program source code of GH.cpp
#include<iostream.h>
#include<graphics.h>
#include<dos.h>
#include<conio.h>
void INTRO()
{
/*Request auto detection of graph driver*/
int gdriver=DETECT,gmode,errorcode,ch=11;
initgraph(&gdriver,&gmode,"c:\\tc"); //Initialises graphics system
//Draws a rectangle (graphics mode)
rectangle(22,7,630,450); //Draws a rectangle
rectangle(32,17,620,440);
//setbkcolor sets the current background colour using the palette
setbkcolor(BLUE+LIGHTGRAY); //Sets the background colour
int a=0,h=0,r,fla;
while((a != 143) && (!kbhit()))
{
h=0;
const char far *t[]={"","","S ","H ","""A","""H","I","D",""};
while((h<=8) && (!kbhit()))
{
setbkcolor(12);
//setcolor sets the current drawing color
setcolor(a+h); //Sets the text colour
//high video selects high intensity text characters
highvideo();
//Sets the current text characterstics
settextstyle(4,HORIZ_DIR,3);
//outtextxy displays a string at the specified location(graphics mode)
if((h % 2)==0)
fla=15;
else
fla=12;
setcolor(fla);
outtextxy(215,450,"Press any key to start.....");
settextstyle(4,HORIZ_DIR,3);
setcolor(15+a);
outtextxy(370,350,"BY:-");
if((h==0) || (h==1) || (h==2))
r=17*h+5;
else
r=15*h;
outtextxy(380+r,380,t[h]);
//Suspends execution for interval (milliseconds)
delay(500);
h++;
}
delay(2000);
a++;
}
closegraph();
initgraph(&gdriver,&gmode,"c:\\tc");
int x=5,y=5,x1=370,y2=530;
rectangle(1,1,620,400);
while(ch<28)
{
moveto(x,y);
settextstyle(ch,0,0);
setcolor(ch);
ch++;
outtextxy(y,x,"DREAM PVT.LTD");
outtextxy(y,x1,"DREAN PVT.LTD");
outtextxy(y2,y,"DREAM PVT.LTD");
outtextxy(y2,x1,"DREAM PVT.LTD");
x+=10;
y+=10;
x1-=10;
y2-=10;
delay(500);
}
setcolor(WHITE+BLINK);
outtextxy(260,190,"DREAM PVT.LTD");
delay(2000);
closegraph();
initgraph(&gdriver,&gmode,"c:\\tc");
setcolor(RED);
settextstyle(4,HORIZ_DIR,5);
outtextxy(100,200,"LOADING DATABASE");
delay(5000);
closegraph();
}
0 Comments