The objective of the record entry system is to develop a login-based record keeping system, which has nested menus and different interface for different sets of users.
The application record entry system contains separate interface defined for an administrator and employees. The application provides a basic menu, which has menu options for both types of users. According to the selection made by the user, the user is prompted to enter his login name and password. On successfully validation the user name and password, a menu is displayed to the user according to his level. For example, an employee after logging into the system, can record his log in and log out timings.
The project record entry system demonstrates working with date and time in C, showing ‘*’ characters when user types re password, user authentication and two level of menus for each type of user. The project also adds validation on user input to ensure proper data entry into database.
The project record entry system uses various C concepts, such as while loop, if statement and switch case statement to display the required functionality.
The Code of Record Entry 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 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 |
/***** Application: Record Entry System Complied on: Borland Turbo C++ 3.0 Copyright:bestengineeringprojects.com *****/ #include <stdio.h> #include <conio.h> #include <string.h> #include <dos.h> #include <ctype.h> void dataentry(void); void selectAdminOption(void); void getData(int option); int showAdminMenu; void main() { int cancelOption ,timeOption,entryOption,exitOption; char choice[1]; char selectOption[1]; testcolor(YELLOW); cancelOption=0; /*****show the main menu for the application*****/ While (cancelOption==0) { clrscr(); gotoxy(30,7); printf("Please Select an Action->"); gotoxy(30,10); printf("Daily Time Record [1] "); gotoxy(30,11); printf("Data Entry [2] "); gotoxy(30,12); printf("Close [3] "); gotoxy(30,15); printf("Please Enter Your Choice (1/2/3): "); scanf("%s",&choice); timeOption=strcmp(choice,"1"); entryOption=strcmp(choice,"2"); exitOption=strcmp(choice,"3"); if (timeOption==0) { clrscr(); gotoxy(23,6); printf("DAILY EMPLOYEE TIME RECORDING SYSTEM"); gotoxy(16,24); printf("Input Any Other key t Return to Previous Screen."); gotoxy(31,9); printf("[1] Employee Log In"); gotoxy(31,10); printf("[2] Employee Log Out"); gotoxy(28,12); printf("Please Enter Your Option: "); scanf("%s",&selectOption); if (strcmp(selectOption,"1")==0) { getData(5); } if (strcmp(selectOption, "2")==0) { setData(6) } cancelOption=0; } if (entryOption==0) { dataentry(); cancelOption=0; } if (exitOption==0) { cancelOption=1; } if (!(timeOption==0 || entryOption==0 || exitOption==0)) { gotoxy(10,17); printf("You Have Enter an Invalid Option. Please Choose Either 1, 2 or 3. "); getch(); cancelOption=0; } } clrscr(); gotoxy(23,13); printf("The Application will Close Now. Thank!"); getch(); } /* This function provides logic for data entry to be done for the system. Access to Data Entry screens will be only allowed to administrator user.*/ void dataentry(void) { char adminName[10], passwd[5], buffer[1]; char tempo[6],sel[1]; int valodUserNameOption,validUserPwdOption,returnOption,UserName,inc,tmp; char plus; clrscr(); validUserNameOption=0; validUserPwdOption=0; while (validUserNameOption==0) { clrscr(); while (validUserNameOption==0) { clrscr(); gotoxy(20,5); printf("IT SOFTWARE DATA ENTRY SYSTEM-ADMIN INTERFACE"); gotoxy(20,24); printf("Info: Type return to go back to the main screen."); gotoxy(28,10); printf("Enter Administration Name: "); scanf("%s",&adminName); returnOption=strcmp(adminName,"return"); UserName=strcmp(adminName,"admin"); if (returnOption==0) { goto stream; } if (!(UserName==0 || returnOption==0)) { gotoxy(32,11); printf("Administrator Name is Invalid. "); getch(); validUserNameOption=0; } else validUserNameOption=1; } gotoxy(30,11) printf("Enter Password:"); inc=0; while (inc<5) { passwd[inc]=getch(); inc=inc+1; printf("*"); } inc=0; while(inc<5) { tempo[inc]=passwd[inc]; inc=inc+1; } while(getch()!=13); if(!strcmp(tempo, "admin12")) { gotoxy(28,13); printf("You have Entered a Wrong Password. Please Try Again. "); getch(); validUserPwdOption=0; validUserNameOption=0; } else { clrscr(); gotoxy(24,11); testcolor(YELLOW+BLINK); cprintf("You Have Successfully Logged In."); gotoxy(24,17); testcolor(YELLOW); printf("Press Any Key to Continue."); validUserPwdOption=1; validUserNameOption=1; getch(); showAdminMenu=0; while(showAdminMenu==0) { clrscr(); gotoxy(24,4); printf("ADMIN OPTIONS"); gotoxy(26,9); printf("Add New Employee [1]"); gotoxy(26,11); printf("Show Daily Entries [2]"); gotoxy(24,13) printf("Search Employee Record [3]"); gotoxy(26,15); printf("Remove Employee [4]"); gotoxy(26,17); printf("Close [5]"); gotoxy(24,21); printf("Please Enter Your Choice: "); selectAdminOption(); } } } stream:{} } /* This function provides the administrator level functionalities, such as Adding or deleting an employee,*/ void selectAdminOption(void) { char chc[1]; int chooseNew,chooseShow,chooseSearch,chooseRemove,chooseClose; gets(chc); chooseNew=strcmp(chc,"1"); chooseShow=strcmp(chc,"2"); chooseSearch=strcmp(chc,"3"); chooseRemove=strcmp(chc,"4"); chooseClose=strcmp(chc,"5"); if (!(chooseNew==0 || chooseShow==0 || chooseSearch==0 || chooseRemove==0 || chooseClose==0)) { gotoxy(19,21); testcolor("Invalid Input!"); gotoxy(34,21); testcolor(YELLOW); cprintf("Press any key to continue."); } if (chooseNew==0) { clrscr(); gotoxy(25,5); getData(1); } else if(chooseShow==0) { getData(2); } else if(chooseSearch==0) { clrscr(); getData(3); } else if(chooseRemove==0) { getData(4); } else if(chooseClose==0) { showAdminMenu=1; } } /* This function retrieves data from the database as well as do data processing according to user requests. The function provides functionality for menu option to both employee as well as administrator user*/ void getData(int option) { FILE *db,*tempdb; char anotherEmp; int choice; int showMenu,posx,posy; char checkSave,checkAddNew; int i; struct employee { char firstname[30]; char lastname[30]; char password[30]; int empid; char loginhour; char loginmin; char loginsec; char logouthour; char logoutmin; char logoutsec; int yr; char mon; char day; }; struct employee empData; char confirmPassword[30]; long int size; char lastNameTemp[30],firstNameTemp[30],password[30]; int searchId; char pass[30]; char findEmployee; char confirmDelete; struct data today; struct time now; clrscr(); /* Opens the employee database*/ db=fopen("d:/empbase.dat","rb+"); if(db==NULL) { db=fopen("d:/empbase.dat","wb+"); if(db==NULL) { printf("The Fill Could not be opened.\n"); exit(); } } printf("Application Database \n"); size=sizeof(empData); showMenu=0; while(showMenu==0) { fflush(stdin); choice=option; /* Based on the choice selected by admin/employee, this switch statement processes the request*/ switch(choice) { /* To add a new employee to the database*/ case 1: fseek(db,0,SEEK_END); anotherEmp='y'; while(anotherEmp=='y') { checkAddNew=0; while(checkAddNew==0) { clrscr(); gotoxy(25,3); printf("ADD A NEW EMPLOYEE"); gotoxy(13,22); printf("Warning: Password Must Contain Six(6) AlphaNumeric Digits."); gotoxy(5,8); printf("Enter First Name: "); scanf("%s",&firstNameTemp); gotoxy(5,10); printf("Enter Last Name: "); scanf("%s",&lastNameTemp); gotoxy(43,8); printf("Enter Password: "); for (i=0;i<6;i++) { password[i]=getch(); printf("* "); } password[6]='\0'; while(getch()!=13); gotoxy(43,10); printf("Confirm Password: "); for (i=0;i<6;i++) { confirmPassword[i]=getch(); printf("* "); } confirmPassword[6]='\0'; while(getch()!=13); if (strcm(password,confirmPassword)) { gotoxy(24,12); printf("Password do not match."); gotoxy(23,13); printf("Press any key to continue."); getch(); } else { checkAddNew=1; rewind(db); empData.empid=0; while(fread(&empData,size,1,db)==1); if(empData.empid<2000) empData.empid=20400; empData.empid=empData.empid+1; gotoxy(29,16); printf("Save Employee information? (y/n):"); checkSave=getche(); if (checkSave=='y') { strcpy(empData.firstname,firstNameTemp); strcpy(empData.lastname,lastNameTemp); strcpy(empData.password,password); empData.loginhour='t'; empData.logouthour='t'; empData.day='j'; fwrite(&empData,size,1,db); } gotoxy(28,16); printf(" "); gotoxy(28,16); printf("Would like to add another employee? (y/n):"); fflush(stdin); anotherEmp=getch(); printf("\n"); } } } break; /* To view time records for all employees*/ case 2: clrscr(); gotoxy(21,2); printf("VIEW EMPLOYEE INFORMATION"); gotoxy(1,5); printf("Employee ID Employee Name Time Logged In Time Logged Out Date\n\n"); rewind(db); posx=3; posy=7; while(fread(&empData,size,1,db)==1) { empData.firstname[0]=toupper(empData.firstname[0]); empData.lastname[0]=toupper(empData.lastname[0]); gotoxy(posx,posy); printf("%d",empData.empid); gotoxy(posx+10,posy); printf("| %s, %s",empData.lastname,empData.firstname); gotoxy(posx+30,posy); if (empData.loginhour=='t') { printf("| Not Logged In"); } else printf("| %d:%d:%d",empData.loginhour,empData.loginmin,empData.loginsec); gotoxy(posx+49.posy); if (empData.logouthour=='t') { printf("| Not Logged Out"); } else printf("| %d:%d:%d",empData.logouthour,empData.logoutmin,empData.logoutsec); if (empData.day=='j') { gotoxy(posx+69,posy); printf("| No Date"); } else { gotoxy(posx+73,posy); printf("| %d/%d/%d",empData.mon,empData.day,empData.yr); } posy=posy+1; } getch(); printf("\n"); break; /* To search a particular employee and view their time records*/ case 3: clrscr(); gotoxy(27,5); printf("SEARCH EMPLOYEE INFORMATION"); gotoxy(25,9); printf("Enter Employee Id to Search"); scanf("%d", $searchId); findEmployee='f'; rewind(db); while(fread(&empData,size,1,db)==1) { if(empData.empid==searchId) { gotoxy(33,11); testcolor(YELLOW+BLINK); cprintf("Employee Information is Available."); testcolor(YELLOW); gotoxy(25,13); printf("Employee name is :%s %s",empData.lastname,empData.firstname); if(empData.loginhour=='t') { gotoxy(25,14); printf("Log In Time: Not Logged In"); } else { gotoxy(25,14); printf("Log In Time is: %d:%d:%d",loginhour,empData.loginmin,empData.loginsec); } if(empData.logouthour=='t') { gotoxy(25,15); printf("Log Out Time: Not Logged Out"); } else { gotoxy(25,15); printf("Log Out Time is: %d:%d:%d",empData.logouthour,empData.logoutmin,empData.logoutsec); } findEmployee='t'; getch(); } } if (findEmployee!='t') { gotoxy(30,11); testcolor(YELLOW+BLINK); cprintf("Employee Information not available. Please modify the search."); testcolor(YELLOW); getch(); } bresk; /* To Remove Entry of an Employee From the Database*/ case 4: clrscr(); gotoxy(25,5); printf("REMOVE AN EMPLOYEE"); gotoxy(25,9); printf("Enter Employee Id to Delete: "); scanf("%d", &searchId); findEmployee='f'; rewind(db); while(fread(&empData,size,1,db)==1) { if (empData.empid==searchId) { gotoxy(33,11); testcolor(YELLOW+BLINK); cprintf("Employee Information is available. "); testcolor(YELLOW); gotoxy(25,13); printf("Employee name is: %s %s",empData.lastname,empData.firstname); findEmployee='t'; } } if (findEmployee!='t') { gotoxy(30,11); testcolor(YELLOW+BLINK); cprintf("Employee Information not available. Please modify the search."); testcolor(YELLOW); getch(); } if (findEmployee=='t') { gotoxy(29,15); printf("Do you want to Delete the Employee? (y/n)"); confirmDelete=getch(); if (confirmDelete=='y' || confirmDelete=='y') { tempdb=fopen("d:/tempo.dat","wb+"); rewind(db); while(fread(&empData,size,1,db)==1) { if (empData.empid!=searchId) { fseek(tempdb,0,SEEK_END); fwrite(&empData,size,1,tempdb); } } fclose(tempdb); fclose(db); remove("d:/empbase.dat"); remove("d:/tempo.dat","d:/empbase.dat"); db=fopen("d:/empbase.dat","rb+"); } } break; /*To login an employee into the system and record the login date and time*/ case 5: clrscr(); gotoxy(20,4); printf("DAILY EMPLOYEE TIME RECORD SYSTEM"); gotoxy(20,23); printf("Warning: Please Enter Numeric Value Only."); gotoxy(23,7); printf("Enter Your Id to Login:"); scanf("%d", &searchId); gotoxy(20,23); printf(" "); findEmployee='f'; rewind(db); while(fread(&empData,size,1,db)==1) { if (empData.empid==searchId) { gotoxy(23,8); printf("Enter Your Password: "); for (i=0;i<i++) { pass[i]=getch(); printf("* "); } pass[6]='\0'; while(getch()!=13); if(strcmp(empData.password,pass)) { gotoxy(23,11); textcolor(YELLOW+BLINK); cprintf("You Have Supplied a Wrong Password."); testcolor(YELLOW); findEmployee='t'; getch(); break(); } gotoxy(23,11); testcolor(YELLOW+BLINK); cprintf("You have successfully Logged In the System."); testcolor(YELLOW); gotoxy(23,13); printf"Employee name: %s %s",empData.lastname,empData.firstname); gettime(&now); getdate(&today); gotoxy(23,14); printf("Your Log In Time: %2d:%2d:%2d",now.ti_min,noe.ti_hour,now.ti_sec); gotoxy(23,15); printf("Your Log In Date: %d/%d/%d",today.da_mon,today.da_day,today.da_year); empData.day=today.da_day; empData.mon=today.da_mon; empData.yr=today.da_year; fseek(db,-size,SEEK_CUR); empData.loginhour=now.ti_min; empData.loginmin=now.ti_hour; empData.loginsec=now.ti_sec; fwrite(&empData,size,1,db); findEmployee='t'; getch(); } } if (findEmployee!='t') { gotoxy(30,11); testcolor(YELLOW+BLINK); cprintf("Employee Information is not available."); testcolor(YELLOW); getch(); } break; /* To logout an employee and record the logout date and time*/ case 6: clrscr(); gotoxy(20,4); printf("DAILY EMPLOYEE TIME RECORDING SYSTEM"); gotoxy(20,23); printf("Warning: Please Enter Numeric Values Only."); gotoxy(23,7); printf("Enter Your Id to Logout: "); scanf("%d",&searchId); gotoxy(20,23); printf(" ") findEmployee='f'; rewind(db); while(fread(&empData,size,1,db)==1) { if (empData.empid==searchId) { gotoxy(23,8); printf("Enter Password: "); for (i=0;i<6;i++) { pass[i]=getch(); printf("* "); } pass[6]='\0'; while(getch()!=13); if (strcmp(empData.password,pass)) { gotoxy(30,11); testcolor(YELLOW+BLINK); cprintf("You Have Supplied a Wrong Password."); testcolor(YELLOW); findEmployee='t'; getch(); break; } gotoxy(23,11); testcolor(YELLOW+BLINK); cprintf("You have successfully Logged Out of the System."); testcolor(YELLOW); gotoxy(23,13); printf("Employee name is: %s%s",empData.lastname,empData.firstname); gettime(&now); getdate(&today); gotoxy(23,14); printf("Your Log Out Time: %2d:%2d:%2d",now.ti_min,now.ti_hour,now.ti_sec); gotoxy(23,15); printf("Your Log Out Date: %d/%d/%d",today.da_mon,today.da_day,today.da_year); fseek(db,-size,SEEK_CUR); empData.logouthour=now.ti_min; empData.logoutmin=now.ti_hour; empData.logoutsec=now.ti_sec; fwrite(&empData,size,1,db); findEmployee='t'; getch(); } } if (findEmployee!='t') { gotoxy(23,11); testcolor(YELLOW+BLINK); cprintf("Employee Information is not available."); testcolor(YELLOW); getch(); } break; /*show previous menu*/ case 9: printf("\n"); exit(); } fclose(db); showMenu=1; } } |