⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 record_entry_project_1.c

📁 these are the mini project codes on inventiry and record entry in c language.
💻 C
📖 第 1 页 / 共 2 页
字号:
        	      printf("Passwords 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=getche();
		   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);
		textcolor(YELLOW+BLINK);
		cprintf("Employee Information is Available.");
		textcolor(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",empData.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);
	   textcolor(YELLOW+BLINK);
	   cprintf("Employee Information not available. Please modify the search.");
	   textcolor(YELLOW);
	   getch();
	   }
	   break;

  /* 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);
		textcolor(YELLOW+BLINK);
		cprintf("Employee Information is Available.");
		textcolor(YELLOW);
		gotoxy(25,13);
		printf("Employee name is: %s %s",empData.lastname,empData.firstname);
		findEmployee='t';

	       }
	   }
	   if (findEmployee!='t')
	   {
	   gotoxy(30,11);
	   textcolor(YELLOW+BLINK);
	   cprintf("Employee Information not available. Please modify the search.");
	   textcolor(YELLOW);
	   getch();
	   }
	   if (findEmployee=='t')
	   {
	   gotoxy(29,15);
	   printf("Do you want to Delete the Employee? (y/n)");
	   confirmDelete=getche();
		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");
		rename("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 RECORDING SYSTEM");
	   gotoxy(20,23);
	   printf("Warning: Please Enter Numeric Values 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<6;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.");
		 textcolor(YELLOW);
		 findEmployee='t';
		 getch();
		 break;
		}
		gotoxy(23,11);
		textcolor(YELLOW+BLINK);
		cprintf("You have successfully Logged In the System.");
		textcolor(YELLOW);
		gotoxy(23,13);
		printf("Employee name: %s %s",empData.lastname,empData.firstname);
		gettime(&now);
		getdate(&today);
		gotoxy(23,14);
		printf("Your LogIn Time: %2d:%2d:%2d",now.ti_min,now.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);
	   textcolor(YELLOW+BLINK);
	   cprintf("Employee Information is not available.");
	   textcolor(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);
		 textcolor(YELLOW+BLINK);
		 cprintf("You Have Supplied a Wrong Password.");
		 textcolor(YELLOW);
		 findEmployee='t';
		 getch();
		 break;
		}
		gotoxy(23,11);
		textcolor(YELLOW+BLINK);
		cprintf("You have successfully Logged Out of the System.");
		textcolor(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);
	   textcolor(YELLOW+BLINK);
	   cprintf("Employee Information is not available.");
	   textcolor(YELLOW);
	   getch();
	   }

	   break;

  /* Show previous menu*/
  case 9:

	   printf("\n");
	   exit();
	   }
   fclose(db);
   showMenu=1;
   }
 }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -