aks rajendra
unread,Mar 2, 2012, 7:22:43 AM3/2/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ECE-ABC-2007, vigne...@gmail.com
#include<stdlib.h>
#include<iostream>
#include<cstring>
#include<fstream>
#include<string>
#include<unistd.h>
using namespace std;
class details
{
int employeeid;
char designation[20];
int experience;
public:
void getdetails()
{
cout<<"\n employee id: ";
cin>>employeeid;
cout<<"\n designation: ";
cin>>designation;
cout<<"\n Years of experience :";
cin>>experience;
}
void showdetails()
{
cout<<"\n\n Displaying Details";
cout<<"-----------------------";
cout<<employeeid<<" is the employee id";
cout<<"\n Designation is "<<designation;
cout<<"\n Years of Experience is "<<experience;
}
};
class rw_details
{
private:
details buffer;
public:
int aflag;
void readdetails();
void writedetails();
};
class leave
{
public:
char i_username[20];
char i_password[20];
char username[20];
char password[20];
int i;
int flag;
string line;
void getusername()
{
cout<<"\nEnter username ";
cin>>i_username;
cout<<"\nEnter password ";
cin>>i_password;
}
void match()
{
flag=0;
ifstream myfile("pro1",ios::out);
while(!myfile.eof())
{
getline(myfile,line);
for(i=0;i<line.length();i++)
username[i]=line[i];
username[i]='\0';
if(!strcmp(username,i_username))
{
getline(myfile,line);
for(i=0;i<line.length();i++)
password[i]=line[i];
password[i]='\0';
if(!strcmp(password,i_password))
{
flag = 1;
break;
}
}
}
if ( flag == 1)
{
cout<<"\n\n username & password matches";
cout<<"\n\n You are Logined as a user";
}
else
{
cout<<"\n\nEnter Correct username & password";
}
myfile.close();
}
};
void rw_details::readdetails()
{
aflag=0;
char i_admin[20],i_admin_pass[20];
char admin[20]="admin";
char admin_pass[20]="admin";
cout<<"\n Enter admin Username";
cin>>i_admin;
cout<<"\n Enter admin password";
cin>>i_admin_pass;
if(!strcmp(i_admin,admin))
{
if(!strcmp(i_admin_pass,admin_pass))
{
ofstream ofile("details.txt",ios::app);
char op;
cout<<"\n Do You want to add a record";
cin>>op;
while(op=='y')
{
buffer.getdetails();
ofile.write((char *)&buffer,sizeof(buffer));
cout<<"\n\n do you need to add one more";
cin>>op;
}
}
}
aflag=1;
if ( aflag == 1)
{
cout<<"\n\n username & password matches";
cout<<"\n\n You are Logined as an admin";
}
else
{
cout<<"\n\nEnter Correct admin username & password";
}
}
void rw_details::writedetails()
{
if(aflag==1)
{
ifstream in("details.txt");
in.read((char *)&buffer,sizeof(buffer));
while(in)
{
buffer.showdetails();
in.read((char *)&buffer,sizeof(buffer));
}
}
}
class apply_leave
{
public:
int a_empid;
char reason[20];
int no_of_days;
int max_leave;
char ch;
char app[20];
int a_aflag;
void apply()
{
cout<<"\n\n Employee id: ";
cin>>a_empid;
cout<<"\n Reason: ";
cin>>reason;
cout<<"\n Number of days on leave: ";
cin>>no_of_days;
}
void display()
{
max_leave=3;
strcpy(app,"Approved");
cout<<"\n\nLeave details of employee "<<a_empid;
cout<<"\nReason for leave "<<reason;
cout<<"\n Number of days of leave required "<<no_of_days;
if(no_of_days<=max_leave)
{
cout<<"\n The leave is "<<app;
}
else
{
a_aflag=0;
char i_admin[20],i_admin_pass[20];
char admin[20]="admin";
char admin_pass[20]="admin";
cout<<"\n Enter admin Username ";
cin>>i_admin;
cout<<"\n Enter admin password ";
cin>>i_admin_pass;
if(!strcmp(i_admin,admin))
{
if(!strcmp(i_admin_pass,admin_pass))
{
a_aflag=1;
cout<<"\nNumber of days of leave requested "<<no_of_days;
cout<<"\nDo you want to approve the employee's leave
request(y/n)? ";
cin>>ch;
if(ch!='y')
{
strcpy(app,"Rejected");
}
}
}
if ( a_aflag == 1)
{
cout<<"\n Approval status processing...";
}
else
{
cout<<"\n Access denied";
}
}
cout<<"\n The leave is "<<app;
}
file_leave b;
int choice;
cout<<"\n<----------Leave Management System---------->";
cout<<"\n 1.Login";
cout<<"\n 2.Add details(admin)";
cout<<"\n 3.Apply For Leave(user)";
cout<<"\n 4.Employee leave request view & approval(user/admin)";
cout<<"\n What do you want to do?";
cout<<"\n\n Enter your choice!";
cin>>choice;
while(choice>0 && choice<5)
{
switch(choice)
{
case 1:
l.getusername();
l.match();
break;
case 2:
r.readdetails();
r.writedetails();
break;
case 3:
b.b_getusername();
b.write();
break;
case 4:
b.read();
break;
default:
break;
}
cout<<"\n\n Do you want to continue";
system("clear");
system("./a.out");
cout<<"\n\n Enter Your choice";
cin>>choice;
}
return 0;
}
[wipro2@wipro-e6170f952 vick]$ vi projecti1.cpp
[wipro2@wipro-e6170f952 vick]$ vi projecti1.cpp
};
class file_leave
{
private:
apply_leave c;
public:
int a_flag,i;
string line;
char i_username[20];
char i_password[20];
char username[20];
char password[20];
void b_getusername()
{
cout<<"\nEnter username ";
cin>>i_username;
cout<<"\nEnter password ";
cin>>i_password;
}
void write()
{
a_flag=0;
ifstream myfile("pro1",ios::out);
while(!myfile.eof())
{
getline(myfile,line);
for(i=0;i<line.length();i++)
username[i]=line[i];
username[i]='\0';
if(!strcmp(username,i_username))
{
getline(myfile,line);
for(i=0;i<line.length();i++)
password[i]=line[i];
password[i]='\0';
if(!strcmp(password,i_password))
{
a_flag = 1;
ofstream of("Lfile.dat",ios::app);
c.apply();
of.write((char*)&c,sizeof(c));
}
}
leave l;
file_leave b;
int choice;
cout<<"\n<----------Leave Management System---------->";
cout<<"\n 1.Login";
cout<<"\n 2.Add details(admin)";
cout<<"\n 3.Apply For Leave(user)";
cout<<"\n 4.Employee leave request view & approval(user/admin)";
cout<<"\n What do you want to do?";
cout<<"\n\n Enter your choice!";
cin>>choice;
while(choice>0 && choice<5)
{
switch(choice)
{
case 1:
l.getusername();
l.match();
break;
case 2:
r.readdetails();
r.writedetails();
break;
case 3:
b.b_getusername();
b.write();
break;
case 4:
b.read();
break;
default:
break;
}
cout<<"\n\n Do you want to continue";
system("clear");
system("./a.out");
cout<<"\n\n Enter Your choice";
cin>>choice;
}
return 0;
}
[wipro2@wipro-e6170f952 vick]$ vi projecti1.cpp
[wipro2@wipro-e6170f952 vick]$ vi projecti1.cpp
}
if ( a_flag == 1)
{
cout<<"\n\n Username & password matches";
cout<<"\n\n You are Logged-in as a user";
}
else
{
cout<<"\n\nEnter Correct username & password";
}
myfile.close();
}
void read()
{
char i_admin[20],i_admin_pass[20];
char admin[20]="admin";
char admin_pass[20]="admin";
cout<<"\n Enter admin Username ";
cin>>i_admin;
cout<<"\n Enter admin password ";
cin>>i_admin_pass;
if(!strcmp(i_admin,admin))
{
if(!strcmp(i_admin_pass,admin_pass))
{
ifstream fo("Lfile.dat");
fo.read((char*)&c,sizeof(c));
while(fo)
{
c.display();
fo.read((char*)&c,sizeof(c));
}
}
}
}
};
int main()
{
leave l;
file_leave b;
int choice;
cout<<"\n<----------Leave Management System---------->";
cout<<"\n 1.Login";
cout<<"\n 2.Add details(admin)";
cout<<"\n 3.Apply For Leave(user)";
cout<<"\n 4.Employee leave request view & approval(user/admin)";
cout<<"\n What do you want to do?";
cout<<"\n\n Enter your choice!";
cin>>choice;
while(choice>0 && choice<5)
{
switch(choice)
{
case 1:
l.getusername();
l.match();
break;
case 2:
r.readdetails();
r.writedetails();
break;
case 3:
b.b_getusername();
b.write();
break;
case 4:
b.read();
break;
default:
break;
}
cout<<"\n\n Do you want to continue";
system("clear");
system("./a.out");
cout<<"\n\n Enter Your choice";
cin>>choice;
}
return 0;
}
[wipro2@wipro-e6170f952 vick]$ vi projecti1.cpp
[wipro2@wipro-e6170f952 vick]$ vi projecti1.cpp
rw_details r;
leave l;
file_leave b;
int choice;
cout<<"\n<----------Leave Management System---------->";
cout<<"\n 1.Login";
cout<<"\n 2.Add details(admin)";
cout<<"\n 3.Apply For Leave(user)";
cout<<"\n 4.Employee leave request view & approval(user/admin)";
cout<<"\n What do you want to do?";
cout<<"\n\n Enter your choice!";
cin>>choice;
while(choice>0 && choice<5)
{
switch(choice)
{
case 1:
l.getusername();
l.match();
break;
case 2:
r.readdetails();
r.writedetails();
break;
case 3:
b.b_getusername();
b.write();
break;
case 4:
b.read();
break;
default:
break;
}
cout<<"\n\n Do you want to continue";
system("clear");
system("./a.out");
cout<<"\n\n Enter Your choice";
cin>>choice;
}
return 0;
}