Monday, November 15, 2021

Human Resource Information System in C++

 A simple Human Resource Information System in C++ that I wrote a long time ago I hope you will find my work useful.

 I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.





Program Listing

#include <iostream>

#include <iomanip>

#include <cmath>

#include <stdlib.h>

#include <string.h>

#include <conio.h>

#include <ctype.h>


using namespace std;


const int PASSLEN = 5;

 

void menu()

{

FILE *fp, *ft ;

char another, choice ;

struct employee

{

char emp_id_no[300];

char name[300];

char address[300];

char position[300];

    float salary;

    char email[300];

    long int mobile;

    long int sss,tin,pag_ibig,philhealth;

} ;

struct employee emp;

char employee_id[300];

long int recsize;

    int flag=0;

fp = fopen ("EMPLOYEE.TXT", "rb+" ) ;

if ( fp == NULL )

{

fp = fopen ( "EMPLOYEE.TXT", "wb+" ) ;

if ( fp == NULL )

{

puts ( "Cannot open file" ) ;

exit(0) ;

}

}

recsize = sizeof ( employee ) ;

while ( 1 )

{

        system("CLS");

        system("COLOR F0"); 

        

cout << fixed <<setprecision(2);

        cout <<"\n";

cout << "\n\t==========================================";

cout <<"\n";

cout <<"\n\t HUMAN RESOURCE INFORMATION SYSTEM IN C++";

cout <<"\n\n";

cout << "\tCreated By Jake R. Pomperada,MAED-IT,MIT   ";

cout <<"\n\t==========================================";

cout <<"\n\n";

cout << "\t[1] INSERT EMPLOYEE RECORD";

cout <<"\n";

cout << "\t[2] BROWSE EMPLOYEE RECORD";

cout <<"\n";

cout << "\t[3] EDIT EMPLOYEE RECORDS" ;

cout <<"\n";

cout  <<"\t[4] FIND EMPLOYEE RECORDS";

cout <<"\n";

cout << "\t[5] REMOVE EMPLOYEE RECORDS";

cout <<"\n";

cout  << "\t[6] QUIT PROGRAM" ;

cout <<"\n\n";

cout  <<"\tSELECT YOUR OPTION :=> ";

fflush (stdin) ;

choice = getche() ;

switch ( choice )

{

case '1' :

fseek ( fp, 0 , SEEK_END ) ;

another = 'Y' ;

while ( another == 'Y' )

{

system("cls");

cout <<"\n";

cout << "\t=== INSERT NEW EMPLOYEE RECORD ===";

cout <<"\n\n";

cout <<"\tEmployee ID Number           : ";

                    fflush (stdin) ;

gets(emp.emp_id_no);;

cout << "\tEmployee Name               : ";

fflush (stdin) ;

gets(emp.name);

cout <<"\tEmployee Home Address        : ";

fflush (stdin) ;

gets(emp.address);

                    cout <<"\tEmployee Position            : ";

fflush (stdin) ;

gets(emp.position);

cout << fixed <<setprecision(2);

    cout <<"\tEmployee Salary              : ";

cin >> emp.salary;

cout <<"\tEmployee Email Address       : ";

fflush (stdin) ;

gets(emp.email);

cout <<"\tEmployee Mobile Number       : ";

    scanf("%ld",&emp.mobile);

cout <<"\tEmployee SSS Number          : ";

    scanf("%ld",&emp.sss);

cout << "\tEmployee TIN Number         : ";

scanf("%ld",&emp.tin);

cout << "\tEmployee PAG-IBIG Number    : ";

scanf("%ld",&emp.pag_ibig);

cout << "\tEmployee PHILHEALTH Number  : ";

scanf("%ld",&emp.philhealth);

cout << "\n";

                    fwrite (&emp,recsize, 1,fp) ;

cout << "\n\n";

cout  << "\n\tAdd New Employee Record (Y/N) : " ;

fflush (stdin) ;

another = toupper(getche()) ;

}

break ;

case '2' :

        system("cls");

rewind ( fp );

cout << "\n\n";

                cout <<"\t=== VIEW EMPLOYEE RECORD ===";

                cout <<"\n\n";

while (fread( &emp, recsize, 1, fp ) == 1 )

        {

       cout <<"\n\tEmployee ID No              : " <<emp.emp_id_no;

       cout <<"\n\tEmployee Name               : " <<emp.name;

       cout <<"\n\tEmployee Home Address       : " <<emp.address;

       cout <<"\n\tEmployee Position           : " <<emp.position;

       cout <<"\n\tEmployee Salary             : PHP " <<emp.salary;

       cout <<"\n\tEmployee Email Address      : " <<emp.email;

       cout <<"\n\tEmployee Mobile Number      : " <<emp.mobile;

       cout <<"\n\tEmployee SSS Number         : " <<emp.sss;

       cout <<"\n\tEmployee TIN Number         : " <<emp.tin;

       cout <<"\n\tEmployee PAG-IBIG Number    : " <<emp.sss;

       cout <<"\n\tEmployee PHILHEALTH Number  : " <<emp.philhealth;

       cout <<"\n";

       }

          cout <<"\n\n";

         system("pause");

break ;

case '3' :

another = 'Y' ;

while ( another == 'Y' )

{

system("cls");

          cout <<"\t=== EDIT STUDENT GRADE RECORD ===";

        cout <<"\n\n";

          cout <<"\tEnter Employee ID Number : ";

                cin >> employee_id;

    rewind ( fp ) ;

cout <<"\n";

while ( fread ( &emp, recsize, 1, fp ) == 1 )

{

if ( strcmp ( emp.emp_id_no,employee_id) == 0 )

{

cout <<"\tEnter Employee ID Number  : ";

                    fflush (stdin) ;

                    gets(emp.emp_id_no);

cout << "\tEmployee Name            : ";

fflush (stdin) ;

gets(emp.name);

cout <<"\tEmployee Home Address     : ";

fflush (stdin) ;

gets(emp.address);

                    cout <<"\tEmployee Position         : ";

fflush (stdin) ;

gets(emp.position);

cout << fixed <<setprecision(2);

cout <<"\tEmployee Salary             : ";

cin >> emp.salary;

cout<<"\tEmployee Email Address       : ";

fflush (stdin) ;

gets(emp.email);

cout <<"\tEmployee Mobile Number      : ";

    scanf("%ld",&emp.mobile);

cout <<"\tEmployee SSS Number         : ";

    scanf("%ld",&emp.sss);

cout << "\tEmployee TIN Number        : ";

scanf("%ld",&emp.tin);

cout << "\tEmployee PAG-IBIG Number   : ";

scanf("%ld",&emp.pag_ibig);

cout << "\tEmployee PHILHEALTH Number : ";

scanf("%ld",&emp.philhealth);

cout << "\n";

fseek ( fp, - recsize, SEEK_CUR ) ;

fwrite ( &emp, recsize, 1, fp ) ;

break ;

}

}

if (strcmp(emp.emp_id_no,employee_id) != 0 )

                 {  

                   cout <<"\n\n";

                   cout <<"\tNo Employee Record in the Database.";

                   cout <<"\n";

                   system("pause");

                   break;

                   }

                 cout <<"\n\n";

     cout  <<"\n\tEdit Another Employee Record (Y/N) : ";

fflush ( stdin ) ;

another = toupper(getche());

}

break ;

      case '4' :

   rewind ( fp ) ;

   another = 'Y' ;

while ( another == 'Y' )

{

system("cls");

        cout <<"\t=== Find Employee Records ===";

        cout <<"\n\n";

     cout <<"\tEnter Student ID Number : ";

                 fflush (stdin) ;

gets(employee_id);

cout <<"\n";

rewind ( fp ) ;

while ( fread ( &emp, recsize, 1, fp ) == 1 )

{

if ( strcmp (emp.emp_id_no,employee_id) == 0 )

{

        cout <<"\n";

        cout <<"\n\tEmployee ID No              : " <<emp.emp_id_no;

      cout <<"\n\tEmployee Name               : " <<emp.name;

      cout <<"\n\tEmployee Home Address       : " <<emp.address;

        cout <<"\n\tEmployee Position           : " <<emp.position;

        cout <<"\n\tEmployee Salary             : PHP " <<emp.salary;

          cout <<"\n\tEmployee Email Address      : " <<emp.email;

      cout <<"\n\tEmployee Mobile Number      : " <<emp.mobile;

        cout <<"\n\tEmployee SSS Number         : " <<emp.sss;

        cout <<"\n\tEmployee TIN Number         : " <<emp.tin;

        cout <<"\n\tEmployee PAG-IBIG Number    : " <<emp.sss;

        cout <<"\n\tEmployee PHILHEALTH Number  : " <<emp.philhealth; 

                    cout <<"\n\n";

        system("pause");

         break;

}

}

      if (strcmp(emp.emp_id_no,employee_id) != 0 )

          {

            cout <<"\n\n";

            cout <<"\tNo Employee Record Found in the Database.";

            cout <<"\n";

            system("pause");

            break;

           }

                    cout  <<"\n\n";

cout  <<"\n\tFind Another Student Record (Y/N) : " ;

fflush ( stdin ) ;

another = toupper(getche());

}

break ;

case '5' :

another = 'Y' ;

while ( another == 'Y' )

{

system("cls");

                    cout <<"\t=== REMOVE EMPLOYEE GRADE RECORD ===";

                    cout <<"\n\n";

cout <<"\tEnter Employee ID Number : ";

                    fflush (stdin) ;

gets(employee_id);

cout <<"\n";

ft = fopen ("TEMP.DAT", "wb" ) ;

rewind (fp) ;

while ( fread (&emp, recsize, 1, fp ) == 1 )

{

if ( strcmp (emp.emp_id_no,employee_id) != 0 )

fwrite ( &emp, recsize, 1, ft ) ;

                 else

                flag=1;

                  }

fclose ( fp ) ;

fclose ( ft ) ;

remove ( "EMPLOYEE.TXT" ) ;

rename ( "TEMP.DAT", "EMPLOYEE.TXT" ) ;

    fp = fopen ( "EMPLOYEE.TXT", "rb+" ) ;

       if(flag==1) {

         cout <<"\n\n";

         cout <<"\tRecord Successfully Deleted From the Database.";

         cout <<"\n";

         system("pause");

         }

else {

             cout <<"\n\n";

             cout <<"\tRecord Not Found in the Database.";

             cout <<"\n";

            system("pause");

             }

                    cout <<"\n";

cout << "\tRemove Another Employee Record (Y/N) : " ;

fflush (stdin) ;

another = toupper(getche());

}

break ;

case '6' :

fclose ( fp ) ;

cout <<"\n\n";

cout <<"\tEND OF PROGRAM";

cout <<"\n\n";

cout << "\tThank You Very Much For Using This Software.";

cout <<"\n\n";

system("PAUSE");

exit(0);

}

}

} // End of Code


string passget()

{

char password[PASSLEN], letter;

int loop;

int len;

string password2;

//Get Password and replace letters with *--------------

loop = 0;

while(loop != PASSLEN)

{

password[loop] = '\0';

loop++;

}

loop = 0;

len = 0;

letter = '\0';

while( letter != '\r' )

{

letter = getch();

if( letter == '\b' && password[0] == '\0')

{

loop = 0;

len = 0;

}

else

{

if( letter == '\b' && password[0] != '\0')

{

cout << "\b";

cout << " ";

cout << "\b";

loop--;

password[loop] = '\0';

len--;

}

else

{

if( isprint( letter ) != 0 && loop < PASSLEN)

{

password[loop] = tolower(letter);

cout << "*" ;

}

loop++;

if (loop <= PASSLEN)

len++;

}

}

}

//Convert Password from character array to string

loop = 0;

len = len;

password2 = "";

while (loop != len)

{

password2 = password2+password[loop];

loop++;

}

return password2;

 } // End of Function Password


void start()

{

string password;

system("COLOR F0"); 

cout << "\n\n";

cout << "\tPASSWORD SECURITY VERSION 1.0";

cout << "\n\n";

cout << "\tEnter Your Password: ";

password = passget();

if (password == "admin") {

menu();

}

else {

cout << "\n\n";

cout << "\tPassword Denied Try Again !!!";

start();

}

} // End of Start Function


int main()

 {

  start();

 }

 



No comments:

Post a Comment