Employee Database Management: Computer Project
Employee Database Management: Computer Project
Employee Database Management: Computer Project
2013
ACKNOWLEDGEMENT
We, with a deep sense of gratitude would like to thank all the people without whose contribution this project work would not have been a success.
Firstly, we would like to thank our Computer Teacher Mrs Madhavi Bhatt, for helping us and guiding me at various stages of the project.
We are obliged to the school authorities for providing Valuable time and resources for completion of the project.
We thank our parents for standing by us and supporting me through our failures and help us gaining confidence.
Without their sincere efforts, this project would not have been what it evolved to be.
Sr.No 2 3 4 5 6 7 8 9
TITLE NEED FOR THE SYSTEM SYSTEM REQUIREMENTS DATA DESIGN FUNCTIONS AND FUNCTION DESCRIPTION SOURCE CODE OUTPUT
SIGN
INTRODUCTION We have created an employee database management system. The project aims at performing the basic functions of employee database. It uses three data files providing facilities like creating an account, modification, depositing, withdrawing etc. The purpose of the project is to provide a systematic and efficient method for managing employee details.
NEED FOR THE SYSTEM Employment management system is nowadays an indispensible part of the fast growing economic world. Hand written records are now obsolete as it tedious and the possibility of making errors exceeds the feasible limits. Moreover it does not address the security concerns of the people.
All these factors have given rise to a need for a system with which one could easily manage the day to day tasks of the bank without any concerns of making errors.
Our project is aimed to suffice some of the requirements of the modern employee management system and to address the drawbacks of the hand written records.
SYSTEM REQUIREMENTS
Hardware and software requirements: A multitasking operating system with DOS support. 50 MB hard drive or more. 8 to 16 MB RAM or more.
DATA DESIGN EMPLOYEE.txt Stores all the details of the employees. Temp.txt Used to store the data temporarily for modification and deletion of employee records. The project includes the following facilities: Creation of employee details. Modification of employee details. Deletion of employee records. View details of list of employees.
Function and function description: The program uses the following functions: PUBLIC FUNCTIONS 1) MAIN_MENU( ): THIS FUNCTION CONTROL ALL THE FUNCTIONS IN THE MAIN MENU. 2) NEW_EMPLOYEE( ) THIS FUNCTION GIVE DATA TO ADD IN THE FILE. 3) MODIFICATION( ) THIS FUNCTION GIVE DATA FOR THE MODIFICATION OF THE EMPLOYEE RECORD. 4) DELETION( ) THIS FUNCTION GIVE CODE NO. FOR THE DELETION OF THE EMPLOYEE RECORD. 5) DISPLAY( ) THIS FUNCTION GIVE CODE FOR THE DISPLAY OF THE RECORD, 6) LIST( ) THIS FUNCTION DISPLAYS THE LIST OF THE EMPLOYEES.
PRIVATE FUNCTIONS 1) EDIT_MENU ( ) THIS FUNCTION CONTROLS ALL THE FUNCTIONS IN THE EDIT MENU. 2) INTRODUCTION( )
3) ADD_RECORD( ) THIS FUNCTION ADDS THE GIVEN DATA IN THE EMPLOYEE'S FILE. 4) MODIFY_RECORD( ) THIS FUNCTION MODIFIES THE GIVEN DATA IN THE EMPLOYEE'S FILE. 5) DELETE_RECORD( ) THIS FUNCTION DELETE THE RECORD IN THE EMPLOYEE FILE FOR THE GIVEN EMPLOYEE CODE. 6) LASTCODE( ) THIS FUNCTION RETURNS THE LAST EMPLOYEE'S CODE. 7) FOUND_CODE( ) THIS FUNCTION RETURN 0 IF THE GIVEN CODE NOT FOUND. 8) RECORDNO( ) THIS FUNCTION RETURNS RECORD NO. OF THE GIVEN CODE. 9) DISPLAY_RECORD( ) THIS FUNCTION DISPLAYS THE RECORD OF THE EMPLOYEES. 10) VALID_DATE( ) THIS FUNCTION RETURN 0 IF THE GIVEN DATE IS INVALID
SOURCE CODE
// PROJECT EMPLOYEE MANAGMENT
#include <fstream.h> #include <process.h> #include <string.h> #include <stdlib.h> #include <stdio.h> #include <ctype.h> #include <conio.h> class MENU { public: void MAIN_MENU(); private: void EDIT_MENU(); }; class EMPLOYEE { public: void NEW_EMPLOYEE(); void MODIFICATION(); void DELETION(); void DISPLAY(); void LIST(); private:
void ADD_RECORD(int,char[],char[],char[],int,int,int,char[],char,char,fl oat,float); void MODIFY_RECORD(int,char[],char[],char[],char[],char,char,float,flo at); void DELETE_RECORD(int); int LASTCODE(); int CODEFOUND(int); int RECORDNO(int); int FOUND_CODE(int); void DISPLAY_RECORD(int); int code, dd, mm, yy; char name[16], address[31], phone[10], desig[16]; char grade, house; float loan, basic; }; // THIS FUNCTION CONTROL ALL THE FUNCTIONS IN THE MAIN MENU void MENU :: MAIN_MENU(void) { char ch; while(1) { clrscr() ;
cout <<"\t\t\t\tDDSM PVT. LTD."; cout <<"\n\n\t1: NEW EMPLOYEE"; cout <<"\n\t2: DISPLAY EMPLOYEE"; cout <<"\n\t3: LIST OF EMPLOYEES"; cout <<"\n\t4: EDIT"; cout <<"\n\t0: QUIT"; cout <<"\n\n\t\tENTER YOUR CHOICE :"; ch = getch() ; if (ch == 27 || ch == '0') exit(1); else if (ch == '1') { EMPLOYEE E; E.NEW_EMPLOYEE(); } else if (ch == '2') { EMPLOYEE E; E.DISPLAY(); } else if (ch == '3') { EMPLOYEE E; E.LIST(); } else if (ch == '4') EDIT_MENU(); }
} void MENU :: EDIT_MENU() { char ch; while(1) { clrscr() ; cout <<"\t\t\tEDIT MENU"; cout <<"\n\t1: DELETE RECORD"; cout <<"\n\t2: MODIFY RECORD"; cout <<"\n\t0: EXIT"; cout <<"\n\n\t\tENTER YOUR CHOICE :"; ch = getch(); if (ch == 27 || ch == '0') break; else if (ch == '1') { EMPLOYEE E; E.DELETION(); } else if (ch == '2') { EMPLOYEE E; E.MODIFICATION(); } } }
void EMPLOYEE :: ADD_RECORD(int ecode, char ename[16], char eaddress[31], char ephone[10], int d, int m, int y, char edesig[16], char egrade, char ehouse, float eloan, float ebasic) { fstream file; file.open("EMPLOYEE.txt", ios::app); code = ecode; strcpy(name,ename); strcpy(address,eaddress); strcpy(phone,ephone); dd = d; mm = m; yy = y; strcpy(desig,edesig); grade = egrade; house = ehouse; loan = eloan; basic = ebasic; file.write((char *) this, sizeof(EMPLOYEE)); file.close(); } void EMPLOYEE :: MODIFY_RECORD(int ecode, char ename[16], char eaddress[31], char ephone[10], char edesig[16], char egrade, char ehouse, float eloan, float ebasic) { int recno;
recno = RECORDNO(ecode); fstream file; file.open("EMPLOYEE.txt", ios::out | ios::ate); strcpy(name,ename); strcpy(address,eaddress); strcpy(phone,ephone); strcpy(desig,edesig); grade = egrade; house = ehouse; loan = eloan; basic = ebasic; int location; location = (recno-1) * sizeof(EMPLOYEE); file.seekp(location); file.write((char *) this, sizeof(EMPLOYEE)); file.close(); } void EMPLOYEE :: DELETE_RECORD(int ecode) { fstream file; file.open("EMPLOYEE.txt", ios::in); fstream temp; temp.open("temp.txt", ios::out); file.seekg(0,ios::beg); while (!file.eof()) { file.read((char *) this, sizeof(EMPLOYEE));
if (file.eof()) break; if (code != ecode) temp.write((char *) this, sizeof(EMPLOYEE)); } file.close(); temp.close(); file.open("EMPLOYEE.txt", ios::out); temp.open("temp.txt", ios::in); temp.seekg(0,ios::beg); while (!temp.eof()) { temp.read((char *) this, sizeof(EMPLOYEE)); if (temp.eof()) break; file.write((char *) this, sizeof(EMPLOYEE)); } file.close(); temp.close(); } int EMPLOYEE :: LASTCODE() { fstream file; file.open("EMPLOYEE.txt", ios::in); file.seekg(0,ios::beg); int count=0; while (file.read((char *) this, sizeof(EMPLOYEE)))
count = code; file.close(); return count; } int EMPLOYEE :: FOUND_CODE(int ecode) { fstream file; file.open("EMPLOYEE.txt", ios::in); file.seekg(0,ios::beg); int found=0; while (file.read((char *) this, sizeof(EMPLOYEE))) { if (code == ecode) { found = 1; break; } } file.close(); return found; } int EMPLOYEE :: RECORDNO(int ecode) { fstream file; file.open("EMPLOYEE.txt", ios::in); file.seekg(0,ios::beg);
int recno=0; while(file.read((char*)this, sizeof(EMPLOYEE))) { recno++; if (code == ecode) break; } file.close(); return recno; } void EMPLOYEE :: LIST() { clrscr(); int row=6, found=0, flag=0; char ch; cout <<"\t\t LIST OF EMPLOYEES"; cout <<"\n\t\t~~~~~~~~~~~~~~~~~"; cout <<"\nCODE NAME PHONE DOJ DESIGNATION GRADE SALARY"; cout <<"\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"; fstream file; file.open("EMPLOYEE.txt", ios::in); file.seekg(0,ios::beg) ; while(file.read((char *) this, sizeof(EMPLOYEE))) {
flag = 0; found = 1; cout <<endl<<code<<" "; cout <<name; if (strlen(name)<8) cout<<"\t\t "; else if(strlen(name)<16)cout<<"\t "; else cout<<" "; cout.write(phone,10); cout <<" "; cout <<dd<<"/"<<mm<<"/"<<yy; if((dd>9)&&(mm>9))cout<<" "; else if((dd>9)||(mm>9))cout<<" "; else cout<<" "; cout <<desig; if (strlen(desig)<8)cout<<"\t\t "; else cout<<"\t "; cout <<grade<<"\t "; if (grade != 'E')cout<<basic; else cout <<"-"; if(row == 23) { flag = 1; row = 6; cout <<"\n\n\tPress any key to continue or Press <ESC> to exit"; ch = getch(); if (ch == 27) break; clrscr();
cout <<"\t\tLIST OF EMPLOYEES"; cout <<"\n\t\t~~~~~~~~~~~~~~~~~~~"; cout <<"\nCODE NAME PHONE DOJ DESIGNATION GRADE SALARY"; cout <<"\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"; } else row++; } if (!found) cout <<"\nRecords not found"; if (!flag) { cout <<"\nPress any key to continue..."; getch(); } file.close(); } void EMPLOYEE :: DISPLAY_RECORD(int ecode) { fstream file; file.open("EMPLOYEE.txt", ios::in); file.seekg(0,ios::beg); while(file.read((char*)this, sizeof(EMPLOYEE))) { if(code == ecode) {
cout <<"Employee Code # " <<code; cout <<"\n~~~~~~~~~~~~~~"; cout <<"\nName : "<<name; cout <<"\nAddress : "<<address; cout <<"\nPhone no. : ";cout.write(phone,10); cout <<"\nJOINING DATE"; cout <<"\n~~~~~~~~~~~~~~"; cout <<"\nDay : "<<dd; cout <<"\nMonth : "<<mm; cout <<"\nYear : "<<yy; cout <<"\nDesignation : "<<desig; cout <<"\nGrade : "<<grade; if (grade != 'E') { cout <<"\nHouse (y/n) : " <<house; cout <<"\nBasic Salary : " <<basic; } cout <<"\nLoan : " <<loan; } } file.close(); } void EMPLOYEE :: NEW_EMPLOYEE() { clrscr(); char ch, egrade, ehouse='N'; char ename[16], eaddress[31], ephone[10], edesig[16];
float eloan=0.0, ebasic=0.0; int d, m, y, ecode, valid; cout <<"<0>=EXIT"; cout <<"\n\n\t\tADDITION OF NEW EMPLOYEE"; ecode= LASTCODE() + 1; if (ecode == 1) { ADD_RECORD(ecode, "null", "null", "null", 0, 0, 0, "null", 'n', 'n', 0.0, 0.0) ; DELETE_RECORD(ecode); } cout <<"\nEmployee # "<<ecode; do { valid = 1; cout <<"\n\nEnter the name of the Employee\t:"; gets(ename); strupr(ename); if (ename[0] == '0') return ; if (strlen(ename) < 1 || strlen(ename) > 16) { valid = 0; cout <<"\nEnter correctly (Range: 1..16)"; getch(); } }while(!valid); do {
valid = 1; cout <<"\nEnter Address of the Employee\t:"; gets(eaddress); strupr(eaddress); if (eaddress[0] == '0') return; if (strlen(eaddress) < 1 || strlen(eaddress) > 30) { valid = 0; cout <<"\nEnter correctly (Range: 1..30)"; getch(); } }while (!valid); do { valid = 1; cout <<"\nEnter Phone no. of the Employee or Press <ENTER> for none\t:"; gets(ephone) ; if (ephone[0] == '0') return; if ((strlen(ephone) < 6 && strlen(ephone) > 0) || (strlen(ephone) > 10)) { valid = 0; cout <<"\nEnter correctly"; getch(); } } while(!valid); if (strlen(ephone) == 0) strcpy(ephone,"-");
do { valid = 1; do { cout <<"\nENTER DAY OF JOINING\t:"; cin>>d; if (d==0) return; } while (d == 0); do { cout <<"\nENTER MONTH OF JOINING\t:"; cin>>m; if (m==0) return; } while (m == 0); do { cout <<"\nENTER YEAR OF JOINING\t:"; cin>>y; if (y==0) return; } while (y == 0); if (d>31 || d<1) valid = 0; else if (((y%4)!=0 && m==2 && d>28) || ((y%4)==0 && m==2 && d>29)) valid = 0; else if ((m==4 || m==6 || m==9 || m==11) && d>30) valid = 0; else if (y<1990 || y>2020) valid = 0 ; if (!valid) {
cout <<"\nEnter correctly"; getch(); } } while (!valid); do { valid = 1; cout<<"\nEnter Designation of the Employee\t:"; gets(edesig); strupr(edesig); if (edesig[0] == '0') return; if (strlen(edesig) < 1 || strlen(edesig) > 15) { valid = 0; cout <<"\nEnter correctly (Range: 1..15)"; getch(); } } while (!valid); do { cout <<"\nEnter Grade of the Employee (A,B,C,D,E)\t:"; egrade = getch(); egrade = toupper(egrade); if (egrade == '0') return ; } while (egrade < 'A' || egrade > 'E'); if (egrade != 'E') { cout <<"\nHouse (y/n)\t:\n";
do { cout <<"\nENTER IF HOUSE ALLOWANCE IS ALLOTED TO EMPLOYEE OR NOT\t:"; ehouse = getch(); ehouse = toupper(ehouse); if (ehouse == '0') return ; } while (ehouse != 'Y' && ehouse != 'N'); } do { valid = 1 ; cout <<"\nENTER LOAN AMOUNT IF ISSUED\t:"; cin>>eloan; if (eloan > 50000) { valid = 0; cout <<"\nSHOULD NOT GREATER THAN 50000"; getch(); } } while (!valid); if (egrade != 'E') { do { cout <<"\nBasic Salary\t:\n"; valid = 1; cout <<"\nENTER BASIC SALARY OF THE EMPLOYEE\t:";
cin>>ebasic; if (ebasic == 0) return; if (ebasic > 50000) { valid = 0; cout <<"\nSHOULD NOT GREATER THAN 50000"; getch(); } } while (!valid); } do { cout <<"\nDo you want to save (y/n)\t:"; ch = getch(); ch = toupper(ch); if (ch == '0') return; } while (ch != 'Y' && ch != 'N'); if (ch == 'N') return; ADD_RECORD(ecode, ename, eaddress, ephone, d, m, y, edesig, egrade, ehouse, eloan, ebasic); } void EMPLOYEE :: DISPLAY() { clrscr(); int ecode; cout <<"\t<0>=EXIT"; cout <<"\n\nEnter code of the Employee\t:";
cin >>ecode; if (ecode == 0) return; clrscr(); if (!FOUND_CODE(ecode)) { cout <<"\n\tRecord not found"; getch(); return; } DISPLAY_RECORD(ecode); cout <<"\n\tPress any key to continue..."; getch(); } void EMPLOYEE :: MODIFICATION() { clrscr(); char ch, egrade, ehouse='N' ; char ename[16], eaddress[31], ephone[10], edesig[16]; float eloan=0.0, ebasic=0.0; int ecode, valid; cout <<"\n<0>=EXIT"; cout <<"\n\nEnter code of the Employee\t:"; cin >>ecode; if (ecode == 0) return; clrscr(); if (!FOUND_CODE(ecode)) {
cout <<"\n\n\t\tRecord not found"; getch(); return; } cout <<"\n<0>=EXIT"; cout <<"\n\n\t\tMODIFICATION OF THE EMPLOYEE RECORD"; DISPLAY_RECORD(ecode); do { cout <<"\n\n\tDo you want to modify this record (y/n) "; ch = getch(); ch = toupper(ch); if (ch == '0') return; } while (ch != 'Y' && ch != 'N'); if (ch == 'N') return; clrscr(); fstream file; file.open("EMPLOYEE.txt", ios::in); file.seekg(0,ios::beg); while (file.read((char *) this, sizeof(EMPLOYEE))) { if (code == ecode) break; } file.close(); cout <<"\n\n\tEmployee Code # " <<ecode; cout <<"\n\tJOINING DATE : "; cout <<dd<<"/"<<mm<<"/"<<yy; do
{ valid = 1; cout <<"\nEnter the name of the Employee or <ENTER> FOR NO CHANGE\t:"; gets(ename); strupr(ename); if (ename[0] == '0') return; if (strlen(ename) > 16) { valid = 0; cout <<"\nEnter correctly (Range: 1..16)"; getch(); } } while (!valid); if (strlen(ename) == 0) { strcpy(ename,name); cout <<ename; } do { valid = 1; cout <<"\nEnter Address of the Employee or <ENTER> FOR NO CHANGE\t:"; gets(eaddress); strupr(eaddress); if (eaddress[0] == '0') return; if (strlen(eaddress) > 30)
{ valid = 0 ; cout <<"\nEnter correctly (Range: 1..30)"; getch(); } } while (!valid); if (strlen(eaddress) == 0) { strcpy(eaddress,address); cout <<eaddress; } do { valid = 1; cout <<"\nEnter Phone no. of the Employee or or <ENTER> FOR NO CHANGE\t:"; gets(ephone); if (ephone[0] == '0') return; if ((strlen(ephone)<6 && strlen(ephone)>0) || (strlen(ephone)>10)) { valid = 0; cout <<"\nEnter correctly"; getch(); } } while (!valid); if (strlen(ephone) == 0) {
strcpy(ephone,phone); cout.write(ephone,10); } do { valid = 1; cout <<"\nEnter Designation of the Employee or <ENTER> FOR NO CHANGE\t:"; gets(edesig); strupr(edesig); if (edesig[0] == '0') return; if (strlen(edesig) > 15) { valid = 0; cout <<"\nEnter correctly (Range: 1..15)"; getch(); } } while (!valid); if (strlen(edesig) == 0) { strcpy(edesig,desig); cout <<edesig; } do { cout <<"\nEnter Grade of the Employee (A,B,C,D,E) or <ENTER> FOR NO CHANGE\t:"; egrade = getch();
egrade = toupper(egrade); if (egrade == '0') return; if (egrade == 13) { egrade = grade; cout <<grade; } } while (egrade < 'A' || egrade > 'E'); if (egrade != 'E') { cout <<"\n\tHouse (y/n): "; do { cout <<"\nALLOTED HOUSE ALLOWANCE ? or <ENTER> FOR NO CHANGE\t:"; ehouse = getch(); ehouse = toupper(ehouse); if (ehouse == '0') return; if (ehouse == 13) { ehouse = house; cout <<ehouse; } } while (ehouse != 'Y' && ehouse != 'N'); } do { valid = 1; cout <<"\nENTER LOAN AMOUNT or 0 FOR NO CHANGE\t:";
cin>>eloan; if (eloan > 50000) { valid = 0; cout <<"\nSHOULD NOT GREATER THAN 50000"; getch(); } } while (!valid); if (eloan == 0) { eloan = loan; cout <<eloan; } if (egrade != 'E') { do { valid = 1; cout <<"\nENTER BASIC SALARY or 0 FOR NO CHANGE\t:"; cin>>ebasic; if (ebasic > 50000) { valid = 0; cout <<"\nSHOULD NOT GREATER THAN 50000"; getch(); } } while (!valid); if (ebasic == 0)
{ ebasic = basic; cout <<ebasic; } } do { cout <<"\n\n\tDo you want to save (y/n) "; ch = getch(); ch = toupper(ch); if (ch == '0') return; } while (ch != 'Y' && ch != 'N'); if (ch == 'N') return; MODIFY_RECORD(ecode,ename,eaddress,ephone,edesig,egrade,e house,eloan,ebasic); cout <<"\nRecord Modified"; cout <<"\nPress any key to continue..."; getch(); } void EMPLOYEE :: DELETION() { clrscr(); char ch; int ecode; cout <<"<0>=EXIT"; cout <<"\n\nEnter code of the Employee ";
cin>>ecode; if (ecode == 0) return ; clrscr(); if (!FOUND_CODE(ecode)) { cout <<"\nRecord not found"; getch(); return; } cout <<"\n\tDELETION OF THE EMPLOYEE RECORD:\n\n"; DISPLAY_RECORD(ecode); do { cout <<"\n\n\tDo you want to delete this record (y/n) "; ch = getch(); ch = toupper(ch); if (ch == '0') return; } while (ch != 'Y' && ch != 'N'); if (ch == 'N') return; DELETE_RECORD(ecode); cout <<"\n\t\tRecord Deleted"; cout <<"\n\tPress any key to continue..."; getch(); } // MAIN FUNCTION CALLING MAIN MENU void main()
LIMITATIONS
We have studied the present employee database management system in detail and designed the project. However this system also has some limitations. It is software in its most primitive form. It does not keep a track record of the previous increments and decrements in the salary. It does not periodically update the annual increment of an employees salary.
Hence it can be concluded that there is much further improvement to be worked upon the system to enhance its productivity and efficiency of the project.