-
Notifications
You must be signed in to change notification settings - Fork 3
/
SALARY(rohan).CPP
171 lines (167 loc) · 4.47 KB
/
SALARY(rohan).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
#include<fstream.h>
#include<conio.h>
#include<stdio.h>
class SALARY
{
char EmpName[20];
int EmpCode;
int Salary;
char Designation1[20];
public:
void GetData3();
void PutData3();
int getEcode2();
};
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);
}
SALARY S;
void main()
{
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 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(strmpi(Ward,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 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();
}