银行客户管理信息系统C语言综合实验班级:物联网141姓名:魏龙龙学号:14488125日期:2015.06.22目录1、实验目的2、实验内容3、实验流程(流程图,功能函数)4、实验结果5、实验心得实验目的:1:本实验为学生提供了一个既动手又动脑,实践的机会:。
2:学生通过分析和解决该实验,将课本上的理论知识和实际有机地结合起来,锻炼学生分析、解决较复杂问题的能力。
3:提高学生编写综合系统程序的能力,强化学生的结构化程序思想。
实验内容:最高权限:设置增加银行职员的登录ID和登录的密码;用户的选择性登录,分为职员和员工,他们分别有自己的操作界面,进入自己的操作界面可以对自己的信息进行相应的操作;职员权限:1、开户;2、查询用户的信息;3、办理存、取款业务;4、销户;5、查询所有用户的信息;6,退出;客户权限:1、存款;2、取款;3、查询余额;4、修改密码;5、退出。
功能函数:职员登录:登陆失败:开户:查询客户的信息:存款:取款:销户、查询所有用户:用户权限存款、查询余额:取款、查询余额:修改密码:实现代码:用户登陆:void login(USER *usr,char *passward)//-1-----failer, 0------other, 1----root{int login=0;char id[9],pwd[9];FILE *fp;if(!(fp=fopen(passward,"rb"))) exit(1);for(int i=0;i<3;i++){printf("Please input your ID:");gets(id);fflush(stdin);printf("Please input your password(3times):");gets(pwd);fflush(stdin);fread(usr,sizeof(USER),1,fp);while(!feof(fp)){if(strcmp(usr->ID,id)==0 && strcmp(usr->Pwd,pwd)==0) {printf("login success!\n"); login=true;break;}fread(usr,sizeof(USER),1,fp);}if(login) break;if(i<3) printf("login failure!Please login again...\n");rewind(fp);}fclose(fp);if(!login){printf("Exit\n"); exit(1);}}开户:bool inputclinet(char *fname,char *passward){clinet t;USER usr;FILE *fp=fopen(fname,"ab+");FILE *file=fopen(passward,"ab+");if((!fp)||(!file))return 0;printf("Please input the ID,name,save and the password:\n");fflush(stdin);gets(t.ID);strcpy(usr.ID,t.ID);fflush(stdin);gets();fflush(stdin);scanf("%lf",&t.save);fflush(stdin);gets(usr.Pwd);usr.Grade=0;printf("\n");fwrite(&t,sizeof(clinet),1,fp);fwrite(&usr,sizeof(USER),1,file);fclose(file);fclose(fp);return 1;}查找客户:bool findclinet(char *fname){int i=0;clinet t;char ID[9];FILE *fp=fopen(fname,"ab+");if(!fp) return 0;printf("Please input te ID that you want to search:\n");fflush(stdin);gets(ID);fread(&t,sizeof(clinet),1,fp);while(!feof(fp)){if(strcmp(ID,t.ID)==0){printf("\tID NAME SAVE\n");printf("\t%s %s %lf\n",t.ID,,t.save);i=1;printf("\n");break;}fread(&t,sizeof(clinet),1,fp);}fclose(fp);return i;}存取款:void save_money(char *fname){char ID[9];double add=0;clinet t;FILE *fp=fopen(fname,"rb+");if(!fp) return;printf("Please input the clinet's ID:\n");fflush(stdin);gets(ID);fread(&t,sizeof(clinet),1,fp);while(!feof(fp)){if(strcmp(ID,t.ID)==0) break;fread(&t,sizeof(clinet),1,fp);}printf("\tID NAME SAVE\n");printf("\t%s %s %.2lf\n",t.ID,,t.save);fseek(fp,-sizeof(clinet),SEEK_CUR);printf("Please input the money that ypu want to save:\n");fflush(stdin);scanf("%lf",&add);t.save += add;fwrite(&t,sizeof(clinet),1,fp);fclose(fp);fp=NULL;}销户:bool move(char *fname,char *passward){char ID[9];double add=0;int i=0;clinet t;USER usr;FILE *fp=fopen(fname,"rb+");FILE *file=fopen(passward,"rb+");if(!fp) return 0;printf("Please input the clinet's ID:\n");fflush(stdin);gets(ID);fread(&t,sizeof(clinet),1,fp);while(!feof(fp)){if(strcmp(ID,t.ID)==0) {i=1; break;}fread(&t,sizeof(clinet),1,fp);}printf("\tID NAME SAVE\n");printf("\t%s %s %.2lf\n",t.ID,,t.save);fseek(fp,-sizeof(clinet),SEEK_CUR);strcpy(t.ID,"00000000");strcpy(,"0000000");t.save=0;fwrite(&t,sizeof(clinet),1,fp);fclose(fp);fread(&usr,sizeof(USER),1,file);while(!feof(file)){if(strcmp(ID,t.ID)==0){i=1;break;}fread(&usr,sizeof(USER),1,file);}fseek(fp,-sizeof(USER),SEEK_CUR);strcpy(usr.ID,"000000");strcpy(usr.Pwd,"000000");fwrite(&usr,sizeof(USER),1,file);fclose(file);return i;}查询所有用户信息:oid printall(char *fname){FILE *fp=NULL;fp=fopen(fname,"rb+");clinet t;printf("This is the client's lists:\n");printf("\tID NAME SAVE\n");fread(&t,sizeof(clinet),1,fp);while(!feof(fp)){printf("\t%s %s %.2lf\n",t.ID,,t.save);fread(&t,sizeof(clinet),1,fp);}fclose(fp);}用户权限存取款:void wiithdraw_money(USER *usr,char *fname){clinet t;double data;FILE *fp=fopen(fname,"rb+");if(!fp) return;fread(&t,sizeof(clinet),1,fp);while(!feof(fp)){if(strcmp(t.ID,usr->ID)==0) break;fread(&t,sizeof(clinet),1,fp);}fseek(fp,-sizeof(clinet),SEEK_CUR);printf("Please input the money tht you want to withdraw:\n");scanf("%lf", &data);t.save -= data;fwrite(&t,sizeof(clinet),1,fp);fclose(fp);fp=NULL;}查询余额:bool search(USER *usr,char *fname){clinet t;int i=0;FILE *fp=fopen(fname,"ab+");if(!fp) return 0;fread(&t,sizeof(clinet),1,fp);while(!feof(fp)){if(strcmp(usr->ID,t.ID)==0){printf("\tID NAME SAVE\n");printf("\t%s %s %lf\n",t.ID,,t.save);i=1;printf("\n");break;}fread(&t,sizeof(clinet),1,fp);}fclose(fp);return i;}修改密码:bool chge_pwd(USER *usr,char *passward){int i=0;USER t;FILE *fp=fopen(passward,"rb+");char pward[9];fread(&t,sizeof(USER),1,fp);while(!feof(fp)){if(strcmp(usr->ID,t.ID)==0){printf("\tID password\n");printf("\t%s %s\n",t.ID,t.Pwd);i=1;printf("\n");break;}fread(&t,sizeof(USER),1,fp);}printf("Please input the password that you want to change:\n");fflush(stdin);gets(pward);fseek(fp,-sizeof(USER),SEEK_CUR);strcpy(usr->Pwd,pward);fwrite(usr,sizeof(USER),1,fp);fclose(fp);return i;}实验心得:在编写这个实验源程序的过程中遇到了不少问题。