职工考勤管理系统

#include
#include
#include
#include

#define PASS_WORD "123456"

typedef struct _Stuff
{
	int no;//工号
	char name[20];//姓名
	struct tm * tm_strat;//上班时间
	struct tm * tm_end;//下班时间
	char state[20];//出勤状况
}Stuff,*PStuff;

void Save_Info(PStuff mon,int n)
{
	int i;
	FILE* pFile = fopen("Mon_Info.dat","w");
	if(pFile==NULL)
	{
		return;
	}
	for(i=0;i=1)
	{
		return i-1;
	}
	return 0;
}

int menu()
{
	int chioce;
	system("cls");
	printf("1:职工上班打卡\n");
	printf("2:职工下班打卡\n");
	printf("3:职工出勤情况\n");
	printf("4:按职工号查询\n");
	printf("5:按职工名查询\n");
	printf("6:考勤信息删除\n");
	printf("7:考勤信息修改\n");
	printf("8:退出\n");
	printf("请输入选择:");
	scanf("%d",&chioce);
	while(chioce<1||chioce>8)
	{
		printf("请重新选择:");
		scanf("%d",&chioce);
	}	
	return chioce;
}

void Print_Stuff(PStuff stu,int n)
{
	int i;
	system("cls");
	printf("%10s%10s%10s\n","工号","姓名","出勤");
	for(i=0;i3)
	{
		printf("请重新选择:");
		scanf("%d",&chioce);
	}	
	switch(chioce)
	{
	case 1:
		printf("请输入新职工号:");
		scanf("%d",&stu[i].no);
		break;
	case 2:
		printf("请输入新职工名:");
		scanf("%s",&stu[i].name);
		break;
	case 3:
		printf("请输入新出勤情况:");
		scanf("%s",str);
		strcpy(stu[i].state,str);
		break;
	case 0:
		return ;
		break;
	}
	printf("修改成功!\n");
	Print_Stuff(&stu[i],1);
}

struct tm * Set_Time()
{
	time_t tmpcal_ptr;  
    struct tm *tmp_ptr = NULL;  
    time(&tmpcal_ptr);
    tmp_ptr = gmtime(&tmpcal_ptr);   
    tmp_ptr = localtime(&tmpcal_ptr);

    printf ("%d.%d.%d ", (1900+tmp_ptr->tm_year), (1+tmp_ptr->tm_mon), tmp_ptr->tm_mday);  
    printf("%d:%d:%d\n", tmp_ptr->tm_hour, tmp_ptr->tm_min, tmp_ptr->tm_sec);
	return tmp_ptr;
}

int Start_Work(PStuff stu,int n)
{
	system("cls");
	printf("请输入员工工号:");
	scanf("%d",&stu[n].no);

	printf("请输入员工姓名:");
	scanf("%s",stu[n].name);

	stu[n].tm_strat = Set_Time();
	stu[n].tm_end=NULL;
	
	if(stu[n].tm_strat->tm_hour >= 9)
	{
		strcpy(stu[n].state,"迟到");
	}
	else
	{
		strcpy(stu[n].state,"全勤");
	}

	printf("上班打卡成功!\n");
	system("pause");
	return n+1;
}

void End_Work(PStuff stu,int n)
{
	int temp,i;
	system("cls");
	printf("请输入员工工号:");
	scanf("%d",&temp);
	for(i=0;itm_hour <= 17)
	{
		strcat(stu[n].state,"早退");
	}
	printf("下班打卡成功!\n");
	system("pause");
}



void Serach_Stuff(PStuff stu,int n)
{
	int i,temp;
	system("cls");
	printf("请输入要查询的职工号:");
	scanf("%d",&temp);
	for(i=0;i

你可能感兴趣的:(C/C++,职工,考勤,系统,C语言)