I need urgent help in my project as i am getting exception 13 error & that also at such a crucial time when i have to submit the project day after tomorrow...please help and tell the mistakes and their will be some mistakes.
the source code is as follows:
#include<fstream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
class patient
{
int id;
char name[50];
char f_name[50],h_name[50];
int age;
char sex,b_gp[4];
char dept[20],di[30];
char d_in[50];
char d_admit[30],d_discharge[30];
char t_w[15];
int m_exp,s_exp;
long c_no;
public:
void enter1();
void disp1();
char*retdoc()
{
return d_in;
}
char*retward()
{
return t_w;
}
char*retdept()
{
return dept;
}
char*retname()
{
return name;
}
void up1(char c[])
{
strcpy(d_in,c);
}
void up2(char d[])
{
strcpy(t_w,d);
}
void up3(int e)
{
s_exp=e;
}
void up4(int f)
{
m_exp=f;
}
void up5(long g)
{
c_no=g;
}
void up6(char h[])
{
strcpy(dept,h);
}
int l3(int ef);
int l4(int gh);
int l5(long ij);
};
int patient::l3(int ef)
{
if(s_exp==ef)
return(0);
else
return(1);
}
int patient::l4(int gh)
{
if(m_exp==gh)
return(0);
else
return(1);
}
int patient::l5(long ij)
{
if(c_no==ij)
return(0);
else
return(1);
}
class doctor
{
int id;
char name[50];
char f_name[50];
char sex;
char dept[20];
char dob[30],d_join[30];
int sal;
long c_no;
public:
void enter2()
{
char ch;
cout<<"\n \n ********************************************************************************\n";
cout<<"\t\t\t\t Enter records \n";
cout<<"\n \n ********************************************************************************\n";
cout<<"\t Enter Doctor's ID \n"<<"\n \t";
cin>>id;
cout<<"\n \t Enter Name \n"<<" \t";
gets(name);
cout<<"\n \t Enter Father's Name\n \n \t" ;
gets(f_name);
cout<<"\n \t Enter Date Of Birth \n \n \t";
gets(dob);
cout<<"\n \t Enter Department \n \n \t";
gets(dept);
cout<<"\n \t Enter Date of Joining \n \n \t";
gets(d_join);
cout<<"\n \t Enter Contact Number\n \n \t";
cin>>c_no;
cout<<"\n \t Enter salary \n \n \t";
cin>>sal;
}
void disp2()
{
cout<<"\n ********************************************************************************\n";
cout<<"\t\t\t\t Display \n";
cout<<"\n ********************************************************************************\n";
cout<<"\n \t Doctor's ID "<<"\t-\t"<<id<<"\n";
cout<<"\n \t Doctor's Name"<<"\t-\t"<<name<<"\n";
cout<<"\n \t Father's Name"<<"\t - \t"<<f_name<<"\n";
cout<<"\n \t Date of Birth"<<"\t-\t"<<dob<<"\n";
cout<<"\n \t Contact Number"<<"\t-\t"<<c_no<<"\n";
cout<<"\n \t Department"<<"\t-\t"<<dept<<"\n";
cout<<"\n \n \t Date of Joining"<<"\t-\t"<<d_join<<"\n";
cout<<"\n \t Salary=Rs"<<sal;
}
char*retname()
{
return name;
}
char*retdept()
{
return dept;
}
void ch1(char a[])
{
strcpy(dept,a);
}
void ch2(long b)
{
c_no=b;
}
void ch3(int c)
{
sal=c;
}
int b1(long ij);
int b2(int ab);
};
int doctor::b1(long ij)
{
if(c_no==ij)
return(0);
else
return(1);
}
int doctor::b2(int ab)
{
if(sal==ab)
return(0);
else
return(1);
}
class staff
{
int id;
char name[50];
char f_name[50];
char sex;
char dept[20];
char dob[30],d_join[30];
char post[15];
int sal;
long c_no;
public:
void enter3()
{
char ch;
cout<<"\n \n ********************************************************************************\n";
cout<<"\t\t\t\t Enter records \n";
cout<<"\n \n ********************************************************************************\n";
cout<<"\t Enter Doctor's ID \n"<<"\n \t";
cin>>id;
cout<<"\n \t Enter Name \n"<<" \t";
gets(name);
cout<<"\n \t Enter Father's Name\n \n \t" ;
gets(f_name);
cout<<"\n \t Enter Date Of Birth \n \n \t";
gets(dob);
cout<<"\n \t Enter post \n \n \t";
gets(post);
cout<<"\n \t Enter Date of Joining \n \n \t";
gets(d_join);
cout<<"\n \t Enter Contact Number\n \n \t";
cin>>c_no;
cout<<"\n \t Enter salary \n \n \t";
cin>>sal;
}
void disp3()
{
cout<<"\n ********************************************************************************\n";
cout<<"\t\t\t\t Display \n";
cout<<"\n ********************************************************************************\n";
cout<<"\n \t staff's ID "<<"\t-\t"<<id<<"\n";
cout<<"\n \t Name"<<"\t-\t"<<name<<"\n";
cout<<"\n \t Father's Name"<<"\t - \t"<<f_name<<"\n";
cout<<"\n \t Date of Birth"<<"\t-\t"<<dob<<"\n";
cout<<"\n \t Contact Number"<<"\t-\t"<<c_no<<"\n";
cout<<"\n \t Post"<<"\t-\t"<<dept<<"\n";
cout<<"\n \t Date of Joining"<<"\t-\t"<<d_join<<"\n";
cout<<"\n \t Salary=Rs"<<sal;
}
char*retpost()
{
return post;
}
char*retname()
{
return name;
}
void al1(char d[])
{
strcpy(post,d);
}
void al2(int f)
{
c_no=f;
}
void al3(int e)
{
sal=e;
}
int c1(long kl);
int c2(int mn);
};
int staff::c1(long kl)
{
if(c_no==kl)
return(0);
else
return(1);
}
int staff::c2(int mn)
{
if(sal==mn)
return(0);
else
return(1);
}
void patient::enter1()
{
char ch;
cout<<"\n \n ********************************************************************************\n";
cout<<"\t\t\t\t Enter records \n";
cout<<"\n \n ********************************************************************************\n";
cout<<"\t Enter Patient's ID \n"<<"\n \t";
cin>>id;
cout<<"\n \t Enter Patient's Name \n"<<" \n\t";
gets(name);
cout<<"\n \t Enter Father's Name or Husband's Name";
cout<<"\n \t (F for father's name and H or husband's Name) \n \n \t";
cin>>ch;
if(ch=='f'|| ch=='F')
{
cout<<"\n \t Enter Father's Name \n \n \t";
gets(f_name);
strcpy(h_name,"null");
}
else if(ch=='h'||ch=='H')
{
cout<<"\n \t Enter Husband's Name \n \n \t";
gets(h_name);
strcpy(f_name,"null");
}
cout<<"\n \t Enter Age \n \n \t";
cin>>age;
cout<<"\n \t Sex (F for Female and M for Male) \n \n \t ";
cin>>sex;
cout<<"\n \t Enter Blood Group \n \n \t";
cin>>b_gp;
cout<<"\n \t Enter Contact Number\n \n \t";
cin>>c_no;
cout<<"\n \t Enter Department \n \n \t";
gets(dept);
cout<<"\n \t Enter Disease \n \n\t ";
gets(di);
cout<<"\n \t Enter Doctor Incharge \n \n \t";
gets(d_in);
cout<<"\n \t Enter Date of Admit \n \n \t";
gets(d_admit);
cout<<"\n \t Is patient discharged (Y for Yes and N for No) \n \n \t";
cin>>ch;
if(ch=='y' || ch=='Y')
{
cout<<"\n \t Enter Date of Discharge \n\n \t";
gets(d_discharge);
}
else if(ch=='n' || ch=='N')
{
strcpy(d_discharge,"null");
}
cout<<"\n \t Enter Type of Ward \n \n \t";
gets(t_w);
cout<<"\n \t Enter Medical Expenses \n \n \t";
cin>>m_exp;
cout<<"\n \t Has Surgery been done Y for Yes and N for No) \n \n \t";
cin>>ch;
if(ch=='y'||ch=='Y')
{
cout<<"\n \t Enter Surgery Expenses \n \n \t";
cin>>s_exp;
}
else if(ch=='n'|| ch=='N')
{
s_exp=0;
}
}
void patient::disp1()
{
cout<<"\n ********************************************************************************\n";
cout<<"\t\t\t\t Display \n";
cout<<"\n ********************************************************************************\n";
cout<<"\n \t Patient's ID- "<<' '<<id<<"\n";
cout<<"\n \t Patients's Name"<<"-"<<' '<<name<<"\n";
if(strcmpi(h_name,"null")==0)
{
cout<<"\n \t Father's Name"<<"-"<<' '<<f_name<<"\n";
}
else if(strcmpi(f_name,"null")==0)
{
cout<<"\n \t Huband's Name"<<"-"<<' '<<h_name<<"\n";
}
cout<<"\n \t Age"<<"-"<<' '<<age;
cout<<"\t \t \t Sex"<<"-"<<' '<<sex<<"\n";
cout<<"\n \t Blood Group"<<"-"<<' '<<b_gp<<"\n";
cout<<"\n \t Contact Number"<<"-"<<' '<<c_no<<"\n";
cout<<"\n \t Department"<<"\t-\t"<<dept<<"\n";
cout<<"\n \t Disease"<<"\t-\t"<<di<<"\n";
cout<<"\n \t Doctor Incharge"<<"\t-\t"<<d_in<<"\n";
cout<<"\n \t Date of Admit"<<"\t-\t"<<d_admit<<"\n";
if(strcmpi(d_discharge,"null")==0)
{
cout<<"\n \t Patient not Discharged";
cout<<"\n \t ______________________";
}
else if(strcmpi(d_discharge,"null")!=0)
{
cout<<"\n \n \t Date of Discharge"<<"\t-\t"<<d_discharge<<"\n";
}
cout<<"\n \t Type of Ward"<<"\t-\t"<<t_w<<"\n";
cout<<"\n ********************************************************************************\n";
cout<<"\t \t \t \t Bill";
cout<<"\n ********************************************************************************\n";
cout<<"\n --------------------------------------------------------------------------------\n";
cout<<"\t Sr no\t\t\t Service \t \t Charges \n";
cout<<"\n --------------------------------------------------------------------------------\n";
cout<<"\t \t 1 \t \t Medical Expenses \t \t "<<m_exp<<"\n";
if(s_exp!=0)
{
cout<<"\t 2 \t \t Surgical Expenses \t \t"<<s_exp<<"\n";
}
else if(s_exp==0)
{
cout<<"\t 2 \t \t Surgical Expenses \t \t "<<s_exp<<"\n \n ";
}
cout<<"\n --------------------------------------------------------------------------------\n";
cout<<"\n \t \t \t \t TOTAL=Rs"<<m_exp+s_exp;
cout<<"\n --------------------------------------------------------------------------------\n";
}
void add1()
{
patient p;
char ch;
cout<<"\n ********************************************************************************\n";
cout<<"\n \t \t \t Add Patient's Record \n";
cout<<"\n ********************************************************************************\n";
ofstream f("hospital.dat",ios::binary);
do
{
p.enter1();
getch();
f.write((char*)&p,sizeof(p));
cout<<"\n \t Do you want to add more records \n";
cin>>ch;
}while(ch=='y'|| ch=='Y');
f.close();
}
void add2()
{
doctor d;
char ch;
cout<<"\n ********************************************************************************\n";
cout<<"\n \t \t \t Add Patient's Record \n";
cout<<"\n ********************************************************************************\n";
ofstream f("hospital.dat",ios::binary);
do
{
d.enter2();
getch();
f.write((char*)&d,sizeof(d));
cout<<"\n \t Do you want to add more records\n";
cin>>ch;
}while(ch=='y' || ch=='Y');
f.close();
}
void add3()
{
staff s;
char ch;
cout<<"\n ********************************************************************************\n";
cout<<"\n \t \t \t Add Patient's Record \n";
cout<<"\n ********************************************************************************\n";
ofstream f("hospital.dat",ios::binary);
do
{
s.enter3();
getch();
f.write((char*)&s,sizeof(s));
cout<<"\n \t Do you want to add more records \n";
cin>>ch;
}while(ch=='y' || ch=='Y');
f.close();
}
void out1()
{
patient p;
char ch;
ifstream f("hospital.dat",ios::binary);
cout<<"\n ********************************************************************************\n";
cout<<"\n \t \t \t \t DISPLAY DATA \n ";
cout<<"\n ********************************************************************************\n";
while(f.read((char*)&p,sizeof(p)));
{
p.disp1();
getch();
}
f.close();
getch();
}
void out2()
{
doctor d;
char ch;
ifstream f("hospital.dat",ios::binary);
cout<<"\n ********************************************************************************\n";
cout<<"\n \t \t \t \t DISPLAY DATA \n ";
cout<<"\n ********************************************************************************\n";
while(f.read((char*)&d,sizeof(d)));
{
d.disp2();
getch();
}
f.close();
getch();
}
void out3()
{
staff s;
char ch;
ifstream f("hospital.dat",ios::binary);
cout<<"\n ********************************************************************************\n";
cout<<"\n \t \t \t \t DISPLAY DATA \n ";
cout<<"\n ********************************************************************************\n";
while(f.read((char*)&s,sizeof(s)));
{
s.disp3();
getch();
}
f.close();
getch();
}
void modify1()
{
patient p;
int x;
char ch,o_name[50],n_name[50],o_w[15],n_w[15];
int o_me,n_me,o_se,n_se,a;
long n_cno,o_cno;
char n_dept[20],o_dept[20];
ifstream f("hospital.dat",ios::binary);
ofstream k("temp.dat");
do
{
cout<<"\n ********************************************************************************\n";
cout<<"\n \t \t \t \t Modify \n";
cout<<"\n ********************************************************************************\n";
cout<<"\n \t In Which Way do You Want to Modify \n";
cout<<"\n --------------------------------------------------------------------------------\n";
cout<<"\n \n \t 1-Doctor Incharge\n \n \t2-Type of Ward\n \n \t3-bill\n \n \t 4-Contact Number\n \n \t 5-Department \n";
cin>>x;
switch(x)
{
case 1:
cout<<"\n \n \t Enter Doctor's Name to Modify\n \n \t";
gets(o_name);
cout<<"\n \n \t Enter New Doctor's Name \n \n \t";
gets(n_name);
while(f.read((char*)&p,sizeof(p)));
if(strcmpi(p.retdoc(),o_name)==0)
{
p.up1(n_name);
p.disp1();
k.write((char*)&p,sizeof(p));
}
else
cout<<"\n \n \t It Couldn't be Modified\n"<<"\n \t ------------------------\n";
cout
k.close();
f.close();
remove("hospital.dat");
rename("temp","hospital");
break;
case 2:
cout<<"\n \n \t Enter the Ward to Modify \n \t";
gets(o_w);
cout<<"\n \n \t Enter New type of Ward \n \t";
gets(n_w);
while(f.read((char*)&p,sizeof(p)));
if(strcmpi(p.retward(),o_w)==0)
{
p.up2(n_w);
p.disp1();
k.write((char*)&p,sizeof(p));
}
else
cout<<"\n \t It Couldn't be Modified\n"<<"\n \n \t ------------------------\n";
k.close();
f.close();
remove("hospital.dat");
rename("temp","hospital");
break;
case 3:
cout<<"\n \n \t Enter whether you Want to Modiy Surgical Expense or Medical Expense";
cout<<"\n (s for surgical and m or medical expense \n";
cin>>ch;
if(ch=='s'|| ch=='S')
{
cout<<"\n \n \t Enter Surgical Expense You Want to Modify \n \t";
cin>>o_se;
cout<<"\n \n \t Enter New Surgical Expense \n \t";
cin>>n_se;
while(f.read((char*)&p,sizeof(p)));
a=p.l3(o_se);
if(a==0)
{
p.up3(n_se);
p.disp1();
k.write((char*)&p,sizeof(p));
}
else
cout<<"\n \n \t It couldn't be modified \n"<<"\n \t _______________________\n";
}
k.close();
f.close();
remove("hospital.dat");
rename("temp","hospital");
}
else if(ch=='m'|| ch=='M')
{
cout<<"\n\n \t Enter Medical Expense You want to Modify \n \t";
cin>>o_me;
cout<<"\n\n \t Enter New Medical Expense \n \t";
cin>>n_me;
while(f.read((char*)&p,sizeof(p)));
a=p.l4(o_me);
if(a==0)
{
p.up4(n_me);
p.disp1();
k.write((char*)&p,sizeof(p));
}
else
cout<<"\n \t It Can Not be Modified \n"<<"\n \t _______________________\n";
k.close();
f.close();
remove("hospital.dat");
rename("temp","hospital");
}
break;
case 4:
cout<<"\n \n \t Enter the Contact Number to Modify \n \t";
cin>>o_cno;
cout<<"\n \n \t enter new type of ward \n \t";
cin>>n_cno;
while(f.read((char*)&p,sizeof(p)));
a=p.l5(o_cno);
if(a==0)
{
p.up5(n_cno);
p.disp1();
k.write((char*)&p,sizeof(p));
}
else
cout<<"\n \n \t It can not be Modified \n"<<"\n \t _______________________\n";
k.close();
f.close();
remove("hospital.dat");
rename("temp","hospital");
break;
case 5:
cout<<"\n \n \t Enter the department to modify \n \t";
gets(o_dept);
cout<<"\n \n \t Enter new department \n \t";
gets(n_dept);
while(f.read((char*)&p,sizeof(p)));
if(strcmpi(p.retdept(),o_dept)==0)
{
p.up1(n_dept);
p.disp1();
k.write((char*)&p,sizeof(p));
}
else
cout<<"\n\n \t It couldn't be modified \n"<<"\n \t _______________________\n";
k.close();
f.close();
remove("hospital.dat");
rename("temp","hospital");
break;
}
cout<<"\n \n \t Do you again want to modify \n \t";
cin>>ch;
}while(ch=='y'|| ch=='Y');
}
void modify2()
{
doctor d;
int x,n_sal,o_sal,a;
char ch;
long n_cno,o_cno;
char n_dept[20],o_dept[20];
ifstream f("hospital.dat",ios::binary);
ofstream k("temp.dat");
do
{
cout<<"\n ********************************************************************************\n";
cout<<"\n \t \t \t \t Modify \n";
cout<<"\n ********************************************************************************\n";
cout<<"\n \t In Which Way do You Want to Modify \n ";
cout<<"\n --------------------------------------------------------------------------------\n";
cout<<"\n \n \t 1-Department \n \n \t 2-Contact Number \n \n \t 3-Salary \n \t";
cin>>x;
switch(x)
{
case 1:
cout<<"\n \n \t Enter the department to modify \n \t";
gets(o_dept);
cout<<"\n \n \t Enter new department \n \t";
gets(n_dept);
while(f.read((char*)&d,sizeof(d)));
if(strcmpi(d.retdept(),o_dept)==0)
{
d.ch1(n_dept);
d.disp2();
k.write((char*)&d,sizeof(d));
}
else
cout<<"\n \n \t It couldn't be modified \n"<<"\n \t _______________________\n";
k.close();
f.close();
remove("hospital.dat");
rename("temp","hospital");
break;
case 2:
cout<<"\n \n \t Enter the Contact Number to Modify \n \t";
cin>>o_cno;
cout<<"\n \n \t Enter new contact number \n \t";
cin>>n_cno;
while(f.read((char*)&d,sizeof(d)));
a=d.b1(o_cno);
if(a==0)
{
d.ch2(n_cno);
d.disp2();
k.write((char*)&d,sizeof(d));
}
else
cout<<"\n \t It can not be Modified \n"<<"\n \t _______________________\n";
k.close();
f.close();
remove("hospital.dat");
rename("temp","hospital");
break;
case 3:
cout<<"\n\n \t Enter salary to Modify \n \t";
cin>>o_sal;
cout<<"\n \n \t Enter New salary \n \t";
cin>>n_sal;
while(f.read((char*)&d,sizeof(d)));
a=d.b2(o_sal);
if(a==0)
{
d.ch3(n_sal);
d.disp2();
k.write((char*)&d,sizeof(d));
}
else
cout<<"\n \n \t It Can Not be Modified \n"<<"\n \t _______________________\n";
k.close();
f.close();
remove("hospital.dat");
rename("temp","hospital");
break;
}
cout<<"\n \n \t Do you again want to modify \n \t";
cin>>ch;
}while(ch=='y'|| ch=='Y');
}
void modify3()
{
staff s;
int x,n_sal,o_sal,a;
char ch;
long n_cno,o_cno;
char n_post[20],o_post[20];
ifstream f("hospital.dat",ios::binary);
ofstream k("temp.dat");
do
{
cout<<"\n ********************************************************************************\n";
cout<<"\n \t \t \t \t Modify \n";
cout<<"\n ********************************************************************************\n";
cout<<"\n \t In Which Way do You Want to Modify \n";
cout<<"\n --------------------------------------------------------------------------------\n";
cout<<"\n \n \t 1-Department\n \n \t 2-Contact Number\n \n \t 3-Salary \n \t";
cin>>x;
switch(x)
{
case 1:
cout<<"\n \n \t Enter the post to modify \n \t";
gets(o_post);
cout<<"\n \n \t Enter new post \n \t";
gets(n_post);
while(f.read((char*)&s,sizeof(s)));
if(strcmpi(s.retpost(),o_post)==0)
{
s.al1(n_post);
s.disp3();
k.write((char*)&s,sizeof(s));
}
else
cout<<"\n \n \t It couldn't be modified \n"<<"\n \t _______________________\n";
k.close();
f.close();
remove("hospital.dat");
rename("temp","hospital");
break;
case 2:
cout<<"\n \n \t Enter the Contact Number to Modify \n \t";
cin>>o_cno;
cout<<"\n \n \t Enter new contact number \n \t";
cin>>n_cno;
while(f.read((char*)&s,sizeof(s)));
a=s.c1(o_cno);
if(a==0)
{
s.al2(n_cno);
s.disp3();
k.write((char*)&s,sizeof(s));
}
else
cout<<"\n \n \t It can not be Modified \n"<<"\n \t _______________________\n";
k.close();
f.close();
remove("hospital.dat");
rename("temp","hospital");
break;
case 3:
cout<<"\n\n \t Enter salary to Modify \n \t";
cin>>o_sal;
cout<<"\n\n \t Enter New salary \n \t";
cin>>n_sal;
while(f.read((char*)&s,sizeof(s)));
a=s.c2(o_sal);
if(a==0)
{
s.al3(n_sal);
s.disp3();
k.write((char*)&s,sizeof(s));
}
else
cout<<"\n\n \t It Can Not be Modified \n"<<"\n \t _______________________\n";
k.close();
f.close();
remove("hospital.dat");
rename("temp","hospital");
break;
}
cout<<"\n \n \t Do you again want to modify \n";
cin>>ch;
}while(ch=='y'|| ch=='Y');
}
void search1()
{
patient p;
int x;
char ch,p_name[50],doc[50],ward[15];
char dep[20];
ifstream f("hospital.dat",ios::binary);
do
{
cout<<"\n ********************************************************************************\n";
cout<<"\n \t \t \t \t SEARCH";
cout<<"\n ********************************************************************************\n";
cout<<"\n \t In which way do you want to search \n";
cout<<"\n \n \t 1-Patient's name\n \n \t 2-Type of ward\n \n \t 3-Department\n \n \t 4-Doctor Incharge\n \t";
cin>>x;
switch(x)
{
case 1:
cout<<"\n\n \t Enter Patient's Name \n \t" ;
gets(p_name);
while(f.read((char*)&p,sizeof(p)));
if(strcmpi(p.retname(),p_name)==0)
{
cout<<"\n \n\t Patient Found \n";
p.disp1();
}
else
cout<<"\n\n \t Patient not Found \n";
f.close();
break;
case 2:
cout<<"\n\n \t Enter the Type of ward \n \t";
gets(ward);
while(f.read((char*)&p,sizeof(p)));
if(strcmpi(p.retward(),ward)==0)
{
cout<<"\n\n \t Ward found \n";
p.disp1();
}
else
cout<<"\n\n \t Ward not found \n";
f.close();
break;
case 3:
cout<<"\n\n \t Enter department \n \t";
gets(dep);
while(f.read((char*)&p,sizeof(p)));
if(strcmpi(p.retdept(),dep)==0)
{
cout<<"\n\n \t Department found \n ";
p.disp1();
}
else
cout<<"\n\n \t Department not found \n ";
f.close();
break;
case 4:
cout<<"\n\n \t Enter doctor's name \n \t";
gets(doc);
while(f.read((char*)&p,sizeof(p)));
if(strcmpi(p.retdoc(),doc)==0)
{
cout<<"\n\n \t Doctor found \n";
p.disp1();
}
else
cout<<"\n\n \t Doctor not found \n";
f.close();
break;
}
cout<<"\n\n \t Do you want to Search again\n \t";
cin>>ch;
}while(ch=='y'|| ch=='Y');
}
void search2()
{
doctor d;
int x;
char ch,d_name[50];
char dep[20];
ifstream f("hospital.dat",ios::binary);
do
{
cout<<"\n ********************************************************************************\n";
cout<<"\n \t \t \t \t SEARCH";
cout<<"\n ********************************************************************************\n";
cout<<"\n \t in which way do you want to search \n";
cout<<"\n \n \t 1-Doctor's name\n \n \t 2-Department \n";
cin>>x;
switch(x)
{
case 1:
cout<<"\n\n \t Enter Doctor's Name \n \t" ;
gets(d_name);
while(f.read((char*)&d,sizeof(d)));
if(strcmpi(d.retname(),d_name)==0)
{
cout<<"\n\n \t Doctor Found \n";
getch();
d.disp2();
}
else
cout<<"\n\n \t Patient not Found \n";
f.close();
break;
case 2:
cout<<"\n\n \t Enter department \n \t";
gets(dep);
while(f.read((char*)&d,sizeof(d)));
if(strcmpi(d.retdept(),dep)==0)
{
cout<<"\n \n \t Department found \n ";
getch();
d.disp2();
}
else
cout<<"\n\n \t Department not found \n ";
f.close();
break;
}
cout<<"\n \t Do you want to Search again \n \t";
cin>>ch;
}while(ch=='y'|| ch=='Y');
}
void search3()
{
staff s;
int x,i;
char ch,s_name[50];
char pos[20];
ifstream f("hospital.dat",ios::binary);
do
{
cout<<"\n ********************************************************************************\n";
cout<<"\n \t \t \t \t SEARCH";
cout<<"\n ********************************************************************************\n";
cout<<"\n \t in which way do you want to search \n";
cout<<"\n \n \t 1-Name\n \n \t 2-Post \n \t";
cin>>x;
switch(x)
{
case 1:
cout<<"\n \n \t Enter Name \n \t" ;
gets(s_name);
while(f.read((char*)&s,sizeof(s));
if(strcmpi(s.retname(),s_name)==0)
{
cout<<"\n \n \t Doctor Found \n";
getch();
s.disp3();
}
else
cout<<"\n \n \t Doctor not Found \n";
f.close();
break;
case 2:
cout<<"\n \n \t Enter Post \n \t";
gets(pos);
while(f.read((char*)&s,sizeof(s));
if(strcmpi(s.retpost(),pos)==0)
{
cout<<"\n\n \t Post found \n \t";
getch();
s.disp3();
}
else
cout<<"\n\n \t Post not found \n \t ";
f.close();
break;
}
cout<<"\n\n \t Do you want to Search again\n \t";
cin>>ch;
}while(ch=='y'|| ch=='Y');
}
void del1()
{
patient p;
int x,i;
char ch,p_name[50],name[50],doc[50],ward[15];
char dep[20];
char sr;
ifstream f("hospital.dat",ios::binary);
ofstream k("temp.dat");
do
{
cout<<"\n ********************************************************************************\n";
cout<<"\n \t \t \t \t Delete \n";
cout<<"\n ********************************************************************************\n";
cout<<"\n \t In which way do you want to delete \n";
cout<<"\n\n \t 1-Patient's name \n\n \t 2-Doctor incharge\n\n \t 3-Department \n \t";
cin>>x;
switch(x)
{
case 1:
cout<<"\n \n \t Enter patient's name \n \t";
gets(p_name);
while(f.read((char*)&p,sizeof(p)));
if(strcmpi(p.retname(),p_name)==0)
{
cout<<"\n \n \t You sure you want to delete(y/n)?\n \t";
cin>>sr;
if(cr=='n' || cr=='N')
{
k.write((char*)&p,sizeof(p));
else
cout<<"\n \n \t RECORD DELETED \n";
}}
else
k.write((char*)&p,sizeof(p));
k.close();
f.close();
remove("hospital.dat");
rename("temp","hospital");
break;
case 2:
cout<<"\n\n \t enter doctor's name \n \t";
gets(doc);
while(f.read((char*)&p,sizeof(p));
if(strcmpi(p.retdoc(),doc)==0)
{
cout<<"\n \n \t You sure you want to delete(y/n)?\n \t";
cin>>sr;
if(cr=='n' || cr=='N')
{
k.write((char*)&p,sizeof(p));
else
cout<<"\n \n \t RECORD DELETED \n";
}}
else
k.write((char*)&p,sizeof(p));
k.close();
f.close();
remove("hospital.dat");
rename("temp","hospital");
break;
case 3:
cout<<"\n \t Enter the department \n \t";
gets(dep);
while(f.read((char*)&p,sizeof(p));
if(strcmpi(p.retdept(),dep)==0)
{
cout<<"\n \n \t You sure you want to delete(y/n)?\n \t";
cin>>sr;
if(cr=='n' || cr=='N')
{
k.write((char*)&p,sizeof(p));
else
cout<<"\n \n \t RECORD DELETED \n";
}}
else
k.write((char*)&p,sizeof(p));
k.close();
f.close();
remove("hospital.dat");
rename("temp","hospital");
break;
}
cout<<"\n \t Do you want to continue \n \t";
cin>>ch;
}while(ch=='y'|| ch=='Y');
}
void del2()
{
doctor d;
int x,i;
char ch,d_name[50],sr;
char dep[20];
ifstream f("hospital.dat",ios::binary);
ofstream k("temp.dat");
do
{
cout<<"\n ********************************************************************************\n";
cout<<"\n \t \t \t \t Delete \n";
cout<<"\n ********************************************************************************\n";
cout<<"\n \t In which way do you want to delete \n";
cout<<"\n \n \t 1-Doctor's name \n \n \t 2-Department \n \t";
cin>>x;
switch(x)
{
case 1:
cout<<"\n \n \t Enter doctor's name \n\t";
gets(d_name);
while(f.read((char*)&d,sizeof(d)));
if(strcmpi(d.retname(),d_name)==0)
{
cout<<"\n \n \t You sure you want to delete(y/n)?\n \t";
cin>>sr;
if(cr=='n' || cr=='N')
{
k.write((char*)&d,sizeof(d));
else
cout<<"\n \n \t RECORD DELETED \n";
}}
else
k.write((char*)&d,sizeof(d));
}
k.close();
f.close();
remove("hospital.dat");
rename("temp","hospital");
break;
case 2:
cout<<"\n \n \t Enter the department \n \t";
gets(dep);
while(f.read((char*)&d,sizeof(d));
if(strcmpi(d.retdept(),dep)==0)
{
cout<<"\n \n \t You sure you want to delete(y/n)?\n \t";
cin>>sr;
if(cr=='n' || cr=='N')
{
k.write((char*)&d,sizeof(d));
else
cout<<"\n \n \t RECORD DELETED \n";
}}
else
k.write((char*)&d,sizeof(d));
k.close();
f.close();
remove("hospital.dat");
rename("temp","hospital");
break;
}
cout<<"\n \n \t Do you want to continue \n \t";
cin>>ch;
}while(ch=='y'|| ch=='Y');
}
void del3()
{
staff s;
int x,i;
char ch,s_name[50],sr;
char pos[20];
ifstream f("hospital.dat",ios::binary);
ofstream k("temp.dat");
do
{
cout<<"\n ********************************************************************************\n";
cout<<"\n \t \t \t \t Delete \n";
cout<<"\n ********************************************************************************\n";
cout<<"\n \t In which way do you want to delete \n \t";
cout<<"\n \n \t 1-Name \n \n \t 2-Post\n \t";
cin>>x;
switch(x)
{
case 1:
cout<<"\n \n \t Enter name \n \t";
gets(s_name);
while(f.read((char*)&s,sizeof(s)));
if(strcmpi(s.retname(),s_name)==0)
{
cout<<"\n \n \t You sure you want to delete(y/n)?\n \t";
cin>>sr;
if(cr=='n' || cr=='N')
{
k.write((char*)&s,sizeof(s));
else
cout<<"\n \n \t RECORD DELETED \n";
}}
else
k.write((char*)&s,sizeof(s));
k.close();
f.close();
remove("hospital.dat");
rename("temp","hospital");
break;
case 2:
cout<<"\n\n \t Enter the post \n \t";
gets(pos);
while(f.read((char*)&s,sizeof(s));
if(strcmpi(s.retpost(),pos)==0)
{
cout<<"\n \n \t You sure you want to delete(y/n)?\n \t";
cin>>sr;
if(cr=='n' || cr=='N')
{
k.write((char*)&s,sizeof(s));
else
cout<<"\n \n \t RECORD DELETED \n";
}}
else
k.write((char*)&s,sizeof(s));
k.close();
f.close();
remove("hospital.dat");
rename("temp","hospital");
break;
}
cout<<"\n\n \t Do you want to continue \n \t";
cin>>ch;
}while(ch=='y'|| ch=='Y');
}
void main()
{
clrscr();
char st,str,ch1,ch2,ch3,ch4,ch5,upass[]={"USER"},apass[]={"ADMINISTRATOR"},pass[15],n_apass[15],n_upass[15];
int x1,x2,x3,x4,x5;
cout<<"\n \t \t \t \t |||||";
cout<<"\n \t \t \t \t |||||";
cout<<"\n \t \t \t \t |||||";
cout<<"\n \t \t \t \t |||||";
cout<<"\n \t \t \t \t |||||";
cout<<"\n \t \t \t \t |||||";
cout<<"\n \t \t \t \t |||||";
cout<<"\n \t \t \t |||||||||||||||||||||";
cout<<"\n \t \t \t |||||||||||||||||||||";
cout<<"\n \t \t \t |||||||||||||||||||||";
cout<<"\n \t \t \t \t |||||";
cout<<"\n \t \t \t \t |||||";
cout<<"\n \t \t \t \t |||||";
cout<<"\n \t \t \t \t |||||";
cout<<"\n \t \t \t \t |||||";
cout<<"\n \t \t \t \t |||||";
cout<<"\n \t \t \t \t |||||";
cout<<"\n \n \n*******************************************************************************";
cout<<"\n \t \t \t \t WELCOME TO \n";
cout<<"\n \t \t ------------SAHARA HOSPITAL------------ \n";
cout<<"\n ******************************************************************************* \n \t";
do
{
cout<<"\n ******************************************************************************* ";
cout<<"\n \n \t \t \t------------CHOOSE------------";
cout<<"\n ******************************************************************************* \n \t";
cout<<"\n \n \t \t \t 1-USER \n \n \t \t \t 2-ADMINISTRATOR \n \n \t \t \t";
cin>>x1;
switch(x1)
{
case 1:
cout<<"\n \n \t Enter password \n \t";
gets(pass);
if(strcmpi(upass,pass)==0)
{
cout<<"\n *******************************************************************************";
cout<<"\n \t \t \t---------WELCOME USER---------";
cout<<"\n ******************************************************************************* \n \t";
do
{
cout<<"\n \n -------------------------------------------------------------------------------\n";
cout<<"\n \t \t \t \t MAIN MENU";
cout<<"\n \n -------------------------------------------------------------------------------\n";
cout<<"\n \t Choose";
cout<<"\n \n \t 1-Patient\n \n \t 2-Doctor\n \n \t 3-Staff \n \t";
cin>>x2;
switch(x2)
{
case 1:
do
{
cout<<"\n *******************************************************************************";
cout<<"\n \t \t------------PATIENT------------";
cout<<"\n ******************************************************************************* \n \t";
cout<<"\n \t \t What Do You Want To Do \n";
cout<<"\n \n \t 1-Enter data \n \n\t 2-Display data \n\n \t 3-Modify data \n\n \t 4-Search data \n\n \t 5-Delete data \n \t";
cin>>x3;
switch(x3)
{
case 1:
add1();
break;
case 2:
out1();
break;
case 3:
modify1();
break;
case 4:
search1();
break;
case 5:
del1();
break;
}
cout<<"\n *******************************************************************************";
cout<<"\n \t \t \t \t PATIENT MENU \n \t";
cout<<"\n *******************************************************************************\n \t";
cout<<"\n \n \t \t Do you want to continue\n \t";
cin>>ch3;
}while(ch3=='y'|| ch3=='Y');
break;
case 2:
do
{
cout<<"\n *******************************************************************************";
cout<<"\n \t \t------------DOCTOR------------";
cout<<"\n ******************************************************************************* \n \t";
cout<<"\n \t \t What Do You Want To Do \n";
cout<<"\n \n \t 1-Enter data \n\n \t 2-Display data \n\n \t 3-Modify data \n\n \t 4-Search data \n\n \t 5-Delete data \n \t";
cin>>x4;
switch(x4)
{
case 1:
add2();
break;
case 2:
out2();
break;
case 3:
modify2();
break;
case 4:
search2();
break;
case 5:
del2();
break;
}
cout<<"\n *******************************************************************************";
cout<<"\n \t \t \t \t DOCTOR MENU \n \t";
cout<<"\n *******************************************************************************";
cout<<"\n \n \t \t Do you want to continue\n \t";
cin>>ch4;
}while(ch4=='y'|| ch4=='Y');
break;
case 3:
do
{
cout<<"\n *******************************************************************************";
cout<<"\n \t \t \t \t ------------STAFF------------";
cout<<"\n ******************************************************************************* \n \t";
cout<<"\n \t \t What Do You Want To Do \n";
cout<<"\n\n \t 1-Enter data \n\n \t 2-Display data \n\n \t 3-Modify data \n\n \t 4-Search data \n\n \t 5-Delete data \n \t";
cin>>x5;
switch(x5)
{
case 1:
add3();
break;
case 2:
out3();
break;
case 3:
modify3();
break;
case 4:
search3();
break;
case 5:
del3();
break;
}
cout<<"\n *******************************************************************************";
cout<<"\n \t \t \t \t STAFF MENU \n \t";
cout<<"\n *******************************************************************************";
cin>>ch5;
}while(ch5=='y'|| ch5=='Y');
}
cout<<"\n *******************************************************************************";
cout<<"\n \t \t \t \t MAIN MENU \n \t";
cout<<"\n ******************************************************************************* \n \t";
cout<<"\n \n \t \t Do you want to continue\n \t";
cin>>ch2;
}while(ch2=='y' || ch2=='Y');
}
break;
case 2:
cout<<"\n \n \t Enter password \n \t";
cin>>pass;
if(strcmpi(apass,pass)==0)
{
cout<<"\n *******************************************************************************";
cout<<"\n \t \t \t ---------WELCOME ADMINISTRATOR---------";
cout<<"\n *******************************************************************************\n \t";
cout<<"\n \n \t Do you want to change the password \n \t";
cin>>str;
if(str=='y' || str=='Y')
{
cout<<"\n \n \t Do you want to change user password or administrartor password\n \t";
cin>>st;
if(st=='u' || st=='U')
{
cout<<"\n \n \t Enter new password \n \t";
cin>>n_upass;
strcpy(upass,n_upass);
}
else
if(st=='a' || st=='A')
{
cout<<"\n\n \t Enter new password \n \t";
cin>>n_apass;
strcpy(apass,n_apass);
}
}
}
break;
}
cout<<"\n *******************************************************************************";
cout<<"\n \t \t Do you want to continue \n \t ";
cout<<"\n *******************************************************************************";
cin>>ch1;
}while(ch1=='y' || ch1=='Y');
getch();
}