-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcustomer.cpp
More file actions
133 lines (127 loc) · 3.64 KB
/
customer.cpp
File metadata and controls
133 lines (127 loc) · 3.64 KB
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
void showcustomerMenu(customer &b)
{
fstream flaundry, fnewlaundry;
int x;
do
{
clrscr();
cout <<blue<<"*****************CUSTOMER MENU************" << endl;
printf("Enter choice...\n");
cout<<green;
printf("1)Display Schedule\n");
printf("2)Mark Laundry Received\n");
printf("3)Exit\n");
cout << "Enter Any one of the choices: ";
cout<<def;
x = input();
switch (x)
{
case 1:
{
ent
string temphostel;
cout << "Enter Hostel: \n";
cin >> temphostel;
if (scheduleExists())
{
viewSchedule_customer(temphostel);
}
else
{
cout << "Schedule Currently Not Available" << endl;
ent
}
break;
}
case 2:
{
laundry templaundry;
flaundry.open("laundry.dat", ios::in);
fnewlaundry.open("temp.dat", ios::out);
flaundry.seekg(0);
fnewlaundry.seekg(0);
while (!flaundry.eof())
{
if (flaundry.eof())
break;
flaundry.read((char *)&templaundry, sizeof(templaundry));
if (strcmp(templaundry.cusId, b.id) == 0)
{
clrscr();
showSlip(templaundry);
ent
cout
<< "Have you received the laundry";
string tempanswer;
cin >> tempanswer;
if (tempanswer == "Y" || tempanswer == "y")
{
templaundry.isReceived = 1;
fnewlaundry.write((char *)&templaundry, sizeof(templaundry));
}
else
{
fnewlaundry.write((char *)&templaundry, sizeof(templaundry));
}
}
else
{
fnewlaundry.write((char *)&templaundry, sizeof(templaundry));
}
}
// if(val1&&val2){cout<<"success";ent}
flaundry.close();
fnewlaundry.close();
int val1 = remove("laundry.dat");
int val2 = rename("temp.dat", "laundry.dat");
ent break;
}
case 3:
{
exit(0);
break;
}
}
} while (x != 3);
}
void logincustomer()
{
fstream fcustomer;
customer b;
string tempid,temppwd;
is_firsttime_launch_customer();
gotoxy(75,21);cout << "enter your ID: ";
cin >> tempid;
fcustomer.open("customer.dat", ios::in);
fcustomer.seekg(0);
while (!fcustomer.eof())
{
fcustomer.read((char *)&b, sizeof(b));
if (strcmp(b.id, tempid.c_str()) == 0)
{
gotoxy(75,22); cout << "User Found!!" << endl;
break;
}
}
if (strcmp(b.id, tempid.c_str()) != 0)
{
gotoxy(75,22); cout << "User not Found!!" << endl;
return;
}
fcustomer.close();
gotoxy(75,23);temppwd = inpPassword(strlen(b.password));
if (!temppwd.empty()) {
temppwd.resize(strlen(b.password));
}
if (strcmp(b.password, temppwd.c_str()) == 0)
{
gotoxy(75,24); cout << "Password match" ;
gotoxy(75,25); cout << "Welcome " << b.username << "!!" << endl;
gotoxy(75,26);ent
showcustomerMenu(b);
}
else
{
gotoxy(75,24);cout<< "PASSWORD DID NOT MATCH!!! TRY AGAIN!!!" << endl;
}
}