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
|
void admin()
{
string name,position,status;
long long int ic;
float basicPay,allowance;
bool ans=false;
ifstream info;
info.open("usernpass.txt");
string answer,nama,line;
cout<<"Which worker do you want to update?"<<endl;
cin.ignore();
getline(cin,answer);
ofstream temp;
temp.open("temp.txt");
while(getline(info,line))
{
if (line!=answer)
{
temp<<line<<endl;
}
else
{
info.close();
temp.close();
remove("usernpass.txt");
rename("temp.txt","usernpass.txt");
cout<<"This worker exists!"<<endl;
cout<<"----------New Worker Info-----------"<<endl<<endl;
cout<<"Name: ";
getline(cin,name);
cout<<"Position: ";
getline(cin,position);
cout<<"NRIC: ";
cin>>ic;
cout<<"Basic Salary: RM";
cin>>basicPay;
cout<<"Status: ";
cin.ignore();
getline(cin,status);
cout<<"Allowance: ";
cin>>allowance;
ofstream info2;
info2.open("usernpass.txt",ios::app|ios::out);
info2<<position+";";
info2<<ic;
info2<<";";
info2<<setiosflags(ios::fixed|ios::showpoint)<<setprecision(2);
info2<<basicPay;
info2<<";"+status+";";
info2<<allowance;
info2<<";";
info2<<endl;
info2.close();
cout<<"Database update complete!!"<<endl;
}
}
}
void workersInfo(string userAndPass)
{
string nama1,nama2,position,status1,status2,emel,fon,money,ic,all;
int ch;
float salary,alowance;
string line;
ifstream user;
user.open("usernpass.txt");
while(getline(user,line))
{
if (line==userAndPass)
{
getline(user,nama1,'\n');
getline(user,emel,';');
getline(user,fon,'\n');
getline(user,position,';');
getline(user,ic,';');
getline(user,money,';');
salary=atoi(money.c_str());
getline(user,status1,';');
getline(user,all,';');
alowance=atoi(all.c_str());
}
}
user.close();
ui.name=nama1;
ui.posi=position;
ui.IC=ic;
ui.stat=status1;
ft.allowance=alowance;
ft.basicPay=salary;
ui.phone=fon;
ui.email=emel;
cout<<endl<<"Name : "<<ui.name<<endl;
cout<<"NRIC : "<<ui.IC<<endl;
cout<<"E-Mail : "<<ui.email<<endl;
cout<<"Contact Number : "<<ui.phone<<endl;
cout<<endl<<"Position : "<<ui.posi<<endl;
cout<<"Work Status : "<<ui.stat<<endl;
shift(ft,ui.stat);
}
float shift(fullTime ft,string stat)
{
int code;
if (stat=="Full Time")
{
ft.rate=socso(ft.basicPay);
displayPartPayment(ft,ui);
}
else if (stat=="Part Time")
calcShift();
}
void calcShift()
{
int hoursStart,hoursEnd,count=1;
pt.OTcalc=0.0;
pt.pay=0.0;
pt.totalHours=0;
pt.OT=0;
pt.hoursWorked=0;
cout<<endl<<"Enter number of days worked in the month : ";
cin>>pt.numDays;
while (count<=pt.numDays)
{
cout<<"Day "<<count<<endl;
cout<<"Enter time you started your shift : ";
cin>>hoursStart;
cout<<"Enter time you ended your shift : ";
cin>>hoursEnd;
pt.totalHours=(hoursEnd-hoursStart);
pt.hoursWorked+=pt.totalHours;
if (pt.totalHours<8)
{
pt.pay+=pt.totalHours*8.00;
}
else if (pt.totalHours>8)
{
pt.OT+=(pt.totalHours-8);
pt.ot=(pt.totalHours-8);
pt.OTcalc+=(pt.ot*8.00*1.5);
pt.pay+=(8*8.00);
}
pt.salary=pt.pay+pt.OTcalc;
count++;
}
partTimeDisplay(pt,ui);
}
void partTimeDisplay(partTime pt,userInfo ui)
{
ofstream partt;
partt.open ("salaryPartTime.dat");
partt<<endl;
partt<<" T E C H N O C U R E S D N B H D "<<endl;
partt<<"-----------------------salary slip-----------------------"<<endl;
partt<<"Name : "<<ui.name<<endl;
partt<<"NRIC : "<<ui.IC<<endl;
partt<<"E-Mail : "<<ui.email<<endl;
partt<<"Contact Number : "<<ui.phone<<endl;
partt<<endl<<"Position : "<<ui.posi<<endl;
partt<<"Work Status : "<<ui.stat<<endl;
partt<<endl<<"---------------------------------------------------"<<endl;
partt<<setiosflags(ios::fixed|ios::showpoint)<<setprecision(2);
partt<<"Hours Worked "<<pt.hoursWorked<<endl;
partt<<"Overtime Hours "<<pt.OT<<endl;
partt<<"---------------------------------------------------"<<endl;
partt<<"Pay "<<pt.pay<<endl;
partt<<"Salary Overtime "<<pt.OTcalc<<endl;
partt<<" ________________"<<endl;
partt<<"Total Pay "<<pt.salary<<endl;
partt<<" ________________"<<endl;
partt.close();
}
| |