-
Notifications
You must be signed in to change notification settings - Fork 0
/
Customer.h
348 lines (287 loc) · 9.52 KB
/
Customer.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
#pragma once
#include<iostream>
#include<string>
#include"Main_window.h"
using namespace std;
#include "Cloths_info_Linkedlist.h"
#include "Customer_Info_Linkedlist.h"
#include "Administrator.h"
#include "Orders_queue.h"
int Add_Bill(int Price,int Quantity)
{
int amount;
amount = Price * Quantity;
return amount;
}
int Customer_Login(Customer_List& newcustomerlist)
{
Customer newcustomer;
cout << "\t\t\t\t\tEnter the Username:\t";
cin >> newcustomer.Username;
cout << "\t\t\t\t\tEnter the Password:\t";
cin >> newcustomer.Password;
int var1 = newcustomerlist.searchCustomerBypassword(newcustomer.Password);
int var2 = newcustomerlist.searchCustomerByusername(newcustomer.Username);
if (var1 != -1 && var2 != -1 && var1 == var2)
{
return -1;
}
cout << "Invalid username or password...!" << endl;
return Customer_Login(newcustomerlist);
}
int Customer_Signup(Customer_List& newcustomerlist)
{
Customer newcustomer;
cout << "\t\t\t\t\tEnter the name\t\t :\t" ;
cin >> newcustomer.Name;
cout << "\t\t\t\t\tEnter the username\t :\t" ;
cin >> newcustomer.Username;
cout << "\t\t\t\t\tEnter the Password\t :\t";
cin >> newcustomer.Password;
cout << "\t\t\t\t\tEnter the E-mail Address :\t" ;
cin >> newcustomer.Email;
cout << "\t\t\t\t\tEnter the Mobile Number :\t" ;
cin >> newcustomer.Mobile_Number;
int var2 = newcustomerlist.searchCustomerByusername(newcustomer.Username);
if (var2 == -1)
{
newcustomerlist.Add_Customer(newcustomer);
return -1;
}
cout << "Password is already exist...!" << endl;
return Customer_Signup(newcustomerlist);
}
void Customer_Window(Customer_List& newcustomerlist, ClothsList& Skirt_list, ClothsList& Frock_list, ClothsList& Trouser_list, ClothsList& Blouse_list, OrdersQueue& orderslist)
{
system("cls");
cout << "\n\t\t\t\t\t\t ----------" << endl;
cout << "\t\t\t\t\t\t CUSTOMER" << endl;
cout << "\t\t\t\t\t\t ----------" << endl;
cout << endl;
cout << "\t\t\t\t\t1. View All Lists" << endl;
cout << "\t\t\t\t\t2. Buy items" << endl;
cout << "\t\t\t\t\t3. Back to the Main Menu" << endl;
//1.View All Lists
int c1;
cin >> c1;
if (c1 == 1) {
system("cls");
cout << "\n\t\t\t\t\t\t-------------" << endl;
cout << "\t\t\t\t\t\t ALL ITEMS" << endl;
cout << "\t\t\t\t\t\t-------------" << endl;
cout << endl;
cout << "----------------------------------------------- |Frock List| --------------------------------------------------------" ;
cout << endl;
Frock_list.printCloths();
cout << endl;
cout << "---------------------------------------------- |Trouser List| --------------------------------------------------------" ;
cout << endl;
Trouser_list.printCloths();
cout << endl;
cout << "----------------------------------------------- |Skirt List| --------------------------------------------------------" ;
cout << endl;
Skirt_list.printCloths();
cout << endl;
cout << "----------------------------------------------- |Blouse List| --------------------------------------------------------" ;
cout << endl;
Blouse_list.printCloths();
cout << endl;
cout << "-> Press (0) go to Back" << endl;
int k;
cin >> k;
if (k == 0) {
system("cls");
return Customer_Window(newcustomerlist, Skirt_list, Frock_list, Trouser_list, Blouse_list, orderslist);
}
else {
system("cls");
return Customer_Window(newcustomerlist, Skirt_list, Frock_list, Trouser_list, Blouse_list, orderslist);
}
}
//Buy items
else if (c1 == 2)
{
system("cls");
cout << endl;
cout << "These are available Items..." << endl;
cout << "----------------------------------------------- |Frock List| --------------------------------------------------------" ;
cout << endl;
Frock_list.printCloths();
cout << endl;
cout << "---------------------------------------------- |Trouser List| --------------------------------------------------------" ;
cout << endl;
Trouser_list.printCloths();
cout << endl;
cout << "----------------------------------------------- |Skirt List| --------------------------------------------------------" ;
cout << endl;
Skirt_list.printCloths();
cout << endl;
cout << "----------------------------------------------- |Blouse List| --------------------------------------------------------" ;
cout << endl;
Blouse_list.printCloths();
cout << endl;
cout << "Here you can get additional discounts:" << endl;
cout << "\t\t\t\t\tTotal" << "\t\t" << "Discount" << endl;
cout << "\t\t\t\t________________________________________" << endl;
cout << "\t\t\t\t\t>5000" << "\t\t" << "5%" << endl;
cout << "\t\t\t\t\t>8000" << "\t\t" << "10%" << endl;
cout << "\t\t\t\t\t>10000" << "\t\t" << "12%" << endl;
cout << endl;
int* a_Id = new int[100];
int* b_Price = new int[100];
int* c_Quantity = new int[100];
int* d_Amount = new int[100];
bool x = true;
int total = 0;
int j=0;
while (x)
{
Cloths cloths;
cout << "Please enter the cloth Id you wish want to buy? :\t" ;
cin >> cloths.Id;
int c_quentity;
cout << "Please enter the Quantity\t\t\t:\t" ;
cin >> c_quentity;
int index;
int price;
int index1 = Frock_list.searchClothsByID(cloths.Id);
int index2 = Trouser_list.searchClothsByID(cloths.Id);
int index3 = Skirt_list.searchClothsByID(cloths.Id);
int index4 = Blouse_list.searchClothsByID(cloths.Id);
if (index1 != -1) {
index = index1;
price = Frock_list.get_price(index);
}
else if (index2 != -1) {
index = index2;
price = Trouser_list.get_price(index);
}
else if (index3 != -1) {
index = index3;
price = Skirt_list.get_price(index);
}
else if (index4 != -1) {
index = index4;
price = Blouse_list.get_price(index);
}
int Amount = Add_Bill( price, c_quentity);
a_Id[j] = cloths.Id;
b_Price[j] = price;
c_Quantity[j] = c_quentity;
d_Amount[j] = Amount;
j++;
total = total + Amount;
cout << endl;
cout << "-> Do you buy any otherthing?" << endl;;
cout << "\t\t\t(1) Yes" << endl;
cout << "\t\t\t(2) No " << endl;
int var;
cin >> var;
if (var == 1) {
x = true;
}
else {
x = false;
}
}
cout << "-> Place Order?" << endl;
cout << "\t\t\t(1) Conform" << endl;
cout << "\t\t\t(2) No" << endl;
int c2;
cin >> c2;
if (c2 == 1) {
system("cls");
cout << "\n\t\t\t\t\t******** CART ********" << endl;
cout << "__________________________________________________________________________________________" << endl;
cout << "Cloth Id\t\t" << "Price\t\t\t" << "Quantity\t\t\t" << "Amount" << endl;
cout << "__________________________________________________________________________________________" << endl;
for (int k = 0; k < j; k++) {
cout << a_Id[k] << "\t\t\t" << b_Price[k] << "\t\t\t" << c_Quantity[k] << "\t\t\t\tRs:" << d_Amount[k] << endl;
}
cout << endl;
cout << "Your Calculated Bill...\n" << endl;
int total_price;
if (total >= 5000 && total < 8000) {
total_price = total - ((total * 5 )/ 100);
cout << "\t\t\tTotal Price with Discount = " << total <<" - (" << total << " * 5%)" << endl;
cout << "\t\t\t\t\t\t = Rs." << total_price << endl;
}
else if (total >= 8000 && total < 10000) {
total_price = total - ((total * 10) / 100);
cout << "\t\t\tTotal Price with Discount = " << total << " - (" << total << " * 10%)" << endl;
cout << "\t\t\t\t\t\t = Rs." << total_price << endl;
}
else if (total >= 10000) {
total_price = total - ((total * 12 )/ 100);
cout << "\t\t\tTotal Price with Discount = " << total << " - (" << total << " * 12%)" << endl;
cout << "\t\t\t\t\t\t = Rs." << total_price << endl;
}
else {
cout << "\t\t\tTotal Price = Rs." << total << endl;
}
cout << "\nHow do you pay the bill?" << endl;
cout << "\t(1) Cash on delivery" << endl;
cout << "\t(2) Card payment" << endl;
cout << endl;
string Homeaddress;
string Mobileno;
string name;
int z;
cin >> z;
if (z == 1) {
cout << " Enter the Name\t:\t";
cin >> name;
cout << " Enter the Home Address :\t";
cin >> Homeaddress;
cout << " Enter the Mobile Number :\t";
cin >> Mobileno;
for (int k = 0; k < j; k++) {
orderslist.Add_orderCOD(a_Id[k], c_Quantity[k], name, Homeaddress, Mobileno);
}
cout << endl;
cout << " We will deliver your order within 3 days..."<< endl;
}
else if (z == 2) {
cout << " Enter the Name\t:\t";
cin >> name;
cout << " Enter the Home Address :\t";
cin >> Homeaddress;
cout << " Enter the Mobile Number :\t";
cin >> Mobileno;
string Cardnumber;
cout << " Enter the Card Number :\t";
cin >> Cardnumber;
string CVV;
cout << " Enter the CVV \t:\t";
cin >> CVV;
string Holder_name;
cout << " Enter the Card Holder Name :\t";
cin >> Holder_name;
for (int k = 0; k < j; k++) {
orderslist.Add_orderCP(a_Id[k], c_Quantity[k], name, Homeaddress, Mobileno, Cardnumber , Holder_name, CVV);
}
cout << endl;
cout << " Payment Successfully..." << endl;
cout << " We will deliver your order within 3 days..." << endl;
}
cout << endl;
cout << "\t\t\t\t\t\tThank you...!" << endl;
}
cout << "-> Press (0) go to Back" << endl;
int k;
cin >> k;
if (k == 0) {
system("cls");
return Customer_Window(newcustomerlist, Skirt_list, Frock_list, Trouser_list, Blouse_list, orderslist);
}
else {
system("cls");
return Customer_Window(newcustomerlist, Skirt_list, Frock_list, Trouser_list, Blouse_list, orderslist);
}
}
//3. Back to the Main Menu
else if (c1 == 3) {
return;
}
return;
}