-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBMS.cpp
1736 lines (1611 loc) · 49.5 KB
/
BMS.cpp
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
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <iostream>
#include <fstream>
#include <windows.h>
#include <conio.h>
#include <iomanip>
#include <ctime>
#include <string>
using namespace std;
// prototypes
void printHeader();
int login();
void adminMenu();
void printAMenu();
void employeeMenu();
void printEMenu();
void addDonor(); // Donor Functions
void deleteDonor();
void updateDonor();
void searchDonor();
void viewDonor();
void addRecipient(); // Recipient Functions
void deleteRecipient();
void updateRecipient();
void searchRecipient();
void viewRecipient();
void addEmployee(); // Employee Functions
void deleteEmployee();
void updateEmployee();
void searchEmployee();
void viewEmployee();
void searchDonorbyAdmin(); // Functions for admin
void viewDonorbyAdmin();
void searchRecipientbyAdmin();
void viewRecipientbyAdmin();
void menuName(string menu, string subMenu); // print submenu
string setcolor(unsigned short color); // color set
string isAlpha(string input); // functions for input
string isNum(string input); // functions for input
string isBG(string input); // functions for input
string contactCheck(string contact); // functions for input
string cnicCheck(string cnic); // functions for input
string usercheck(string username); // functions for input
int choiceCheck(int choice); // functions for input
void DonorToFile(string name, string age, string bloodgroup, string city, string contact, string contributer); // store data to file
void RecipientToFile(string name, string age, string bloodgroup, string city, string contact, string contributer); // store data to file
void EmployeeToFile(string name, string age, string cnic, string contact, string username, string password); // store data to file
void LoadDonor(); // load file to arrays
void LoadRecipient(); // load file to arrays
void LoadEmployee(); // load file to arrays
void updateDonorFile(); // update file
void updateEmployeeFile(); // update file
void updateRecipientFile(); // update file
string Dataparse(string line, int field);
void gotoxy(int x, int y);
// employee data
string nameE[100];
string ageE[100];
string usernameE[100];
string passwordE[100];
string cnicE[100];
string contactE[100];
string contributer;
int indexE = 0; // index for employees arrays
// donor data
string nameD[100];
string ageD[100];
string bloodgroupD[100];
string cityD[100];
string statusD[100];
string contactD[100];
string contributerD[100];
int indexD = 0; // index for donors arrays
// recipient data
string nameR[100];
string ageR[100];
string bloodgroupR[100];
string cityR[100];
string contactR[100];
string contributerR[100];
int indexR = 0; // index for recipients arrays
main()
{
LoadDonor(); // load files
LoadRecipient();
LoadEmployee();
while (true)
{
system("cls");
printHeader();
int user = login();
if (user == 1)
{
system("cls"); // calling admin interference
printHeader();
adminMenu();
}
else if (user == 2)
{
system("cls"); // calling employee interference
printHeader();
employeeMenu();
}
else if (user == 3)
{
cout << endl; // if wrong credentials
cout << "Wrong Credentials!! Try again!!";
Sleep(300);
}
}
}
void printHeader()
{
time_t now = time(0); // date display
char *date_time = ctime(&now);
gotoxy(78, 1);
cout << date_time << endl;
cout << endl;
setcolor(12); // header display
cout << " ____ _ _ _____ _ _ " << endl;
cout << " | _ \\| | | | | __ \\ | | (_) " << endl;
cout << " | |_) | | ___ ___ __| | | | | | ___ _ __ __ _| |_ _ ___ _ __ " << endl;
cout << " | _ <| |/ _ \\ / _ \\ / _` | | | | |/ _ \\| '_ \\ / _` | __| |/ _ \\| '_ \\ " << endl;
cout << " | |_) | | (_) | (_) | (_| | | |__| | (_) | | | | (_| | |_| | (_) | | | | " << endl;
cout << " |____/|_|\\___/ \\___/ \\__,_| |_____/ \\___/|_| |_|\\__,_|\\__|_|\\___/|_| |_| " << endl;
setcolor(11);
cout << " __ __ _ _____ _ " << endl;
cout << " | \\/ | | | / ____| | | " << endl;
cout << " | \\ / | __ _ _ __ __ _ __ _ ___ _ __ ___ ___ _ __ | |_ | (___ _ _ ___| |_ ___ _ __ ___ " << endl;
cout << " | |\\/| |/ _` | '_ \\ / _` |/ _` |/ _ \\ '_ ` _ \\ / _ \\ '_ \\| __| \\___ \\| | | / __| __/ _ \\ '_ ` _ \\ " << endl;
cout << " | | | | (_| | | | | (_| | (_| | __/ | | | | | __/ | | | |_ ____) | |_| \\__ \\ || __/ | | | | | " << endl;
cout << " |_| |_|\\__,_|_| |_|\\__,_|\\__, |\\___|_| |_| |_|\\___|_| |_|\\__| |_____/ \\__, |___/\\__\\___|_| |_| |_| " << endl;
cout << " __/ | __/ | " << endl;
cout << " |___/ |___/ " << endl;
setcolor(15);
}
int login()
{
string username, password;
int choice;
cout << endl;
cout << endl;
cout << endl;
cout << "Welcome to Blood Donation Management System";
cout << endl;
cout << endl;
cout << endl;
cout << "Enter Username: "; // inputs
cin >> username;
cout << "Enter Password: ";
cin >> password;
if (username == "admin" && password == "admin")
{
choice = 1; // for admin
}
else
{
for (int i = 0; i < 100; i++)
{
if (username == usernameE[i] && password == passwordE[i])
{
contributer = username;
choice = 2; // for employee
break;
}
else
{
choice = 3;
}
}
}
return choice;
}
void adminMenu()
{
int choice = 0;
while (choice != 10)
{
system("cls");
printHeader();
cout << endl;
cout << endl;
string menu = "Login"; // submenu variables
string subMenu = "Admin Menu";
menuName(menu, subMenu);
printAMenu(); // menu
choice = choiceCheck(choice); // admin options
if (choice == 1)
{
system("cls");
printHeader();
addEmployee();
}
if (choice == 2)
{
system("cls");
printHeader();
deleteEmployee();
}
if (choice == 3)
{
system("cls");
printHeader();
updateEmployee();
}
if (choice == 4)
{
system("cls");
printHeader();
searchEmployee();
}
if (choice == 5)
{
system("cls");
printHeader();
viewEmployee();
}
if (choice == 6)
{
system("cls");
printHeader();
searchDonorbyAdmin();
}
if (choice == 7)
{
system("cls");
printHeader();
viewDonorbyAdmin();
}
if (choice == 8)
{
system("cls");
printHeader();
searchRecipientbyAdmin();
}
if (choice == 9)
{
system("cls");
printHeader();
viewRecipientbyAdmin();
}
}
}
void printAMenu()
{
cout << endl;
cout << "1. Add New Employee..." << endl;
cout << "2. Delete Employee... " << endl;
cout << "3. Update Employee Details... " << endl;
cout << "4. Search For Employee... " << endl;
cout << "5. View all Employees... " << endl;
cout << endl;
cout << "6. Search For Donor... " << endl;
cout << "7. View all Donors... " << endl;
cout << endl;
cout << "8. Search For Recipient... " << endl;
cout << "9. View all Recipient... " << endl;
cout << endl;
cout << "10. Log out... " << endl;
cout << endl;
cout << "Enter Your Option: ";
}
void employeeMenu()
{
int choice = 0;
while (choice != 11)
{
system("cls");
printHeader();
cout << endl;
cout << endl;
string menu = "Login"; // submenu variables
string subMenu = "Employee Menu";
menuName(menu, subMenu);
printEMenu();
choice = choiceCheck(choice); // employee options
if (choice == 1)
{
system("cls");
printHeader();
addDonor();
}
if (choice == 2)
{
system("cls");
printHeader();
deleteDonor();
}
if (choice == 3)
{
system("cls");
printHeader();
updateDonor();
}
if (choice == 4)
{
system("cls");
printHeader();
searchDonor();
}
if (choice == 5)
{
system("cls");
printHeader();
viewDonor();
}
if (choice == 6)
{
system("cls");
printHeader();
addRecipient();
}
if (choice == 7)
{
system("cls");
printHeader();
deleteRecipient();
}
if (choice == 8)
{
system("cls");
printHeader();
updateRecipient();
}
if (choice == 9)
{
system("cls");
printHeader();
searchRecipient();
}
if (choice == 10)
{
system("cls");
printHeader();
viewRecipient();
}
}
}
void printEMenu()
{
cout << endl;
cout << "1. Add New Donor..." << endl;
cout << "2. Delete Donor... " << endl;
cout << "3. Update Donor Details... " << endl;
cout << "4. Search For Donor... " << endl;
cout << "5. View Details of all Donors... " << endl;
cout << endl;
cout << "6. Add New Recipient..." << endl;
cout << "7. Delete Recipient... " << endl;
cout << "8. Update Recipient Details... " << endl;
cout << "9. Search For Recipient... " << endl;
cout << "10. View Details of all Recipients... " << endl;
cout << endl;
cout << "11. Log out... " << endl;
cout << endl;
cout << "Enter Your Option: ";
}
void addDonor()
{
cout << endl;
string menu = "Employee Menu"; // submenu variables
string subMenu = "Add Donor ";
menuName(menu, subMenu);
cout << endl;
cout << endl;
cout << "Enter Details of the New Donor:-" << endl; // details
cout << endl;
cout << "Enter Name: ";
nameD[indexD] = isAlpha(nameD[indexD]);
cout << "Enter Age(+18): ";
ageD[indexD] = isNum(ageD[indexD]);
cout << "Enter Bloodgroup: ";
bloodgroupD[indexD] = isBG(bloodgroupD[indexD]);
cout << "Enter City: ";
cityD[indexD] = isAlpha(cityD[indexD]);
cout << "Enter Contact No.(11 numbers): ";
contactD[indexD] = contactCheck(contactD[indexD]);
contributerD[indexD] = contributer;
DonorToFile(nameD[indexD], ageD[indexD], bloodgroupD[indexD], cityD[indexD], contactD[indexD], contributerD[indexD]); // to file
indexD++;
cout << endl;
cout << "Donor Added Sucessfully...";
Sleep(300);
cout << endl;
cout << "Press any key for back...";
getch();
}
void deleteDonor()
{
int index;
string deleteName;
cout << endl;
string menu = "Employee Menu"; // submenu variables
string subMenu = "Delete Donor ";
menuName(menu, subMenu);
cout << endl;
cout << endl;
cout << "Enter Name of the Donor: "; // donor name
cin.clear();
cin.sync();
getline(cin >> ws, deleteName);
cout << endl;
bool notFound = true;
for (int idx = 0; idx < 100; idx++)
{
if ((deleteName == nameD[idx]) && (contributer == contributerD[idx]))
{
index = idx;
cout << left << setw(20) << "Name" << left << setw(20) << "Age" << left << setw(20) << "Bloodgroup" << left << setw(20) << "City" << left << setw(20) << "Contact No." << endl;
cout << endl;
cout << left << setw(20) << nameD[index] << left << setw(20) << ageD[index] << left << setw(20) << bloodgroupD[index] << left << setw(20) << cityD[index] << left << setw(20) << contactD[index] << endl;
for (int j = idx; j <= 100 - 1; j++) // moving arrays one index back
{
nameD[j] = nameD[j + 1];
ageD[j] = ageD[j + 1];
bloodgroupD[j] = bloodgroupD[j + 1];
cityD[j] = cityD[j + 1];
contactD[j] = contactD[j + 1];
contributerD[j] = contributerD[j + 1];
}
indexD--;
updateDonorFile();
cout << endl;
cout << "Donor Removed..." << endl;
notFound = true;
break;
}
else
{
notFound = false;
}
}
if (notFound == false)
{
setcolor(12);
cout << endl;
cout << "Donor Not Found" << endl;
cout << endl;
setcolor(15);
cout << "Press any key for back...";
getch();
}
else
{
cout << endl;
cout << "Press any key for back...";
getch();
}
}
void updateDonor()
{
int index;
string updateName;
cout << endl;
string menu = "Employee Menu"; // submenu variables
string subMenu = "Update Donor ";
menuName(menu, subMenu);
cout << endl;
cout << endl;
cout << "Enter Name of the Donor: "; // donor name
cin.clear();
cin.sync();
getline(cin >> ws, updateName);
cout << endl;
bool notFound = true;
for (int idx = 0; idx < 100; idx++)
{
if (updateName == nameD[idx] && (contributer == contributerD[idx]))
{
index = idx;
cout << left << setw(20) << "Name" << left << setw(20) << "Age" << left << setw(20) << "Bloodgroup" << left << setw(20) << "City" << left << setw(20) << "Contact No." << endl;
cout << endl;
cout << left << setw(20) << nameD[index] << left << setw(20) << ageD[index] << left << setw(20) << bloodgroupD[index] << left << setw(20) << cityD[index] << left << setw(20) << contactD[index] << endl;
cout << endl; // update details
cout << "Enter Name: ";
nameD[index] = isAlpha(nameD[index]);
cout << "Enter Age(+18): ";
ageD[index] = isNum(ageD[index]);
cout << "Enter Bloodgroup: ";
bloodgroupD[index] = isBG(bloodgroupD[index]);
cout << "Enter City: ";
cityD[index] = isAlpha(cityD[index]);
cout << "Enter Contact No. (11 numbers): ";
contactD[index] = contactCheck(contactD[index]);
contributerD[index] = contributer;
updateDonorFile();
cout << endl;
cout << "Donor Updated..." << endl;
notFound = true;
break;
}
else
{
notFound = false;
}
}
if (notFound == false)
{
setcolor(12);
cout << "Donor Not Found" << endl;
cout << endl;
setcolor(15);
cout << "Press any key for back...";
getch();
}
else
{
cout << endl;
cout << "Press any key for back...";
getch();
}
}
void searchDonor()
{
int index;
string searchBG;
string check;
cout << endl;
string menu = "Employee Menu"; // submenu variables
string subMenu = "Search Donor ";
menuName(menu, subMenu);
cout << endl;
cout << endl;
cout << "Enter Bloodgroup of the Donor: "; // blood group
cin >> searchBG;
bool notFound = true;
bool one = false;
cout << endl;
cout << left << setw(20) << "Name" << left << setw(20) << "Age" << left << setw(20) << "Bloodgroup" << left << setw(20) << "City" << left << setw(20) << "Contact No." << endl;
cout << endl;
for (int idx = 0; idx < 100; idx++)
{
if (searchBG == bloodgroupD[idx] && (contributer == contributerD[idx])) // display donor
{
index = idx;
cout << left << setw(20) << nameD[index] << left << setw(20) << ageD[index] << left << setw(20) << bloodgroupD[index] << left << setw(20) << cityD[index] << left << setw(20) << contactD[index] << endl;
notFound = true;
one = true;
}
else if (one == false)
{
notFound = false;
}
}
if (notFound == false)
{
setcolor(12);
cout << "Donor Not Found" << endl;
cout << endl;
setcolor(15);
cout << "Press any key for back...";
getch();
}
else
{
cout << endl;
cout << "Press any key for back...";
getch();
}
}
void viewDonor()
{
bool flag = false;
cout << endl;
string menu = "Employee Menu"; // submenu variables
string subMenu = "View All Donors ";
menuName(menu, subMenu);
cout << endl;
cout << endl;
cout << "Following Are the Donors: " << endl;
cout << endl;
cout << left << setw(20) << "Name" << left << setw(20) << "Age" << left << setw(20) << "Bloodgroup" << left << setw(20) << "City" << left << setw(20) << "Contact No." << endl;
cout << endl;
for (int index = 0; index < 100; index++)
{
if ((nameD[index] != "") && (contributer == contributerD[index])) // display
{
cout << left << setw(20) << nameD[index] << left << setw(20) << ageD[index] << left << setw(20) << bloodgroupD[index] << left << setw(20) << cityD[index] << left << setw(20) << contactD[index] << endl;
flag = true;
}
}
if (flag == false)
{
setcolor(12);
cout << "Donors not Found" << endl;
cout << "Add Donors to View Donors" << endl;
cout << endl;
setcolor(15);
}
cout << endl;
cout << "Press any key for back...";
getch();
}
void addRecipient()
{
cout << endl;
string menu = "Employee Menu"; // submenu variables
string subMenu = "Add Recipient ";
menuName(menu, subMenu);
cout << endl;
cout << endl;
cout << "Enter Details of the New Recipient:-" << endl; // details
cout << endl;
cout << "Enter Name: ";
nameR[indexR] = isAlpha(nameR[indexR]);
cout << "Enter Age(+18): ";
ageR[indexR] = isNum(ageR[indexR]);
cout << "Enter Bloodgroup: ";
bloodgroupR[indexR] = isBG(bloodgroupR[indexR]);
cout << "Enter City: ";
cityR[indexR] = isAlpha(cityR[indexR]);
cout << "Enter Contact No.(11 numbers): ";
contactR[indexR] = contactCheck(contactR[indexR]);
contributerR[indexR] = contributer;
RecipientToFile(nameR[indexR], ageR[indexR], bloodgroupR[indexR], cityR[indexR], contactR[indexR], contributerR[indexR]);
indexR++;
cout << endl;
cout << "Recipient Added Sucessfully...";
Sleep(300);
cout << endl;
cout << "Press any key for back...";
getch();
}
void deleteRecipient()
{
int index;
string deleteName;
cout << endl;
string menu = "Employee Menu"; // submenu variables
string subMenu = "Delete Recipient ";
menuName(menu, subMenu);
cout << endl;
cout << endl;
cout << "Enter Name of the Recipient: ";
cin.clear();
cin.sync();
getline(cin >> ws, deleteName);
cout << endl;
bool notFound = true;
for (int idx = 0; idx < 100; idx++)
{
if (deleteName == nameR[idx] && (contributer == contributerR[idx]))
{
index = idx;
cout << left << setw(20) << "Name" << left << setw(20) << "Age" << left << setw(20) << "Bloodgroup" << left << setw(20) << "City" << left << setw(20) << "Contact No." << endl;
cout << endl;
cout << left << setw(20) << nameR[index] << left << setw(20) << ageR[index] << left << setw(20) << bloodgroupR[index] << left << setw(20) << cityR[index] << left << setw(20) << contactR[index] << endl;
for (int j = idx; j <= 100 - 1; j++) // moving arrays one index back
{
nameR[j] = nameR[j + 1];
ageR[j] = ageR[j + 1];
bloodgroupR[j] = bloodgroupR[j + 1];
cityR[j] = cityR[j + 1];
contactR[j] = contactR[j + 1];
contributerR[j] = contributerR[j + 1];
}
indexR--;
updateRecipientFile();
cout << endl;
cout << "Recipient Removed..." << endl;
notFound = true;
break;
}
else
{
notFound = false;
}
}
if (notFound == false)
{
setcolor(12);
cout << endl;
cout << "Recipient Not Found" << endl;
setcolor(15);
cout << endl;
cout << "Press any key for back...";
getch();
}
else
{
cout << endl;
cout << "Press any key for back...";
getch();
}
}
void updateRecipient()
{
int index;
string updateName;
cout << endl;
string menu = "Employee Menu"; // submenu variables
string subMenu = "Update Recipient ";
menuName(menu, subMenu);
cout << endl;
cout << endl;
cout << "Enter Name of the Recipient: "; // recipient name
cin.clear();
cin.sync();
getline(cin >> ws, updateName);
cout << endl;
bool notFound = true;
for (int idx = 0; idx < 100; idx++)
{
if (updateName == nameR[idx] && (contributer == contributerR[idx]))
{
index = idx;
cout << left << setw(20) << "Name" << left << setw(20) << "Age" << left << setw(20) << "Bloodgroup" << left << setw(20) << "City" << left << setw(20) << "Contact No." << endl;
cout << endl;
cout << left << setw(20) << nameR[index] << left << setw(20) << ageR[index] << left << setw(20) << bloodgroupR[index] << left << setw(20) << cityR[index] << left << setw(20) << contactR[index] << endl;
cout << endl;
cout << "Enter Name: ";
nameR[index] = isAlpha(nameR[index]);
cout << "Enter Age(+18): ";
ageR[index] = isNum(ageR[index]);
cout << "Enter Bloodgroup: ";
bloodgroupR[index] = isBG(bloodgroupR[index]);
cout << "Enter City: ";
cityR[index] = isAlpha(cityR[index]);
cout << "Enter Contact No.(11 numbers): ";
contactR[index] = contactCheck(contactR[index]);
contributerR[index] = contributer;
updateRecipientFile();
cout << endl;
cout << "Recipient Updated..." << endl;
notFound = true;
break;
}
else
{
notFound = false;
}
}
if (notFound == false)
{
setcolor(12);
cout << "Recipient Not Found" << endl;
cout << endl;
setcolor(15);
cout << "Press any key for back...";
getch();
}
else
{
cout << endl;
cout << "Press any key for back...";
getch();
}
}
void searchRecipient()
{
int index;
string searchBG;
cout << endl;
string menu = "Employee Menu"; // submenu variables
string subMenu = "Search Recipient ";
menuName(menu, subMenu);
cout << endl;
cout << endl;
cout << "Enter Bloodgroup of the Recipient: "; // bloodgroup name
cin >> searchBG;
bool notFound = true;
bool one = false;
cout << endl;
cout << left << setw(20) << "Name" << left << setw(20) << "Age" << left << setw(20) << "Bloodgroup" << left << setw(20) << "City" << left << setw(20) << "Contact No." << endl;
cout << endl;
for (int idx = 0; idx < 100; idx++)
{
if (searchBG == bloodgroupR[idx] && (contributer == contributerR[idx])) // display details
{
index = idx;
cout << left << setw(20) << nameR[index] << left << setw(20) << ageR[index] << left << setw(20) << bloodgroupR[index] << left << setw(20) << cityR[index] << left << setw(20) << contactR[index] << endl;
notFound = true;
one = true;
}
else if (one == false)
{
notFound = false;
}
}
if (notFound == false)
{
setcolor(12);
cout << "Recipient Not Found" << endl;
cout << endl;
setcolor(15);
cout << "Press any key for back...";
getch();
}
else
{
cout << endl;
cout << "Press any key for back...";
getch();
}
}
void viewRecipient()
{
bool flag = false;
cout << endl;
string menu = "Employee Menu"; // submenu variables
string subMenu = "View All Recipients ";
menuName(menu, subMenu);
cout << endl;
cout << endl;
cout << "Following Are the Recipients: " << endl;
cout << endl;
cout << left << setw(20) << "Name" << left << setw(20) << "Age" << left << setw(20) << "Bloodgroup" << left << setw(20) << "City" << left << setw(20) << "Contact No." << endl;
cout << endl;
for (int index = 0; index < 100; index++)
{
if ((nameR[index] != "") && (contributer == contributerR[index])) // display all
{
cout << left << setw(20) << nameR[index] << left << setw(20) << ageR[index] << left << setw(20) << bloodgroupR[index] << left << setw(20) << cityR[index] << left << setw(20) << contactR[index] << endl;
flag = true;
}
}
if (flag == false)
{
setcolor(12);
cout << "Recipients not Found" << endl;
cout << "Add Recipients to View Recpients" << endl;
setcolor(15);
cout << endl;
}
cout << endl;
cout << "Press any key for back...";
getch();
}
void addEmployee()
{
cout << endl;
string menu = "Admin Menu"; // submenu variables
string subMenu = "Add Employee";
menuName(menu, subMenu);
cout << endl;
cout << endl;
cout << "Enter Details of the New Employee:-" << endl; // details
cout << endl;
cout << "Enter Name: ";
nameE[indexE] = isAlpha(nameE[indexE]);
cout << "Enter Age(+18): ";
ageE[indexE] = isNum(ageE[indexE]);
cout << "Enter CNIC(13 numbers): ";
cnicE[indexE] = cnicCheck(cnicE[indexE]);
cout << "Enter Contact No(11 numbers): ";
contactE[indexE] = contactCheck(contactE[indexE]);
cout << "Enter Username: ";
usernameE[indexE] = usercheck(usernameE[indexE]);
cout << "Enter Password: ";
cin >> passwordE[indexE];
EmployeeToFile(nameE[indexE], ageE[indexE], cnicE[indexE], contactE[indexE], usernameE[indexE], passwordE[indexE]); // to file
indexE++;
cout << endl;
cout << "Employee Added Sucessfully...";
Sleep(300);
cout << endl;
cout << "Press any key for back...";
getch();
}
void deleteEmployee()
{
int index;
string deleteName;
cout << endl;
string menu = "Admin Menu"; // submenu variables
string subMenu = "Delete Employee";
menuName(menu, subMenu);
cout << endl;
cout << endl;
cout << "Enter Username of the Employee: "; // empolyee name
cin.clear();
cin.sync();
getline(cin >> ws, deleteName);
cout << endl;
bool notFound = true;
for (int idx = 0; idx < 100; idx++)
{
if (deleteName == usernameE[idx])
{
index = idx;
cout << left << setw(20) << "Name" << left << setw(20) << "Age" << left << setw(20) << "CNIC" << left << setw(20) << "Contact No." << left << setw(20) << "Username" << left << setw(20) << "Password" << endl;
cout << endl;
cout << left << setw(20) << nameE[index] << left << setw(20) << ageE[index] << left << setw(20) << cnicE[index] << left << setw(20) << contactE[index] << left << setw(20) << usernameE[index] << left << setw(20) << passwordE[index] << endl;
for (int j = idx; j <= 100 - 1; j++) // moving arrays one index back
{
nameE[j] = nameE[j + 1];
ageE[j] = ageE[j + 1];
cnicE[j] = cnicE[j + 1];
contactE[j] = contactE[j + 1];
usernameE[j] = usernameE[j + 1];
passwordE[j] = passwordE[j + 1];
}
indexR--;
updateEmployeeFile();
cout << endl;
cout << "Employee Removed..." << endl;
notFound = true;
break;
}
else
{
notFound = false;
}
}
if (notFound == false)
{
setcolor(12);
cout << endl;
cout << "Employee Not Found" << endl;
cout << endl;
setcolor(15);
cout << "Press any key for back...";
getch();
}
else
{
cout << endl;
cout << "Press any key for back...";
getch();
}
}
void updateEmployee()
{
int index;
string updateName;
cout << endl;
string menu = "Admin Menu"; // submenu variables
string subMenu = "Update Employee";
menuName(menu, subMenu);
cout << endl;
cout << endl;
cout << "Enter username of the Employee: ";
cin.clear();
cin.sync();
getline(cin >> ws, updateName);