C语言程序设计物业管理系统.docx
《C语言程序设计物业管理系统.docx》由会员分享,可在线阅读,更多相关《C语言程序设计物业管理系统.docx(13页珍藏版)》请在冰豆网上搜索。
C语言程序设计物业管理系统
#defineM5
structPeople
{
inta;
charming[30];
charxiang[30];
intb;
intc;
}P[M];
voidmain()
{
inta=1;
voidmenu_1(inta);
menu_1(a);
}
voidmenu_1(inta)
{
voidmenu_2();
voidmenu_3();
voidbiao_1();
intloop=1;
while(loop)
{
system("cls");
printf("\tWELCOME\n");
printf("\t--------------------(*^◎^*)--------------------\n");
printf("\t--\n");
printf("\t--\n");
printf("\t-1.小区用户管理-\n");
printf("\t-2.物业收费管理-\n");
printf("\t-3.生成小区住户收费报表-\n");
printf("\t-4.退出-\n");
printf("\t--\n");
printf("\t--\n");
printf("\t-------------------o(╯□╰)o-------------------\n");
printf("\tEND\n");
printf("请输入所要选择内容的序号(1-4):
[]\b\b");
scanf("%d",&a);
switch(a)
{
case1:
menu_2();break;
case2:
menu_3();break;
case3:
biao_1();break;
case4:
exit(0);break;
default:
exit(0);
}
getchar();
getchar();
}
}
voidmenu_2()
{
voidscan_1();
voidadd_1();
voidrewrite_1();
voiddelete_1();
voidseek_1();
inta;
system("cls");
printf("\t*欢迎使用小区用户管理系统*\n");
printf("\t-----------------↖(^ω^)↗---------------------\n");
printf("\t--\n");
printf("\t--\n");
printf("\t-1.浏览用户资料-\n");
printf("\t-2.录入用户资料-\n");
printf("\t-3.更改用户资料-\n");
printf("\t-4.删除用户资料-\n");
printf("\t-5.查找用户资料-\n");
printf("\t--\n");
printf("\t--\n");
printf("\t-----------------O(∩_∩)O~---------------------\n");
printf("\tEND\n");
printf("请输入所要选择内容的序号(1-3):
[]\b\b");
scanf("%d",&a);
switch(a)
{
case1:
scan_1();break;
case2:
add_1();break;
case3:
rewrite_1();break;
case4:
delete_1();break;
case5:
seek_1();break;
default:
exit(0);
}
}
voidscan_1()
{
FILE*fp;
charch;
if((fp=fopen("e:
\\data.txt","r+"))==NULL)
{
printf("cannotopenthefile!
");
exit(0);
}
ch=fgetc(fp);
while(ch!
=EOF)
{
putchar(ch);
ch=fgetc(fp);
}
fclose(fp);
printf("\n");
}
voidadd_1()
{
FILE*fp;
if((fp=fopen("e:
\\data.txt","a"))==NULL)
{
printf("文件不能打开/n");
exit(0);
}
else
{
inti;intnum;
printf("输入所要输入数据的数目=");
scanf("%d",&num);
for(i=2;i{
printf("编号:
");
scanf("%d",&P[i].a);
printf("姓名:
");
scanf("%s",P[i].ming);
printf("项目:
");
scanf("%s",P[i].xiang);
printf("已交:
");
scanf("%d",&P[i].b);
printf("已欠:
");
scanf("%d",&P[i].c);
fprintf(fp,"%d%s%s%d%d",P[i].a,P[i].ming,P[i].xiang,P[i].b,P[i].c);
fprintf(fp,"\n");
}
fclose(fp);
}
}
voidsavein_1()
{
inti;
FILE*fp;
fp=fopen("e:
\\data.txt","r");
for(i=0;i<3;i++)
fscanf(fp,"%d%s%s%d%d",&P[i].a,P[i].ming,P[i].xiang,&P[i].b,&P[i].c);
fclose(fp);
}
voidrewrite_1()
{
FILE*fp;
voidsavein_1();
if((fp=fopen("e:
\\data.txt","a"))==NULL)
{
printf("文件不能打开/n");
exit(0);
}
else
{
inti=0,num;
savein_1();
printf("输入所要更改的编号[]\b\b");
scanf("%d",&num);
while(P[i].a!
=num)
i++;
printf("请输入所要的新标号\n");
scanf("%d",&P[i-1].a);
printf("请输入所要的姓名\n");
scanf("%s",P[i-1].ming);
printf("请输入所要的收费项目\n");
scanf("%s",P[i-1].xiang);
printf("请输入所欠的物业费\n");
scanf("%d",&P[i-1].b);
printf("请输入已交的物业费\n");
scanf("%d",&P[i-1].c);
fp=fopen("e:
\\data.txt","w+");
i=0;
do
{
fprintf(fp,"%d%s%s%d%d",P[i].a,P[i].ming,P[i].xiang,P[i].b,P[i].c);
i++;
}while(i<=2);
fclose(fp);
}
}
voiddelete_1()
{
FILE*fp;
voidsavein_1();
intnum,i=0;
printf("请输入所要删除人的编号:
[]\b\b");
scanf("%d",&num);
savein_1();
while(P[i].a!
=num)
i++;
for(i;i<=5;i++)
{
P[i].a=P[i+1].a;
strcpy(P[i].ming,P[i+1].ming);
strcpy(P[i].xiang,P[i+1].xiang);
P[i].b=P[i+1].b;
P[i].c=P[i+1].c;
}
fp=fopen("e:
\\data.txt","w");
i=0;
do
{
fprintf(fp,"%d%s%s%d%d",P[i].a,P[i].ming,P[i].xiang,P[i].b,P[i].c);
i++;
}while(i<=5);
fclose(fp);
}
voidseek_1()
{
voidsavein_1();
intnum,i=0;
printf("请输入所要查找的人的编号:
[]\b\b");
scanf("%d",&num);
savein_1();
while(i!
=num)
i++;
printf("%d%s%s%d%d",P[i-1].a,P[i-1].ming,P[i-1].xiang,P[i-1].b,P[i-1].c);
}
voidmenu_3()
{
voidscan_2();
voidadd_2();
voidrewrite_1();
voiddelete_2();
inta;
system("cls");
printf("\t*欢迎使用物业收费管理系统*\n");
printf("\t------------------(⊙_⊙)----------------------\n");
printf("\t--\n");
printf("\t--\n");
printf("\t-1.浏览小区收费项目-\n");
printf("\t-2.增加小区收费数目-\n");
printf("\t-3.更改小区收费项目-\n");
printf("\t-4.删除小区收费项目-\n");
printf("\t--\n");
printf("\t--\n");
printf("\t-------------------(⊙o⊙)----------------------\n");
printf("\t-END-\n");
printf("请输入所要选择内容的序号(1-3):
[]\b\b");
scanf("%d",&a);
switch(a)
{
case1:
scan_2();break;
case2:
add_2();break;
case3:
rewrite_1();break;
case4:
delete_2();break;
default:
exit(0);
}
}
voidscan_2()
{
FILE*fp;
charch;
if((fp=fopen("e:
\\data.txt","r+"))==NULL)
{
printf("cannotopenthefile!
");
exit(0);
}
ch=fgetc(fp);
while(ch!
=EOF)
{
putchar(ch);
ch=fgetc(fp);
}
fclose(fp);
}
voidadd_2()
{
inti,num;
FILE*fp;
if((fp=fopen("e:
\\data.txt","a"))==NULL)
{
printf("文件不能打开/n");
exit(0);
}
else
{
printf("输入所要输入数据的数目=");
scanf("%d",&num);
for(i=3;i{
printf("编号:
");
scanf("%d",&P[i].a);
printf("姓名:
");
scanf("%s",&P[i].ming);
printf("项目:
");
scanf("%s",&P[i].xiang);
printf("已交:
");
scanf("%d",&P[i].b);
printf("已欠:
");
scanf("%d",&P[i].c);
fprintf(fp,"%d%s%s%d%d",P[i].a,P[i].ming,P[i].xiang,P[i].b,P[i].c);
}
fclose(fp);
printf("\n");
}
}
/*voidrewrite_2()
{
FILE*fp;
if((fp=fopen("e:
\\data.txt","w"))==NULL)
{
printf("文件不能打开/n");
exit(0);
}
else
{inti,num;
printf("输入所要输入数据的数目=");
scanf("%d",&num);
for(i=3;i{
printf("项目:
");
scanf("%s",&P[i].xiang);
fprintf(fp,"%s",P[i].xiang);
fprintf(fp,"\n");
}
fclose(fp);
}
}
*/
voiddelete_2(intd)
{
FILE*fp;
voidsavein_1();
intnum,i=0;
printf("请输入所要删除人的编号:
[]\b\b");
scanf("%d",&num);
savein_1();
while(i!
=num)
i++;
for(i=num;;i++)
{
P[i].a=P[i+1].a;
strcpy(P[i].ming,P[i+1].ming);
strcpy(P[i].xiang,P[i+1].xiang);
P[i].b=P[i+1].b;
P[i].b=P[i+1].b;
}
fp=fopen("e:
\\data.txt","a");
do
{
i=0;
fprintf(fp,"%d%s%s%d%d",P[i].a,P[i].ming,P[i].xiang,P[i].b,P[i].c);
i++;
}while(i<=5);
fclose(fp);
}
voidbiao_1()
{
FILE*fp;
charch;
if((fp=fopen("e:
\\data.txt","r+"))==NULL)
{
printf("cannotopenthefile!
");
exit(0);
}
ch=fgetc(fp);
while(ch!
=EOF)
{
putchar(ch);
ch=fgetc(fp);
}
fclose(fp);
printf("\n");
}