-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdmin.h
153 lines (147 loc) · 3.9 KB
/
Admin.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#pragma once
#include <iomanip>
#include "Appointment.h"
#include "User.h"
#include "Doctor.h"
#include "Oladoc.h"
#include "Appointment.h"
#include "Availability.h"
#include <iostream>
#include <fstream>
#include <string>
class Admin:public User{
private:
string Username;
string Password;
public:
int menu();
bool login();
void view_P_data();
void view_D_data();
void view_schedule(string Doctor_CNIC);
void edit_schedule(string Doctor_CNIC);
void edit_P_info(string Patient_CNIC);
void edit_D_info(string Doctor_CNIC);
};
void Admin::view_schedule(string Doctor_CNIC) {
Doctor search;
ifstream read("doctor_data.dat",ios::binary);
while(read.read((char*)&search,sizeof(search))){
if (stringCmp(search.getcnic(),Doctor_CNIC)){
cout<<"Doctor Found... \n Displaying Schedule : ";
search.getAvail().view_schedule(search.getcnic());
break;
}
}
read.close();
}
void Admin::edit_schedule(string Doctor_CNIC) {
Doctor setup;
setup.getAvail().edit_schedule(Doctor_CNIC);
}
bool Admin::login(){
char user[100], pass[100];
cout << "Enter your Username or CNIC to Login : ";
cin>>user;
cout << "Enter your password : ";
cin>>pass;
if (stringCmp(user,"Admin"))
{
cout<<"Correct user!\n";
if (stringCmp(pass, "Abc123@"))
{
cout<<"Login Successful!\n";
Username=user;
Password=pass;
return 1;
}
}
cout<<"Login Failed!\n";
return 0;
}
void Admin::edit_P_info(string Patient_CNIC) {
Patient edit;
ifstream finding("patient_data.dat",ios::binary);
while (finding.read((char*)&edit,sizeof(edit))){
if (stringCmp(edit.getcnic(),Patient_CNIC)){
edit.edit_info();
break;
}
}
}
void Admin::edit_D_info(string Doctor_CNIC) {
Doctor edit;
ifstream finding("doctor_data.dat",ios::binary);
while (finding.read((char*)&edit,sizeof(edit))){
if (stringCmp(edit.getcnic(),Doctor_CNIC)){
edit.edit_info();
break;
}
}
}
void Admin::view_P_data() {
Patient search;
int counter=1;
cout<<"Displaying Patients...\n";
ifstream read("patient_data.dat",ios::binary);
while(read.read((char*)&search,sizeof(search))){
cout<<"Patient # "<<counter<<endl;
cout<<search;
cout<<endl<<endl;
counter++;
}
read.close();
}
void Admin::view_D_data() {
Doctor search;
int counter=1;
cout<<"Displaying Doctors...\n";
ifstream read("doctor_data.dat",ios::binary);
while(read.read((char*)&search,sizeof(search))){
cout<<"Doctor # "<<counter<<endl;
cout<<search;
cout<<endl<<endl;
counter++;
}
read.close();
}
int Admin::menu(){
Doctor Doc;
string temp;
cin.ignore();
cout<<"Please Select :\n\t1.Display All Docs\n\t2.Display All Patient\n\t3.View Doctor Schedule\n\t4.Edit Doctor Schedule\n\t5.Edit Patient Info\n\t6.Edit Doctor Info\n\t9.Logout\nSelection : ";
int select;
cin>>select;
switch (select){
case 1:
view_D_data();
break;
case 2:
view_P_data();
break;
case 3:
cout<<"Please Enter the Doctor's CNIC : ";
cin>>temp;
view_schedule(temp);
break;
case 4:
cout<<"Please Enter the Doctor's CNIC : ";
cin>>temp;
edit_schedule(temp);
break;
case 5:
cout<<"Please Enter the Patient's CNIC : ";
cin>>temp;
edit_P_info(temp);
break;
case 6:
cout<<"Please Enter the Doctor's CNIC : ";
cin>>temp;
edit_D_info(temp);
break;
case 9:
return 1;
break;
}
menu();
}