STAFF PERSONNEL SYSTEM
required to develop a Win32 console application to enter, search, edit and view personnel information of the staff in the company based on different access priority. This application will be used by the Human Resource personnel, staff and the administrator of this application. The main purpose of this application is to store and edit the complete personal record of each staff in the company


One of the most important modules of the staff personnel system is the LOGIN module. Each user of the system has its own user name and password. The administrator of the application has the highest access priority which enables him/her to perform all the functionalities that exist in the application. In addition to that, the administrator is able to register users from the human resource department. The staffs of the company have the lowest access priority that only enables them to view their personal information.
The human resource personnel are allowed to:
Register staff as users of the system
Add, search and edit personal information of staff in the company
Delete record of any staff in the company
The following details of each staff are recorded:
Staff Number
Name
Identification Card (IC) Number
Gender
Designation
Department
Date Joined
Nationality
Religion
Date Of Birth
Marital Status

Each staff has a unique staff number and this will be automatically generated by the system.
Classification of designation for staff is categorised as follows:
Managing Director
Senior Manager
Manager
Senior Executive
Executive
Junior Executive
The category of designation and the related department are determined by you in the system.
The search of any record in the system can be done by using the following categories:
A Staff Number or range of Staff Number
Name
IC Number
Classification
And other categories
If a list of record is displayed after the search, the system should allow fine searching in order to allow only one record to be displayed as the final selection. You should design the system so that the user is able to edit the selective category in the search record. After the edit process is done, the user is prompted for saving purpose.
You should determine the selection in the main menu for each login user. After each final result is displayed, the system should prompt the user whether he/she would like to continue or not.

Ok ... So ?

He posted his code in the Geek's Lounge for some reason. Without code tags of course. ;)

He posted his code in the Geek's Lounge for some reason. Without code tags of course. ;)

Is that so...??? I didn't know it... Thought he too is one among those guys who post their requirements and ask us to code... ;)

Is that so...??? I didn't know it... Thought he too is one among those guys who post their requirements and ask us to code... ;)

Well he was originally. I had to post and ask him to show effort. Then he slopped some code together and posted it.

no frnds it is not like that

i want to convert it in class
how to do that plz tell
here iz ma code

#include<iostream>
#include<string>
using namespace std;



int main(){
    cout<<"\n\n\n\t\t\tSTAFF PERSONNEL SYSTEM\n\n\n\n\n";

    string  username ,password;
    string  user="admin",pass="admin123";


cout<<"Username: "; 
cin>>username;
cout<<"\n\nPassword: "; 
cin>>password;
if(user==username && pass==password) 
{
    cout << "Access granted\n";
cout<<"\n\n\nwelcome to admin\n\n\n\n\n";

cout << "\t\t\t\tSHASHANK SINGH Corporation S-P-S [v.2.0]"<<endl;
   cout << "\t\t\t\t<C> Copy Right 2009 All Rights Reserved"<<endl;
}
else
{

cout<<"invalid username and password,please try again\n";

}
return 0;
}

Edited 3 Years Ago by Dani: Formatting fixed

#include<iostream>
#include<fstream>
#include<string>
#include <cstdlib> // for exit function
#include<iomanip>

using namespace std;
void AddToFile(string name,int staffno,string ic,string gender,string designation,string department,string dateofjoined,string nationality,string religion,string dateofbirth,string maritalstatus);




class Test{



 public:





 void admin(string user,string pass){

   //cout<<" user value: "<<user;
   //cout<<"pass value: "<<pass;

char select;    
string name;
int staffno;
string ic;
string gender;
string designation;
string department;
string dateofjoined;
string nationality;
string religion;
string dateofbirth;
string maritalstatus;

if(user=="admin" && pass=="pass") {

    cout<<"\n\n\t\tWELCOME ADMINISTRATOR";
     cout<<"\n\n1-ADD A RECORD :";
     cout<<"\n\n2-EDIT A RECORD:";

     cout<<"\n\n3-DELETE A RECORD :";
     cout<<"\n\n4-SEARCH A RECORD :";
     cout<<"\n\n5-VIEW THE RECORDS :";
     cout<<"\n\n6-EXIT :";
     cout<<"\n\nSelect [1-6] :";
     cin>>select;



     switch (select){


     case '1':
         cout<<"\t\t\tADD A RECORD :";
         cout<<"you can add a reacord";
         cout<<"\n\nEnter Name :";
         cin>>name;
         cout<<"\n\nEnter Staff Number :";
         cin>>staffno;
         cout<<"\n\nEnter Identification Card (IC) Number :";
         cin>>ic;
         cout<<"\n\nEnter Gender :";
         cin>>gender;
         cout<<"\n\nEnter Designation :";
         cin>>designation;
         cout<<"\n\nEnter Department :";
         cin>>department;
         cout<<"\n\nEnter Date Joined :";
         cin>>dateofjoined;
         cout<<"\n\nEnter Nationality :";
         cin>>nationality;
         cout<<"\n\nEnter Religion :";
         cin>>religion;
         cout<<"\n\nEnter Date Of Birth :";
         cin>>dateofbirth;
         cout<<"\n\nEnter Marital Status :";
         cin>>maritalstatus;

         AddToFile(name,staffno,ic,gender,designation,department,dateofjoined,nationality,religion,dateofbirth,maritalstatus);
         cout<<"data saved in file successfully....";      

         break;

         case '2':
         cout<<"\t\t\tEDIT A RECORD:";

         break; 

         case '3':
         cout<<"\t\t\tDELETE A RECORD :";
         break;
         case '4':
         cout<<"\t\t\tSEARCH A RECORD :";
         break;
         case '5':
         cout<<"\t\t\tVIEW THE RECORDS :";
         break;
         case '6':
         cout<<"\t\t\tEXIT :";
         cout<<"Welcome Again";
         break;

         }
   }
      else
         cout<<"invalid username and password";

     }




};


          int main(){

            Test ts;
            string user,pass;

            cout<<"Enter Username : ";
            cin>>user;
            cout<<"\n\nEnter password : ";
            cin>>pass;
            ts.admin(user,pass);
            return 0;  
          }


     void AddToFile(string name,int staffno,string ic,string gender,string designation,string department,string dateofjoined,string nationality,string religion,string dateofbirth,string maritalstatus){

     //cout<<name;


     ofstream outdata;
     outdata.open("shashank.doc",ios::app);

     if( !outdata ) { // file couldn't be opened
      cout << "Error: file could not be opened" << endl;
      exit(1);
     }
      outdata << name;

      outdata<<"   "<<  staffno  ;
      outdata<<"   "<<  ic ;
      outdata<<"   "<<  gender  ;
      outdata<<"   "<<  designation  ;
      outdata<<"   "<<  department  ;
      outdata<<"   "<<  dateofjoined  ;
      outdata<<"   "<<  nationality ;
      outdata<<"   "<<  religion  ;
      outdata<<"   "<<  dateofbirth  ;
      outdata<<"   "<<  maritalstatus << endl;


      outdata.close();
//a
     }//end method addtofile

Edited 3 Years Ago by Dani: Formatting fixed

how to convert this program in object oreint ???and how to use stuctures in it.???????......how i can do inheretence in this program ???????????.........how to make the user in put case senstive in c++????????????

Edited 7 Years Ago by shashanderson: n/a

how to convert this program in object oreint ???and how to use stuctures in it.???????......how i can do inheretence in this program ???????????.........how to make the user in put case senstive in c++????????????

Use the class concepts and use objects hence you will make it object oriented.

After using classes you can use inheritance concepts.

If you compare characters then it will definitely be case sensitive. As ASCII of 'a' is not equal to ASCII of 'A'.

#include<iostream>
#include<fstream>
#include<string>
#include <cstdlib> // for exit function
#include<iomanip>

using namespace std;

void AddToFile(string name,string staffno,string ic,string gender,string designation,string department,string dateofjoined,string nationality,string religion,string dateofbirth,string maritalstatus);
void DeleteTheFile(string name,string staffno,string ic,string gender,string designation,string department,string dateofjoined,string nationality,string religion,string dateofbirth,string maritalstatus);   
void genderSex();
void marital_status();
void readFromFile();

class Test{

 public:


 void admin(string user,string pass){
  int sex;
  char select;  
  string name;
  string staffno;
  string ic;
  string gender;
  string designation;
  string department;
  string dateofjoined;
  string nationality;
  string religion;
  string dateofbirth;
  string maritalstatus;

if(user=="admin" && pass=="pass") {

     cout<<"\n\n\t\tWELCOME ADMINISTRATOR";
     cout<<"\n\n1-ADD A RECORD :";
     cout<<"\n\n2-VIEW A RECORD:";

     cout<<"\n\n3-EDIT A RECORD :";
     cout<<"\n\n4-DELETE A RECORD :";
     cout<<"\n\n5-SEARCH THE RECORDS :";
     cout<<"\n\n6-EXIT :";
     cout<<"\n\nSelect [1-6] :";
     cin>>select;

     switch (select){

      case '1':
         cout<<"\t\t\tADD A RECORD :";
         cout<<"you can add a reacord";
         cout<<"\n\nEnter Name :";
         cin>>name;
         cout<<"\n\nEnter Staff Number :";
         cin>>staffno;
         cout<<"\n\nEnter Identification Card (IC) Number :";
         cin>>ic;
         cout<<"\n\nEnter Gender :";
         cout<<"\n\n\n1-Male";
         cout<<"\n\n2-Female";


         cout<<"\n\n\nEnter [1-2] :" ;
         cin>>sex;

         if(sex==1){
          gender="Male";
         }
         else if (sex==2){
          gender="Female";
         }
          else {
            cout<<"Invalid Selection";
            genderSex(); 
          }


         cout<<"\n\nEnter Designation :";
         cin>>designation;
         cout<<"\n\nEnter Department :";
         cin>>department;
         cout<<"\n\nEnter Date Joined :";
         cin>>dateofjoined;
         cout<<"\n\nEnter Nationality :";
         cin>>nationality;
         cout<<"\n\nEnter Religion :";
         cin>>religion;
         cout<<"\n\nEnter Date Of Birth :";
         cin>>dateofbirth;
         cout<<"\n\nEnter Marital Status :";
         cin>>maritalstatus;

        AddToFile(name,staffno,ic,gender,designation,department,dateofjoined,nationality,religion,dateofbirth,maritalstatus);
        cout<<"data saved in file successfully....";       

         break;

         case '2':
         cout<<"\t\t\tVIEW THE RECORDS :"<<endl;
         readFromFile();
         cout<<"Data from file viewed sucsessfully";
         break;
         case '3 ':
         cout<<"\t\t\tEDIT A RECORD:";
         break; 
         case '4':
         cout<<"\t\t\tDELETE A RECORD :";
         break;
         case '5':
         cout<<"\t\t\tSEARCH A RECORD :";
         break;
         case '6':
         cout<<"\t\t\tEXIT :";
         cout<<"Welcome Again";
         break;

         }
      }
      else
         cout<<"invalid username and password";

    }//end if 

   };  //end class


         int main(){

            Test ts;
            string user,pass;
            cout<<"Enter Username : ";
            cin>>user;
            cout<<"\n\nEnter password : ";
            cin>>pass;
            ts.admin(user,pass);
            return 0;  
            }


     void AddToFile(string name,string staffno,string ic,string gender,string designation,string department,string dateofjoined,string nationality,string religion,string dateofbirth,string maritalstatus){

     ofstream outdata;
     outdata.open("shashank.doc",ios::app);

     if( !outdata ) { // file couldn't be opened
      cout << "Error: file could not be opened" << endl;
      exit(1);
     }

      outdata << name;
      outdata<<"   "<<  staffno  ;
      outdata<<"   "<<  ic ;
      outdata<<"   "<<  gender  ;
      outdata<<"   "<<  designation  ;
      outdata<<"   "<<  department  ;
      outdata<<"   "<<  dateofjoined  ;
      outdata<<"   "<<  nationality ;
      outdata<<"   "<<  religion  ;
      outdata<<"   "<<  dateofbirth  ;
      outdata<<"   "<<  maritalstatus << endl;
      outdata.close();

    }//end method addtofile


    void readFromFile(){

        char str[2000];
        fstream indata("shashank.doc",ios::in);

        while(!indata.eof()){
           indata.getline(str,2000);
           cout <<str<<endl;
        }
         indata.close();
         cout <<endl;

    }  //end of reading method







     void genderSex(){

         int sex;
         string gender;
         cout<<"\n\n\nEnter [1-2] :" ;
         cin>>sex;

         if(sex==1){ 
          gender="Male";
         }
          else if(sex==2){
           gender="Female";
          }
         else 
         cout<<"Invalid Selection";        

        }//end gender method

Edited 3 Years Ago by Dani: Formatting fixed

i can now read and write data but how to do search and delete record in it ............????????????...............i am anable to convert it in class and do inheretence ................?????????

Not only have you posted this in another thread, you have yet again ignored the fact you need to put your code in tags.

Not only have you posted this in another thread, you have yet again ignored the fact you need to put your code in tags.

Exactly. Shall we answer here or there? Code tags. Use 'em. Please don't post code again without them.

Edited 3 Years Ago by happygeek: fixed formatting

First off, I cannot understand your classes... Should be more like:

#include<iostream>
#include<fstream>
#include<string>
#include <cstdlib> // for exit function
#include<iomanip>

using namespace std;

void AddToFile(string name,string staffno,string ic,string gender,string designation,string department,string dateofjoined,string nationality,string religion,string dateofbirth,string maritalstatus);
void DeleteTheFile(string name,string staffno,string ic,string gender,string designation,string department,string dateofjoined,string nationality,string religion,string dateofbirth,string maritalstatus); 
void genderSex();
void marital_status();
void readFromFile();

// I don't have a clue what you have done with your class... 
// here is your test class
class Test {

	  public:
	        Test();
			test(char theUsername[], char thePassword[]);
			char* getUsername();
			char* getPassword();
			
			void setUsers(char theUsername[], char thePassword[]);
	
	  private:
	         int sex;
			 char select; 
			 string name;
			 string staffno;
			 string ic;
			 string gender;
			 string designation;
			 string department;
			 string dateofjoined;
			 string nationality;
			 string religion;
			 string dateofbirth;
			 string maritalstatus;
};			
// here is the functions for that class
Test::Test(){}
Test::Test(char theUsername[], char thePassword[])
{

   strcpy(name, theUsername);
   strcpy(pass, thePassword);
}

char* Test::getUsername()
{
   return name;
}
char* Test::getPassword()
{
   return password;
}
void Test::setUsers(string theUsername[], string thePassword[])
{
   strcpy(name, theUsername);
   strcpy(pass, thePassword);
}

// now we can create the functions to check
void Test::CheckValues(char user[], char pass[])
{
   if(name == user && pass == pass)
     return true;
     return false;
}

int main(){

Test ts;
string user_entered;
string pass_entered;

cout << "Please enter your username";
cin >> user_entered;
cout << "Please enter your password";
cin >> pass_entered;

ts.setUsers(user_entered, pass_entered);

system("cls");

cout << "Your username is: " << ts.getUsername() << endl;
cout << "Your password is: " << ts.getPassword() << endl;

if(ts.CheckValues() == true)
{

  cout << "YAY you are now logged in";
  cout << "HAPPY BIRTHDAY";
}else{
   cout << "OOO no, you cannot log in";
   cout << "But happy birthday anyway ;)";
}

system("PAUSE");
return EXIT_SUCSESS;
}
This article has been dead for over six months. Start a new discussion instead.