Project File on C++
-
Upload
kapil-agarwal -
Category
Documents
-
view
221 -
download
0
Transcript of Project File on C++
-
8/3/2019 Project File on C++
1/59
AProject File
On
C++
-
8/3/2019 Project File on C++
2/59
/* This project is basically for the user's who want to develop C++ menu driven programs
and building application through their real life. It
contains an assumend example of an organization (XYZ Company). The personneldepartment of the organization interacts with regard to the employee
managment, the job criteria, and salary behaviour of about more than 100 employees.
Also they have number of terms and contitions for employees (which is givenin the programs by comment line either in // or /* ). It comprises a menu driven program,
and includes number of options, procedures for each selective modules
with a complete class declaration of OOPs concept. The complete project handles twodata bases as DETAILS.dat and EMP.dat. This project includes number of libraries
including different header files and their respective functions which is noted down after
the source code of the project.
According to the requirements, the employer deals with certain attributes like:
emp_no - Employee number
name - Employee name
address - Employee addressdd, mm, yy - Date of birth & date of joining
city - Employee citystate - Employee state
zip - Employee Zip code
salary - Employee basic salary
grade - Employee grade according to grade calculationemp_job - Employee job/designation
deptno - Employee department number
And the above attributes are divided into two databases as: DETAILS.dat & EMP.dat
data file
The field contents of DETAILS.dat as:int emp_no;
char name[30], address[30];
int dd, mm, yy;char city[10], state[2], zip[10];
and the fields contents of EMP.dat as:
int emp_no;
int dd, mm, yy;char grade[2];
char emp_job[12];
float salary;int deptno;
This project is developed using C++ class concepts and having number of differentuser defined function (UDFs) as follows:
DRAW_LINE(.....)
-
8/3/2019 Project File on C++
3/59
This function passes four parameters including three integer and one character to
draw different lines to design the screen beautiful. The character parameter draw the
ASCII character line-by-line on screen. So, for horizontal line draw this function isusefull.
DRAW_VER(.....)
The DRAW_VER(.....) function is helpful for drawing vertical lines on screen to design
either menu or program forms for data entry, modify, display, delete etc..
DRAW_BOX(.....)
This function creates different size of boxes on the screen according to the respectiveparameters. Out of all the parameters they draw boxes till the limit you want.
MAIN_SCREEN(.....)
This is the main screening menu which will display your 6 different prompts and havingdifferent activities.
Each prompt is connected with different functions to perform the respective purposes.
Out of all the options
the last one produces another sub-menu for modifying and deleting existing employeeinformations.
While handling the main menu you can press any selective number to perform theoperation or press 0 (Zero) to exit from
the main menu. But it is also helpful in almost all menus that, you can press 0 (zero) to
exit from the respective menu.
MENU_EDIT(.....)
This is one of the sub function which is connected from the MAIN_SCREEN() function
to perform the modification and deletion operation
on employee data from DETAILS.dat and EMP.dat data file.
All the the ways the menus are perform the operation according to the employee number
(emp_no) except
the "Open New Employee" of MAIN_SCREEN() function because, the "Open NewEmployee" form automatically creates
the employee number after a brief search to the existing employee numbers. Basically,
the numbers are generating automatically, like your 'Banking Project'.
EMP_APPEND(.....)
-
8/3/2019 Project File on C++
4/59
The EMP_APPEND() function declared in both details and employee class. This function
is used to append new records into both DETAIL.dat and EMP.dat data file
by passing their recpective parameters.
modify()
This function is used to display a modification screen for modifying the employee details
by entering the employee number. While modifying the employee number
(emp_no) will be entered by the user and will search in both the data bases, and then therespective records can modified.
The function uses a function found_employee() to search the particular employee is exists
or not. If exists then the function
display(..) will display the details of employee from DETAILS.dat and EMP.dat data file.After modifying the data it again
re-writes the same in both the data files through modify_employee(.....) and
modify_salary(.....) functions respectively.
delete_employee(.....)
This is the sub-function of "Edit Employee" prompt of main menu. This function is used
to delete an existing employee details from both DETAILS.dat and EMP.dat data file.
This function is declared both in
details class and employee class. While in delete_employee function, you have to enterthe employee number for delete! and the deleted informations will display in the screen
through the function display_employee() and a prompt for delete. If you will press
'Y/y' then the records will be deleted from both DETAILS.dat and EMP.dat data file.
display_emp_list()
This function is used to display all existing employee list from DETAILS.dat and
EMP.dat data file. While listing the records of all employees it used two other function
found_salary() and *found_job from employee class to displays the designation andsalary of each employee.
last_emp_no(....)
This function detects the last employee number in the DETAILS.dat data file. While
entering new records into data files, it will first find the last employee number for the
new_employee(...) function forgenerating the next employee number automatically.
found_employee(.....)
As the project operated with only the key field employee number and when the employee
number entered it always checks in the data base DETAILS.dat that whether the
employee is exist or not. If exists, then further
-
8/3/2019 Project File on C++
5/59
the employee can processed eiter for modify, delete, display or etc.
*return_name(...)
If their is any requirement of the employee name to display at any momemt then, this
function returns the name of the employee fromDETAILS.dat data file with the parameter employee number (emp_no). This function
uses emp_no as the parameter to search in the data base.
*return_address(...)
If their is any requirement of the employee address to display at any momemt then, this
function returns the address of the employee fromDETAILS.dat data file with the parameter employee number (emp_no). This function
uses emp_no as the parameter to search in the data base.
display_from_details(...)
This function is used to display the employee details from DETAILS.dat data file. Beforedisplaying the name and address information, the fuction
passes emp_no as a parameter for which employee detail is to display. If the employee
no. found the the related informations will display in the screen.
srecordno(...)
This is very important function which returns the record position in the data file. Whileknowing the record number it will easy for modifying the existing employee details in
both DETAILS.dat and EMP.dat data files.
display(...)
This function is used to display the information related to employee number.Because, this function passes a parameter emp_no and according the number the
information is displayed.
This is a multi-declared function in class detials and employee.
send_DATA(...)
While generating a salary report, this function displays the name and address informationfrom DETAILS.dat data file with the help of
employee number (emp_no as a parameter).
modify_employee(...)
This function is used to re-write the name and address information both in the
DETAILS.dat and EMP.dat data file. The function
-
8/3/2019 Project File on C++
6/59
passes number of parameters which will be re-written in data file.
new_employee(.....)
This is the first function used for first option "Open New Employee" in
MAIN_SCREEN() function. When any new employee entered into the company, thedetailed
information is entered by using this function.
close_employee()
This is similar function like delete_employee(). It uses one parameter emp_no, for which
employee has to delete from EMP.dat data file.If it is true to delete then the employee salary behaviours will be deleted from EMP.dat
data file.
display_employee()
This is an another option in MAIN_SCREEN() function who dipslays the existingemployee lists in the screen. Also, this function uses other two function like *return_job
and return_salary for displaying job/designation and salary simultaneously with the
employee name and address.
Left_clear() and Right_clear()
This two function is used to clear the existing screen from a spacified row and till aspecified column. This functoin uses two parameters as int, int.
For left from a column position to till a last column. If your display/output screen divided
into two halves, then the screen may clear till 39th and 79th respectively according tothe parameters of the functions.
month_salary()
This function is used to create a monthly salary slip of an employee. The user has to enter
the employee number and if the employee exists in DETAILS.dat data file then, the
respective screen of salary slip will be displayed andall other benefits and deductions will calculated including income tax (as on table given
before the function source code). The final net salary displays individually employee
wise on screen.
modify_salary()
The function modify_salary() is used to re-write the modified record in EMP.dat data file.
When the user modifies the existing data according to the previous data, then all the
fields related to EMP.dat data file
-
8/3/2019 Project File on C++
7/59
will receive through the parameters in modify_salary() function which will re-write in the
previous position of EMP.dat data file.
All the way the function uses one major in-build function seekp(), which find the positionof the record in the data file where the record will be
re-written. Once the position will found, then the modified record will written easily on
the existing record.
found_salary()
This function is used to found the salary of a selected employee, for which receives a
parameter as emp_no into the function and
returns the found salary into the display_emp_list function.
found_job()
On the same way the function also found the job/designation of a selected employee, for
which recieves a parameter as emp_no into the function andreturn the found emp_job into the display_emp_list function.
change_salary()
The basic aim of the function is used to change the employee salary when he/she gets any
increment on basic salary.While changing the salary in EMP.dat data file, all other information related with the
employee in the data file will again
over written like modification techniques. Because while writting only one field into filethe record contents may distrub or
shifted its position either backward or forward, so the key record number may changes
which you won't except. Thus to avoid this typeof concurrency the user has to pass all information related to the data file again on same
way like addition of new record. But here the record is
not appended but over written.
box_for_display()
This function display the employee number and the date on the screen. Also the functioncalls the function
display_from_details to display the informations from DETAILS.dat data file accourding
to the employee number,which is one of the parameter in both box_for_display() and display_from_details()
functions.
*/
// Declaration of header files
-
8/3/2019 Project File on C++
8/59
#include
#include
#include #include
#include
#include #include
#include
#include #include
// This file includede from your library directory or compiler to support the graphics
mode#include "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
{public:
void MAIN_SCREEN(void);
void help(void);private:
void MENU_EDIT(void);
};
// details class for employee address section
class details
{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 the customer employee informationint last_emp_no(void); // To know the last employee number
int found_employee(int); // To found the employee is in "DETAILS.dat"
or not
-
8/3/2019 Project File on C++
9/59
char *return_name(int); // Function for validation entry of customer name
char *return_address(int); // Function for validation entry of customer
addressvoid display_from_details(int); // Function for displaying all the details
from DETAILS.dat data file
int recordno(int);void display(int); // To display the customer employee
void send_DATA(int); // Send details information into salary report
private:
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]); // Function to modify
the customer employee// void box_for_list(void); // Drawing a box;
int emp_no;
char name[30], address[30];
int dd, mm, yy;char city[10], state[3], zip[10];
};
// employee class for salary and designation
class employee
{public:
void new_employee(void); // Function to create a new employee
void close_employee(void); // Function to close an employeevoid display_employee(void); // Function to display the employees
void Left_clear(int, int); // Function to perform a left clear on specified
row from a specified columnvoid Right_clear(int, int); // Function to perform a right clear on specified
row from a specified column
void month_salary(void); // Function to list monthWise change_salaryreport
void display(int); // Function to display a change_salary employee
void modify_salary(int, int, int, int, char t_grade[2], char t_emp_job[12],
float, int); // Function to modify other informations related to employeeint recordno(int);
float found_salary(int); // Function to find salary from EMP.dat data
filechar *found_job(int); // Function to find the employee job for displaying a
total list
void change_salary(void); // Function to change the employee salary
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
-
8/3/2019 Project File on C++
10/59
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 the system date/ Enter date
char grade[2]; // As the employee type is Deposit or
Withdraw char emp_job[12]; // employee type as Cheque or Cash
float salary;
int deptno;};
// Function for horizontal line draw
void BOX_CLASS::DRAW_LINE(int column1, int column2, int row, char c){
for (column1; column1
-
8/3/2019 Project File on C++
11/59
{
c1 = c;
c2 = c;c3 = c;
c4 = c;
l1 = c;c2 = c;
}
gotoxy(column1, row1);cout
-
8/3/2019 Project File on C++
12/59
// setcolor sets the current drawing color
setcolor(RED);
// Sets the current text characteristics
settextstyle(0,HORIZ_DIR,1); // Changes the text style (font)
// outtextxy displays a string at the specified location (graphics mode)
outtextxy(420,90," = Exit"); // To display a text in a particular
row and coloumn position
setcolor(5);
settextstyle(1,HORIZ_DIR,2);
// outtextxy displays a string at the specified location (graphics mode)
outtextxy(170,350, "Developed by Author & Her Team");
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. SalarySlip");
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 system
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
-
8/3/2019 Project File on C++
13/59
break;
}
case '2':{
details EMP_ADD;
EMP_ADD.display_emp_list(); // Glogal list of employeefunction
break;
}case '3':
{
employee a;
a.display_employee(); // Displaying individual employeesall change_salary
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, "");MENU_EDIT(); // Sub menu for modifying or deleting any
employee
break;
}}
}
for (int i = 25; i >= 1; i--){
delay(2);
gotoxy(1, i);clrscr();
}
}
-
8/3/2019 Project File on C++
14/59
// Function for modify record and 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;
elseif (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
-
8/3/2019 Project File on C++
15/59
void control::help(void)
{
// getch gets a character from console but does not echo to the screengetch();
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 selects a new character color in text mode
textcolor(LIGHTGRAY);
delay(2);
gotoxy(5, 6);cout
-
8/3/2019 Project File on C++
16/59
delay(2);
gotoxy(6, 18);
cout
-
8/3/2019 Project File on C++
17/59
if (t_emp_no == 0)
return;
clrscr();
if (!found_employee(t_emp_no))
{ gotoxy(5, 5);
cout
-
8/3/2019 Project File on C++
18/59
a.Left_clear(5, 15);
gotoxy(2, 13);
for (j = 1; j
-
8/3/2019 Project File on C++
19/59
cout
-
8/3/2019 Project File on C++
20/59
{
valid = 0;
gotoxy(5, 23);cprintf("\7Address should not greater than 25");
getch();
}} while (!valid);
if (strlen(t_address) > 0)modified = 1;
if (!modified)
return;
a.Left_clear(21, 18);
gotoxy(5, 23);
cout >tdd;
gotoxy(23, 18);cout > tmm;
gotoxy(26, 18);cout > tyy;a.Left_clear(5,23);
do{
a.Left_clear(12, 19);
a.Left_clear(5, 23);gotoxy(5, 23);
cout 9)
{
valid = 0;gotoxy(5, 23);
cprintf("\7City should not greater than 9");
getch();
}
-
8/3/2019 Project File on C++
21/59
} while (!valid);
a.Left_clear(5, 23);
do
{
a.Left_clear(14, 20);a.Left_clear(5, 23);
gotoxy(5, 23);
cout 2)
{ valid = 0;
gotoxy(5, 23);cprintf("\7State should not greater than 1");
getch();
}
} while (!valid);a.Left_clear(5, 23);
do{
a.Left_clear(15, 21);
a.Left_clear(5, 23);gotoxy(5, 23);
cout 9)
{valid = 0;
gotoxy(5, 23);
cprintf("\7Zip should not greater than 9");getch();
}
} while (!valid);
a.Left_clear(5, 23);
-
8/3/2019 Project File on C++
22/59
do
{a.Right_clear(59, 16);
a.Left_clear(5, 23);
gotoxy(5, 23);cout 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 > m1;gotoxy(64, 17);
cout > y1;
gotoxy(59, 18);
cin >> t_deptno;
do
{a.Right_clear(59, 19);
a.Left_clear(5, 23);
gotoxy(5, 23);cout
-
8/3/2019 Project File on C++
23/59
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 = 3001 && t_salary = 4001 && t_salary 5000)
{strcpy(t_grade, "O");
}
elsereturn;
gotoxy(59, 20);cout
-
8/3/2019 Project File on C++
24/59
} 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.DATa.modify_salary(t_emp_no, d1, m1, y1, t_grade, t_emp_job, t_salary, t_deptno);
gotoxy(5, 23);
cout
-
8/3/2019 Project File on C++
25/59
gotoxy(10, 10);
cout
-
8/3/2019 Project File on C++
26/59
break;
}
}sfile.close();
}
// Function to insert modifyed 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 fileint location = 0;
location = (recno-1) * sizeof(details);
file.seekg(0, ios::beg);
// Search the position in file
file.seekp(location);
// Re-write 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;
-
8/3/2019 Project File on C++
27/59
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 filesfile.seekp(location);
// Re-write 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
-
8/3/2019 Project File on C++
28/59
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);
// Append 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);
// Delete the record using copy method into temporaty 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);
// Overwrites the temporay contents into original DETAILS.dat data file
while (!temp.eof())
-
8/3/2019 Project File on C++
29/59
{
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 the record using copy method into temporaty filewhile (!file.eof())
{
file.read((char *)this, sizeof(employee));
if (file.eof())
-
8/3/2019 Project File on C++
30/59
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 temporay 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 in EMP.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);
}
-
8/3/2019 Project File on C++
31/59
// 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 filewhile (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 accouding 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
-
8/3/2019 Project File on C++
32/59
return;
clrscr();
details EMP_ADD;if (!EMP_ADD.found_employee(t_emp_no))
{
gotoxy(5, 5);cout
-
8/3/2019 Project File on C++
33/59
cout
-
8/3/2019 Project File on C++
34/59
{
gotoxy(25, 22);
cout
-
8/3/2019 Project File on C++
35/59
-
8/3/2019 Project File on C++
36/59
-
8/3/2019 Project File on C++
37/59
// 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 employee is their in DETAILS.dat data file or notwhile (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;
-
8/3/2019 Project File on C++
38/59
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
-
8/3/2019 Project File on C++
39/59
// 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
-
8/3/2019 Project File on C++
40/59
return;
}
gotoxy(30, 4);
cout
-
8/3/2019 Project File on C++
41/59
/* The accounts department gives salary to each individuals on every month by certain
conditions. All the terms and conditions are assumed percentages and values. But itmay different from company to company. The employees are benefited certain earnings
and deductions as:
Earnings:
DA - Dearness Allowance
HRA - House Rent AllowanceCONVA - Conveyance Allowance.
Deductions:
PF - Provident FundE.S.I - Employee State Insurance
ITAX - Income Tax
CSF - Canteen FAcility. For each category of employee the cantee charge is Rs.
350/-All the employees are gets their facilities on according to their Basic salary as:
Table of Dearness Allowance, House Rent Allowance, and conveyance Allowance
--------------------------------------------------------------------------------------
Basic Salary DA HRA CONVA
--------------------------------------------------------------------------------------2500 to 3000 90% of Basic 20% of Basic 10% of Basic
3001 to 4000 120% of Basic 30% of Basic 15% of Basic
4001 to 5000 140% of Basic 35% of Basic 20% of BasicAbove 5000 150% of Basic 40% of Basic 25% of Basic
--------------------------------------------------------------------------------------
Each employee is deducting 12% of provident fund from their basic salary and dearness
allowance
Each employee deducting 0.7% of ESI from their basic salaryIf the employee is liable to pay income tax then, on every month the ITAX is also
deducted from his salary. The taxation slab is as:
Table of Taxation Slab--------------------------------------------------------------------------------------
Net Income Range Rate of Income-Tax Deductions
--------------------------------------------------------------------------------------Up to Rs. 40,000 Nill
Rs. 40,000 - Rs. 60,000 10% of the amount by which the tital
income exceeds Rs. 40, 000Rs. 60,000 - Rs. 1,50,000 Rs. 2,000 plus 20% of the amount by which to total
income exceeds Rs. 90,000
Rs. 1,50,000 and above Rs. 20,000 plus 30% of the amount by
which the total income exceeds Rs. 1,50,000
-
8/3/2019 Project File on C++
42/59
--------------------------------------------------------------------------------------
Also there is a standard deduction of the gross income i.e,; 1/3.
Note: As the employeer provides 12% as PF, 10% is exempted, and remaining is taxable*/
void employee::month_salary(void){
clrscr();
char t_acc[10];char *cmonth;
int j;
int t, t_emp_no;
gotoxy(71, 1);cout
-
8/3/2019 Project File on C++
43/59
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
-
8/3/2019 Project File on C++
44/59
gotoxy(8, 12);
for (i = 0; i
-
8/3/2019 Project File on C++
45/59
{
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 monthlygross
ANN_GROSS = TOTAL_EARN * 12; // Annual gross
// Calculation part for deduction as pf (12%) , esi (.7%) , csf (Rs. 350/-)EPF = (salary+DA) * 0.12; // Calculates 12% as provident fund
// Calculates 0.7% as employee state insuranceESI = salary * 0.07;
CANTEEN = 350; // Canteen charge
// Note: As the employeer provides 12% as PF, 10% is exempted, and// remaining 2% is taxable.
// Annually 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 40000)
TAXABLE = ANN_GROSS - 40000;else
TAXABLE = 0;
// Steps to calculate the tax
if (TAXABLE
-
8/3/2019 Project File on C++
46/59
if (TAXABLE > 20000 && 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
-
8/3/2019 Project File on C++
47/59
-
8/3/2019 Project File on C++
48/59
-
8/3/2019 Project File on C++
49/59
gotoxy(48, 20);
cout
-
8/3/2019 Project File on C++
50/59
cout
-
8/3/2019 Project File on C++
51/59
int t_emp_no;
t_emp_no = EMP_ADD.last_emp_no();t_emp_no++;
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
-
8/3/2019 Project File on C++
52/59
gotoxy(40, 19);
cout
-
8/3/2019 Project File on C++
53/59
gotoxy(23, 12);
cin >>tdd;
gotoxy(25, 12);cout > tmm;gotoxy(28, 12);
cout > tyy;
do
{Left_clear(13, 13);
Left_clear(5, 23);
gotoxy(5, 23);
cout 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 2)
{
-
8/3/2019 Project File on C++
54/59
valid = 0;
gotoxy(5, 23);
cprintf("\7State should not greater than 1");getch();
}
} while (!valid);
do
{Left_clear(15, 15);
Left_clear(5, 23);
gotoxy(5, 23);
cout 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 11)
{valid = 0;
gotoxy(5, 23);
cprintf("\7Designation should not greater than 9");
getch();
-
8/3/2019 Project File on C++
55/59
}
} while (!valid);
Right_clear(59, 16);
gotoxy(59, 16);
cin >>d1;gotoxy(61, 16);
cout > m1;
gotoxy(64, 16);
cout > y1;
gotoxy(59, 17);
cin >> t_deptno;
do
{Right_clear(59, 18);
Left_clear(5, 23);
gotoxy(5, 23);
cout = 2500 && t_salary = 3001 && t_salary
-
8/3/2019 Project File on C++
56/59
}
else
if (t_salary >= 4001 && t_salary 5000)
{strcpy(t_grade, "O");
}
else
return;
gotoxy(59, 19);
cout
-
8/3/2019 Project File on C++
57/59
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 records in EMP.dat data file for generating
automatic employee numberint 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 organization.void employee::close_employee(void)
{
clrscr();char ch;
char t_acc[10];
int t, t_emp_no;gotoxy(71, 1);
cout
-
8/3/2019 Project File on C++
58/59
cout
-
8/3/2019 Project File on C++
59/59
gotoxy(10, 20);
do{
Left_clear(5, 15);
gotoxy(5, 20);cout