forked from HACK-IT-ROHAN/Hactoberfest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ATTENDANCE(tushar).CPP
168 lines (154 loc) · 3.09 KB
/
ATTENDANCE(tushar).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
#include<fstream.h>
#include<conio.h>
#include<stdio.h>
class ATTENDANCE
{
char EName[20];
int ECode;
int WorkingDays;
int DaysPresent;
int DaysAbsent;
public:
void GetData5();
void PutData5();
int getECode3();
};
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);
}
ATTENDANCE A;
void main()
{
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()
{
{
a++;
if(A.getECode3()==t)
{
A.GetData5();
dfile.seekp((a-1)*sizeof(A),ios::beg);
dfile.write((char*)& A,sizeof(A));
q++;
}
}
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));
}
}
void Display_File2()
{
ifstream bfile("pro2.dat",ios::binary);
while(bfile.read((char*)& W,sizeof(W)))
{
W.PutData6();
}
bfile.close();
cout<<"\n\t";
getche();
}
efile.close();
ffile.close();
cout<<"\n\t";
getche();
}