您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 管理学资料 > C语言课程设计--银行管理系统
#includestdio.h#includemalloc.h#includestring.h#includestdlib.h#includetime.henumLB{cun,qu};typedefstruct//客户资料{intID;charname[6];intkey;charadd[10];chartel[11];floatmoney;}KH;typedefstruct//支取记录{time_tnow;charL[6];floatnum;charop[6];floatba;}JL;//为字符串处理准备intx,y;charn[6];//输入客户voidCreateKH(KH&K){printf(输入客户ID:);scanf(%d,&K.ID);printf(输入用户名:);scanf(%s,K.name);printf(输入支取密码(6位数字):);scanf(%d,&K.key);printf(输入客户地址:);scanf(%s,K.add);printf(输入客户电话:);scanf(%s,K.tel);K.money=0;}intCZKH(KHK[11],charname[6])//按客户名查找返回ID{inti;for(i=1;i=10;i++)if(strcmp(K[i].name,name)==0)break;returni;}intDR()//登入{system(cls);printf(\n\n\n———————用户登入———————\n\n\n\n);KHK[11];charna[6];intkey,a;FILE*fr=fopen(客户组.txt,rb);fread((char*)&K,sizeof(KH),11,fr);fclose(fr);printf(输入用户名:);scanf(%s,na);a=CZKH(K,na);printf(\n输入密码(6位数字):);scanf(%d,&key);if(key==K[a].key){system(cls);printf(\n\n\n成功登入!\n\n\n);returna;}else{system(cls);printf(用户密码错误!\n\n\n);system(pause);return0;}}voidXJKH()//新建客户{system(cls);charn[6];KHr,K[11],c[11];FILE*fr=fopen(客户组.txt,rb);fread((char*)&K,sizeof(KH),11,fr);fclose(fr);CreateKH(r);x=r.ID;K[x]=r;sprintf(n,%s.txt,K[x].name);FILE*jw=fopen(n,wb);fclose(jw);FILE*fw=fopen(客户组.txt,wb);fwrite((char*)&K,sizeof(KH),11,fw);fclose(fw);FILE*fo=fopen(客户组.txt,rb);fread((char*)&c,sizeof(KH),11,fo);fclose(fo);system(cls);printf(\nID:%2d用户名:%6s密码:%6d地址:%5s电话:%11s余额:%10.2f\n\n,c[x].ID,c[x].name,c[x].key,c[x].add,c[x].tel,c[x].money);system(pause);}voidCQ()//存取款{JLJ;KHc[11];charn[6];x=DR();if(x==0){}else{//新建支取记录FILE*fr=fopen(客户组.txt,rb);fread((char*)&c,sizeof(KH),11,fr);fclose(fr);sprintf(n,%s.txt,c[x].name);printf(\nID:%2d用户名:%6s余额:%10.2f\n\n,c[x].ID,c[x].name,c[x].money);structtm*today;time(&J.now);today=localtime(&J.now);//判断存取并交易printf(经办人:);scanf(%s,J.op);if(strcmp(J.op,xky)==0){printf(交易类别(存入/取出):);scanf(%s,J.L);if(strcmp(J.L,存入)==0||strcmp(J.L,取出)==0){printf(输入交易金额:);scanf(%f,&J.num);if(strcmp(J.L,存入)==0){J.ba=c[x].money+J.num;c[x].money=J.ba;}if(strcmp(J.L,取出)==0){J.ba=c[x].money-J.num;if(J.ba0){printf(余额不足!操作失败!\n\n);system(pause);return;}c[x].money=J.ba;}FILE*jw=fopen(n,ab);fwrite((char*)&J,sizeof(JL),1,jw);fclose(jw);}else{printf(\n\n输入错误\n\n);system(pause);return;}FILE*fw=fopen(客户组.txt,wb);fwrite((char*)&c,sizeof(KH),11,fw);fclose(fw);printf(时间:%4d-%02d-%02d%02d:%02d:%02d类别:%s金额:%10.2f经办人:%s余额:%10.2f\n\n,1900+today-tm_year,today-tm_mon+1,today-tm_mday,today-tm_hour,today-tm_min,today-tm_sec,J.L,J.num,J.op,J.ba);system(pause);}else{printf(\n\n交易不被允许!\n\n);system(pause);return;}}}voidXGJM(int&x)//修改界面{KHK[11];inti;charm[6];FILE*fw;FILE*fr=fopen(客户组.txt,rb);fread((char*)&K,sizeof(KH),11,fr);fclose(fr);printf(\n\n\n—————————选择修改项—————————\n\n\n\n);printf(1,用户名2,密码\n\n3,地址4,电话\n\n0,返回\n\n\n);printf(选择:);scanf(%d,&i);y=x;switch(i){case1:system(cls);sprintf(n,%s.txt,K[x].name);printf(输入新用户名:);scanf(%s,K[y].name);printf(修改成功);sprintf(m,%s.txt,K[y].name);printf(\nID:%2d用户名:%6s密码:%6d地址:%5s电话:%11s余额:%10.2f\n\n,K[y].ID,K[y].name,K[y].key,K[y].add,K[y].tel,K[y].money);rename(n,m);fw=fopen(客户组.txt,wb);fwrite((char*)&K,sizeof(KH),11,fw);fclose(fw);system(pause);break;case2:system(cls);printf(输入新密码:);scanf(%d,&K[x].key);printf(\n修改成功);printf(\nID:%2d用户名:%6s密码:%6d地址:%5s电话:%11s余额:%10.2f\n\n,K[x].ID,K[x].name,K[x].key,K[x].add,K[x].tel,K[x].money);fw=fopen(客户组.txt,wb);fwrite((char*)&K,sizeof(KH),11,fw);fclose(fw);system(pause);break;case3:system(cls);printf(输入新地址:);scanf(%s,K[x].add);printf(\n修改成功);printf(\nID:%2d用户名:%6s密码:%6d地址:%5s电话:%11s余额:%10.2f\n\n,K[x].ID,K[x].name,K[x].key,K[x].add,K[x].tel,K[x].money);fw=fopen(客户组.txt,wb);fwrite((char*)&K,sizeof(KH),11,fw);fclose(fw);XGJM(x);break;case4:system(cls);printf(输入新电话:);scanf(%s,K[x].tel);printf(\n修改成功);printf(\nID:%2d用户名:%6s密码:%6d地址:%5s电话:%11s余额:%10.2f\n\n,K[x].ID,K[x].name,K[x].key,K[x].add,K[x].tel,K[x].money);fw=fopen(客户组.txt,wb);fwrite((char*)&K,sizeof(KH),11,fw);fclose(fw);XGJM(x);break;case0:return;default:system(cls);printf(\n\n\n输入错误,重新输入\n\n\n);printf(\nID:%2d用户名:%6s密码:%6d地址:%5s电话:%11s余额:%10.2f\n\n,K[x].ID,K[x].name,K[x].key,K[x].add,K[x].tel,K[x].money);XGJM(x);}}voidXGZH()//修改账户{KHK[11];FILE*fr=fopen(客户组.txt,rb);fread((char*)&K,sizeof(KH),11,fr);fclose(fr);x=DR();if(x==0){}else{printf(\nID:%2d用户名:%6s密码:%6d地址:%5s电话:%11s余额:%10.2f\n\n,K[x].ID,K[x].name,K[x].key,K[x].add,K[x].tel,K[x].money);XGJM(x);}}voidCXJL()//查询历史交易记录{system(cls);inti;KHK[11];JLJ[50];FILE*fr=fopen(客户组.txt,rb);fread((char*)&K,sizeof(KH),11,fr);fclose(fr);x=DR();if(x==0){}else{sprintf(n,%s.txt,K[x].name);FILE*jr=fopen(n,rb);fread((char*)&J,sizeof(JL),50,jr);fclose(jr);printf(交易编号时间类别金额经办人余额\n\n);for(i=0;i=50;i++){if(strcmp(J[i].L,存入)==0||strcmp(J[i].L,取出)==0){structtm*today;today=localtime(&J[i].now);printf(%02d%4d-%02d-%02d%02d:%02d:%02d%s%10.2f%s%10.2f\n,i+1,1900+today-tm_year,today-tm_mon+1,today-tm_mday,today-tm_hour,today-tm_min,today-tm_sec,J[i].L,J[i].num,J[i].op,J[i].ba);}}system(pause);}}voidCXYE()//查询余额{system(cls);KHc[11];FILE*fo=fopen(客户组.txt,rb);fread((char*)&c,sizeof(KH),11,fo)
本文标题:C语言课程设计--银行管理系统
链接地址:https://www.777doc.com/doc-6373208 .html