考勤管理系统(普通成员函数与修改密码函数)

int get_staff()
{
    char password1[20];
    int flag=0,i;
    printf("\n\n\n   请输入您的编号: ");
    scanf("%s",sdl);
    fflush(stdin); //清除缓冲区 
    if(head->next==NULL)
    {
        printf("   没有员工信息\n");
        return 0;
    }
    for(u=head->next;u!= NULL;u=u->next)  
    {  
        if(strcmp(u->employee_number,sdl)==0)  
        {  
            flag=0; 
            printf("   请输入密码:");                            //共有三次输入机会 
            for(i=0;i<3;i++) 
            {
                scanf("%s",password1);    
                fflush(stdin);            //清除缓冲区 
                if(strcmp(u->password,password1)==0)            //判断输入密码是否一致 
                {
                    printf("\n   密码正确,登陆成功!"); 
                    printf("\n");
                    system("pause");
                    return 1;
                    break;                                    //运行成功 ,跳出循环 
                } 
                else
                {
                    if(i<2) 
                    {
                        printf("   密码错误,请重新输入:");    //若前面两次都输错,则报错 
                    }
                }
            }
            if(i>2)
            {
                printf("   密码错误次数已达上限\n   将返回上一步,请重新选择登录身份!\n");
                system("pause");
                system("cls");
                return 0;
            }
        }
    }
    if(flag==0)
    {
        printf("   没有找到您的编号,请再输入试试吧!\n");
    }
    system("pause");
    system("cls");
}
void staff()
{
    system("cls");
    int choice;
    char name[8]; 
    if(get_staff())            //调用密码函数,判断是否能够继续
    {
        strcpy(name,u->name);
        system("cls");
        while(1)
        {
            printf("\n\n\n   尊敬的%s小主您好,欢迎进入考勤信息管理系统!\n\n",name); 
            printf("   普通职员模式\n\n");
            printf("   ***********************考勤信息管理系统********************\n");
            printf("   *                                                         *\n");
            printf("   *       1.查询日出勤信息                                  *\n");     
            printf("   *                                                         *\n");
            printf("   *       2.查询月出勤信息                                  *\n");
            printf("   *                                                         *\n");
            printf("   *       3.修改自己的密码                                  *\n");
            printf("   *                                                         *\n");
            printf("   *       0.退出管理系统                                    *\n");
            printf("   ***********************************************************\n");
            printf("   请选择:");
            scanf("%d",&choice);
            fflush(stdin);        //清除缓冲区 
            if(choice==0||choice==1||choice==2||choice==3)
            {
                switch(choice)
                {
                case 0:    quit();             break;        //退出程序函数 
                case 1:    find_day();            break;
                case 2: find_mon();            break;
                case 3:    change_password();    break;
                }    
            } 
            else
            {
                printf("   输入有误,请重新输入:\n");
                fflush(stdin);        //清除缓冲区 
                //备注:VS2019可能无法使用fflush(stdin)函数消除缓冲区,可以使用rewind(stdin)函数替换
                choice=1;             //重新给choice赋值,防止跳出循环 
            }
            printf("\n\n");    
        }
    } 
    else 
    {
        return ;    //退出程序 
    }
}
void find_day()
{
    system("cls");
    int flag=0,year,mon,day;
    printf("\n\n\n   根据日期查询信息\n");
    printf("   请输入您要查询的日期: ");
    scanf("%d %d %d",&year,&mon,&day); 
    fflush(stdin); //清除缓冲区 
    for(cu=chead->next;cu!= NULL;cu=cu->next)  
    { 
           if(strcmp(cu->att_number,sdl)==0)
        {
            if(cu->att_year==year)
            {
                if(cu->att_mon==mon)  
                {  
                    if(cu->att_day==day) 
                    {
                        flag++; 
                        printf("   查找成功!\n");
                        puts("      考勤日期    职工编号  所属部门  出勤状态   到岗时间   下岗时间\n");
                        printf("      ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈\n");  
                        printf("      %d %d %d    %s   %s      %s       %d %d       %d %d\n",cu->att_year,cu->att_mon,cu->att_day,cu->att_number,cu->att_department,cu->attendance_status,cu->att_uphour,cu->att_upmin,cu->att_downhour,cu->att_downmin);
                        break;
                    }
                }
            }
        }        
    }    
    if(flag==0)
    {
        printf("   --->未找到该天你的出勤的信息!\n"); 
    }
    system("pause");
    system("cls");
}
void find_mon()
{
    system("cls");
    int flag=0,year,mon;
    double sum_intime=0,sum_traveltime=0,sum_latetime=0,sum_overtime=0;
    printf("\n\n\n   根据日期查询信息\n");
    printf("   请输入您要查询的年月份: ");
    scanf("%d %d",&year,&mon); 
    fflush(stdin); //清除缓冲区 
    for(cu=chead->next;cu!= NULL;cu=cu->next)  
    {
        if(strcmp(cu->att_number,sdl)==0)
        {    
            if(cu->att_year==year)
            {
                if(cu->att_mon==mon)  
                {  
                    flag++; 
                    if(flag==1)
                    {
                        printf("   查找成功!\n");
                        puts("      考勤日期    职工编号  所属部门  出勤状态   到岗时间   下岗时间\n");
                        printf("      ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈\n");  
                    }
                    printf("      %d %d %d    %s   %s      %s       %d %d       %d %d\n",cu->att_year,cu->att_mon,cu->att_day,cu->att_number,cu->att_department,cu->attendance_status,cu->att_uphour,cu->att_upmin,cu->att_downhour,cu->att_downmin);
                    printf("\n"); 
                    sum_intime+=cu->att_intime;
                    sum_traveltime+=cu->att_traveltime;
                    sum_latetime+=cu->att_latetime;
                    sum_overtime+=cu->att_overtime;
                    continue;
                }
            }
        }        
    }
    if(flag>0)
        {
            printf("\n\n\n");
            printf("   考勤日期  月在岗时间  月出差时间  月迟到时间  月加班时间\n");
            printf("   ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈\n");
            printf("   %d %d    %lf   %lf   %lf    %lf\n",year,mon,sum_intime,sum_traveltime,sum_latetime,sum_overtime);
            sum_intime=0;
            sum_traveltime=0;
            sum_latetime=0;
            sum_latetime=0;
            printf("\n");
        }
    if(flag==0)
    {
        printf("   --->未找到此月你的出勤的信息!\n"); 
    }
    system("pause");
    system("cls");
}
void change_password()
{
    system("cls");
    printf("\n\n\n   请输入新的密码: ");  
    while(1)
    {
        scanf("%s",u->password);
        fflush(stdin);        //清除缓冲区 
        if(strlen(u->password)>15)
        {
            printf("   密码输入过长   请重新输入\n");
        }
        if(strlen(u->password)<=15)
        {
            break;
        }
    }
    printf("\n   --->修改成功!\n");
    staff_storage();
    system("pause");
    system("cls");
}

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值