forked from RoHaNaLpHaCoDeR/C-programs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MCD.CPP
1010 lines (981 loc) · 24.4 KB
/
MCD.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<fstream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
class ATTENDANCE
{
char EName[20];
int ECode;
int WorkingDays;
int DaysPresent;
int DaysAbsent;
public:
void GetData5();
void PutData5();
int getECode3();
};
class BUDGET
{
int BudForEducation;
int BudForHealth;
int BudForTransport;
int BudForElectricity;
int BudForWater;
public:
void GetData2();
void PutData2();
int GetBudget();
int getAverageBud();
};
class EMPLOYEES
{
int EmployeeCode;
char EmployeeName[20];
char Designation[20];
char Division [20];
public:
void GetData1();
void PutData1();
int getEcode1();
};
class PROJECTS
{
char Sector[20];
int ProjectNo;
char ProjectName[20];
int Cost;
char HeadOfOperation[20];
int Deadline;
public:
void GetData4();
void PutData4();
int getProjectNo();
};
class SALARY
{
char EmpName[20];
int EmpCode;
int Salary;
char Designation1[20];
public:
void GetData3();
void PutData3();
int getEcode2();
};
class WARDLIST
{
char Division[20];
char Zone[20];
char Ward[20];
public:
void GetData6();
void PutData6();
char*getward();
};
void ATTENDANCE::GetData5()
{
cout<<"\n\tEnter the name of the Employee\n\t";
gets(EName);
cout<<"\n\tEnter the Employee Code\n\t";
cin>>ECode;
cout<<"\n\tEnter the total number of working days\n\t";
cin>>WorkingDays;
cout<<"\n\tEnter the number of days on which the employee was present\n\t";
cin>>DaysPresent;
cout<<"\n\tEnter the number of days on which the employee was absent\n\t";
cin>>DaysAbsent;
}
void ATTENDANCE::PutData5()
{
cout<<"\n\tThe name of the employee :\n\t"<<EName<<"\n\tEmployee code :\n\t"<<ECode<<"\n\tNumber of working days :\n\t"<<WorkingDays<<"\n\tPresent days :\n\t"<<DaysPresent<<"\n\tAbsent days :\n\t"<<DaysAbsent;
}
int ATTENDANCE::getECode3()
{
return(ECode);
}
void BUDGET:: GetData2()
{
cout<<"enter budget for education";
cin>>BudForEducation;
cout<<"enter budget for health";
cin>>BudForHealth;
cout<<"enter budget for transport";
cin>>BudForTransport;
cout<<"enter budget for electricity";
cin>>BudForElectricity;
cout<<"enter budget for water";
cin>>BudForWater;
}
void BUDGET:: PutData2()
{
cout<<BudForEducation<<"\t"<<BudForHealth<<"\t"<<BudForTransport<<"\t"<<BudForElectricity<<"\t"<<BudForWater<<"\t"<<endl;
}
int BUDGET:: getAverageBud()
{
int AverageBudget;
AverageBudget=(BudForEducation+BudForHealth+BudForTransport+BudForElectricity+BudForWater)/5;
cout<<"average budget="<<AverageBudget;
return(AverageBudget);
}
int BUDGET:: GetBudget()
{
cout<<"budget for education";
return(BudForEducation);
cout<<"budget for health";
return(BudForHealth);
cout<<"budget for transport";
return(BudForTransport);
cout<<"budget for electricity";
return(BudForElectricity);
cout<<"budget for water";
return(BudForWater);
}
void EMPLOYEES ::GetData1()
{
cout<<"enter Employee's Code";
cin>>EmployeeCode;
cout<<"enter Employee's Name";
gets(EmployeeName);
cout<<"Enter Employee's Designation";
gets(Designation);
cout<<"enter employee's Division";
gets(Division);
}
void EMPLOYEES:: PutData1()
{
cout<<EmployeeCode<<"\t"<<EmployeeName<<"\t"<<Designation<<"\t"<<Division<<endl;
}
int EMPLOYEES:: getEcode1()
{
return(EmployeeCode);
}
void PROJECTS::GetData4()
{
cout<<"\n\tEnter the type of work which is to be done\n\t";
gets(Sector);
cout<<"\n\tEnter the Project Number\n\t";
cin>>ProjectNo;
cout<<"\n\tEnter the name of the Project\n\t";
gets(ProjectName);
cout<<"\n\tEnter the average cost of the Project (in Crores)\n\t";
cin>>Cost;
cout<<"\n\tEnter the name of the person in charge of this project\n\t";
gets(HeadOfOperation);
cout<<"\n\tEnter the deadline for submitting the project\n\t";
cin>>Deadline;
}
void PROJECTS::PutData4()
{
cout<<"\n\tType of Work :\n\t"<<Sector<<"\n\tProject Number :\n\t"<<ProjectNo<<"\n\tName of the project :\n\t"<<ProjectName<<"\n\tCost of making :\n\t"<<Cost<<"\n\tPerson in Charge :\n\t"<<HeadOfOperation<<"\n\tDeadline :\n\t"<<Deadline;
}
int PROJECTS::getProjectNo()
{
return(ProjectNo);
}
void SALARY::GetData3()
{
cout<<"enter Employee Name";
gets(EmpName);
cout<<"enter Employee Code";
cin>>EmpCode;
cout<<"enter Employee Salary";
cin>>Salary;
cout<<"enter Employee's Destination";
gets(Designation1);
}
void SALARY::PutData3()
{
cout<<EmpName<<"\t"<<EmpCode<<"\t"<<Salary<<"\t"<<Designation1;
}
int SALARY:: getEcode2()
{
return(EmpCode);
}
void WARDLIST::GetData6()
{
cout<<"\n\tEnter the name of the Division of the MCD\n\t";
gets(Division);
cout<<"\n\tEnter the name of the Zone\n\t";
gets(Zone);
cout<<"\n\tEnter the name of the Ward\n\t";
gets(Ward);
}
void WARDLIST::PutData6()
{
cout<<"\n\tThe name of the division :\n\t"<<Division<<"\n\tName of the Zone :\n\t"<<Zone<<"\n\tName of the Ward :\n\t"<<Ward;
}
char* WARDLIST::getward()
{
return(Ward);
}
ATTENDANCE A;
BUDGET B;
EMPLOYEES E;
PROJECTS P;
SALARY S;
WARDLIST W;
void ATTENDANCE()
{
clrscr();
void Enter_File1();
void Display_File1();
void Search1();
void Modify1();
void Delete1();
int choice;
do
{
cout<<"\n\tMain Menu\n\t";
cout<<"\n\t1.Add a record\n\t";
cout<<"\n\t2.Display the record\n\t";
cout<<"\n\t3.Search a record\n\t";
cout<<"\n\t4.Modify a record\n\t";
cout<<"\n\t5.Delete a record\n\t";
cout<<"\n\t6.Want to exit?\n\t";
cout<<"Enter your choice";
cin>>choice;
switch(choice)
{
case 1: Enter_File1();
break;
case 2: Display_File1();
break;
case 3: Search1();
break;
case 4: Modify1();
break;
case 5: Delete1();
break;
}
}while(choice!=6);
getche();
}
void Enter_File1()
{
ofstream afile("pro1.dat",ios::binary|ios::app);
A.GetData5();
afile.write((char*)& A,sizeof(A));
afile.close();
cout<<"\n\t";
getche();
}
void Display_File1()
{
ifstream bfile("pro1.dat",ios::binary);
while(bfile.read((char*)& A,sizeof(A)))
{
A.PutData5();
}
bfile.close();
cout<<"\n\t";
getche();
}
void Search1()
{
int p=-1;
int z;
ifstream cfile("pro1.dat",ios::binary);
cout<<"\n\tPlease enter the Employee code which is to be searched\n\t";
cin>>z;
while(cfile.read((char*)& A,sizeof(A)))
{
if(A.getECode3()==z)
{
p++;
}
}
if(p==-1)
cout<<"\n\tSorry!Record not found\n\t";
cfile.close();
getche();
}
void Modify1()
{
int q=-1;
int a=0;
int t;
cout<<"\n\tPlease enter the Employee code which is to modified\n\t";
cin>>t;
fstream dfile("pro1.dat",ios::in|ios::out|ios::binary);
while(dfile.read((char*)& A,sizeof(A)))
{
a++;
if(A.getECode3()==t)
{
A.GetData5();
dfile.seekp((a-1)*sizeof(A),ios::beg);
dfile.write((char*)& A,sizeof(A));
q++;
}
}
if(q==-1)
cout<<"Sorry Record not found";
dfile.close();
getche();
}
void Delete1()
{
int b;
ifstream efile("pro1.dat",ios::binary);
ofstream ffile("temp1.dat",ios::binary);
cout<<"\n\tPlease enter the Employee code to be deleted\n\t";
cin>>b;
while(efile.read((char*)& A,sizeof(A)))
{
if(A.getECode3()!=b)
{
ffile.write((char*)& A,sizeof(A));
}
}
remove("pro1.dat");
rename("temp1.dat","pro1.dat");
efile.close();
ffile.close();
cout<<"\n\t";
getche();
}
void BUDGET()
{
clrscr();
void enterbudget();
void calculatebudget();
void displaybudget();
void searchbudget();
void modifybudget();
void deletebudget();
int c;
do
{
cout<<"\n main menu "<<endl;
cout<<"1. enter the value of all budgets"<<endl;
cout<<"2. calculate average budget "<<endl;
cout<<"3. display all budgets "<<endl;
cout<<"4. search a budget value "<<endl;
cout<<"5. modify a value of budget "<<endl;
cout<<"6. delete a budget value "<<endl;
cout<<"7.exit "<<endl;
cout<<"enter your choice"<<" ";
cin>>c;
switch(c)
{
case 1: enterbudget();
break;
case 2: calculatebudget();
break;
case 3: displaybudget();
break;
case 4: searchbudget();
break;
case 5: modifybudget();
break;
case 6: deletebudget();
break;
}
}while(c!=7);
getche();
}
void enterbudget()
{
ofstream afile("pro.dat",ios::binary|ios::app);
B.GetData2();
afile.write((char*)& B, sizeof(B));
afile.close();
cout<<endl;
getche();
}
void calculatebudget()
{
ifstream gfile("pro.dat",ios::binary);
while(gfile.read((char*)& B, sizeof(B)))
{
B.getAverageBud();
}
gfile.close();
}
void displaybudget()
{
ifstream bfile("pro.dat",ios::binary);
while(bfile.read((char*)& B, sizeof(B)))
{
B.PutData2();
}
bfile.close();
cout<<endl;
getche();
}
void searchbudget()
{
int p=-1,z;
ifstream cfile("pro.dat",ios::binary);
cout<<"please enter budget to be searched:\n";
cin>>z;
while(cfile.read((char*)& B,sizeof(B)))
{
if(B.GetBudget()==z)
{
cout<<"budget";
p++;
}
}
if(p==-1)
cout<<"sorry!record not found\n";
cout<<endl;
cfile.close();
getche();
}
void modifybudget()
{
int g=-1,a=0,t;
cout<<"please enter the budget to be modified:\n";
cin>>t;
fstream dfile("pro.dat",ios::in|ios::binary|ios::out );
while(dfile.read((char*)& B,sizeof(B)))
{
a++;
if(B.GetBudget()==t)
{
B.GetData2();
dfile.seekp((a-1)*sizeof(B),ios::beg);
dfile.write((char*)& B, sizeof(B));
g++;
}
}
if(g==-1)
cout<<"sorry record not found\n";
dfile.close();
getche();
}
void deletebudget()
{
int b;
ifstream efile("pro.dat",ios::binary);
ofstream ffile("Pro.dat",ios::binary);
cout<<"please enter the budget to be deleted\n";
cin>>b;
while(efile.read((char*)& B,sizeof(B)))
{
if(B.GetBudget()!=b)
{
ffile.write((char*)& B,sizeof(B));
}
}
remove("pro.dat");
rename("Pro.dat","pro.dat");
efile.close();
ffile.close();
cout<<endl;
getche();
}
void EMPLOYEES()
{
clrscr();
int c;
void enteremployee();
void displayemployee();
void searchemployee();
void modifyemployee();
void deleteemployee();
do
{
cout<<"\n main menu"<<endl;
cout<<"1.Enter Employee details"<<endl;
cout<<"2.Display Employee details"<<endl;
cout<<"3.Search Employee Details"<<endl;
cout<<"4.Modify Employee Details"<<endl;
cout<<"5.Delete Employee Details"<<endl;
cout<<"6.want to exit"<<endl;
cout<<"enter your choice";
cin>>c;
switch(c)
{
case 1: enteremployee();
break;
case 2: displayemployee();
break;
case 3: searchemployee();
break;
case 4: modifyemployee();
break;
case 5: deleteemployee();
break;
}
}while(c!=6);
getche();
}
void enteremployee()
{
ofstream afile("champ.dat",ios::binary|ios::app);
E.GetData1();
afile.write((char*)& E, sizeof(E));
afile.close();
cout<<endl;
getche();
}
void displayemployee()
{
ifstream bfile("champ.dat",ios::binary);
while(bfile.read((char*)& E, sizeof(E)))
{
E.PutData1();
}
bfile.close();
cout<<endl;
getche();
}
void searchemployee()
{
int p=-1,z;
ifstream cfile("champ.dat",ios::binary);
cout<<"please enter the employee code to be searched:\n";
cin>>z;
while(cfile.read((char*)& E,sizeof(E)))
{
if(E.getEcode1()==z)
{
E.PutData1();
p++;
}
}
if(p==-1)
cout<<"sorry!record not found\n";
cout<<endl;
cfile.close();
getche();
}
void modifyemployee()
{
int g=-1,a=0,t;
cout<<"please enter the employee code to be modified:\n";
cin>>t;
fstream dfile("champ.dat",ios::in|ios::binary|ios::out );
while(dfile.read((char*)& E, sizeof(E)))
{
a++;
if(E.getEcode1()==t)
{
E.GetData1();
dfile.seekp((a-1)*sizeof(E),ios::beg);
dfile.write((char*)& E, sizeof(E));
g++;
}
}
if(g==-1)
cout<<"sorry record not found\n";
dfile.close();
cout<<endl;
getche();
}
void deleteemployee()
{
int b;
ifstream efile("champ.dat",ios::binary);
ofstream ffile("bigchamp.dat",ios::binary);
cout<<"please enter the employee code to be deleted\n";
cin>>b;
while(efile.read((char*)& E, sizeof(E)))
{
if(E.getEcode1()!=b)
{
ffile.write((char*)& E,sizeof(E));
}
}
remove("champ.dat");
rename("bigchamp.dat","champ.dat");
efile.close();
ffile.close();
cout<<endl;
getche();
}
void PROJECTS()
{
clrscr();
void Enter_File();
void Display_File();
void Search();
void Modify();
void Delete();
int choice;
do
{
cout<<"\n\tMain Menu\n\t";
cout<<"\n\t1.Add a record\n\t";
cout<<"\n\t2.Display the record\n\t";
cout<<"\n\t3.Search a record\n\t";
cout<<"\n\t4.Modify a record\n\t";
cout<<"\n\t5.Delete a record\n\t";
cout<<"\n\t6.Want to exit?\n\t";
cout<<"Enter your choice";
cin>>choice;
switch(choice)
{
case 1: Enter_File();
break;
case 2: Display_File();
break;
case 3: Search();
break;
case 4: Modify();
break;
case 5: Delete();
break;
}
}while(choice!=6);
getche();
}
void Enter_File()
{
ofstream afile("pro.dat",ios::binary|ios::app);
P.GetData4();
afile.write((char*)& P,sizeof(P));
afile.close();
cout<<"\n\t";
getche();
}
void Display_File()
{
ifstream bfile("pro.dat",ios::binary);
while(bfile.read((char*)& P,sizeof(P)))
{
P.PutData4();
}
bfile.close();
cout<<"\n\t";
getche();
}
void Search()
{
int p=-1;
int z;
ifstream cfile("pro.dat",ios::binary);
cout<<"\n\tPlease enter the Project number which is to be searched\n\t";
cin>>z;
while(cfile.read((char*)& P,sizeof(P)))
{
if(P.getProjectNo()==z)
{
p++;
}
}
if(p==-1)
cout<<"\n\tSorry!Record not found\n\t";
cfile.close();
getche();
}
void Modify()
{
int q=-1;
int a=0;
int t;
cout<<"\n\tPlease enter the project number which is to modified\n\t";
cin>>t;
fstream dfile("pro.dat",ios::in|ios::out|ios::binary);
while(dfile.read((char*)& P,sizeof(P)))
{
a++;
if(P.getProjectNo()==t)
{
P.GetData4();
dfile.seekp((a-1)*sizeof(P),ios::beg);
dfile.write((char*)& P,sizeof(P));
q++;
}
}
if(q==-1)
cout<<"Sorry Record not found";
dfile.close();
getche();
}
void Delete()
{
int b;
ifstream efile("pro.dat",ios::binary);
ofstream ffile("temp.dat",ios::binary);
cout<<"\n\tPlease enter the Project number to be deleted\n\t";
cin>>b;
while(efile.read((char*)& P,sizeof(P)))
{
if(P.getProjectNo()!=b)
{
ffile.write((char*)& P,sizeof(P));
}
}
remove("pro.dat");
rename("temp.dat","pro.dat");
efile.close();
ffile.close();
cout<<"\n\t";
getche();
}
void SALARY()
{
clrscr();
int c;
void entersalary();
void displaysalary();
void searchsalary();
void deletesalary();
void modifysalary();
do
{
cout<<"\n main menu"<<endl;
cout<<"1.add Employee salary detail"<<endl;
cout<<"2.display Employee salary details"<<endl;
cout<<"3.search Employee salary details"<<endl;
cout<<"4.modify Employee salary details"<<endl;
cout<<"5.delete Employee salary details"<<endl;
cout<<"6.want ot exit"<<endl;
cout<<"enter your selection";
cin>>c;
switch(c)
{
case 1: entersalary();
break;
case 2: displaysalary();
break;
case 3: searchsalary();
break;
case 4: modifysalary();
break;
case 5: deletesalary();
break;
}
}while(c!=6);
getche();
}
void entersalary()
{
ofstream afile("devel.dat",ios::binary|ios::app );
S.GetData3();
afile.write((char*)& S, sizeof(S));
afile.close();
cout<<endl;
getche();
}
void displaysalary()
{
ifstream bfile("devel.dat",ios::binary);
while(bfile.read((char*)& S, sizeof(S)))
{
S.PutData3();
}
bfile.close();
cout<<endl;
getche();
}
void searchsalary()
{
int p=-1,z;
ifstream cfile("devel.dat",ios::binary);
cout<<"please enter the employee code to be searched:\n";
cin>>z;
while(cfile.read((char*)& S,sizeof(S)))
{
if(S.getEcode2()==z)
{
S.PutData3();
p++;
}
}
if(p==-1)
cout<<"sorry!record not found\n";
cout<<endl;
cfile.close();
getche();
}
void modifysalary()
{
int g=-1,a=0,t;
cout<<"please enter the employee code to be modified:\n";
cin>>t;
fstream dfile("devel.dat",ios::in|ios::binary|ios::out );
while(dfile.read((char*)& S,sizeof(S)))
{
a++;
if(S.getEcode2()==t)
{
S.GetData3();
dfile.seekp((a-1)*sizeof(S),ios::beg);
dfile.write((char*)& S, sizeof(S));
g++;
}
}
if(g==-1)
cout<<"sorry record not found\n";
dfile.close();
getche();
}
void deletesalary()
{
int b;
ifstream efile("devel.dat",ios::binary);
ofstream ffile("prototype.dat",ios::binary);
cout<<"please enter the employee code to be deleted\n";
cin>>b;
while(efile.read((char*)& S,sizeof(S)))
{
if(S.getEcode2()!=b)
{
ffile.write((char*)& S, sizeof(S));
}
}
remove("devel.dat");
rename("prototype.dat","devel.dat");
efile.close();
ffile.close();
cout<<endl;
getche();
}
void WARDLIST()
{
clrscr();
void Enter_File2();
void Display_File2();
void Search2();
void Modify2();
void Delete2();
int choice;
do
{
cout<<"\n\tMain Menu\n\t";
cout<<"\n\t1.Add a record\n\t";
cout<<"\n\t2.Display the record\n\t";
cout<<"\n\t3.Search a record\n\t";
cout<<"\n\t4.Modify a record\n\t";
cout<<"\n\t5.Delete a record\n\t";
cout<<"\n\t6.Want to exit?\n\t";
cout<<"Enter your choice";
cin>>choice;
switch(choice)
{
case 1: Enter_File2();
break;
case 2: Display_File2();
break;
case 3: Search2();
break;
case 4: Modify2();
break;
case 5: Delete2();
break;
}
}while(choice!=6);
getche();
}
void Enter_File2()
{
ofstream afile("pro2.dat",ios::binary|ios::app);
W.GetData6();
afile.write((char*)& W,sizeof(W));
afile.close();
cout<<"\n\t";
getche();
}
void Display_File2()
{
ifstream bfile("pro2.dat",ios::binary);
while(bfile.read((char*)& W,sizeof(W)))
{
W.PutData6();
}
bfile.close();
cout<<"\n\t";
getche();
}
void Search2()
{
int p=-1;
char z[20];
ifstream cfile("pro2.dat",ios::binary);
cout<<"\n\tPlease enter the Ward name which is to be searched\n\t";
gets(z);
while(cfile.read((char*)& W,sizeof(W)))
{
if(strcmpi(W.getward(),z)==0)
{
p++;
W.PutData6();
}
}
if(p==-1)
cout<<"\n\tSorry!Record not found\n\t";
cfile.close();
getche();
}
void Modify2()
{
int q=-1;
int a=0;
char t[20];
cout<<"\n\tPlease enter the Ward name which is to modified\n\t";
gets(t);
fstream dfile("pro2.dat",ios::in|ios::out|ios::binary);
while(dfile.read((char*)& W,sizeof(W)))
{
a++;
if(strcmpi(W.getward(),t)==0)
{
W.GetData6();
dfile.seekp((a-1)*sizeof(W),ios::beg);
dfile.write((char*)& W,sizeof(W));
q++;
}
}
if(q==-1)
cout<<"Sorry Record not found";
dfile.close();
getche();
}
void Delete2()
{
char b[20];
ifstream efile("pro2.dat",ios::binary);
ofstream ffile("temp2.dat",ios::binary);
cout<<"\n\tPlease enter the Ward name to be deleted\n\t";
gets(b);
while(efile.read((char*)& W,sizeof(W)))
{
if(strcmpi(W.getward(),b)!=0)
{
ffile.write((char*)& W,sizeof(W));
}
}
remove("pro2.dat");
rename("temp2.dat","pro2.dat");
efile.close();
ffile.close();
cout<<"\n\t";
getche();
}
void main()
{
int c;
clrscr();
do
{
cout<<"Main Menu "<<endl;
cout<<"1.Attendance of the employees"<<endl;
cout<<"2.Budget for various works"<<endl;
cout<<"3.Enter the employee details"<<endl;
cout<<"4.Projects to complete"<<endl;
cout<<"5.Provide the salaries to the employees"<<endl;
cout<<"6.Enter the list of respective wards"<<endl;
cout<<"enter your choice"<<" ";
cin>>c;
switch(c)
{
case 1: ATTENDANCE();
break;
case 2: BUDGET();
break;
case 3: EMPLOYEES();
break;