#include<iostream.h>#include<conio.h>#include<stdio.h>#include<fstream.h>
#include<stdlib.h>
#include<string.h>
struct date
{
int day;
int month;
int year;
};
struct per_info
{
char name[15];
long int contct;
char b_g[3];
char email[100];
char adress[100];
};
struct salary
{
int basic;
int net_pay;
int bonus;
int taxes;
};
struct student
{
per_info stu_info;
date dob;
};
student stu;
struct teacher
{
per_info teach_info;
date teach_doj;
salary teach_salary;
};
teacher teach;
struct admin
{
per_info admin_info;
date admin_doj;
salary admin_salary;
};
admin adm;
void stu_label()
{
cout<<"===============================================================================\n";
cout<<"========================== STUDENT RECORD =====================================\n";
cout<<"===============================================================================\n\n";
}
void teach_label()
{
cout<<"===============================================================================\n";
cout<<"========================== TEACHER RECORD =====================================\n";
cout<<"===============================================================================\n\n";
}
void admin_label()
{
cout<<"===============================================================================\n";
cout<<"============================ ADMIN RECORD =====================================\n";
cout<<"===============================================================================\n\n";
}
void stu_input()
{
stu_label();
ofstream sf;
sf.open("student.txt",ios::ate);
cout<<"Enter Name: ";
gets(stu.stu_info.name);
sf<<"Name: "<<stu.stu_info.name<<"\n";
cout<<"Enter Contact: ";
cin>>stu.stu_info.contct;
sf<<"Contact :"<<stu.stu_info.contct<<"\n";
cout<<"Enter Adress: ";
gets(stu.stu_info.adress);
sf<<"Adress: "<<stu.stu_info.adress<<"\n";
cout<<"Enter Email: ";
gets(stu.stu_info.email);
sf<<"Email: "<<stu.stu_info.email<<"\n";
cout<<"Enter Blood Group: ";
cin>>stu.stu_info.b_g;
sf<<"Blood Group: "<<stu.stu_info.b_g<<"\n";
cout<<"Enter DOB:\n";
cout<<"Day: ";
cin>>stu.dob.day;
cout<<"Month: ";
cin>>stu.dob.month;
cout<<"Year: ";
cin>>stu.dob.year;
sf<<"DOB: "<<stu.dob.day<<"/"<<stu.dob.month<<"/"<<stu.dob.year<<"\n\n";
sf<<endl;
cout<<endl;
sf.close();
}
void admin_input()
{
admin_label();
ofstream af;
af.open("admin.txt",ios::ate);
cout<<"Enter Name: ";
gets(adm.admin_info.name);
af<<"Name: "<<adm.admin_info.name<<"\n";
cout<<"Enter Contact: ";
cin>>adm.admin_info.contct;
af<<"Contact: "<<adm.admin_info.contct<<"\n";
cout<<"Enter Adress: ";
gets(adm.admin_info.adress);
af<<"Address: "<<adm.admin_info.adress<<"\n";
cout<<"Enter Email: ";
gets(adm.admin_info.email);
af<<"Email: "<<adm.admin_info.email<<"\n";
cout<<"Enter Blood Group: ";
cin>>adm.admin_info.b_g;
af<<"Blood Grozzzup: "<<adm.admin_info.b_g<<"\n";
cout<<"Enter DOJ:\n";
cout<<"Day: ";
cin>>adm.admin_doj.day;
cout<<"Month: ";
cin>>adm.admin_doj.month;
cout<<"Year: ";
cin>>adm.admin_doj.year;
af<<"DOJ: "<<adm.admin_doj.day<<"/"<<adm.admin_doj.month<<"/"<<adm.admin_doj.year<<"\n";
cout<<"Enter Basic Salary: ";
cin>>adm.admin_salary.basic;
cout<<"Enter Bonus: ";
cin>>adm.admin_salary.bonus;
cout<<"Enter Taxes: ";
cin>>adm.admin_salary.taxes;
adm.admin_salary.net_pay=adm.admin_salary.basic+adm.admin_salary.bonus-adm.admin_salary.taxes;
af<<"Net Salary: "<<adm.admin_salary.net_pay<<"\n\n";
cout<<endl;
af.close();
}
void teacher_input()
{
teach_label();
ofstream tf;
tf.open("teacher.txt",ios::ate);
cout<<"Enter Name: ";
gets(teach.teach_info.name);
tf<<"Name :"<<teach.teach_info.name<<"\n";
cout<<"Enter Contact: ";
cin>>teach.teach_info.contct;
tf<<"Contact :"<<teach.teach_info.contct<<"\n";
cout<<"Enter Adress: ";
gets(teach.teach_info.adress);
tf<<"Adress :"<<teach.teach_info.adress<<"\n";
cout<<"Enter Email: ";
gets(teach.teach_info.email);
tf<<"Email :"<<teach.teach_info.email<<"\n";
cout<<"Enter Blood Group: ";
cin>>teach.teach_info.b_g;
tf<<"Blood Group :"<<teach.teach_info.b_g<<"\n";
cout<<"Enter DOJ:\n";
cout<<"Day: ";
cin>>teach.teach_doj.day;
cout<<"Month: ";
cin>>teach.teach_doj.month;
cout<<"Year: ";
cin>>teach.teach_doj.year;
tf<<"DOJ: "<<teach.teach_doj.day<<"/"<<teach.teach_doj.month<<"/"<<teach.teach_doj.year<<"\n";
cout<<"Enter Basic Salary: ";
cin>>teach.teach_salary.basic;
cout<<"Enter Bonus: ";
cin>>teach.teach_salary.bonus;
cout<<"Enter Taxes: ";
cin>>teach.teach_salary.taxes;
teach.teach_salary.net_pay=teach.teach_salary.basic+teach.teach_salary.bonus-teach.teach_salary.taxes;
tf<<"Net Salary: "<<teach.teach_salary.net_pay<<"\n\n";
cout<<endl;
tf.close();
}
void stu_output()
{
stu_label();
char data[100];
ifstream sof;
sof.open("student.txt",ios::in);
while(!sof.eof())
{
sof.getline(data,100);
cout<<data<<"\n";
}
sof.close();
}
void teach_output()
{
teach_label();
char data[100];
ifstream tof;
tof.open("teacher.txt",ios::in);
while(!tof.eof())
{
tof.getline(data,100);
cout<<data<<"\n";
}
tof.close();
}
void admin_output()
{
admin_label();
char data[100];
ifstream aof;
aof.open("admin.txt",ios::in);
while(!aof.eof())
{
aof.getline(data,100);
cout<<data<<"\n";
}
aof.close();
}
void stu_search()
{
char search[]=" ",data[100],name[]="Name: ";
stu_label();
cout<<"Enter Name to search: ";
gets(search);
strcat(name,search);
ifstream sof;
sof.open("student.txt",ios::in);
clrscr();
while(!sof.eof())
{
sof.getline(data,100);
if(strcmp(name,data)==0)
{
cout<<data<<"\n";
sof.getline(data,100);
cout<<data<<"\n";
sof.getline(data,100);
cout<<data<<"\n";
sof.getline(data,100);
cout<<data<<"\n";
sof.getline(data,100);
cout<<data<<"\n";
sof.getline(data,100);
cout<<data<<"\n";
}
else
{
continue;
}
}
sof.close();
}
void teach_search()
{
char search[]=" ",data[100],name[]="Name: ";
teach_label();
cout<<"Enter Name to search: ";
gets(search);
strcat(name,search);
ifstream tof;
tof.open("teacher.txt",ios::in);
clrscr();
while(!tof.eof())
{
tof.getline(data,100);
if(strcmp(name,data)==0)
{
cout<<data<<"\n";
tof.getline(data,100);
cout<<data<<"\n";
tof.getline(data,100);
cout<<data<<"\n";
tof.getline(data,100);
cout<<data<<"\n";
tof.getline(data,100);
cout<<data<<"\n";
tof.getline(data,100);
cout<<data<<"\n";
tof.getline(data,100);
cout<<data<<"\n";
}
else
{
continue;
}
}
tof.close();
}
void admin_search()
{
char search[]=" ",data[100],name[]="Name: ";
admin_label();
cout<<"Enter Name to search: ";
gets(search);
strcat(name,search);
ifstream aof;
aof.open("admin.txt",ios::in);
clrscr();
while(!aof.eof())
{
aof.getline(data,100);
if(strcmp(name,data)==0)
{
cout<<data<<"\n";
aof.getline(data,100);
cout<<data<<"\n";
aof.getline(data,100);
cout<<data<<"\n";
aof.getline(data,100);
cout<<data<<"\n";
aof.getline(data,100);
cout<<data<<"\n";
aof.getline(data,100);
cout<<data<<"\n";
aof.getline(data,100);
cout<<data<<"\n";
}
else
{
continue;
}
}
aof.close();
}
void main()
{
int x=0;
PAS:
int c=0;
char pass[9];
char r[8] = "pakistan";
int p;
cout<<"\n\n\n\n\n\n\n\n\n\t\t\tEnter Password: ";
for (int i=0;i<9;i++)
{
if(i !=9)
{
pass[i] = getch();
cout<<"*";
}
else
{
continue;
}
}
for (int j=0;j<8;j++)
{
if (pass[j] == r[j])
c = c+1;
}
clrscr();
if (c == 8)
{
cout<<"\n\n\n\n\n\n\n\n";
cout<<"\t\t\t============================\n";
cout<<"\t\t\t=======ACCESS GRANTED=======\n";
cout<<"\t\t\t============================\n";
getch();
clrscr();
XY:
cout<<"===============================================================================\n";
cout<<"========================== Welcome to Database System =========================\n";
cout<<"===============================================================================\n\n";
int ch=0;
cout<<"1- Student Record\n2- Teacher Record\n3- Admin Record\n4- Exit\n\nPress Any: ";
cin>>ch;
clrscr();
if(ch==1)
{
stu_label();
int stu_ch=0;
cout<<"1- Enter Record\n2- Show Record\n3- Search Record\n4- Pervious Menu\n\nPress Any: ";
cin>>stu_ch;
clrscr();
if(stu_ch==1)
{
int che;
do
{
stu_input();
clrscr();
cout<<"\n\n\n\t\t\t\tRecord Saved !\n";
cout<<"\n1- Enter Another Record\n2- Main Menu\n\nPress Any: ";
cin>>che;
clrscr();
if(che != 1)
{
goto XY;
}
}
while(che == 1);
}
else if(stu_ch==2)
{
stu_output();
getch();
clrscr();
goto XY;
}
else if(stu_ch==3)
{
stu_search();
cout<<"Record Not Found";
getch();
clrscr();
goto XY;
}
else if(stu_ch==4)
{
goto XY;
}
else
{
cout<<"Invalid Input";
}
}
else if(ch==2)
{
teach_label();
int tea_ch=0;
cout<<"1- Enter Record\n2- Show Record\n3- Search Record\n4- Previous Menu\n\nPress Any: ";
cin>>tea_ch;
clrscr();
if(tea_ch==1)
{
int che;
do
{
teacher_input();
clrscr();
cout<<"\n\n\n\t\t\t\tRecord Saved !\n";
cout<<"\n1- Enter Another Record\n2- Main Menu\n\nPress Any: ";
cin>>che;
clrscr();
if(che != 1)
{
goto XY;
}
}
while(che == 1);
}
else if(tea_ch==2)
{
teach_output();
getch();
clrscr();
goto XY;
}
else if(tea_ch==3)
{
teach_search();
cout<<"Record Not Found";
getch();
clrscr();
goto XY;
}
else if(tea_ch==4)
{
goto XY;
}
else
{
cout<<"Invalid Input";
}
}
else if(ch==3)
{
admin_label();
int adm_ch=0;
cout<<"1- Enter Record\n2- Show Record\n3- Search Record\n4- Previous Menu\n\nPress Any: ";
cin>>adm_ch;
clrscr();
if(adm_ch==1)
{
int che;
do
{
admin_input();
clrscr();
cout<<"\n\n\n\t\t\t\tRecord Saved !\n";
cout<<"\n1- Enter Another Record\n2- Main Menu\n\nPress Any: ";
cin>>che;
clrscr();
if(che != 1)
{
goto XY;
}
}
while(che == 1);
}
else if(adm_ch==2)
{
admin_output();
getch();
clrscr();
goto XY;
}
else if(adm_ch==3)
{
admin_search();
cout<<"Record Not Found";
getch();
clrscr();
goto XY;
}
else if(adm_ch==4)
{
goto XY;
}
else
{
cout<<"Invalid Input";
}
}
else if(ch==4)
{
exit(0);
}
else
{
cout<<"Invalid input";
}
}
else
{
x++;
if( x < 3)
{
cout<<"\n\n\n\n\n\t\t\t============================\n";
cout<<"\t\t\t====== Caution !!!!!! ======\n";
cout<<"\t\t\t============================\n";
cout<<"\n\n\n\t\t\t ACCESS ABORTED !\n\n";
cout<<"\t\t\t Press Enter to Retry !";
getch();
clrscr();
goto PAS;
}
else
{
cout<<"\n\n\n\n\n\t\t\t** Retry later!! **";
}
}
getch();
}
No comments:
Post a Comment