小区物业代码.docx
《小区物业代码.docx》由会员分享,可在线阅读,更多相关《小区物业代码.docx(21页珍藏版)》请在冰豆网上搜索。
小区物业代码
#include
#include
#include
#include
#include
#include
usingnamespacestd;
constintN=20;
structfangxingziliao//房型资料
{
stringnumberofhouse;
stringhouse;
intmianji;
};
structzhuhuziliao//住户资料
{
stringnumberofuser;
stringnameofuser;
stringtel;
stringaddress;
intyufu;
intqianfei;
};
structcheweiguanli//住户停车车位管理
{
intnumberofcar;
};
structshoufeiguanli//住户物业收费管理
{
stringnameofmoney;
intmoney;
stringdanwei;
intzhouqi;
};
structwuye//小区物业管理系统
{
structfangxingziliaohouse;
structzhuhuziliaouser;
structcheweiguanlicar;
structshoufeiguanlimoney;
};
voidlock()//由于密码不正确退出程序
{
cout<<"\n\n\t\t对不起,由于您操作有误,不允许进入!
"<exit(0);
}
voidenter(stringcode)//登陆界面
{
charco;
inti=0,t=1,j=0,a;
vectorch;
cout<<"\n\n\t\t您有3次机会,请输入密码:
";//有三次机会
for(;j<3&&t!
=0;j++)
{
ch.clear();
a=0;
while((co=getch())!
='\r')//输入密码
{
if(co==8)
{
cout<<"\b\b";
continue;
}
cout<<"*";
ch.push_back(co);
}
for(i=0;i{
if(ch[i]!
=code[i])
{
system("cls");
if(j==2)
lock();
cout<<"\n\n\t\t密码错误,您还有"<<2-j<<"次机会,请重新输入:
";
t=0;
continue;
}
else
a++;
}
if(a==code.length())
return;
t=1;
}
}
voidWelcome()//启动界面
{
cout<<"\t1:
录入物业管理信息"<cout<<"\t2:
计算小区的房型种类"<cout<<"\t3:
查询住户的欠费状况"<cout<<"\t4:
显示住户投诉报表"<cout<<"\t5:
显示住户报修报表"<cout<<"\t6:
按照欠费金额进行排序,显示用户相关信息"<cout<<"\t7:
查找住户的车位信息"<cout<<"\t8:
显示所有用户信息"<cout<<"\t9:
将小区的所有相关信息内容存为文件"<cout<<"\t#:
修改密码"<cout<<"\t0:
退出"<}
voidshowhouse(structwuyem[N],intn)//显示房型资料
{
cout<<"\n\n房型编号住户姓名房型\t建筑面积"<for(inti=0;i{
cout<}
cout<}
voidshowuser(structwuyem[N],intn)//显示住户资料
{
cout<<"\n\n住户编号住户姓名联系电话联系地址预付金额欠费金额"<for(inti=0;i{
cout<}
cout<}
voidshowcar(structwuyem[N],intn)//显示车位资料
{
cout<<"\n\n住户姓名车位编号"<for(inti=0;i{
cout<}
cout<}
voidshowmoney(structwuyem[N],intn)//显示收费资料
{
cout<<"\n\n住户姓名收费名称收费金额收费单位收费周期(月)"<for(inti=0;i{
cout<}
cout<}
voidshow(structwuyem[N],intn,stringnameofhouse,inttotalnumber)//显示用户相关信息
{
intx,t=1;
cout<<"小区名称\t楼宇总数"<cout<do
{
cout<<"\t1:
房型资料"<cout<<"\t2:
住户资料"<cout<<"\t3:
住户停车车位管理"<cout<<"\t4:
住户物业收费管理"<cout<<"\t0:
返回上层"<cout<<"请选择:
";
cin>>x;
switch(x)
{
case1:
system("cls");
showhouse(m,n);
break;
case2:
system("cls");
showuser(m,n);
break;
case3:
system("cls");
showcar(m,n);
break;
case4:
system("cls");
showmoney(m,n);
break;
case0:
system("cls");
cout<<"\n\n\n\n";
Welcome();
t=0;
break;
default:
system("cls");
cout<<"\n\n";
cout<<"输入错误,请重新输入"<continue;
}
}
while(t);
}
voidfangxingzhonglei(structwuyem[N],intn)//计算房型种类
{
inta[N],i,j,num=0;
for(i=0;ia[i]=-1;
for(i=0;i{
for(j=i+1;j{
if(m[i].house.house==m[j].house.house)
{
a[j]=i;
}
}
}
for(i=0;i{
if(a[i]==-1)
num++;
}
system("cls");
cout<<"\n\n\n\n\t\t共有"<}
voidfindqianfei(structwuyem[N],intn)//查询住户的欠费状况
{
cout<<"请输入用户姓名:
";
stringname;
cin>>name;
for(inti=0;i{
if(m[i].user.nameofuser==name)
{
system("cls");
cout<<"\n\n\t\t"<return;
}
}
system("cls");
cout<<"\n\n\t\t未找到"<}
voidfindcar(structwuyem[N],intn)//查找住户的车位信息
{
cout<<"请输入用户姓名:
";
stringname;
cin>>name;
for(inti=0;i{
if(m[i].user.nameofuser==name)
{
system("cls");
cout<<"\n\n\t\t"<"<return;
}
}
system("cls");
cout<<"\n\n\t\t未找到"<}
voidswap(structwuye*a,structwuye*b)//交换数据
{
structwuyem;
m=*a;
*a=*b;
*b=m;
}
voidsort(structwuyem[N],intn)//按歉费金额对用户进行排序
{
cout<<"已按欠费金额排序"<inti;
for(i=0;ifor(intj=i+1;jif(m[i].user.qianfeiswap(m[i],m[j]);
cout<}
voidtousu()//显示投诉文件
{
fstreamts("tousu.txt");
if(!
ts)
{
cout<<"cannotbeopened!
"<}
cout<<"投诉文件:
"<<'\n'<charch;
while(ts.get(ch))
cout<cout<Welcome();
}
voidbaoxiu()//显示保修文件
{
fstreambx("baoxiu.txt");
if(!
bx)
{
cout<<"cannotbeopened!
"<}
cout<<"报修文件:
"<<'\n'<charch;
while(bx.get(ch))
cout<cout<Welcome();
}
stringchangecode(string*co)//修改密码
{
fstreammm;
mm.open("code.txt",ios:
:
out);
charch;
vectorcode,code1;
system("cls");
do
{
code.clear();
code1.clear();
cout<<"\n\n\t\t请输入新密码:
";
while((ch=getch())!
='\r')//输入第一遍密码
{
if(ch==8)
{
cout<<"\b\b";
continue;
}
cout<<"*";
code.push_back(ch);
}
system("cls");
cout<<"\n\n\t\t请确认新密码:
";
while((ch=getch())!
='\r')//输入第二遍密码
{
if(ch==8)
{
cout<<"\b\b";
continue;
}
cout<<"*";
code1.push_back(ch);
}
if(code==code1)//比较两次输入的密码是否相同
{
*co="";
for(inti=0;code[i];i++)
*co+=code[i];
mm<<*co;
mm.close();
system("cls");
cout<<"\n\n\t\t密码已修改,请继续选择"<Welcome();
return*co;
}
else
{
system("cls");
cout<<"\n\n\t\t两次输入不一致,请重新修改"<continue;
}
}
while
(1);
}
voidwritefile(structwuyem[N],intn,char*ss)//将用户信息存入文件
{
ofstreamofile(ss);
if(!
ofile)
{
cout<<"cann'tbeopenned";
return;
}
ofile<<"房型编号房型建筑面积住户编号住户姓名联系电话联系地址预付金额欠费金额车位编号收费名称收费金额收费单位收费周期"<for(inti=0;i{
ofile<&&ofile<<""<&&ofile<<""<&&ofile<<""<}
ofile.close();
cout<<"已保存为xxx.txt"<}
intmain()//主函数
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),688);//设置文字背景颜色
inti=0,num=0;
charx;
inttotalnumber;
stringnameofhouse;
stringcode;
fstreammm("code.txt");
charch;
mm>>code;
mm.close();
enter(code);//需要输入密码以进入系统
system("cls");
cout<<"<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n";
cout<<(ch=1)<<"\t\t\t\t\t\t\t\t\t"<cout<\t\t\t"<cout<cout<张建军"<cout<cout<<">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n\n";
charyn='y';
fstreamifile("user.txt");
if(!
ifile)
{
cout<<"cannotbeopened!
"<}
else
{
charch[100000];
ifile>>ch;
cout<}
structwuyem[N];
cout<<"请先录入用户信息"<Welcome();//进入主目录
do
{
cout<<"请选择:
";
cin>>x;
switch(x)
{
case'1':
//读取指定个数的用户资料
system("cls");
ifile>>nameofhouse>>totalnumber;
cout<<"\n\n\n\n\t\t请确定总住户人数:
";
cin>>num;
system("cls");
for(i=0;i{
ifile>>m[i].house.numberofhouse>>m[i].house.house>>m[i].house.mianji
&&ifile>>m[i].user.numberofuser>>m[i].user.nameofuser>>m[i].user.tel>>m[i].user.address>>m[i].user.yufu>>m[i].user.qianfei
&&ifile>>m[i].car.numberofcar
&&ifile>>m[i].money.nameofmoney>>m[i].money.money>>m[i].money.danwei>>m[i].money.zhouqi;
}
cout<<"\n\n\n\n\t\t已录入"<"<Welcome();
break;
case'2':
//计算房型种类
system("cls");
cout<<"\n\n\t\t未完成\n";
fangxingzhonglei(m,num);
Welcome();
break;
case'3':
//查询用户欠费情况
do
{
system("cls");
cout<<"\n\n\t\t";
findqianfei(m,num);
cout<<"\t\t继续?
(y/n)";
cin>>yn;
}
while(yn=='y'||yn=='Y');
system("cls");
cout<<"\n\n\n\n";
Welcome();
break;
case'4':
//显示投诉文件
system("cls");
cout<<"\n\n\t\t";
tousu();
break;
case'5':
//显示报修文件
system("cls");
cout<<"\n\n\t\t";
baoxiu();
break;
case'6':
//按欠费金额进行排序,并显示用户相关信息
system("cls");
cout<<"\n\n\t\t";
sort(m,num);
showuser(m,num);
system("pause");
system("cls");
cout<<"\n\n\n\n";
Welcome();
break;
case'7':
//查询用户车位信息
do
{
system("cls");
cout<<"\n\n\t\t";
findcar(m,num);
cout<<"\t\t继续?
(y/n)";
cin>>yn;
}
while(yn=='y'||yn=='Y');
system("cls");
cout<<"\n\n\n\n";
Welcome();
break;
case'8':
//显示用户各种信息
system("cls");
cout<<"\n\n";
show(m,num,nameofhouse,totalnumber);
system("cls");
cout<<"\n\n\n\n";
Welcome();
break;
case'9':
//将所有数据保存在xxx.txt
system("cls");
cout<<"\n\n\t\t";
writefile(m,num,"xxx.txt");
Welcome();
break;
case'#':
//修改密码
system("cls");
cout<<"\n\n\t\t";
changecode(&code);
break;
case'0':
//退出
system("cls");
cout<<"\n\n\t\t感谢使用小区物业管理系统"<!
!
!
"<