个人财务管理系统C++代码

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

#include
#include
#include
#include
#include
#include
#include
using namespace std;

class Time //时间类
{
int month;
int day;
int year;
public:
void GetTime(int n,int m,int d){year=n,month=m;day=d;}
void CheckTime();
}Time1;

void Time::CheckTime() //时间错误检查
{
if(month>12 ||month<1)
{
MessageBox(NULL,"月份输入错误","错误!",MB_OK);
exit(0);
}
else
{
if(month==1||month==3 ||month==5||month==7||month==8||month==10||month==12)
{
if(day>31 || day<1)
{
MessageBox(NULL,"日期输入错误","错误!",MB_OK);
exit(0);
}
}
else
{
if(month==4||month==6 ||month==9||month==11)
if(day<1||day>30)
{
MessageBox(NULL,"日期输入错误","错误!",MB_OK);
exit(0);
}
}
}
if(month==2)
if(day>29||day<1)
{
MessageBox(NULL,"日期输入错误","错误!",MB_OK);
exit(0);
}
}













typedef class CFinance:public Time
{
public:
int year,month,day;
double Income,Output;
CFinance *next;
}Infor;


void SearchIncomeInfor(Infor *head);
void SearchOutputInfor(Infor *head);
int menu_select();
void SearchDateInfor(Infor *head);


Infor *Inforinitlist() //创建信息空链表
{
Infor *head;
head=(Infor*)malloc(sizeof(Infor));
head->next =NULL;
return head;
}


int menu_select()
{
char *m[6]={"1.录入财务信息","2.浏览财务信息","3.查询财务信息","4.统计财务信息",
"5.保存财务信息","6.退出财务系统"};
char *c;
c=new char[50];
do
{
system("cls");
cout<<"\t\t----------财务管理系统总菜单----------------"<for(int i=0;i<6;i++)
cout<<"\t\t\t"<cout<<"Choice"<cin>>c;
}
while(c[0]<'1'||c[0]>'6'||c[1]);
return(c[0]-'0');
}




void SaveToFile(Infor *head)
{
fstream FInfor("FInfor.dat",ios::out | ios::binary);
if(!FInfor)
{
cout<<"文件打开失败!";
//exit(0);
}
Infor *p;
p=head->next;
while(p!=NULL)
{
FInfor<<"\t年份:"<year<FInfor<<"\t月份:"<month<FInfor<<"\t日期:"<day<FInfor<<"\t收入情况:"<Income<FInfor<<"\t支出情况:"<Output<FInfor<<"\t\t\t\t\t\t";
p=p->next;
}
// 通常notepad 都会放在C盘下面的Windows 目录下,


FInfor.close();
system("C:/WINDOWS/NOTEPAD FInfor.dat");
}












void InputFinanceInfor(Infor *head)
{
system("cls");
cout<<"\t\t------------------输入财务信息---------------------"<Infor *p1,*p2,*p3;
p3=head;
if(NULL!=p3->next)
{
p3=p3->next;

}
p2=p3;
char input,*in;
in=&input;
do
{
p1=(Infor*)malloc(sizeof(Infor));
cout<<"\t\t\t年份[int]: ";
cin>>p1-

>year;
cout<cin>>p1->month;
cout<cin>>p1->day;
cout<cin>>p1->Income;
cout<cin>>p1->Output;
p2->next=p1;
p2=p1;
cout<cin>>*in;
system("pause");
}while(toupper(input)!='N');
p2->next=NULL;
}

void ListFinanceInfor(Infor *head)
{
Infor *p;
p=head->next;
if(p!=NULL)
{
system("cls");
cout<while(p!=NULL)
{
cout<<"\t\t-------------------------------------------"<cout<year<cout<month<cout<day<cout<<"\t\t收入情况:"<Income<cout<<"\t\t支出情况:"<Output<cout<<"\t\t=================================="<p=p->next;
}
}

}

//查询总菜单
void SearchMenu(Infor *head)
{
Infor *p;
p=head->next;
int Ch;
system("cls");
cout<cout<<"=========1.支出查询========="<cout<<"=========2.收入查询========="<cout<<"=========3.日期查询========="<cout<<"=========4.返回上层========="<cout<<"****************************"<cout<<"Option:";
cin>>Ch;
switch (Ch)
{
case 1:
SearchOutputInfor(p);
system("pause");
break;
case 2:
SearchIncomeInfor(p);
system("pause");
break;
case 3:
SearchDateInfor(p);
system("pause");
break;
case 4:
system("cls");
return;
default:
break;
}
}


void SearchOutputInfor(Infor *head)
{
Infor *p;
p=head;
system("cls");
cout<while(p!=NULL)
{
if(0!=p->Output)
{
cout<year<cout<month<cout<day<cout<Output<cout<<"\t\t ---------------------------------------"<}
p=p->next;
}
}

void SearchIncomeInfor(Infor *head)
{
Infor *p;
p=head;
system("cls");
cout<while(p!=NULL)
{
if(0!=p->Output)
{
cout<year<cout<month<cout<day<cout<Income<cout<<"\t\t ---------------------------------------"<}
p=p->next;
}
}


void SearchDateInfor(Infor *head)
{
int x,y,z;
Infor *p;
p=head;
cout<<"请输入日期。"<cin>>x>>y>>z;
Time1.GetTime(x,y,z);
Time1.CheckTime();
cout<

"<while(x!=p->year||y!=p->month||z!=p->day)
{
if(p->next ==NULL)
{
cout<<"未找到记录!"<cout<<"\t\t----------------------------------------"<return;
}

p=p->next;
}
system("cls");
cout<year<cout<month<cout<day<cout<Income<cout<Output<cout<<"\t\t ---------------------------------------"<}

void CalculateMonthInfor(Infor *head)
{
int x,y;
Infor *p;
p=head;
system("cls");
cout<cout<<"输入年份,月份!"<cin>>x>>y;
while(p!=NULL)
{
if(x==p->year&&y==p->month)
{
cout<year<cout<month<cout<day<cout<Output<cout<Income<cout<<"\t\t ---------------------------------------"<}
p=p->next;
}
}





void CalculateYearInfor (Infor *head)
{
int x;
Infor *p;
p=head;
system("cls");
cout<cout<<"输入年份!"<cin>>x;
while(p!=NULL)
{
if(x==p->year)
{
cout<year<cout<month<cout<day<cout<Output<cout<Income<cout<<"\t\t ---------------------------------------"<}
p=p->next;
}
}




void CalculateDayInfor (Infor *head)
{
int x,y,z;
Infor *p;
p=head;
system("cls");
cout<cout<<"输入年份,月份,日期!"<cin>>x>>y>>z;
while(p!=NULL)
{
if(x==p->year&&y==p->month&&z==p->day)
{
cout<year<cout<month<cout<day<cout<Output<cout<Income<cout<<"\t\t ---------------------------------------"<}
p=p->next;
}
}
























void CalculateInfor(Infor *head)
{
Infor *p;
p=head->next;
int Ch;
system("cls");
cout<cout<<"=========1.按年统计========="<cout<<"=========2.按月统计========="<cout<<"=========3.按日统计========="<cout<<"=========4.返回上层========="<cout<<"****************************"<cout<<"Option:";
cin>>Ch;
switch (Ch)
{
case 1:
CalculateYearInfor(p);
system("pause");
break;
case 2:
CalculateMonthInfor(p);
system(

"pause");
break;
case 3:
CalculateDayInfor(p);
system("pause");
break;
case 4:
system("cls");
return;
default:
break;
}
}















void main()
{
system("color 3D");
Infor *st,*head=NULL;
st=Inforinitlist();
int choice=0;
while(choice!=6)
{
choice=menu_select();
switch(choice)
{
case 1:
InputFinanceInfor(st);system("pause");
break;
case 2:
ListFinanceInfor(st);system("pause");
case 3:
SearchMenu(st);system("pause");
break;
case 4:
CalculateInfor(st);system("pause");
break;
case 5:
system("cls");SaveToFile(st);
break;
case 6:
exit(0);
break;
default:;
}
}
}
































相关文档
最新文档