Leave Management System In C++ With Source Code
The Leave Management System In C++ With Source Code is developed using C++ programming language, this method is built on the idea of storing and generating all employee records and leave records.
A c++ employee leave management system goal is to assist you in organizing and maintaining the records of employees who have worked for an organization.
Additionally, the user has the ability to add, access, alter, and delete employee records as well as their leave. This project does not have a login system.
This employee leave management in c++ with source code is a basic employee database for an office or company where the user can conveniently store employee records and leave records because it is not time-consuming.
The Leave Management Framework was written in the C++ programming language and has a basic coding structure that makes it easy to understand the system’s functions.
This Leave Management System In C++ Open Source design is straightforward and clean, making it easy for users to learn, use, and navigate.
These are the following features of the system
- Can Add new Employee
- Modify Current Data
- View All Employee List
- Apply New Leave Application
- Modify Current Leave Application
Anyway if you want level up your knowledge in programming especially C/C++ Programming Language, try this new article I’ve made for you Best C Projects with Source Code for Beginners Free Download 2020.
To run this Leave Management System In C++ Free Download make sure that you have a Code Blocks or any platform of C++ installed in your computer.
Leave Management System In C++ With Source Code Steps On How To Run The Project
Time needed: 5 minutes.
These are the steps on how to run Leave Management System In C++ With Source Code
- Step 1: Download
First, download the source code given below.
- Step 2: Extract file.
Second, after you finished download the source code, extract the zip file.
- Step 3: Open CodeBlocks
Third, open “CodeBlocks IDE”.
- Step 4: Open Project.
Fourth, open file tab and Open File after that open folder LeaveSystem then click the “Leave Management System.cpp“.
- Step 5: Run Project
Fifth, run the project.
- Step 6: The actual code.
You are free to copy the given source code below or download the downloadable source code given.
The Code Given Below is the Actual Code of System
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 |
#include <iostream> #include <cstdio> #include <string.h> #include <fstream> #include <stdlib.h> #include <sstream> #define s6 "\t\t\t\t\t\t" #define s5 "\t\t\t\t\t" #define s4 "\t\t\t\t" #define s3 "\t\t\t" #define s2 "\t\t" #define s1 "\t" #define s0 "" #define sp0 "" #define sp1 " " #define sp2 " " #define sp3 " " #define sp4 " " #define sp5 " " #define nl endl #define cyp "Choose your option : " using namespace std; void recover(char* , char*); float getSal(string ); class Employee { public : string name, ssn, sal, age, exp, casual, sick, study, parental, sdate, edate, days; Employee(){ casual="20",sick="15",study="10",parental="40",sdate="-",edate="-",days="0"; } void deleteLeave(); void searchLeave(); void modLeave(); void dispLeave(); void addUser(); void modUser(); }; void addUser() { Employee e; cout<<nl<<s2<<"--- A D D U S E R ---"<<nl<<nl; cout<<s2<<sp2<<"Enter the ID : "; cin>>e.ssn; e.ssn.resize(8); cout<<s2<<sp2<<"Enter the Name : "; cin>>e.name; e.name.resize(8); cout<<s2<<sp2<<"Enter the Age : "; cin>>e.age; e.age.resize(8); cout<<s2<<sp2<<"Enter the Salary : "; cin>>e.sal; e.sal.resize(8); cout<<s2<<sp2<<"Enter the Experience : "; cin>>e.exp; e.exp.resize(8); fstream file1,file2,file3; file1.open("emp.txt",ios::binary|ios::app); file2.open("leave.txt",ios::binary|ios::app); file3.open("salary.txt",ios::binary|ios::app); if(!file1||!file2){ system("cls"); cout<<s4<<"Error Occured!"<<nl; return; } e.casual=e.casual+"/20-0",e.sick=e.sick+"/15-0",e.study=e.study+"/10-0",e.parental=e.parental+"/40-0"; e.casual.resize(10),e.sick.resize(10),e.study.resize(10),e.parental.resize(10),e.sdate.resize(10),e.edate.resize(10),e.days.resize(5); file1<<"\t|"<<e.ssn<<"|\t"<<e.name<<"|"<<e.age<<"|"<<e.sal<<"|"<<e.exp<<"|"<<nl; file2<<e.ssn<<"|"<<e.name<<"|"<<e.casual<<"|"<<e.sick<<"|"<<e.study<<"|"<<e.parental<<"|"<<e.sal<<"|"<<e.sdate<<"|"<<e.edate<<"|"<<e.days<<"|"<<nl; file3<<e.ssn<<"|"<<e.sal<<"|"<<nl; file1.close(); file2.close(); file3.close(); cout<<s4<<"User added successfully!"<<nl<<nl<<nl; } void modUser() { char ch; string id,str; int found=0,count=0; fstream file1,file2; file1.open("emp.txt",ios::binary|ios::in); cout<<nl<<s2<<"--- M O D I F Y U S E R ---"<<nl<<nl; cout<<s2<<sp4<<"Enter Employee ID : "; cin>>id; id.resize(8); if(!file1){ system("cls"); cout<<s4<<"Error Occured"<<nl; return; } int index=5; while(file1){ file1.seekg(index, ios::beg); getline(file1,str,'|'); if(str==id){ found=1; break; } else{ index+=51; str.clear(); count++; } } file1.close(); if(found==1) { start: int ch,beg,end; string newstr,str; cout<<s4<<"1. EDIT AGE"<<nl; cout<<s4<<"2. EDIT SALARY"<<nl; cout<<s4<<"3. EDIT EXPERIENCE"<<nl<<nl; cout<<s4<<cyp; cin>>ch; cout<<nl; if(ch==1 || ch==2 || ch==3){ cout<<s4<<"Enter the new value : "; cin>>newstr; } else goto start; newstr.resize(8); file1.open("emp.txt",ios::binary|ios::in); file2.open("temp.txt",ios::binary|ios::app); while(count--){ getline(file1,str); file2<<str<<endl; } if(ch==1) beg=3,end=2; else if(ch==2) beg=4,end=1; else if(ch==3) beg=5,end=0; for(int i=0;i<beg;i++){ getline(file1,str,'|'); file2<<str<<"|"; } file2<<newstr<<"|"; getline(file1,str,'|'); for(int i=0;i<end;i++){ getline(file1,str,'|'); file2<<str<<"|"; } while(file1){ getline(file1,str); file2<<str; if(file1) file2<<endl; } file1.close(); file2.close(); cout<<s4<<"Employee has been updated!"<<nl<<nl; char fn1[]="emp.txt",fn2[]="temp.txt"; recover(fn1,fn2); } else cout<<s2<<sp4<<"Employee not found!"<<nl<<nl; } void recover(char *fn1,char *fn2) { remove(fn1); rename(fn2,fn1); } void displayUsers() { string str; fstream file; file.open("emp.txt",ios::binary|ios::in); if(!file){ system("cls"); cout<<s4<<"Error Occured"<<nl; return; } cout<<nl<<"\tEmployee ID"<<s2<<"Name"<<s2<<"Age"<<s2<<"Salary"<<s1<<sp2<<"Experience"<<nl<<nl; while(file){ getline(file,str,'|'); cout<<str; } file.close(); int t=80; cout<<nl; while(t--) cout<<"-"; cout<<nl<<nl; file.close(); } void modLeave() { string id,str; int found=0,count=0; fstream file1,file2; file1.open("leave.txt",ios::binary|ios::in); cout<<nl<<s2<<"--- A P P L Y L E A V E ---"<<nl<<nl; cout<<s2<<sp4<<"Enter the Employee ID : "; cin>>id; cout<<nl; id.resize(8); if(!file1){ system("cls"); cout<<s4<<"Error Occured"<<nl; return; } int index=0; while(file1){ file1.seekg(index, ios::beg); getline(file1,str,'|'); if(str==id){ found=1; break; } else{ index+=100; str.clear(); count--; } } file1.close(); if(found==1) { start: string sdate,edate; int ch,com=7,beg,end,nol,ex=0,lea,tot,days=0,leave,nod; float sal,per; cout<<s2<<sp4<<"1. CASUAL LEAVE"<<nl; cout<<s2<<sp4<<"2. SICK LEAVE"<<nl; cout<<s2<<sp4<<"3. STUDY LEAVE"<<nl; cout<<s2<<sp4<<"4. PARENTAL LEAVE"<<nl<<nl; cout<<s0<<cyp; cin>>ch; cout<<"========================================================="; cout<<nl; if(ch==1){ beg=0,end=3,tot=20,per=.08; } else if(ch==2){ beg=1,end=2,tot=15,per=0.05;} else if(ch==3){ beg=2,end=1,tot=10,per=0.03;} else if(ch==4){ beg=3,end=0,tot=40,per=0.15;} file1.open("leave.txt",ios::binary|ios::in); file2.open("temp1.txt",ios::binary|ios::app); while(count--){ getline(file1,str); file2<<str<<endl; } for(int i=0;i<2;i++){ getline(file1,str,'|'); file2<<str<<"|"; } for(int i=0;i<beg;i++){ getline(file1,str,'|'); file2<<str<<"|"; } cout<<s2<<sp4<<"Enter the number of leaves : "; cin>>nol; getline(file1,str,'|'); stringstream buf1(str); buf1>>lea; leave=lea; if(lea-nol<0) days=abs(lea-nol); lea=lea-nol; if(days!=0) lea=0; fstream buf2; buf2.open("mod.txt",ios::binary|ios::out); buf2<<lea<<"/"<<tot<<"-"<<days; buf2.close(); buf2.open("mod.txt",ios::binary|ios::in); getline(buf2,str); buf2.close(); remove("mod.txt"); str.resize(10); file2<<str<<"|"; for(int i=0;i<end;i++){ getline(file1,str,'|'); file2<<str<<"|"; } getline(file1,str,'|'); sal=getSal(id); if(leave-nol<0) sal=sal-(float)sal*per*abs(tot-leave); ostringstream buf4; buf4<<sal; str=buf4.str();; str.resize(8); file2<<str<<"|"; cout<<s2<<sp4<<"Enter the Start Date(dd/mm/yyyy) : "; cin>>sdate; cout<<s2<<sp4<<"Enter the End Date(dd/mm/yyy) : "; cin>>edate; sdate.resize(10); edate.resize(10); file2<<sdate<<"|"; file2<<edate<<"|"; for(int i=0;i<3;i++) getline(file1,str,'|'); stringstream buf5(str); buf5>>nod; nod=nod+nol; ostringstream buf6; buf6<<nod; str=buf6.str(); str.resize(5); file2<<str<<"|"; while(file1){ getline(file1,str); file2<<str; if(file1) file2<<endl; } file1.close(); file2.close(); char fn1[]="leave.txt",fn2[]="temp1.txt"; recover(fn1,fn2); cout<<s4<<"Leave updated!"<<nl<<nl; } else cout<<s4<<"User not found!"<<nl<<nl; } void dispLeave() { string str; fstream file; file.open("leave.txt",ios::binary|ios::in); if(!file){ system("cls"); cout<<s4<<"Error Occured"<<nl; return; } cout<<nl<<"Employee ID\t"<<"Name\t\t"<<"CL(20)\t\t"<<"SL(15)\t\t"<<"STL(10)\t\t"<<"PL(40)\t\t"<<"Salary\t\t"<<"Start Date"<<sp2<<sp2<<"End Date"<<sp2<<sp2<<"NoofLeaves"<<nl<<nl; while(file){ getline(file,str,'|'); cout<<str<<"\t"; } cout<<nl<<nl; cout<<"Note : This table shows remaining leaves."<<nl<<sp2<<"CL : CASUAL LEAVE"<<nl<<sp2<<"SL : SICK LEAVESEAVE"<<nl<<sp2<<"STL : STUDY LEAVE"<<nl<<sp2<<"PL : PARENTAL LEAVE"<<nl<<sp2<<"Number after '-' sign indicates extra leaves."<<nl<<nl; file.close(); } void deleteLeave() { string id,str; int found=0,count=0; fstream file1,file2; file1.open("leave.txt",ios::binary|ios::in); cout<<s2<<"--- D E L E T E L E A V E ---"<<nl<<nl; cout<<s2<<sp4<<"Enter the Employee ID to delete : "; cin>>id; id.resize(8); if(!file1){ system("cls"); cout<<s2<<sp4<<"Error Occured"<<nl; return; } int index=0; while(file1){ file1.seekg(index,ios::beg); getline(file1,str,'|'); if(str==id){ found=1; break; } else{ index+=100; str.clear(); count=count+1; } } file1.close(); if(found==1) { file1.open("leave.txt",ios::binary|ios::in); file2.open("temp1.txt",ios::binary|ios::app); while(count>0){ getline(file1,str); file2<<str; count=count-1; if(count>0) file2<<nl; } for(int i=0;i<2;i++){ getline(file1,str,'|'); file2<<str<<"|"; } str="20/20-0";str.resize(10); file2<<str<<"|"; str="15/15-0";str.resize(10); file2<<str<<"|"; str="10/10-0";str.resize(10); file2<<str<<"|"; str="40/40-0";str.resize(10); file2<<str<<"|"; float sal=getSal(id); ostringstream buf; buf<<sal; str=buf.str(); str.resize(8); file2<<str<<"|"; str="-";str.resize(10); file2<<str<<"|"<<str<<"|"; str="0";str.resize(10); file2<<str<<"|"; for(int i=0;i<8;i++) getline(file1,str,'|'); while(file1){ getline(file1,str); file2<<str; if(file1) file2<<endl; } file1.close(); file2.close(); char fn1[]="leave.txt",fn2[]="temp1.txt"; recover(fn1,fn2); } else cout<<s2<<sp4<<"User not found!"<<nl; } float getSal(string id) { fstream file; float sal; string str; file.open("salary.txt",ios::binary|ios::in); if(!file){ system("cls"); cout<<s4<<"Error Occured"<<nl; return 0; } while(file){ getline(file,str,'|'); str.resize(8); if(str==id) break; } str.clear(); getline(file,str,'|'); stringstream buf(str); buf>>sal; file.close(); return sal; } void searchLeave() { string id,str; cout<<nl<<s2<<"--- S E A R C H L E A V E ---"<<nl<<nl; cout<<s2<<sp4<<"Enter the Employee ID : "; cin>>id; id.resize(8); fstream file; file.open("leave.txt",ios::binary|ios::in); if(!file){ system("cls"); cout<<s4<<"Error Occured"<<nl; return; } while(file){ getline(file,str,'|'); str.resize(8); if(str==id){ break; } } cout<<nl<<"Employee ID\t"<<"Name\t\t"<<"CL(20)\t\t"<<"SL(15)\t\t"<<"STL(10)\t\t"<<"PL(40)\t\t"<<"Salary\t\t"<<"Start Date"<<sp2<<sp2<<"End Date"<<sp2<<sp2<<"NoofLeaves"<<nl<<nl; cout<<str<<"\t"; for(int i=0;i<9;i++){ getline(file,str,'|'); cout<<str<<"\t"; } file.close(); cout<<nl<<nl; } int main() { while(true){ start: int ch; cout<<"========================================================="<<nl; cout<<s0<<"------ L E A V E M A N A G E M E N T S Y S T E M ------"<<nl; cout<<"========================================================= "<<nl<<nl; cout<<s2<<"--- M A I N M E N U ---"<<nl<<nl; cout<<s2<<sp4<<"1. APPLY LEAVE"<<nl; cout<<s2<<sp4<<"2. DELETE LEAVE"<<nl; cout<<s2<<sp4<<"3. SEARCH LEAVE"<<nl; cout<<s2<<sp4<<"4. MODIFY LEAVE"<<nl; cout<<s2<<sp4<<"5. DISPLAY ALL LEAVES"<<nl; cout<<s2<<sp4<<"6. USER MANAGEMENT"<<nl; cout<<s2<<sp4<<"7. EXIT"<<nl; cout<<nl<<s0<<cyp; cin>>ch; cout<<"========================================================="; cout<<nl; switch(ch) { case 1: modLeave(); break; case 2: deleteLeave(); break; case 3: searchLeave(); break; case 4: modLeave(); break; case 5: dispLeave(); break; case 6: int ch1; cout<<nl<<s2<<"--- U S E R M E N U ---"<<nl<<nl; cout<<s2<<sp4<<"1. ADD USER"<<nl<<s2<<sp4<<"2. MODIFY USER"<<nl; cout<<s2<<sp4<<"3. SHOW ALL USERS"<<nl; cout<<nl<<s0<<cyp; cin>>ch1; cout<<"========================================================="; cout<<nl; if(ch1==1) addUser(); else if(ch1==2) modUser(); else if(ch1==3) displayUsers(); break; case 7: exit(0); default : goto start; } } return 0; } |
Run Quick Virus Scan For Safe Download
Run Quick Scan For Safe DownloadDownloadable Source Code
Conclusion
This leave system in c++ is only a project made for school requirement purposes only. You can download this source code and modify it to suit your client requirements, since this is a student project it means you cannot really expect 100% functionality from this.
Related Articles
- Leave Management System Project Django With Source Code
- Leave Management System In C# With Source Code
- Employee Management System In C With Source Code
- Leave Management System Project in Python with Source Code
- Leave Management System PHP Source Code
- Library Management System In C++ With Source Code
- School Management System In C++ With Source Code
- Student Record System in C with Source Code
- Calendar In C Programming With Source Code
- Mini Project for Phonebook in C with Source Code
- Employee Management System In C With Source Code
- School Billing System in C with Source Code
- Telephone Directory In C++ Project With Source Code
- Blood Bank Management System Project In C++ With Source Code
- Payroll Management System In C++ With Source Code
- Pizza Hut Management System Project in C++ with Source Code
- Clinic Management System Project in C++ with Source Code
- C++ Program On Student Report Card With Source Code
- Car Rental Management System Project In C++ With Source Code
- Periodic Table In C++ With Source Code
- Railway Reservation System in C++ With Source Code
Other Articles you might read also:
- Library Management System Project in VB.Net With Source Code
- Online Library Management System in PHP Source Code
- Student Management System Project in Python with Source Code
- Online Student Registration System Project in PHP
- Library Management System Project In Python and MySQL
- Library Management System Project in Django with Source Code
- Online Library Management System in PHP Source Code
- ICHS Library Management System
- College Management System Project in Django with Source Code
- Search Filter In Django With Source Code
- Best Python Course Online | Python Course Free 2021
- CRANE Thesis Documentation Chapter 1
- CRANE Thesis Documentation Chapter 2 – Related Literature
- ECOMMERCE IN JAVASCRIPT FRAMEWORK WITH SOURCE CODE
- Cafe Reservation System Source Code Using PHP
- Hotel Reservation System SourceCode in PHP
- Online Frozen Foods Ordering System Source Code
- Online Hotel Management System Source Code
- To Do List Project in Python with Source Code | Video | 2020
- Currency Converter In Python With Source Code
- Music Player In JavaScript With Source Code
- CRUD Operation In JavaScript With Source Code
Inquiries
If you have any questions or suggestions about leave monitoring system c++, please feel free to leave a comment below.