家庭财务管理系统源代码

合集下载

家庭财务管理系统课程设计的原代码

家庭财务管理系统课程设计的原代码

1、frm_borrowgo.frmDim Mydb As New ADODB.RecordsetDim Mydb1 As New ADODB.RecordsetDim Str_text As StringDim strflag As StringPrivate Sub cmd_add_Click()txt_man。

Locked = Falsetxt_way。

Locked = Falsetxt_money。

Locked = FalseCombo1。

Locked = FalseCheck1.Enabled = TrueDTPicker1。

Enabled = Truetxt_man。

Text = ”"txt_way。

Text = ””txt_money。

Text = ”"Combo1.Text = "”strflag = "添加”Cmdsave。

Enabled = TrueEnd SubPrivate Sub cmd_close_Click()Unload MeEnd SubPrivate Sub cmd_del_Click()Dim A As BooleanA = MsgBox("是否真的要删除这条记录?", vbOKCancel + 32 + 256, "删除")If A = True ThenExeCutesql "delete from 借出where 得款人=’”&txt_man。

Text & ”’", Str_textMsgBox ”记录已删除!”,, "删除"If Mydb。

RecordCount 〉0 ThenMydb.MoveNextIf Mydb.EOF Then Mydb.MoveLastCall DbCall BangdingLabel7.Caption = Mydb。

C语言财务管理系统(源代码)教案.doc

C语言财务管理系统(源代码)教案.doc
void initialize();
void save_to_file();
void clear_data();
fi_data *get_last();
fi_data *get_previous(fi_data *p);
void input_info(fi_info *info);
void show_info(fi_data *p[],int count);
fflush(stdin);
getchar();
}
else
{
menu_fun[selected]();
}
selected=0;
}
}
void add_income()
{
fi_data *p=(fi_data *)malloc(sizeof(fi_data));
memset(p,0,sizeof(fi_data));
void delete_payout();
void update_payout();
void count_total();
void quit();
void search_data(fi_type type);
void delete_data(fi_type type);
void update_data(fi_type type);
input_info(&(p->info));
p->info.type=payout;
if(head==NULL)
{
head=p;
}
else
{
get_last(head)->next=p;
}
}
void search_payout()

c语言编写-家庭财务管理系统

c语言编写-家庭财务管理系统
s[recNumber].in=Tm.in;
strcpy(s[recNumber].intime,Tm.intime);
s[recNumber].out=Tm.out;
strcpy(s[recNumber].outtime,Tm.outtime);
if (fp==NULL) /*判断是否打开成功*/
{
printf("\n打开文件%s失败!按任意键结束!\n",Da);
exit(0);
}
while(fread(&Tm,sizeof(money),1,fp)!=(int)NULL) /*从文件中读取数据,是否读取成功*/
fp=fopen(Da,"ab+");
if (fp==NULL) /*判断文件是否成功打开*/
{
printf("\n 打开文件 %s 失败!按任意键结束!\n",Da);
exit(0);
}
while(fread(&ch,sizeof(money),1,fp)!=(int)NULL) /*从文件中读取数据并判断是否成功*/
scanf("%f",&Tm.in);
printf("输入收入时间:");
scanf("%s",Tm.intime);
printf("输入成员支出:");
scanf("%f",&Tm.out);
printf("输入支出时间:");
{ printf("###############################################\n");

家庭支出管理系统详细代码

家庭支出管理系统详细代码

先在D盘先建立“密码.txt(在里面写入初始六位密码)”;“支出信息。

txt”即可。

代码:#include <stdio.h>#include <stdlib.h>#include <ctype.h>#include <string.h>#include <conio.h>#include <malloc.h>typedef struct //定义结构体{char type[20];//消费类型float Getsum;//消费金额char place[20];//消费地点int time;//消费时间}family;family fam[80];int menu()//显示该系统所具备的功能{char c;do{system("cls");//清屏printf("\t\t***************************\n");printf("\t\t**********菜单系统*********\n");printf("\t\t|1.输入消费信息|\n");printf("\t\t|2.计算消费总和|\n");printf("\t\t|3.显示消费情况|\n");printf("\t\t|4.对同种类型消费进行排序并显示|\n");printf("\t\t|5.消费情况分析|\n");printf("\t\t|6.保存数据|\n");printf("\t\t|0.退出系统|\n");printf("\t\t***************************\n");printf("\t\t***************************\n");printf("\t\t\t请对应选择所需选项(0-6):");c=getchar();}while(c<'0'||c>'6');return(c-'0');}void password()//密码验证和密码修改{int m;printf("\t\t****************登陆界面****************\n");printf("\t\t****************************************\n");printf("\t\t**\t\t1.密码修改**\n");printf("\t\t**\t\t2.登陆**\n");printf("\t\t****************************************\n");printf("\t\t****************************************\n");printf("\t\t\t请输入您所要的选项(1,2):");scanf("%d",&m);getchar();switch(m){case 1://密码修改{int i,j;char a[7],b[7],c[7],d[7];FILE *fp1; FILE *fp2;fp1=fopen("D:\\密码.txt","r");if(!fp1){printf("file cannot be opened");exit(1);}for(i=0;!feof(fp1);i++) //feof判断文件是否结束{a[i]=fgetc(fp1);}fclose(fp1);printf("\t\t\t请输入原密码:");for(j=0;j<7;j++){scanf("%c",b+j);//判断数组b是否和原密码是否相等if(b[j]>='0'&&b[j]<='9'||b[j]>='a'&&b[j]<='z'||b[j]>='A'&&b[j]<='Z')putchar('*');}if(a[0]==b[0]&&a[1]==b[1]&&a[2]==b[2]&&a[3]==b[3]&&a[4]==b[4]&&a[5]==b[5]) {do{printf("\t\t\t请设置您的新密码: ");for(j=0;j<7;j++){scanf("%c",c+j);if(c[j]>='0'&&c[j]<='9'||c[j]>='a'&&c[j]<='z'||c[j]>='A'&&c[j]<='Z')putchar('*');}printf("\t\t\t请确认您的新密码: ");for(j=0;j<7;j++){scanf("%c",d+j);if(d[j]>='0'&&d[j]<='9'||d[j]>='a'&&d[j]<='z'||d[j]>='A'&&d[j]<='Z')putchar('*');}}while(!(c[0]==d[0]&&c[1]==d[1]&&c[2]==d[2]&&c[3]==d[3]&&c[4]==d[4]&&c[5]==d[5]));//利用do while语句进行判定两次密码是否成功!fp2=fopen("D:\\密码.txt","w+");if(!fp2){printf("the file cannot be opened!");exit(1);}i=0;while (i<6){fprintf(fp2,"%c",c[i]);i++;}fclose(fp2);printf("\t\t\t密码修改成功!\n");}else{printf("\t\t\t密码错误\n");exit(0);}}case 2://密码验证{char e[7],f[7];int n=0;int i,j;FILE *fp1;fp1=fopen("D:\\密码.txt","r");if(!fp1){printf("the file cannot be opened!");exit(1);}for(i=0;!feof(fp1);i++){ e[i]=fgetc(fp1); }do{printf("\t\t\t请输入六位数密码:");for(j=0;j<7;j++){scanf("%c",f+j);if(f[j]>='0'&&f[j]<='9'||f[j]>='a'&&f[j]<='z'||f[j]>='A'&&f[j]<='Z')putchar('*');}if(!(e[0]==f[0]&&e[1]==f[1]&&e[2]==f[2]&&e[3]==f[3]&&e[4]==f[4]&&e[5]==f[5])){printf("\n密码错误!请重新输入:\n");n++;}if (n>3){printf("error\n");exit(0);}}while(!(e[0]==f[0]&&e[1]==f[1]&&e[2]==f[2]&&e[3]==f[3]&&e[4]==f[4]&&e[5]==f[5]));//利用do~while语句进行判定密码是否错误!printf("\n\t\t\t欢迎使用!\n");}}}int Input(family sum[],int n)//输入消费信息{int i=0;char sign='y',x[10];while(sign!='n'&&sign!='N'){printf("\t\t\t种类:");scanf("\t\t\t%s",sum[n+i].type);printf("\t\t\t支出(大于0):");scanf("\t\t\t%f",&sum[n+i].Getsum);printf("\t\t\t地点:");scanf("\t\t\t%s",sum[n+i].place);printf("\t\t\t时间(0-31):");scanf("\t\t\t%d",&sum[n+i].time);if(sum[n+i].time<1||sum[n+i].time>31)return false;gets(x);printf("\t\t\t需要再次输入吗?(y/n)");scanf("\t\t\t%c",&sign);//判断是否需要重新输入i++;}}void Getsum(family sum[], int n) //计算消费总金额{float getsum=0;int i=0;for(i=0;i<n;i++){getsum+=sum[i].Getsum;}printf("\t\t\t%f\n",getsum);}void Showitems(family sum[],int n)//输出所输入的消费信息{int i;printf("\t\t\t--------------------------------------\n");printf("\t\t\t种类支出地点时间\n");printf("\t\t\t--------------------------------------\n");for(i=1;i<n+1;i++){printf("\t\t\t%-8s %-12f %-8s %-10d\n",sum[i-1].type,sum[i-1].Getsum,sum[i-1].place,sum[i-1].ti me);if(i>1&&i%10==0)//这边为什么会有i%10==0(保证输入多次信息的时候可以一次性显示) {printf("\t\t\t----------------\n");printf("\t\t\t");printf("\t\t\t----------------\n");}}printf("\t\t\t");system("pause");}void sort(family sum[],int n)//对消费信息进行归类和选择法排序升序排名{int i,j;family temp;FILE *fp;fp=fopen("D:\\支出信息.txt","a+");if(fp==NULL){printf("\t\t\tthe file cannot be opened!\n");exit(1);}for(i=0;i<n-1;i++)for(j=i+1;j<n;j++){if(strcmp(sum[i].type,sum[j].type)==1){temp=sum[j];sum[i]=temp;sum[j]=sum[i]; }elseif(strcmp(sum[j].type,sum[i].type)==0){if(sum[i].Getsum>sum[j].Getsum){temp=sum[j];sum[j]=sum[i];sum[i]=temp;}}}}fclose(fp);}//排序后是写入文件的写入数组解决不了void Analyseitems(family sum[],int n) //求各种消费类型的金额占总金额的百分比//在解决相同type的问题上可以利用数组去存储字符串,但系统一直崩溃。

家庭财务评估系统-毕业设计-源代码

家庭财务评估系统-毕业设计-源代码

附录1家庭财务评估系统源代码指导教师:王金凤组员:刘杰王剑锋张恒琳✓应用程序入口XAML:<Application x:Class="Finance.App"xmlns="/winfx/2006/xaml/presentation"xmlns:x="/winfx/2006/xaml"StartupUri="Login.xaml"ShutdownMode="OnLastWindowClose"><!--StartupUri="Login.xaml"--><Application.Resources><ResourceDictionary><ResourceDictionary.MergedDictionaries><ResourceDictionary Source="/Resource/Stylesource.xaml"/></ResourceDictionary.MergedDictionaries></ResourceDictionary></Application.Resources></Application>✓资源文件代码[Stylesource.xaml]<ResourceDictionary xmlns="/winfx/2006/xaml/presentation" xmlns:x="/winfx/2006/xaml"><Style x:Key="L_tstyle"><!--登录窗口文本框的样式--><Setter Property="Control.BorderBrush" Value="LightGray"/><Setter Property="Control.BorderThickness" Value="1"/><Style.Triggers><Trigger Property="Control.IsMouseOver" Value="True"><Setter Property="Control.BorderBrush" Value="LightBlue"/><Setter Property="Control.BorderThickness" Value="2"/></Trigger><Trigger Property="Control.IsFocused" Value="True"><Setter Property="Control.BorderBrush" Value="LightGray"/><Setter Property="Control.BorderThickness" Value="1.1"/></Trigger></Style.Triggers></Style><Style x:Key="R_tstyle" TargetType="PasswordBox"><!--注册窗口文本框的样式--><Setter Property="Control.BorderBrush" Value="LightBlue"/><Setter Property="Control.BorderThickness" Value="1.1"/><Style.Triggers><Trigger Property="Control.IsFocused" Value="True"><Setter Property="Control.BorderBrush" Value="LightGray"/><Setter Property="Control.BorderThickness" Value="1.1"/></Trigger><Trigger Property="Control.IsMouseOver" Value="true"><Setter Property="Control.BorderBrush" Value="LightGray"/><Setter Property="Control.BorderThickness" Value="1.1"/></Trigger></Style.Triggers></Style><Style x:Key="contentCenterStyle" TargetType="{x:Type TextBlock}"> <Setter Property="HorizontalAlignment" Value="Center" /><Setter Property="VerticalAlignment" Value="Center"/></Style><Style TargetType="DataGridCell"><Setter Property="FocusVisualStyle" Value="{x:Null}"/><Style.Triggers><Trigger Property="IsSelected" Value="True"><Setter Property="BorderThickness" Value="1"/><Setter Property="BorderBrush" Value="White"/><Setter Property="Foreground" Value="Black"/><Setter Property="TextBlock.FontSize" Value="20"/><Setter Property="Background" Value="AliceBlue"/></Trigger><Trigger Property="IsMouseOver" Value="true"><Setter Property="TextBlock.FontSize" Value="20"/><Setter Property="Background" Value="White"/><Setter Property="Foreground" Value="LightGray"/></Trigger></Style.Triggers></Style></ResourceDictionary>注册界面UI-Xaml:<Windowx:Class="Finance.Regedit"xmlns="/winfx/2006/xaml/presentation" xmlns:x="/winfx/2006/xaml"Title="ConchNotes注册"Height="522"Width="849"WindowStyle="SingleBorderWindow"Background="LightGray"Name="frmRegedit"WindowStartupLocation="CenterScreen"ResizeMode="NoResize"Closed="frmRegedit_Closed"Icon="/Finance;component/Images/doit.ico"xmlns:local="clr-namespace:Finance.Codes" Loaded="frmRegedit_Loaded"> <Window.Resources><Style TargetType="TextBox"><Setter Property="Control.BorderThickness" Value="1.1" /><Setter Property="Control.BorderBrush" Value="LightBlue"/><Style.Triggers><Trigger Property="IsMouseOver" Value="true"><Setter Property="Control.BorderBrush" Value="LightGray"/><Setter Property="Control.BorderThickness" Value="1.1" /></Trigger></Style.Triggers></Style><Style TargetType ="Hyperlink" ><Setter Property="TextBlock.TextDecorations" Value="{x:Null}"/><Style.Triggers><Trigger Property ="IsMouseOver" Value ="True" ><Setter Property ="Foreground" Value ="Red" /><!-- 在鼠标悬停时显示下划线--><Setter Property ="TextBlock.TextDecorations" Value="{x:Null}" /></Trigger></Style.Triggers></Style></Window.Resources><Grid><Grid.RowDefinitions><RowDefinition Height="400"/><RowDefinition Height="83*" /></Grid.RowDefinitions><Border BorderBrush="White" BorderThickness="1" Name="border1" Background="White" CornerRadius="10" Margin="20,10,20,0"><Grid><Grid.ColumnDefinitions><ColumnDefinition Width="366"/><ColumnDefinition Width="419*" /></Grid.ColumnDefinitions><StackPanel Grid.Column="0" Grid.Row="0"><TextBlock Text="您很快就拥有完美的理财能力!" FontSize="17" Margin="15,30,15,20" FontFamily="黑体"/><TextBlock TextWrapping="Wrap" Margin="15,0,0,0" FontFamily="宋体" FontSize="14"Foreground="#FF6F6C6C">"财智"它辅助你设置预算,控制乱消费,在线理财你可以更方便的去发现自己的财务漏洞。

C语言家庭财务管理系统

C语言家庭财务管理系统
do
{
n=scanf("%s %s %f",J[i].rq,J[i].zy,&J[i].xf);
if(J[i]Biblioteka xf==0)break;/*收入和支出为0则退出*/
if(n==3)i++;
}
while(n==3);
N=i; /*修改家庭财务信息记录数*/
}
void SaveJ(char file[])/*保存家庭财务信息关系*/
{
int n,i=0;
FILE *fp=fopen("JTCWGLXT.txt","r");
char s[80];fgets(s,80,fp);
do
{
n=fscanf(fp,"%s %s %f %f",J[i].rq,J[i].zy,&J[i].xf,&J[i].ye);
if(n==4)i++;/*若读到4个数据则i加1*/
}
while(n==4);
fclose(fp);
return i;
}
void DispJ()/*显示家庭财务信息*/
{
int i;
printf("%s %8s %8.2f%8.2f\n",J[0].rq,J[0].zy,J[0].xf,J[0].ye);
for(i=1;i<N;i++)
printf("%s %8s %8.2f%8.2f\n",J[i].rq,J[i].zy,J[i].xf,J[i-1].ye+J[i].xf);
fprintf( fp,"%s %8s %8.2f%8.2f\n",J[i].rq,J[i].zy,J[i].xf,J[i-1].ye+J[i].xf);

C语言课程设计——家庭财务管理系统

C语言课程设计——家庭财务管理系统

课程安排报告之阳早格格创做课程安排题目:家庭财务管制系统教死姓名:博业:疑息工程班级:指挥西席:2018年 1月 8日1.需要分解根据家庭账务管制的需要,建坐一个“家庭账务管制系统”,以便当对付家庭凡是支进及开销举止记录战管制.该系统央供:①家庭月支进管制②家庭月开销管制③统计家庭总支进/总开销④系统提供支进/开销的增加、简略战建改功能.2. 总体安排根据以上分解,原家庭账务管制系统主要包罗:①从键盘键进家庭月支进、月开销数据;②查询月支进、月开销明细;③简略支进、开销数据;④建改支进、开销数据;⑤统计总支进/总开销;⑥退出系统.除main()函数除中,系统还定义了以下函数去真止各部分真质:①add_income():增加支进数据函数.②add_payout():增加开销数据函数.③search_data():查找数据函数.④initialize():初初化函数,读与文原数据.⑤show_info():隐现数据函数.⑥count_total():统计函数,统计总支进、总开销.⑦update_data():建改疑息函数.⑧delete_data():简略数据函数.⑨quit():退出函数.步调结构功能图如下:3.仔细安排4.尝试截止4.1 步调运止主菜单4.2 增加支进尝试4.3 查询支进明细尝试4.4 简略支进尝试4.5 建改支进尝试4.6 增加开销尝试4.7 查询开销明细尝试4.8 简略开销尝试4.9 建改开销尝试4.10 统计总支进/开销尝试4.11 退出系统尝试5.硬件支配使用证明书籍原系统采与下令止对付话办法举止支配,运止后出现主界里(如下图所示),而后依照主界里菜单指引支配即可.编写步调之前要有一个完全的思路,不克不迭写到哪里算哪里.那样很简单遗漏,连绝性也短佳.通过原次的课程安排让尔对付于数组、文献的存搁、循环结构等知识有了越发深进的明白.期视正在以去的课程安排中对付于知识的使用不妨越发的流利.代码:#include <stdio.h>#include <stdlib.h>#include <string.h>#include <conio.h>#define MAXNAME 11 //家庭成员姓名的最大少度#define MAXDETAIL 21 //注最大少度//自定义罗列典型fi_type,用去表示支进与开销typedef enum _fi_type{income=1,//支进payout =-1 //开销} fi_type;// 家庭财务疑息结构体typedef struct _fi_info{int year;int month;fi_type type;char name[9];float money;char detail[11];}fi_info;// 保存财务数据结构的结构体typedef struct _fi_data{fi_info info;struct _fi_data* next;} fi_data;fi_data *head;//财务数据的头结面 void menu();//菜单函数void add_income();void search_income();void delete_income();void update_income();void add_payout();void search_payout();void delete_payout();void update_payout();void count_total();void quit();//void search_data(fi_type type); void delete_data(fi_type type);void update_data(fi_type type); //void initialize();void save_to_file();void clear_data();fi_data *get_last();fi_data *get_previous(fi_data *p); void input_info(fi_info *info);void show_info(fi_data *p);void menu(){printf("\n");printf("\t\t ~~~~~~~~~~~~~~~~~~~~~~\n");printf("\t\t ~~~~~~~~~~~~~~~~~~~~~~\n");printf("\t\t\t 家庭财务管制系统\n");printf("\t\t ~~~~~~~~~~~~~~~~~~~~~~\n");printf("\t\t ~~~~~~~~~~~~~~~~~~~~~~\n");printf("\t\t*******************************************\ n");printf("\t\t支进管制:");printf("1.增加支进");printf(" 2.查询支进明细\n");printf("\t\t\t 3.简略支进");printf(" 4.建改支进\n");printf("\t\t*******************************************\ n");printf("\t\t开销管制:");printf("5.增加开销");printf(" 6.查询开销明细\n");printf("\t\t\t 7.简略开销");printf(" 8.建改开销\n");printf("\t\t*******************************************\ n");printf("\t\t统计:");printf("9.统计总支进/总开销\n");printf("\t\t*******************************************\ n");printf("\t\t退出:0.退出系统\n");printf("\t\t*******************************************\ n\n\n");}void main(){int selected=0;initialize();while(selected>=0&&selected<=9){system("cls");menu();printf("\t\t>请采用要举止的支配(0-9):");if(scanf("%d",&selected)!=1||selected<0||selected>9){printf("\t\t>输进有误!请采用(0-9)之间的数字!按任性键沉试");getchar();}else{switch(selected){case 0:exit(0);clear_data();break;case 1:add_income();save_to_file();break;case 2:search_income();break;case 3:delete_income();save_to_file();break;case 4:update_income();save_to_file();break;case 5:add_payout();save_to_file();break;case 6:search_payout();break;case 7:delete_payout();save_to_file();break;case 8:update_payout();save_to_file();break;case 9:count_total();break;}}}void add_income()//增加支进{fi_data *p=(fi_data *)malloc(sizeof(fi_data)); p->next=NULL;input_info(&(p->info));p->info.type=income;if(head==NULL)head=p;elseget_last()->next=p;}void add_payout()//增加开销{fi_data *p=(fi_data *)malloc(sizeof(fi_data)); p->next=NULL;input_info(&(p->info));p->info.type=payout;if(head==NULL)head=p;elseget_last()->next=p;//输进函数void input_info(fi_info *info){printf("\t\t>请输进年月(YYYY/M)");scanf("%d/%d",&(info->year),&(info->month)); printf("\t\t>请输进家庭成员姓名(最大少度为%d):",MAXNAME-1);scanf("%s",info->name);printf("\t\t>输进金额:");scanf("%f",&(info->money));printf("\t\t>请输进备注(最大少度为%d):",20); scanf("%s",info->detail);}//查找数据函数void search_data(fi_type type){int year=0;int month=0;fi_data *p=NULL;int count=0;char input=' ';while(1){printf("\t\t>请输进要查询的年月(YYYY/M)");if(scanf("%d/%d",&year,&month)!=2){printf("\t\t>输进有误\n");}else{p=head;count=0;while(p!=NULL){if((p->info.year==year)&&(p->info.month==month)&&(p->info.type==type)){show_info(p);system("PAUSE");count++;}p=p->next;}if(count==0){printf("\t\t>不找到数据\n");}printf("\t\t>继承查找其余数据?(y or n)"); input=getchar();if(input=='y'||input=='Y')continue;elsebreak;}}}//初初化函数,读与文原数据void initialize(){FILE * fp=NULL;fi_data *p=NULL;fi_data *last=NULL;int count=0;fp=fopen("data.txt","rb");if(fp==NULL)fp=fopen("data.txt","w");fclose(fp);return;}p=(fi_data*)malloc(sizeof(fi_data));memset(p,0,sizeof(fi_data));p->next=NULL;while(fread(&(p->info),sizeof(fi_info),1,fp)==1) {if(head==NULL)head=p;else{last=get_last();last->next=p;}count++;fseek(fp,count*sizeof(fi_info),SEEK_SET);p=(fi_data *)malloc(sizeof(fi_data));memset(p,0,sizeof(fi_data));p->next=NULL;free(p);p=NULL;fclose(fp);}//隐现疑息函数void show_info(fi_data *p){int i=0;printf("|\t\t|\t\t|\t\t|\t\t|\t\t|\t\t|\n");printf("|NO.\t |年/月\t\t|典型\t\t|姓名\t\t|金额\t\t|备注\t\t|\n"); printf("|%5d\t|%4d/%02d\t|%4s\t|%10s\t|%10.2f|%20s|\n",i+1, p->info.year,p->info.month,p->info.type==income?"支进":"开销",p->,p->info.money,p->info.detail);printf("|\t\t|\t\t|\t\t|\t\t|\t\t|\t\t|\n");}//统计总支进、总开销void count_total(){float total_income=0.0;float total_payout=0.0;fi_data *p=head;while(p!=NULL){if(p->info.type==income){total_income+=p->info.money;}else{total_payout+=p->info.money;}p=p->next;}printf("\t\t+\t\t+\t\t+\n");printf("\t\t|合计支进\t|合计开销\t|结余\t|\n");printf("\t\t%12.2f|%12.2f|%12.2f|\n",total_income,total_payout,t otal_income-total_payout);printf("\t\t+\t\t+\t\t+\n");printf("\t\t>按任性键返回主菜单");getchar();getchar();}//保存到文献void save_to_file(){FILE *fp=fopen("data.txt","wb" );fi_data *p=head;while(p!=NULL){fwrite(&(p->info),sizeof(fi_info),1,fp); fseek(fp,0,SEEK_END);p=p->next;}fclose(fp);}//建改疑息函数void update_data(fi_type type){ int year=0;int month=0;fi_data *p=NULL;fi_data *pre=NULL;char input;int count=0;int i=0;while(1){ printf("\t\t>请输进要查询的年月(YYYY/M)");if(scanf("%d/%d",&year,&month)!=2){printf("\t\t>输进有误\n");}else{p=head;count=0;while(p!=NULL){if((p->info.year==year)&&(p->info.month==month)&&(p->info.type==type)){count++;show_info(p);input_info(&(p->info));printf("\t\t建改乐成\n");p=get_previous(p);}p=p->next;}if(count==0)printf("\t\t>不找到数据\n");printf("\t\t>继承查找其余数据?(y or n)"); input=getchar();if(input=='y'||input=='Y')continue;elsebreak;}}}void delete_data(fi_type type)//简略数据函数 {int year=0;int month=0;fi_data *p=NULL;fi_data *pre=NULL;int count=0;char input=' ';int i=0;{ printf("\t\t>请输进要查询的年月(YYYY/M)");if(scanf("%d/%d",&year,&month)!=2){printf("\t\t>输进有误\n");}else{p=head;count=0;while(p!=NULL){if((p->info.year==year)&&(p->info.month==month)&&(p->info.type==type)){count++;show_info(p);pre=get_previous(p);if(pre==NULL)head=head->next;elsepre->next=p->next;printf("\t\t>简略乐成\n");}p=p->next;}if(count==0)printf("\t\t>不找到数据\n");printf("\t\t>继承查找其余数据?(y or n)"); input=getchar();if(input=='y'||input=='Y')continue;elsebreak;}}}void clear_data()//浑空链表数据{fi_data *p=NULL;while(head!=NULL){if(head->next!=NULL){p=head;head=head->next;free(p);p=NULL;}else{free(head);head=NULL;}}}fi_data *get_last(){fi_data * p=head;if(p==NULL)return p;while((p!=NULL)&&(p->next!=NULL)) p=p->next;return p;}fi_data *get_previous(fi_data *p) {fi_data *previous=head;while(previous!=NULL){if(previous->next==p)break;previous=previous->next;}return previous;}void search_payout(){search_data(payout);}void delete_payout(){delete_data(payout);}void update_payout(){update_data(payout);}void search_income() {search_data(income); }void delete_income() {delete_data(income); }void update_income() {update_data(income); }。

财务管理系统附程序源代码

财务管理系统附程序源代码

附程序源代码:program xmjl;usesForms,windows,main in 'main.pas' {Form1},dm in 'dm.pas' {dm2: TDataModule},about in 'about.pas' {AboutBox},report in 'report.pas' {qr1: TQuickRep},logosrc in 'logosrc.pas' {logo},login in 'login.pas' {denglu};{$R *.res}beginApplication.Initialize;logo:=tlogo.Create(application);logo.Show;logo.Update;Application.CreateForm(Tdm2, dm2);Application.CreateForm(Tdenglu, denglu);sleep(1000);logo.Hide;logo.Free;Application.Run;end.unit logosrc;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, jpeg, ExtCtrls;typeTlogo = class(TForm)Image1: TImage;private{ Private declarations }public{ Public declarations }end;varlogo: Tlogo;implementation{$R *.dfm}end.unit login;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Mask, Buttons;typeTdenglu = class(TForm)BitBtn1: TBitBtn;BitBtn2: TBitBtn;ComboBox1: TComboBox;MaskEdit1: TMaskEdit;Label1: TLabel;Label2: TLabel;procedure BitBtn2Click(Sender: TObject);procedure FormCreate(Sender: TObject);procedure BitBtn1Click(Sender: TObject);private{ Private declarations }public{ Public declarations }end;vardenglu: Tdenglu;implementationuses dm,main;{$R *.dfm}procedure Tdenglu.BitBtn2Click(Sender: TObject); beginapplication.Terminate;end;procedure Tdenglu.FormCreate(Sender: TObject); beginwith dm2.ADOTable1 dobeginopen;first;while not eof dobegincombobox1.Items.Add(fields[0].Value );next;end;combobox1.ItemIndex :=0;end;end;procedure Tdenglu.BitBtn1Click(Sender: TObject); beginwith dm2.ADOTable1 dobeginif locate('us',combobox1.Text,[]) thenbeginif maskedit1.text=fields[1].Value thenbeginhide;with tform1.Create(self) doshowmodal;end;application.Terminate ;end;end;end;end.unit main;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, ToolWin, Menus, DBActns, ActnList, DB,ExtCtrls, StdCtrls, Mask, DBCtrls, ImgList, Buttons, Grids, DBGrids;typeTForm1 = class(TForm)PageControl1: TPageControl;StatusBar1: TStatusBar;TabSheet1: TTabSheet;TabSheet2: TTabSheet;TabSheet3: TTabSheet;TabSheet5: TTabSheet;MainMenu1: TMainMenu;N1: TMenuItem;N2: TMenuItem;N4: TMenuItem;N5: TMenuItem;N8: TMenuItem;N9: TMenuItem;N10: TMenuItem;N12: TMenuItem;N13: TMenuItem;N14: TMenuItem;N15: TMenuItem;N16: TMenuItem;N17: TMenuItem;N18: TMenuItem;DataSource1: TDataSource;ActionList1: TActionList;DataSetFirst1: TDataSetFirst;DataSetPrior1: TDataSetPrior;DataSetNext1: TDataSetNext;DataSetLast1: TDataSetLast;DataSetInsert1: TDataSetInsert;DataSetDelete1: TDataSetDelete;DataSetEdit1: TDataSetEdit;DataSetPost1: TDataSetPost;Panel1: TPanel;Panel2: TPanel;Label1: TLabel;Label2: TLabel;Label3: TLabel;Label4: TLabel;DBEdit1: TDBEdit; DBEdit2: TDBEdit; DBEdit9: TDBEdit; DBEdit10: TDBEdit; DBEdit11: TDBEdit; Panel3: TPanel;BitBtn1: TBitBtn;BitBtn2: TBitBtn;BitBtn3: TBitBtn;BitBtn4: TBitBtn; ImageList1: TImageList; BitBtn5: TBitBtn;BitBtn10: TBitBtn;Label25: TLabel;Label26: TLabel;Panel4: TPanel;BitBtn6: TBitBtn;BitBtn7: TBitBtn;BitBtn8: TBitBtn;BitBtn9: TBitBtn;BitBtn11: TBitBtn;BitBtn12: TBitBtn;BitBtn13: TBitBtn;Panel8: TPanel;DBGrid1: TDBGrid; Panel9: TPanel;Label27: TLabel; ComboBox1: TComboBox; Label28: TLabel;Edit1: TEdit;BitBtn14: TBitBtn;BitBtn15: TBitBtn;Panel13: TPanel;DBGrid3: TDBGrid; Panel14: TPanel;Label59: TLabel;Label60: TLabel; ComboBox3: TComboBox; Edit3: TEdit;BitBtn18: TBitBtn;BitBtn19: TBitBtn;BitBtn21: TBitBtn;Timer1: TTimer;DBEdit3: TDBEdit;Panel5: TPanel;Label7: TLabel;Label8: TLabel;Label9: TLabel;Label10: TLabel;Label11: TLabel;Label12: TLabel;Label13: TLabel;Label14: TLabel;DBEdit4: TDBEdit;DBEdit5: TDBEdit;DBEdit6: TDBEdit;DBEdit7: TDBEdit;DBEdit8: TDBEdit;DBEdit12: TDBEdit;TabSheet4: TTabSheet;Panel6: TPanel;GroupBox1: TGroupBox;SpeedButton1: TSpeedButton;DBGrid2: TDBGrid;DBEdit13: TDBEdit;DBEdit14: TDBEdit;DBNavigator1: TDBNavigator;Label15: TLabel;Label16: TLabel;DataSource2: TDataSource;procedure N9Click(Sender: TObject);procedure N10Click(Sender: TObject);procedure N12Click(Sender: TObject);procedure N8Click(Sender: TObject);procedure N14Click(Sender: TObject);procedure N5Click(Sender: TObject);procedure BitBtn5MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);procedure filldata(sender:tcombobox);procedure search(f1:tcombobox;t1:tedit);procedure dispall;procedure FormActivate(Sender: TObject);procedure BitBtn14Click(Sender: TObject);procedure BitBtn15Click(Sender: TObject);procedure BitBtn13Click(Sender: TObject);procedure BitBtn21Click(Sender: TObject);procedure Timer1Timer(Sender: TObject);procedure BitBtn11MouseUp(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);procedure BitBtn18Click(Sender: TObject);procedure SpeedButton1Click(Sender: TObject);private{ Private declarations }public{ Public declarations }end;varForm1: TForm1;implementationuses about,dm,report,login;{$R *.dfm}procedure TForm1.N9Click(Sender: TObject);begintabsheet2.Show;end;procedure TForm1.N10Click(Sender: TObject);begintabsheet3.Show;end;procedure TForm1.N12Click(Sender: TObject);begintabsheet5.Show;end;procedure TForm1.N8Click(Sender: TObject);begintabsheet1.Show;end;procedure TForm1.N14Click(Sender: TObject);beginapplication.Terminate ;end;beginwith taboutbox.Create(self) doShowModal ;end;procedure TForm1.BitBtn5MouseUp(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);begindbedit1.Text:=inttostr(dm2.adoquery1.RecordCount+1);dbedit2.SetFocus;end;procedure TForm1.filldata(sender:tcombobox);variCount: Integer; //将从数据模块中取得的数据库表的字段名填入ComboBox中beginsender.Items.Clear; //首先清空ComboBox中Items的值for iCount := 0 to DM2.ADOQuery1.Fields.Count - 2 dobeginsender.Items.Add(DM2.ADOQuery1.Fields[iCount].FieldName); //加入字段名DM2.ADOQuery1.Next; //向下移动到下一个字段end;sender.ItemIndex := 0; //设置表单刚出现时ComboBox的值为第一个end;procedure TForm1.search(f1:tcombobox;t1:tedit); //自定义过程search(在数据库中搜寻指定条件的数据)varSearchField: string; //要查找的字段名SearchValue: string; //要查找的字段值beginSearchField := Trim(f1.Text); //将ComboBox的值赋给SearchField SearchValue := '%' + Trim(t1.Text) + '%'; //将Edit的值赋给SearchFieldwith DM2.ADOQuery1 dobeginclose; //先关闭数据模块中的ADOQuerysql.Clear; //清空ADOQuery中的SQL值sql.Add('select * from xmb where ' + SearchField + ' like ''' +SearchV alue + ''''); //进行数据查询的SQL语句(SearchFidel和SearchValue// 分别赋到SQL语句中end;Dm2.ADOQuery1.Open; //打开数据模块中的ADOQueryend;procedure TForm1.FormActivate(Sender: TObject);beginfilldata(combobox1);filldata(combobox3);tabsheet1.Show;end;procedure TForm1.BitBtn14Click(Sender: TObject);beginsearch(combobox1,edit1);end;procedure TForm1.BitBtn15Click(Sender: TObject);begindispall;end;procedure TForm1.dispall;beginwith dm2.ADOQuery1 dobeginclose;sql.clear;sql.Add('select * from xmb');open;end;end;procedure TForm1.BitBtn13Click(Sender: TObject);beginif MessageDlg('你确信要删除记录?',mtwarning,[mbok,mbcancel],0)=mrok thenDM2.ADOQuery1.Delete;end;procedure TForm1.BitBtn17Click(Sender: TObject);begindispall;end;procedure TForm1.BitBtn21Click(Sender: TObject);beginwith tqr1.Create(self) doPreview;end;procedure TForm1.Timer1Timer(Sender: TObject);beginstatusbar1.Panels[3].Text :=timetostr(now);statusbar1.Panels[4].Text :=formatdatetime('yyyy年MM月dd日',now); end;procedure TForm1.BitBtn11MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);begindbedit12.SetFocus;end;procedure TForm1.BitBtn18Click(Sender: TObject);beginsearch(combobox3,edit3);end;procedure TForm1.SpeedButton1Click(Sender: TObject);beginwith dm2.ADOQuery1 dobeginclose;sql.Clear;sql.Add('delete * from xmb');ExecSQL;close;sql.Clear;sql.Add('select * from xmb');open;end;end;end.unit dm;interfaceusesSysUtils, Classes, ADODB, DB;typeTdm2 = class(TDataModule)ADOConnection1: TADOConnection;ADOQuery1: TADOQuery;ADOQuery1DSDesigner: TWideStringField;ADOQuery1DSDesigner2: TBCDField;ADOQuery1DSDesigner3: TBCDField;ADOQuery1DSDesigner4: TDateTimeField;ADOQuery1DSDesigner5: TWideStringField;ADOQuery1total: TCurrencyField;ADOTable1: TADOTable;procedure ADOQuery1CalcFields(DataSet: TDataSet); private{ Private declarations }public{ Public declarations }end;vardm2: Tdm2;implementation{$R *.dfm}procedure Tdm2.ADOQuery1CalcFields(DataSet: TDataSet); beginadoquery1total.Value :=ADOQuery1DSDesigner2.V alue -ADOQuery1DSDesigner3.value ; end;end.unit report;interfaceuses Windows, SysUtils, Messages, Classes, Graphics, Controls, StdCtrls, ExtCtrls, Forms, QuickRpt, QRCtrls, DB, ADODB;Tqr1 = class(TQuickRep)ColumnHeaderBand1: TQRBand;TitleBand1: TQRBand;QRLabel1: TQRLabel;DetailBand1: TQRBand;QRLabel2: TQRLabel;QRLabel3: TQRLabel;QRLabel4: TQRLabel;QRLabel5: TQRLabel;QRLabel6: TQRLabel;QRLabel7: TQRLabel;QRDBText1: TQRDBText;QRDBText2: TQRDBText;QRDBText3: TQRDBText;QRDBText4: TQRDBText;QRDBText5: TQRDBText;QRDBText6: TQRDBText;QRShape1: TQRShape;QRShape2: TQRShape;QRShape3: TQRShape;QRShape7: TQRShape;QRShape8: TQRShape;QRShape9: TQRShape;SummaryBand1: TQRBand;QRSysData1: TQRSysData;QRLabel8: TQRLabel;QRLabel9: TQRLabel;QRSysData2: TQRSysData;QRLabel10: TQRLabel;QRSysData3: TQRSysData; privatepublicend;varqr1: Tqr1;implementationuses dm;{$R *.DFM}unit about;interfaceuses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls, Buttons, ExtCtrls;typeTAboutBox = class(TForm)Panel1: TPanel;ProgramIcon: TImage;ProductName: TLabel;V ersion: TLabel;Copyright: TLabel;Comments: TLabel;OKButton: TButton;private{ Private declarations }public{ Public declarations }end;varAboutBox: TAboutBox;implementation{$R *.dfm}end.。

C语言家庭财务管理系统代码

C语言家庭财务管理系统代码

#include <stdio.h>#include <stdlib.h>#include <string.h>struct Data{char name[20];char riqi[8];float money;char beizhu[50];};struct list{struct Data info;struct list *next;};struct list *Inhead=NULL;struct list *Intail=NULL;struct list *zhichuhead=NULL;struct list *zhichutail=NULL;struct list *temp=NULL;void chaxun_income();void chaxun_zhichu();void xiugai_income();void xiugai_zhichu();void Save_income(){FILE *fp;fp=fopen("D:\家庭财务管理.txt","w");struct list *p = Inhead;while(p != NULL){fwrite(&p->info, sizeof(struct Data), 1, fp);p = p->next;}fclose(fp);}void Save_zhichu(){FILE *fp;fp=fopen("D:\家庭财务管理支出.txt","w");struct list *p = zhichuhead;while(p != NULL){fwrite(&p->info, sizeof(struct Data), 1, fp);p = p->next;}fclose(fp);}void Open(){FILE *fp;fp=fopen("D:\家庭财务管理.txt","r");if(fp!=NULL){struct Data linshi;while(fread(&linshi, sizeof(struct Data), 1, fp) == 1){temp=(struct list*)malloc(sizeof(struct list));temp->info=linshi;temp->next=NULL;if(Inhead == NULL){Inhead = temp;Intail = temp;}else{Intail->next = temp;Intail = temp;}}fclose(fp);}}void Menu(){ system("cls");printf("\n");printf("\n");printf("\n");printf("\n");printf("******************\n");printf("欢迎使用家庭财务管理系统\n");printf("******************\n");printf(" \n");printf(" 1:收入操作\n");printf(" 2:支出操作\n");printf(" 3:统计操作\n");printf(" 0:退出\n");}void Openzhichu(){FILE *fp;fp=fopen("D:\家庭财务管理支出.txt","r");if(fp!=NULL){struct Data linshi;while(fread(&linshi, sizeof(struct Data), 1, fp) == 1){temp=(struct list*)malloc(sizeof(struct list));temp->info=linshi;temp->next=NULL;if(zhichuhead == NULL){zhichuhead = temp;zhichutail = temp;}else{zhichutail->next = temp;zhichutail = temp;}}fclose(fp);}}void mingzi (){char chazhao[20];printf("请输入查询的名字");gets(chazhao);struct list *p = Inhead;while(p != NULL){if(strcmp(p->,chazhao)==0){printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("收入:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);system("PAUSE");}p = p->next;}if(Inhead!=NULL){char panduan;printf("是否继续查询(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){chaxun_income();}}}void mingzi_zhichu (){char chazhao[20];printf("请输入查询的名字");gets(chazhao);struct list *p = zhichuhead;while(p != NULL){if(strcmp(p->,chazhao)==0){printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("收入:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);system("PAUSE");}p = p->next;}if(zhichuhead!=NULL){char panduan;printf("是否继续查询(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){chaxun_zhichu();}}}void mingzi_xiugai_income(){char xiugai[20];printf("请输入修改的名字");fflush(stdin);gets(xiugai);struct list *p = Inhead;while(p != NULL){if(strcmp(p->,xiugai)==0){fflush(stdin);printf("姓名:");gets(p->);fflush(stdin);printf("日期:");gets(p->info.riqi);fflush(stdin);printf("支出: ");scanf("%f",&p->info.money);fflush(stdin);printf("备注:");gets(p->info.beizhu);fflush(stdin);//------}p = p->next;}Save_income();if(Inhead!=NULL){char panduan;printf("是否继续修改(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){xiugai_income();}}}void mingzi_xiugai_zhichu(){char xiugai[20];printf("请输入修改的名字");fflush(stdin);gets(xiugai);struct list *p = zhichuhead;while(p != NULL){if(strcmp(p->,xiugai)==0){fflush(stdin);printf("姓名:");gets(p->);fflush(stdin);printf("日期:");gets(p->info.riqi);fflush(stdin);printf("支出: ");scanf("%f",&p->info.money);fflush(stdin);printf("备注:");gets(p->info.beizhu);fflush(stdin);//------}p = p->next;}Save_zhichu();if(zhichuhead!=NULL){char panduan;printf("是否继续修改(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){xiugai_zhichu();}}}void riqi(){char chazhao[20];printf("请输入查询的日期");gets(chazhao);struct list *p = Inhead;while(p != NULL){if(strcmp(p->info.riqi,chazhao)==0){printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("收入:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);system("PAUSE");}p = p->next;}if(Inhead!=NULL){char panduan;printf("是否继续查询(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){chaxun_income();}}}void riqi_zhichu(){char chazhao[20];printf("请输入查询的日期");gets(chazhao);struct list *p = zhichuhead;while(p != NULL){if(strcmp(p->info.riqi,chazhao)==0){printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("收入:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);system("PAUSE");}p = p->next;}if(zhichuhead!=NULL){char panduan;printf("是否继续查询(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){chaxun_zhichu();}}}void riqi_xiugai_income(){char xiugai[20];printf("请输入修改的日期");fflush(stdin);gets(xiugai);struct list *p = Inhead;while(p != NULL){if(strcmp(p->info.riqi,xiugai)==0){fflush(stdin);printf("姓名:");gets(p->);fflush(stdin);printf("日期:");gets(p->info.riqi);fflush(stdin);printf("支出: ");scanf("%f",&p->info.money);fflush(stdin);printf("备注:");gets(p->info.beizhu);fflush(stdin);//------}p = p->next;}Save_income();if(Inhead!=NULL){char panduan;printf("是否继续修改(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){xiugai_income();}}}void riqi_xiugai_zhichu(){char xiugai[20];printf("请输入修改的日期");fflush(stdin);gets(xiugai);struct list *p = zhichuhead;while(p != NULL){if(strcmp(p->info.riqi,xiugai)==0){fflush(stdin);printf("姓名:");gets(p->);fflush(stdin);printf("日期:");gets(p->info.riqi);fflush(stdin);printf("支出: ");scanf("%f",&p->info.money);fflush(stdin);printf("备注:");gets(p->info.beizhu);fflush(stdin);//------}p = p->next;}Save_zhichu();if(zhichuhead!=NULL){char panduan;printf("是否继续修改(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){xiugai_zhichu();}}}void money (){float chazhao;printf("请输入查询的money");scanf("%f",&chazhao);fflush(stdin);struct list *p = Inhead;while(p != NULL){if(p->info.money==chazhao){printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("收入:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);system("PAUSE");}p = p->next;}if(Inhead!=NULL){char panduan;printf("是否继续查询(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){chaxun_income();}}}void money_zhichu (){float chazhao;printf("请输入查询的money");scanf("%f",&chazhao);fflush(stdin);struct list *p = zhichuhead;while(p != NULL){if(p->info.money==chazhao){printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("收入:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);system("PAUSE");}p = p->next;}if(zhichuhead!=NULL){char panduan;printf("是否继续查询(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){chaxun_zhichu();}}}void money_xiugai_income(){float xiugai;printf("请输入修改的money");scanf("%f",&xiugai);fflush(stdin);struct list *p = Inhead;while(p != NULL){if(p->info.money==xiugai){fflush(stdin);printf("姓名:");gets(p->);fflush(stdin);printf("日期:");gets(p->info.riqi);fflush(stdin);printf("支出: ");scanf("%f",&p->info.money);fflush(stdin);printf("备注:");gets(p->info.beizhu);fflush(stdin);//------}p = p->next;}Save_income();if(Inhead!=NULL){char panduan;printf("是否继续修改(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){xiugai_income();}}}void money_xiugai_zhichu(){float xiugai;printf("请输入修改的money");scanf("%f",&xiugai);fflush(stdin);struct list *p = zhichuhead;while(p != NULL){if(p->info.money==xiugai){fflush(stdin);printf("姓名:");gets(p->);fflush(stdin);printf("日期:");gets(p->info.riqi);fflush(stdin);printf("支出: ");scanf("%f",&p->info.money);fflush(stdin);printf("备注:");gets(p->info.beizhu);fflush(stdin);//------}p = p->next;}Save_zhichu();if(zhichuhead!=NULL){char panduan;printf("是否继续修改(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){xiugai_zhichu();}}}void beizhu(){char chazhao[20];printf("请输入查询的备注");gets(chazhao);struct list *p = Inhead;while(p != NULL){if(strcmp(p->info.beizhu,chazhao)==0){printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("收入:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);system("PAUSE");}p = p->next;}if(Inhead!=NULL){char panduan;printf("是否继续查询(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){chaxun_income();}}}void beizhu_zhichu(){char chazhao[20];printf("请输入查询的备注");gets(chazhao);struct list *p = zhichuhead;while(p != NULL){if(strcmp(p->info.beizhu,chazhao)==0){printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("收入:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);system("PAUSE");}p = p->next;}if(zhichuhead!=NULL){char panduan;printf("是否继续查询(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){chaxun_zhichu();}}}void beizhu_xiugai_income(){char xiugai[20];printf("请输入修改的备注");fflush(stdin);gets(xiugai);struct list *p = Inhead;while(p != NULL){if(strcmp(p->info.beizhu,xiugai)==0){fflush(stdin);printf("姓名:");gets(p->);fflush(stdin);printf("日期:");gets(p->info.riqi);fflush(stdin);printf("支出: ");scanf("%f",&p->info.money);fflush(stdin);printf("备注:");gets(p->info.beizhu);fflush(stdin);//------}p = p->next;}Save_income();if(Inhead!=NULL){char panduan;printf("是否继续修改(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){xiugai_income();}}}void beizhu_xiugai_zhichu(){char xiugai[20];printf("请输入修改的备注");fflush(stdin);gets(xiugai);fflush(stdin);struct list *p = zhichuhead;while(p != NULL){if(strcmp(p->info.beizhu,xiugai)==0){fflush(stdin);printf("姓名:");gets(p->);fflush(stdin);printf("日期:");gets(p->info.riqi);fflush(stdin);printf("支出: ");scanf("%f",&p->info.money);fflush(stdin);printf("备注:");gets(p->info.beizhu);fflush(stdin);//------}p = p->next;}Save_zhichu();if(zhichuhead!=NULL){char panduan;printf("是否继续修改(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){xiugai_zhichu();}}}void Income_menu(){system("cls");printf("\n");printf("\n");printf("\n");printf("\n");printf("******************\n");printf("欢迎使用家庭财务管理系统\n");printf("******************\n");printf(" \n");printf(" 1.添加收入\n");printf(" 2.删除收入\n");printf(" 3.查询收入\n");printf(" 4.显示收入\n");printf(" 5.修改收入\n");printf(" 0.返回上一级\n");}void zhichu_menu(){system("cls");printf("\n");printf("\n");printf("\n");printf("\n");printf("******************\n");printf("欢迎使用家庭财务管理系统\n");printf("******************\n");printf(" \n");printf(" 1.添加支出\n");printf(" 2.删除支出\n");printf(" 3.查询支出\n");printf(" 4.显示支出\n");printf(" 5.修改支出\n");printf(" 0.返回上一级\n");}void chaxun_menu(){system("cls");printf("\n");printf("\n");printf("\n");printf("\n");printf("******************\n");printf("欢迎使用家庭财务管理系统\n");printf("******************\n");printf(" \n");printf(" 1.按名字查询\n");printf(" 2.按日期查询\n");printf(" 3.按money询\n");printf(" 4.按备注查询\n");printf(" 0.返回上一级\n"); }void xiugai_menu(){system("cls");printf("\n");printf("\n");printf("\n");printf("\n");printf("******************\n");printf("欢迎使用家庭财务管理系统\n");printf("******************\n");printf(" \n");printf(" 1.按名字修改\n");printf(" 2.按日期修改\n");printf(" 3.按money修改\n");printf(" 4.按备注修改\n");printf(" 0.返回上一级\n");}void Add_income(){char panduan;do{temp=(struct list*)malloc(sizeof(struct list));printf("姓名");gets(temp->);fflush(stdin);printf("日期(XX年XX月XX日)");gets(temp->info.riqi);fflush(stdin);printf("收入");scanf("%f",&temp->info.money);fflush(stdin);printf("备注");gets(temp->info.beizhu);fflush(stdin);printf("\n");//------自己添加temp->next=NULL;if(Inhead == NULL){Inhead = temp;Intail = temp;}else{Intail->next = temp;Intail = temp;}Save_income();//后面可以添加“继续添加功能”printf("是否(Y/N)继续添加信息\n");panduan=getchar();fflush(stdin);}while(panduan=='Y'||panduan=='y');system("PAUSE");}void Add_zhichu(){char panduan;do{temp=(struct list*)malloc(sizeof(struct list));printf("姓名");gets(temp->);fflush(stdin);printf("日期(XX年XX月XX日)");gets(temp->info.riqi);fflush(stdin);printf("支出");scanf("%f",&temp->info.money);fflush(stdin);printf("备注");gets(temp->info.beizhu);fflush(stdin);printf("\n");//------自己添加temp->next=NULL;if(zhichuhead == NULL){zhichuhead = temp;zhichutail = temp;}else{zhichutail->next = temp;zhichutail = temp;}Save_zhichu();//后面可以添加“继续添加功能”printf("是否(Y/N)继续添加信息\n");panduan=getchar();fflush(stdin);}while(panduan=='Y'||panduan=='y');system("PAUSE");}void Del_income(){char shanchu[20];struct list *p=NULL;struct list *m =NULL;struct list *n =NULL;p=Inhead;printf("请输入删除姓名");gets(shanchu);if(strcmp(Inhead->,shanchu)==0){while(Inhead!=NULL && strcmp(Inhead->,shanchu)==0) {char ch;printf("找到一个数据名字为%s,确认删除Y/N?",shanchu);ch=getchar();fflush(stdin);if(ch=='y'||ch=='Y') Inhead=Inhead->next;else break;}}else{if(strcmp(Intail->,shanchu)==0){do{ m=p;p=p->next;}while(p!=Intail);m->next=NULL;}//删除尾巴else{do{m=p;p=p->next;n=p->next;}while(strcmp(p->,shanchu)!=0&&n->next!=NULL);if(strcmp(p->,shanchu)==0)m->next=n;}}//删除除头节点之外的节点,自己课后完成Save_income();if(Inhead!=NULL){char panduan;printf("是否继续删除(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){Del_income();}}}void Del_zhichu(){char shanchu[20];struct list *p=NULL;struct list *m =NULL;struct list *n =NULL;p=zhichuhead;printf("请输入删除姓名");gets(shanchu);if(strcmp(zhichuhead->,shanchu)==0){while(zhichuhead!=NULL && strcmp(zhichuhead->,shanchu)==0) {char ch;printf("找到一个数据名字为%s,确认删除Y/N?",shanchu);ch=getchar();fflush(stdin);if(ch=='y'||ch=='Y') zhichuhead=zhichuhead->next;else break;}}else{if(strcmp(zhichutail->,shanchu)==0){do{ m=p;p=p->next;}while(p!=zhichutail);m->next=NULL;}//删除尾巴else{do{m=p;p=p->next;n=p->next;}while(strcmp(p->,shanchu)!=0&&n->next!=NULL);if(strcmp(p->,shanchu)==0)m->next=n;}}Save_zhichu();//删除除头节点之外的节点,自己课后完成if(zhichuhead!=NULL){char panduan;printf("是否继续删除(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){Del_zhichu();}}}void xiugai_income(){xiugai_menu();int choice;printf(" 请输入你的选择:");scanf("%d",&choice);fflush(stdin);switch(choice){case 1: mingzi_xiugai_income();break;case 2: riqi_xiugai_income();break;case 3: money_xiugai_income();break;case 4: beizhu_xiugai_income();break;default: printf("输入错误");break;}}void xiugai_zhichu(){xiugai_menu();int choice;printf(" 请输入你的选择:");scanf("%d",&choice);fflush(stdin);switch(choice){case 1: mingzi_xiugai_zhichu();break;case 2: riqi_xiugai_zhichu();break;case 3: money_xiugai_zhichu();break;case 4: beizhu_xiugai_zhichu();break;default: printf("输入错误");break;}}void chaxun_income(){chaxun_menu();int choice;printf(" 请输入你的选择:");scanf("%d",&choice);fflush(stdin);switch(choice){case 1: mingzi();break;case 2: riqi();break;case 3: money();break;case 4: beizhu();break;default: printf("输入错误");break;}}void chaxun_zhichu(){chaxun_menu();int choice;printf(" 请输入你的选择:");scanf("%d",&choice);fflush(stdin);switch(choice){case 1: mingzi_zhichu();break;case 2: riqi_zhichu();break;case 3: money_zhichu();break;case 4: beizhu_zhichu();break;default: printf("输入错误");break;}}void Sho_income(){struct list *p = Inhead;while(p != NULL){printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("收入:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);p = p->next;}system("PAUSE");}void Sho_zhichu(){struct list *p = zhichuhead;while(p != NULL){fflush(stdin);printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("支出:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);p = p->next;}system("PAUSE");}void Income(){int choice;while(1){Income_menu();printf("请输入选择");scanf("%d",&choice);fflush(stdin);if(choice==0){break;}elseswitch(choice){case 1: Add_income(); Save_income();break;case 2: Del_income(); Save_income();break;case 3: chaxun_income(); Save_income();break;case 4: Sho_income(); Save_income();break;case 5: xiugai_income(); Save_income();break;}}}void zhichu(){int choice;while(1){zhichu_menu();printf("请输入选择");scanf("%d",&choice);fflush(stdin);if(choice==0){break;}elseswitch(choice){case 1: Add_zhichu(); Save_zhichu();break;case 2: Del_zhichu(); Save_zhichu();break;case 3: chaxun_zhichu(); Save_zhichu();break;case 4: Sho_zhichu(); Save_zhichu();break;case 5: xiugai_zhichu(); Save_zhichu();break;}}}void tongji_menu(){system("cls");printf("\n");printf("\n");printf("\n");printf("\n");printf("******************\n");printf("欢迎使用家庭财务管理系统\n");printf("******************\n");printf(" \n");printf(" 1.总收入\n");printf(" 2.总支出\n");printf(" 3.总资金\n");printf(" 0.返回上一级\n");}void zongshouru(){float shouru=0;struct list *linshi;linshi=Inhead;if(linshi!=NULL){do{shouru=linshi->info.money+shouru;linshi=linshi->next;}while(linshi!=NULL);printf("%.4f",shouru);system("PAUSE");}}void zongzhichu(){float zhichu=0;struct list *linshi;linshi=zhichuhead;if(linshi!=NULL){do{zhichu=linshi->info.money+zhichu;linshi=linshi->next;}while(linshi!=NULL);printf("%.4f",zhichu);system("PAUSE");}}void zongzijin(){float zhichu=0;float zongzijin;struct list *linshi;linshi=zhichuhead;if(linshi!=NULL){do{zhichu=linshi->info.money+zhichu;linshi=linshi->next;}while(linshi!=NULL);}float shouru=0;linshi=Inhead;if(linshi!=NULL){do{shouru=linshi->info.money+shouru;linshi=linshi->next;}while(linshi!=NULL);printf("%.4f",shouru-zhichu);system("PAUSE");}}void Tongji(){while(1){tongji_menu();int choice;printf(" 请输入你的选择:");scanf("%d",&choice);if(choice==0){break;}switch(choice){case 1: zongshouru();break;case 2: zongzhichu();break;case 3: zongzijin();break;default: printf("输入错误");break;}}}void Quit(){char panduan;printf("确认退出(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){exit(0);}}int main(){Open();Openzhichu();system("color 72");while(1){Menu();int choice;printf(" 请输入你的选择:");scanf("%d",&choice);fflush(stdin);switch(choice){case 1: Income();break;case 2: zhichu();break;case 3: Tongji();break;case 0: Quit();break;default: printf("输入错误");break;}}return 0;}。

家庭财务管理系统课程设计的原代码

家庭财务管理系统课程设计的原代码

1、frm_borrowgo.frmDim Mydb As New ADODB.RecordsetDim Mydb1 As New ADODB.RecordsetDim Str_text As StringDim strflag As StringPrivate Sub cmd_add_Click()txt_man.Locked = Falsetxt_way.Locked = Falsetxt_money.Locked = FalseCombo1.Locked = FalseCheck1.Enabled = TrueDTPicker1.Enabled = Truetxt_man.Text = ""txt_way.Text = ""txt_money.Text = ""Combo1.Text = ""strflag = "添加"Cmdsave.Enabled = TrueEnd SubPrivate Sub cmd_close_Click()Unload MeEnd SubPrivate Sub cmd_del_Click()Dim A As BooleanA = MsgBox("是否真的要删除这条记录?", vbOKCancel + 32 + 256, "删除")If A = True ThenExeCutesql "delete from 借出 where 得款人='" & txt_man.Text & "'", Str_textMsgBox "记录已删除!", , "删除"If Mydb.RecordCount > 0 ThenMydb.MoveNextIf Mydb.EOF Then Mydb.MoveLastCall DbCall BangdingLabel7.Caption = Mydb.RecordCountEnd IfEnd IfEnd SubPrivate Sub cmd_edit_Click()On Error Resume NextDim A As Booleantxt_man.Locked = Falsetxt_way.Locked = Falsetxt_money.Locked = FalseCombo1.Locked = FalseCheck1.Enabled = TrueDTPicker1.Enabled = Truestrflag = "修改"Cmdsave.Enabled = TrueEnd SubPrivate Sub Cmdsave_Click()On Error Resume NextDim A As BooleanIf strflag = "添加" ThenA = MsgBox("是否添加前记录?", vbYesNo + 32, "添加记录")If A = True ThenExeCutesql "insert into 借出 values('" & txt_man.Text & "','" & txt_money.Text & "','" & Combo1.Text & "','" & DTPicker1.Value & "','" & txt_way.Text & "','" & Check1.Value & "')", Str_textMsgBox "数据已经保存!", vbOKOnly + 64, "成功"Call DbLabel7.Caption = Mydb.RecordCountEnd IfElseIf strflag = "修改" ThenA = MsgBox("是否修改前记录?", vbYesNo + 32, "添加记录")If A = True ThenMydb.Update'Mydb.RequeryCall DbMsgBox "数据修改成功!", vbOKOnly + 64, "成功"End IfEnd IfCmdsave.Enabled = Falsetxt_man.Locked = Truetxt_way.Locked = Truetxt_money.Locked = TrueCombo1.Locked = TrueCheck1.Enabled = FalseDTPicker1.Enabled = FalseEnd SubPrivate Sub Combo1_Change()Dim A As IntegerSet Mydb1 = ExeCutesql("select 姓名 from 成员", Str_text)' Set Combo1.DataSource = Mydb1A = Mydb1.RecordCountFor I = 1 To ACombo1.AddItem Mydb1.Fields(0)Mydb1.MoveNextIf Mydb1.EOF Then Exit ForNext IEnd SubPrivate Sub Command1_Click()On Error Resume Next'Call DbMydb.MoveFirstCall BangdingEnd SubPrivate Sub Command2_Click()On Error Resume Next'Call Db'If Not Mydb.BOF Then Mydb.MovePreviousMydb.MovePreviousIf Mydb.BOF ThenMsgBox "这已经是第一条记录了!", vbOKOnly + 32, "注意"Mydb.MoveFirstEnd IfCall BangdingEnd SubPrivate Sub Command3_Click()On Error Resume Next'Call Db'Mydb.MovePrevious'If Mydb.BOF Then' MsgBox "这已经是第一条记录了!", vbOKOnly + 32, "注意"' Mydb.MoveFirst'End IfMydb.MoveNextIf Mydb.EOF ThenMsgBox "这已经是最后一条记录了!", vbOKOnly + 32, "注意"Mydb.MoveLastEnd IfCall BangdingEnd SubPrivate Sub Command4_Click()On Error Resume Next'Call DbMydb.MoveLastCall BangdingEnd SubPrivate Sub Form_Load()On Error Resume Next'Set Mydb = ExeCutesql("select * from 借出", Str_text) Call Db'Call BangdingCheck1.Value = 0Label7.Caption = Mydb.RecordCountDTPicker1.Value = DateCmdsave.Enabled = Falsetxt_man.Locked = Truetxt_way.Locked = Truetxt_money.Locked = TrueCombo1.Locked = TrueCheck1.Enabled = FalseDTPicker1.Enabled = FalseEnd SubPrivate Function Db()On Error Resume NextSet Mydb = ExeCutesql("select * from 借出", Str_text) End FunctionPrivate Function Bangding()On Error Resume NextSet txt_man.DataSource = MydbSet txt_money.DataSource = MydbSet DTPicker1.DataSource = MydbSet txt_way.DataSource = MydbSet Check1.DataSource = Mydbtxt_man.DataField = "得款人"txt_money.DataField = "金额"DTPicker1.Value = "日期"txt_way.DataField = "借款原因"Check1.DataField = "已还"Set Combo1.DataSource = MydbCombo1.DataField = "出借人"End Function2、frm_borromin.frmDim Mydb As New ADODB.RecordsetDim Mydb1 As New ADODB.RecordsetDim Str_text As StringDim strflag As StringPrivate Sub cmd_close_Click()Unload MeEnd SubPrivate Sub cmd_add_Click()txt_man.Locked = Falsetxt_way.Locked = Falsetxt_money.Locked = FalseCombo1.Locked = FalseCheck1.Enabled = TrueDTPicker1.Enabled = Truetxt_man.Text = ""txt_way.Text = ""txt_money.Text = ""Combo1.Text = ""strflag = "添加"Cmdsave.Enabled = TrueEnd SubPrivate Sub cmd_del_Click()Dim A As BooleanA = MsgBox("是否真的要删除这条记录?", vbOKCancel + 32 + 256, "删除")If A = True ThenExeCutesql "delete from 借入 where 得款人='" & txt_man.Text & "'", Str_textMsgBox "记录已删除!", , "删除"If Mydb.RecordCount > 0 ThenMydb.MoveNextIf Mydb.EOF Then Mydb.MoveLastCall DbCall BangdingLabel7.Caption = Mydb.RecordCountEnd IfEnd IfEnd SubPrivate Sub cmd_edit_Click()On Error Resume NextDim A As Booleantxt_man.Locked = Falsetxt_way.Locked = Falsetxt_money.Locked = FalseCombo1.Locked = FalseCheck1.Enabled = TrueDTPicker1.Enabled = Truestrflag = "修改"Cmdsave.Enabled = TrueEnd SubPrivate Sub Cmdsave_Click()On Error Resume NextDim A As BooleanIf strflag = "添加" ThenA = MsgBox("是否添加前记录?", vbYesNo + 32, "添加记录")If A = True ThenExeCutesql "insert into 借入 values('" & txt_man.Text & "','" & txt_money.Text & "','" & Combo1.Text & "','" & Format(DTPicker1.Value, "yyyy-mm-dd") & "','" & txt_way.Text & "','" & Check1.Value & "')", Str_textMsgBox "数据已经保存!", vbOKOnly + 64, "成功"Call DbLabel7.Caption = Mydb.RecordCountEnd IfElseIf strflag = "修改" ThenA = MsgBox("是否修改前记录?", vbYesNo + 32, "添加记录")If A = True ThenMydb.Update'Mydb.RequeryCall DbMsgBox "数据修改成功!", vbOKOnly + 64, "成功"End IfEnd Iftxt_man.Locked = Truetxt_way.Locked = Truetxt_money.Locked = TrueCombo1.Locked = TrueCheck1.Enabled = FalseDTPicker1.Enabled = FalseCmdsave.Enabled = FalseEnd SubPrivate Sub Combo1_Change()Set Mydb1 = ExeCutesql("select 姓名 from 成员", Str_text)'Set Combo1.DataSource = Mydb1For I = 1 To Mydb1.RecordCountCombo1.AddItem (Mydb1.Fields(0))Mydb1.MoveNextIf Mydb1.EOF Then Exit ForNext IEnd SubPrivate Sub Command1_Click()On Error Resume Next' Call DbMydb.MoveFirstCall BangdingEnd SubPrivate Sub Command3_Click()On Error Resume Next'Call DbMydb.MoveNextIf Mydb.EOF ThenMsgBox "这已经是最后一条记录了!", vbOKOnly + 32, "注意"Mydb.MoveLastEnd IfCall BangdingEnd SubPrivate Sub Command2_Click()On Error Resume NextMydb.MovePreviousIf Mydb.BOF ThenMsgBox "这已经是第一条记录了!", vbOKOnly + 32, "注意"Mydb.MoveFirstEnd IfCall BangdingEnd SubPrivate Sub Command4_Click()On Error Resume Next'Call DbMydb.MoveLastCall BangdingEnd SubPrivate Sub Form_Load()On Error Resume NextCall DbCall BangdingCmdsave.Enabled = FalseCheck1.Value = 0Label7.Caption = Mydb.RecordCountDTPicker1.Value = Datetxt_man.Locked = Truetxt_way.Locked = Truetxt_money.Locked = TrueCombo1.Locked = TrueCheck1.Enabled = FalseDTPicker1.Enabled = FalseEnd SubPrivate Function Db()Set Mydb = ExeCutesql("select * from 借入", Str_text) End FunctionPrivate Function Bangding()On Error Resume NextSet txt_man.DataSource = MydbSet txt_money.DataSource = MydbSet DTPicker1.DataSource = MydbSet txt_way.DataSource = MydbSet Check1.DataSource = Mydbtxt_man.DataField = "得款人"txt_money.DataField = "金额"DTPicker1.DataField = "日期"txt_way.DataField = "出借原因"Check1.DataField = "已还"Set Combo1.DataSource = MydbCombo1.DataField = "出借人"End Function3、frm_choose.frmPrivate Sub cmd_choose_Click()On Error Resume NextCommonDialog1.Filter = "database(*.mdb)|*.mdb"CommonDialog1.ShowOpenStr_path = CommonDialog1.FileNameText1.Text = CommonDialog1.FileNameSaveSetting "小财迷", "personal", "路径", Str_pathText2.Text = CommonDialog1.FileNameIf Text2.Text <> "" Thenfrm_login.ShowUnload MeElseShowEnd IfEnd SubPrivate Sub cmd_ok_Click()On Error Resume NextStr_path = Text1.TextSaveSetting "小财迷", "personal", "路径", Str_pathfrm_login.ShowUnload MeEnd Sub4、frm_date.frmDim Mydb As New ADODB.RecordsetDim Riqi, Riqi1, Year1, Month As StringPrivate Sub Command1_Click()'Dim Riqi, Riqi1, Year, Month As StringIf Combo1.Text = "" ThenMsgBox "请选择年份!", vbOKOnly + 32, "注意!"ElseIf Combo2.Text = "" ThenMsgBox "请选择月份!", vbOKOnly + 32, "注意!"ElseAA = TrueYear1 = Combo1.TextMonth = Combo2.TextRiqi = Year1 & "-" & MonthRiqi1 = Year1 & "-" & Month + 1'MsgBox Riqi'Set Mydb = ExeCutesql("select * from 收入where 日期between '" & Riqi & "' and '" & Riqi1 & "' ", "")Cdate1 = Format(Riqi, "yyyy-mm")Cdate2 = Format(Riqi1, "yyyy-mm")Unload MeEnd IfEnd IfEnd SubPrivate Sub Form_Load()Dim A As IntegerA = 2000For I = 2000 To Int(Year(Now))Combo1.AddItem AA = A + 1Next IEnd Sub5、frm_expend.frmDim Mydb As New ADODB.RecordsetDim Mydb1 As New ADODB.RecordsetDim Mydb2 As New ADODB.RecordsetDim Count1 As New ADODB.RecordsetDim Str_text As StringPrivate Sub cmd_add_Click()On Error Resume NextDim A, BB = 1Set Count1 = ExeCutesql("select * from 支出", Str_text)Count1.MoveLastB = Count1.Fields(7) + 1A = MsgBox("是否添加前记录?", vbYesNo + 32, "添加记录")If A = vbYes ThenIf txt_intake.Text = "" ThenMsgBox "请填写去向!", vbOKOnly + 32, "注意!"ElseExeCutesql "insert into 支出values('" & Format(DTPicker1.Value, "yyyy-mm-dd") & "','" _& Combo1.Text & "','" & txt_money.Text & "','" & Combo2.Text & "','" & txt_intake.Text _& "','" & Combo3.Text & "','" & txt_mome.Text & "','" & B & "')", Str_textMsgBox "数据已经保存!", vbOKOnly + 64, "成功"Call XiangmuCall DbEnd IfEnd IfEnd SubPrivate Sub cmd_close_Click()Unload MeEnd SubPrivate Sub cmd_del_Click()On Error Resume NextDim AA = MsgBox("是否删除当前记录?", vbYesNo + 32 + 256, "添加记录")If A = vbYes ThenExeCutesql "DELETE from 支出 where key=" & txt_note.Text & "", Str_textCall DbSet Mydb = ExeCutesql("select * from 支出 ", Str_text)Set MSHFlexGrid1.DataSource = MydbEnd IfEnd SubPrivate Sub cmd_edit_Click()On Error Resume NextDim AA = MsgBox("是否修改前记录?", vbYesNo + 32, "添加记录")If A = vbYes ThenExeCutesql "Update 支出Set 日期= '" & Format(DTPicker1.Value, "yyyy-mm-dd") & "',方式='" & Combo1.Text & "',金额=" & txt_money.Text & ", 去向='" & txt_intake.Text & "',人员='" & Combo3.Text & "',备注='" & txt_mome.Text & "' Where key = " & txt_note.Text & " ", Str_text 'Mydb.RequeryCall DbMsgBox "数据修改成功!", vbOKOnly + 64, "成功"End IfEnd SubPrivate Sub Combo2_Change()Call Db1End SubPrivate Sub Combo3_Change()Call Db2End SubPrivate Sub Form_Load()Call DbCall Db1Call Db2DTPicker1.Value = Date' Combo3.Locked = True' Combo1.Locked = TrueEnd SubPublic Function Db()Set Mydb = ExeCutesql("select * from 支出 order by key", Str_text) Set MSHFlexGrid1.DataSource = MydbEnd FunctionPublic Function Db1()On Error Resume NextDim A As IntegerSet Mydb1 = ExeCutesql("select * from 支出项目 ", Str_text)A = Mydb1.RecordCountSet Combo2.DataSource = Mydb1For I = 1 To ACombo2.AddItem Mydb1.Fields(0)Mydb1.MoveNextIf Mydb1.EOF Then Exit ForNext IEnd FunctionPublic Function Db2()On Error Resume NextDim A As IntegerSet Mydb2 = ExeCutesql("select * from 成员", Str_text)A = Mydb2.RecordCountSet Combo3.DataSource = Mydb2For I = 1 To ACombo3.AddItem Mydb2.Fields(0)Mydb2.MoveNextIf Mydb2.EOF Then Exit ForNext ICombo3.AddItem "全家"End FunctionPrivate Sub Form_Unload(Cancel As Integer)'Mydb.Close'Mydb1.Close'Mydb2.CloseEnd SubPrivate Sub MSHFlexGrid1_Click()On Error Resume NextDTPicker1.Value = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 1) Combo1.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 2)txt_money.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 3) Combo2.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 4)txt_intake.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 5) Combo3.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 6)txt_mome.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 7)txt_note.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 8)End SubPrivate Sub txt_money_LostFocus()Dim A As BooleanDim CC = txt_money.TextA = IsNumeric(C)If C = "" ThenMsgBox "请输入金额!", vbOKOnly + 32, "注意!"txt_money.SetFocusElseIf A = False ThenMsgBox "金额只能输入数字!", vbOKOnly + 32, "注意!"txt_money.SetFocusEnd IfEnd IfEnd SubPrivate Function Xiangmu()Dim ADim Str_text As StringDim Db As New ADODB.RecordsetStr_text = Combo2.TextSet Db = ExeCutesql("select * from 支出项目 where value='" & Str_text & "'", "")'MsgBoxIf Not Str_text = Db.Fields(0) ThenExeCutesql "insert into 支出项目 values('" & Str_text & "')", ""End IfEnd FunctionPrivate Function Renyuan()'Dim A'Dim Str_text As String'Dim Db As New ADODB.Recordset'Str_text = Combo3.Text'Set Db = ExeCutesql("select * from 成员 where value='" & Str_text & "'", "")'MsgBox'If Not Str_text = Db.Fields(0) Then' ExeCutesql "insert into 成员 values('" & Str_text & "')", ""'End IfEnd Function6、frm_family.frmDim Mydb As New ADODB.RecordsetDim Mydb1 As New ADODB.RecordsetDim Count1 As New ADODB.RecordsetDim Str_text As StringPrivate Sub cmd_add_Click()On Error Resume NextDim A, BB = 1Set Count1 = ExeCutesql("select * from 成员 ", Str_text)Count1.MoveLastB = Count1.Fields(4) + 1A = MsgBox("是否添加前记录?", vbYesNo + 32, "修改记录")If A = vbYes ThenExeCutesql "insert into 成员 values('" & Text1.Text & "','" & Text2.Text & "','" & Format(DTPicker1.Value, "yyyy-mm-dd") & "','" & Text3.Text & "'," & B & ") ", Str_textCall DbMydb.MoveLastMsgBox "数据已经保存!", vbOKOnly + 64, "成功"End IfEnd SubPrivate Sub cmd_close_Click()Unload MeEnd SubPrivate Sub cmd_del_Click()On Error Resume NextDim AA = MsgBox("是否删除当前记录", vbYesNo + 32 + 256, "删除记录")If A = vbYes ThenExeCutesql "DELETE from 成员 where key=" & txt_key.Text & "", Str_text'Mydb.Requery'If Mydb.EOF Then Mydb.MoveLast'Call DbSet Mydb = ExeCutesql("select * from 成员", Str_text)Set MSHFlexGrid1.DataSource = MydbEnd IfEnd SubPrivate Sub cmd_edit_Click()On Error Resume NextDim AA = MsgBox("是否修改前记录?", vbYesNo + 32, "修改记录")If A = vbYes ThenExeCutesql "Update 成员 set 称呼='" & Text1.Text & "',姓名='" & Text2.Text _& "',生日='" & DTPicker1.Value & "',格言='" & Text3.Text & "'where key=" & txt_key.Text & "", Str_textMsgBox "数据已经修改成功!", vbOKOnly + 64, "成功"Call DbEnd IfEnd SubPrivate Sub Form_Load()Call DbDTPicker1.Value = DateEnd SubPrivate Function Db()Set Mydb = ExeCutesql("select * from 成员", Str_text)Set MSHFlexGrid1.DataSource = MydbEnd FunctionPrivate Sub MSHFlexGrid1_Click()On Error Resume NextText1.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 1)Text2.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 2)DTPicker1.Value = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 3) Text3.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 4)txt_key.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 5)End Sub7、frm_fix.frmDim Mydb As New ADODB.RecordsetDim Mydb1 As New ADODB.RecordsetDim Man As New ADODB.RecordsetDim Count1 As New ADODB.RecordsetDim Str_text As StringPrivate Sub cmd_add_Click()On Error Resume NextDim A, BB = 1Set Count1 = ExeCutesql("select key from 定期存款 ", Str_text) Count1.MoveLastB = Count1.Fields(0) + 1A = MsgBox("是否添加前记录?", vbYesNo + 32, "修改记录")If A = vbYes ThenExeCutesql "insert into 定期存款values('" & Format(DTPicker1.Value, "yyyy-mm-dd") & "','" & txt_name.Text _& "','" & txt_address.Text & "','" & txt_size.Text & "'," & txt_money.Text & ",'" & txt_time.Text & "','" & Combo1.Text & "','" & Check1.Value & "'," & B & ")", Str_textCall BangdingEnd IfEnd SubPrivate Sub cmd_del_Click()On Error Resume NextDim AA = MsgBox("是否删除当前记录?", vbYesNo + 32 + 256, "添加记录")If A = vbYes ThenExeCutesql "DELETE from 定期存款 where key=" & txt_key.Text & "", Str_textCall BangdingEnd IfEnd SubPrivate Sub cmd_edit_Click()On Error Resume NextDim AA = MsgBox("是否修改前记录?", vbYesNo + 32, "添加记录")If A = vbYes ThenExeCutesql "Update 定期存款 Set 日期 = '" & DTPicker1.Value & "',银行名称='" & txt_name.Text _& "',银行地址=" & txt_address.Text & ", 银行账号='" & txt_size.Text & "',金额='" & txt_money.Text _& "',期限='" & txt_time.Text & "',存款人='" & Combo1.Text & "',取否='" & Check1.Value & "' Where key = " & txt_key.Text & " ", Str_text 'Mydb.RequeryCall BangdingMsgBox "数据修改成功!", vbOKOnly + 64, "成功"End IfEnd SubPrivate Sub cmd_quit_Click()Unload MeEnd SubPrivate Sub Form_Load()Dim A As IntegerDTPicker1.Value = DateCall BangdingSet Mydb1 = ExeCutesql("select 姓名 from 成员 ", Str_text)A = Mydb1.RecordCountSet Combo1.DataSource = Mydb1For I = 1 To ACombo1.AddItem Mydb1.Fields(0)Mydb1.MoveNextIf Mydb1.EOF Then Exit ForNext IEnd SubPrivate Function Bangding()Set Mydb = ExeCutesql("select * from 定期存款 ", Str_text) Set MSHFlexGrid1.DataSource = MydbEnd FunctionPrivate Sub MSHFlexGrid1_Click()On Error Resume NextDTPicker1.Value = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 1) txt_name.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 2)txt_address.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 3)txt_size.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 4)txt_money.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 5) txt_time.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 6)Combo1.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 7)Check1.Value = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 8)txt_key.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 9)End Sub8、frm_intake.frmDim Mydb As New ADODB.RecordsetDim Mydb1 As New ADODB.RecordsetDim Mydb2 As New ADODB.RecordsetDim Count1 As New ADODB.RecordsetDim Str_text As StringPrivate Sub cmd_add_Click()On Error Resume NextDim A, BB = 1Set Count1 = ExeCutesql("select * from 收入", Str_text)Count1.MoveLastB = Count1.Fields(7) + 1A = MsgBox("是否添加前记录?", vbYesNo + 32, "添加记录")If A = vbYes ThenIf txt_intake.Text = "" ThenMsgBox "请填写来源!", vbOKOnly + 32, "注意"txt_intake.SetFocusElseExeCutesql "INSERT INTO 收入VALUES('" & Format(DTPicker1.Value, "yyyy-mm-dd") & "','" _& Combo1.Text & "'," & txt_money.Text & ",'" & Combo2.Text & "','" & txt_intake.Text _& "','" & Combo3.Text & "','" & txt_mome.Text & "'," & B & ")", Str_textMsgBox "数据已经保存!", vbOKOnly + 64, "成功"Call XiangmuCall DbEnd IfEnd IfEnd SubPrivate Sub cmd_close_Click()Unload MeEnd SubPrivate Sub cmd_del_Click()On Error Resume NextDim AA = MsgBox("是否删除当前记录?", vbYesNo + 32 + 256, "添加记录")If A = vbYes Then'Mydb.UpdateBatchExeCutesql "DELETE from 收入 where key=" & txt_note.Text & "", Str_textCall DbSet Mydb = ExeCutesql("select * from 收入 ", Str_text)Set MSHFlexGrid1.DataSource = MydbEnd IfEnd SubPrivate Sub cmd_edit_Click()'On Error Resume NextDim AA = MsgBox("是否修改当前记录?", vbYesNo + 32, "添加记录")If A = vbYes ThenExeCutesql "Update 收入 Set 日期 = '" & Format(DTPicker1.Value, "yyyy-mm-dd") & "',方式='" & Combo1.Text & "',金额=" & txt_money.Text & ", 来源='" & txt_intake.Text & "',人员='" & Combo3.Text & "',备注='" & txt_mome.Text & "' Where key = " & txt_note.Text & " ", Str_textCall DbMsgBox "数据修改成功!", vbOKOnly + 64, "成功"End If'MsgBox "Update 收入 Set 日期 = '" & DTPicker1.Value & "',方式='" & Combo1.Text & "',金额=" & txt_money.Text & ", 来源='" & txt_intake.Text & "',人员='" & Combo3.Text & "',备注='" & txt_mome.Text & "' Where key = '" & txt_note.Text & " '"End SubPrivate Sub Combo2_Change()Call Db1End SubPrivate Sub Combo3_Change()Call Db2End SubPrivate Sub Command1_Click()Call DbEnd SubPrivate Sub Form_Load()Call DbCall Db1Call Db2DTPicker1.Value = Date'Combo3.Locked = True'Combo1.Locked = TrueEnd SubPublic Function Db()Set Mydb = ExeCutesql("select * from 收入 order by key ", Str_text) Set MSHFlexGrid1.DataSource = MydbEnd FunctionPublic Function Db1()On Error Resume NextDim A As IntegerSet Mydb1 = ExeCutesql("select * from 收入项目 ", Str_text)A = Mydb1.RecordCountSet Combo2.DataSource = Mydb1For I = 1 To ACombo2.AddItem Mydb1.Fields(0)Mydb1.MoveNextIf Mydb1.EOF Then Exit ForNext IEnd FunctionPublic Function Db2()On Error Resume NextDim A As IntegerSet Mydb2 = ExeCutesql("select * from 成员", Str_text)A = Mydb2.RecordCountSet Combo3.DataSource = Mydb2For I = 1 To ACombo3.AddItem Mydb2.Fields(0)Mydb2.MoveNextIf Mydb2.EOF Then Exit ForNext ICombo3.AddItem "全家"End FunctionPrivate Sub Form_Unload(Cancel As Integer)'Mydb.Close'Mydb1.Close'Mydb2.CloseEnd SubPrivate Sub MSHFlexGrid1_Click()On Error Resume NextDTPicker1.Value = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 1) Combo1.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 2)txt_money.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 3) Combo2.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 4)txt_intake.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 5) Combo3.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 6)txt_mome.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 7)txt_note.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 8)End SubPrivate Sub txt_money_LostFocus()Dim A As BooleanDim CC = txt_money.TextA = IsNumeric(C)If C = "" ThenMsgBox "请输入金额!", vbOKOnly + 32, "注意!"txt_money.SetFocusElseIf A = False ThenMsgBox "金额只能输入数字!", vbOKOnly + 32, "注意!"txt_money.SetFocusEnd IfEnd IfEnd SubPrivate Function Xiangmu()Dim ADim Str_text As StringDim Db As New ADODB.RecordsetStr_text = Combo2.TextSet Db = ExeCutesql("select * from 支出项目 where value='" &Str_text & "'", "")'MsgBoxIf Not Str_text = Db.Fields(0) ThenExeCutesql "insert into 支出项目 values('" & Str_text & "')", ""End IfEnd Function9、frm_list.frmDim Mydb As New ADODB.RecordsetDim Mydb1 As New ADODB.RecordsetDim Money As New ADODB.RecordsetDim Money1 As New ADODB.RecordsetDim Str_text As StringPrivate Sub Command1_Click()frm_rate.ShowEnd SubPrivate Sub Command2_Click()frm_date.ShowEnd SubPrivate Sub Command3_Click()Unload MeEnd SubPrivate Sub Form_Activate()On Error Resume NextDim A, B, C As IntegerDim D As StringDim Year1, Month1, Riqi, Riqi1, Riqi3, Riqi4If AA = True ThenSet Mydb = ExeCutesql("select * from 收入 where 日期 between '" & Cdate1 & "' and '" & Cdate2 & "' ", "")Set MSHFlexGrid1.DataSource = MydbSet Mydb1 = ExeCutesql("select * from 支出 where 日期 between '" & Cdate1 & "' and '" & Cdate2 & "' ", "")Set MSHFlexGrid2.DataSource = Mydb1Set Money = ExeCutesql("select sum(金额) from 收入 where 日期between '" & Cdate1 & "'and '" & Cdate2 & "'", "")A = Money.Fields(0)If IsNull(A) ThenA = 0。

C语言课程设计——家庭财务管理系统

C语言课程设计——家庭财务管理系统

C语言课程设计——家庭财务管理系统#include<tdio.h>#include<tring.h>#include<tdlib.h>#include<conio.h>#definema某ize2000//定义家庭成员最大人数#definema某infor20000//定义收支信息的最大容量tructpeople//家庭成员登录信息结构{charuername[200];//用户名(也是姓名)charcode[200];//密码charflag[200];//标志0为普通成员,1为家长}peo[ma某ize];tructthing//成员收支信息结构{charname[30];//姓名intyear;//年份intmonth;//月份intoutput;//支出}thi[ma某infor];intn=0,m=0;//全局变量n为文件中家庭成员实际容量m为文件中收支信息实际容量inthold()//将数据写进文件中{FILE某fp;inti;fp=fopen("peoplelit4.t某t","w");{fprintf(fp,"%d\n",n);for(i=0;i<n;i++)fprintf(fp,"%%%\n",peo[i].uername,peo[i].code,peo[i].flag);} fcloe(fp);fp=fopen("thinglit4.t某t","w");{fprintf(fp,"%d\n",m);for(i=0;i<m;i++)}fcloe(fp);return0;}intcarry()//将数据从文件中读出{FILE某fp;inti;if((fp=fopen("peoplelit4.t某t","r"))!=NULL){fcanf(fp,"%d\n",&n);for(i=0;i<n;i++)fcanf(fp,"%%%\n",peo[i].uername,peo[i].code,peo[i].flag);} fcloe(fp);if((fp=fopen("thinglit4.t某t","r"))!=NULL){fcanf(fp,"%d\n",&m);for(i=0;i<m;i++)}fcloe(fp);return0;}intmater()//初始化家长{carry();if(n==0){trcpy(peo[n].uername,"小明"); trcpy(peo[n].code,"2022");trcpy(peo[n].flag,"1");n++;}hold();return0;}intadd_people()//增加新的家庭成员{intj=1,i,q=100,m=3;carry();printf("\n【添加新成员】\n\n"); printf("\n请输入新成员姓名:");canf("%",peo[n].uername);for(i=0;i<n;i++){if(trcmp(peo[i].uername,peo[n].uername)==0){j=0;break;}}if(j==0)printf("\n该成员已存在。

家庭财务管理系统(多文件版)

家庭财务管理系统(多文件版)
scanf("%d%d",&year,&month);
for(i=0;i<m;i++)
if(strcmp(inf[i].name,name) == 0 && inf[i].year == year && inf[i].month == month)
{
g=i;
h=1;
if(k==1)
{
for(i=0;i<n;i++)
if(strcmp(peo[i].username,name)==0)
{
g=i;
p=1;
break;
}
if(p==1)
{
n=h-1;
fp=fopen("memberlist.txt","w");
int year; //年份
int month; //月份
int income; //收入
int output; //支出
}inf[MAX_INF];
int n,m; //全局变量 n为文件中家庭成员实际容量 m为文件中收支信息实际容量
#define FINANCE_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <ctype.h>
#define MAX_PEO 2000 //定义家庭成员最大人数
printf(" 1. 浏览家庭成员信息 2. 修改家庭成员收支信息\n");

C语言家庭财务管理系统代码

C语言家庭财务管理系统代码

#include <stdio.h>#include <stdlib.h>#include <string.h>struct Data{char name[20];char riqi[8];float money;char beizhu[50];};struct list{struct Data info;struct list *next;};struct list *Inhead=NULL;struct list *Intail=NULL;struct list *zhichuhead=NULL;struct list *zhichutail=NULL;struct list *temp=NULL;void chaxun_income();void chaxun_zhichu();void xiugai_income();void xiugai_zhichu();void Save_income(){FILE *fp;fp=fopen("D:\家庭财务管理.txt","w");struct list *p = Inhead;while(p != NULL){fwrite(&p->info, sizeof(struct Data), 1, fp);p = p->next;}fclose(fp);}void Save_zhichu(){FILE *fp;fp=fopen("D:\家庭财务管理支出.txt","w");struct list *p = zhichuhead;while(p != NULL){fwrite(&p->info, sizeof(struct Data), 1, fp);p = p->next;}fclose(fp);}void Open(){FILE *fp;fp=fopen("D:\家庭财务管理.txt","r");if(fp!=NULL){struct Data linshi;while(fread(&linshi, sizeof(struct Data), 1, fp) == 1){temp=(struct list*)malloc(sizeof(struct list));temp->info=linshi;temp->next=NULL;if(Inhead == NULL){Inhead = temp;Intail = temp;}else{Intail->next = temp;Intail = temp;}}fclose(fp);}}void Menu(){ system("cls");printf("\n");printf("\n");printf("\n");printf("\n");printf("******************\n");printf("欢迎使用家庭财务管理系统\n");printf("******************\n");printf(" \n");printf(" 1:收入操作\n");printf(" 2:支出操作\n");printf(" 3:统计操作\n");printf(" 0:退出\n");}void Openzhichu(){FILE *fp;fp=fopen("D:\家庭财务管理支出.txt","r");if(fp!=NULL){struct Data linshi;while(fread(&linshi, sizeof(struct Data), 1, fp) == 1){temp=(struct list*)malloc(sizeof(struct list));temp->info=linshi;temp->next=NULL;if(zhichuhead == NULL){zhichuhead = temp;zhichutail = temp;}else{zhichutail->next = temp;zhichutail = temp;}}fclose(fp);}}void mingzi (){char chazhao[20];printf("请输入查询的名字");gets(chazhao);struct list *p = Inhead;while(p != NULL){if(strcmp(p->,chazhao)==0){printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("收入:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);system("PAUSE");}p = p->next;}if(Inhead!=NULL){char panduan;printf("是否继续查询(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){chaxun_income();}}}void mingzi_zhichu (){char chazhao[20];printf("请输入查询的名字");gets(chazhao);struct list *p = zhichuhead;while(p != NULL){if(strcmp(p->,chazhao)==0){printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("收入:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);system("PAUSE");}p = p->next;}if(zhichuhead!=NULL){char panduan;printf("是否继续查询(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){chaxun_zhichu();}}}void mingzi_xiugai_income(){char xiugai[20];printf("请输入修改的名字");fflush(stdin);gets(xiugai);struct list *p = Inhead;while(p != NULL){if(strcmp(p->,xiugai)==0){fflush(stdin);printf("姓名:");gets(p->);fflush(stdin);printf("日期:");gets(p->info.riqi);fflush(stdin);printf("支出: ");scanf("%f",&p->info.money);fflush(stdin);printf("备注:");gets(p->info.beizhu);fflush(stdin);//------}p = p->next;}Save_income();if(Inhead!=NULL){char panduan;printf("是否继续修改(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){xiugai_income();}}}void mingzi_xiugai_zhichu(){char xiugai[20];printf("请输入修改的名字");fflush(stdin);gets(xiugai);struct list *p = zhichuhead;while(p != NULL){if(strcmp(p->,xiugai)==0){fflush(stdin);printf("姓名:");gets(p->);fflush(stdin);printf("日期:");gets(p->info.riqi);fflush(stdin);printf("支出: ");scanf("%f",&p->info.money);fflush(stdin);printf("备注:");gets(p->info.beizhu);fflush(stdin);//------}p = p->next;}Save_zhichu();if(zhichuhead!=NULL){char panduan;printf("是否继续修改(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){xiugai_zhichu();}}}void riqi(){char chazhao[20];printf("请输入查询的日期");gets(chazhao);struct list *p = Inhead;while(p != NULL){if(strcmp(p->info.riqi,chazhao)==0){printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("收入:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);system("PAUSE");}p = p->next;}if(Inhead!=NULL){char panduan;printf("是否继续查询(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){chaxun_income();}}}void riqi_zhichu(){char chazhao[20];printf("请输入查询的日期");gets(chazhao);struct list *p = zhichuhead;while(p != NULL){if(strcmp(p->info.riqi,chazhao)==0){printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("收入:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);system("PAUSE");}p = p->next;}if(zhichuhead!=NULL){char panduan;printf("是否继续查询(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){chaxun_zhichu();}}}void riqi_xiugai_income(){char xiugai[20];printf("请输入修改的日期");fflush(stdin);gets(xiugai);struct list *p = Inhead;while(p != NULL){if(strcmp(p->info.riqi,xiugai)==0){fflush(stdin);printf("姓名:");gets(p->);fflush(stdin);printf("日期:");gets(p->info.riqi);fflush(stdin);printf("支出: ");scanf("%f",&p->info.money);fflush(stdin);printf("备注:");gets(p->info.beizhu);fflush(stdin);//------}p = p->next;}Save_income();if(Inhead!=NULL){char panduan;printf("是否继续修改(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){xiugai_income();}}}void riqi_xiugai_zhichu(){char xiugai[20];printf("请输入修改的日期");fflush(stdin);gets(xiugai);struct list *p = zhichuhead;while(p != NULL){if(strcmp(p->info.riqi,xiugai)==0){fflush(stdin);printf("姓名:");gets(p->);fflush(stdin);printf("日期:");gets(p->info.riqi);fflush(stdin);printf("支出: ");scanf("%f",&p->info.money);fflush(stdin);printf("备注:");gets(p->info.beizhu);fflush(stdin);//------}p = p->next;}Save_zhichu();if(zhichuhead!=NULL){char panduan;printf("是否继续修改(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){xiugai_zhichu();}}}void money (){float chazhao;printf("请输入查询的money");scanf("%f",&chazhao);fflush(stdin);struct list *p = Inhead;while(p != NULL){if(p->info.money==chazhao){printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("收入:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);system("PAUSE");}p = p->next;}if(Inhead!=NULL){char panduan;printf("是否继续查询(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){chaxun_income();}}}void money_zhichu (){float chazhao;printf("请输入查询的money");scanf("%f",&chazhao);fflush(stdin);struct list *p = zhichuhead;while(p != NULL){if(p->info.money==chazhao){printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("收入:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);system("PAUSE");}p = p->next;}if(zhichuhead!=NULL){char panduan;printf("是否继续查询(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){chaxun_zhichu();}}}void money_xiugai_income(){float xiugai;printf("请输入修改的money");scanf("%f",&xiugai);fflush(stdin);struct list *p = Inhead;while(p != NULL){if(p->info.money==xiugai){fflush(stdin);printf("姓名:");gets(p->);fflush(stdin);printf("日期:");gets(p->info.riqi);fflush(stdin);printf("支出: ");scanf("%f",&p->info.money);fflush(stdin);printf("备注:");gets(p->info.beizhu);fflush(stdin);//------}p = p->next;}Save_income();if(Inhead!=NULL){char panduan;printf("是否继续修改(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){xiugai_income();}}}void money_xiugai_zhichu(){float xiugai;printf("请输入修改的money");scanf("%f",&xiugai);fflush(stdin);struct list *p = zhichuhead;while(p != NULL){if(p->info.money==xiugai){fflush(stdin);printf("姓名:");gets(p->);fflush(stdin);printf("日期:");gets(p->info.riqi);fflush(stdin);printf("支出: ");scanf("%f",&p->info.money);fflush(stdin);printf("备注:");gets(p->info.beizhu);fflush(stdin);//------}p = p->next;}Save_zhichu();if(zhichuhead!=NULL){char panduan;printf("是否继续修改(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){xiugai_zhichu();}}}void beizhu(){char chazhao[20];printf("请输入查询的备注");gets(chazhao);struct list *p = Inhead;while(p != NULL){if(strcmp(p->info.beizhu,chazhao)==0){printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("收入:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);system("PAUSE");}p = p->next;}if(Inhead!=NULL){char panduan;printf("是否继续查询(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){chaxun_income();}}}void beizhu_zhichu(){char chazhao[20];printf("请输入查询的备注");gets(chazhao);struct list *p = zhichuhead;while(p != NULL){if(strcmp(p->info.beizhu,chazhao)==0){printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("收入:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);system("PAUSE");}p = p->next;}if(zhichuhead!=NULL){char panduan;printf("是否继续查询(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){chaxun_zhichu();}}}void beizhu_xiugai_income(){char xiugai[20];printf("请输入修改的备注");fflush(stdin);gets(xiugai);struct list *p = Inhead;while(p != NULL){if(strcmp(p->info.beizhu,xiugai)==0){fflush(stdin);printf("姓名:");gets(p->);fflush(stdin);printf("日期:");gets(p->info.riqi);fflush(stdin);printf("支出: ");scanf("%f",&p->info.money);fflush(stdin);printf("备注:");gets(p->info.beizhu);fflush(stdin);//------}p = p->next;}Save_income();if(Inhead!=NULL){char panduan;printf("是否继续修改(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){xiugai_income();}}}void beizhu_xiugai_zhichu(){char xiugai[20];printf("请输入修改的备注");fflush(stdin);gets(xiugai);fflush(stdin);struct list *p = zhichuhead;while(p != NULL){if(strcmp(p->info.beizhu,xiugai)==0){fflush(stdin);printf("姓名:");gets(p->);fflush(stdin);printf("日期:");gets(p->info.riqi);fflush(stdin);printf("支出: ");scanf("%f",&p->info.money);fflush(stdin);printf("备注:");gets(p->info.beizhu);fflush(stdin);//------}p = p->next;}Save_zhichu();if(zhichuhead!=NULL){char panduan;printf("是否继续修改(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){xiugai_zhichu();}}}void Income_menu(){system("cls");printf("\n");printf("\n");printf("\n");printf("\n");printf("******************\n");printf("欢迎使用家庭财务管理系统\n");printf("******************\n");printf(" \n");printf(" 1.添加收入\n");printf(" 2.删除收入\n");printf(" 3.查询收入\n");printf(" 4.显示收入\n");printf(" 5.修改收入\n");printf(" 0.返回上一级\n");}void zhichu_menu(){system("cls");printf("\n");printf("\n");printf("\n");printf("\n");printf("******************\n");printf("欢迎使用家庭财务管理系统\n");printf("******************\n");printf(" \n");printf(" 1.添加支出\n");printf(" 2.删除支出\n");printf(" 3.查询支出\n");printf(" 4.显示支出\n");printf(" 5.修改支出\n");printf(" 0.返回上一级\n");}void chaxun_menu(){system("cls");printf("\n");printf("\n");printf("\n");printf("\n");printf("******************\n");printf("欢迎使用家庭财务管理系统\n");printf("******************\n");printf(" \n");printf(" 1.按名字查询\n");printf(" 2.按日期查询\n");printf(" 3.按money询\n");printf(" 4.按备注查询\n");printf(" 0.返回上一级\n"); }void xiugai_menu(){system("cls");printf("\n");printf("\n");printf("\n");printf("\n");printf("******************\n");printf("欢迎使用家庭财务管理系统\n");printf("******************\n");printf(" \n");printf(" 1.按名字修改\n");printf(" 2.按日期修改\n");printf(" 3.按money修改\n");printf(" 4.按备注修改\n");printf(" 0.返回上一级\n");}void Add_income(){char panduan;do{temp=(struct list*)malloc(sizeof(struct list));printf("姓名");gets(temp->);fflush(stdin);printf("日期(XX年XX月XX日)");gets(temp->info.riqi);fflush(stdin);printf("收入");scanf("%f",&temp->info.money);fflush(stdin);printf("备注");gets(temp->info.beizhu);fflush(stdin);printf("\n");//------自己添加temp->next=NULL;if(Inhead == NULL){Inhead = temp;Intail = temp;}else{Intail->next = temp;Intail = temp;}Save_income();//后面可以添加“继续添加功能”printf("是否(Y/N)继续添加信息\n");panduan=getchar();fflush(stdin);}while(panduan=='Y'||panduan=='y');system("PAUSE");}void Add_zhichu(){char panduan;do{temp=(struct list*)malloc(sizeof(struct list));printf("姓名");gets(temp->);fflush(stdin);printf("日期(XX年XX月XX日)");gets(temp->info.riqi);fflush(stdin);printf("支出");scanf("%f",&temp->info.money);fflush(stdin);printf("备注");gets(temp->info.beizhu);fflush(stdin);printf("\n");//------自己添加temp->next=NULL;if(zhichuhead == NULL){zhichuhead = temp;zhichutail = temp;}else{zhichutail->next = temp;zhichutail = temp;}Save_zhichu();//后面可以添加“继续添加功能”printf("是否(Y/N)继续添加信息\n");panduan=getchar();fflush(stdin);}while(panduan=='Y'||panduan=='y');system("PAUSE");}void Del_income(){char shanchu[20];struct list *p=NULL;struct list *m =NULL;struct list *n =NULL;p=Inhead;printf("请输入删除姓名");gets(shanchu);if(strcmp(Inhead->,shanchu)==0){while(Inhead!=NULL && strcmp(Inhead->,shanchu)==0) {char ch;printf("找到一个数据名字为%s,确认删除Y/N?",shanchu);ch=getchar();fflush(stdin);if(ch=='y'||ch=='Y') Inhead=Inhead->next;else break;}}else{if(strcmp(Intail->,shanchu)==0){do{ m=p;p=p->next;}while(p!=Intail);m->next=NULL;}//删除尾巴else{do{m=p;p=p->next;n=p->next;}while(strcmp(p->,shanchu)!=0&&n->next!=NULL);if(strcmp(p->,shanchu)==0)m->next=n;}}//删除除头节点之外的节点,自己课后完成Save_income();if(Inhead!=NULL){char panduan;printf("是否继续删除(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){Del_income();}}}void Del_zhichu(){char shanchu[20];struct list *p=NULL;struct list *m =NULL;struct list *n =NULL;p=zhichuhead;printf("请输入删除姓名");gets(shanchu);if(strcmp(zhichuhead->,shanchu)==0){while(zhichuhead!=NULL && strcmp(zhichuhead->,shanchu)==0) {char ch;printf("找到一个数据名字为%s,确认删除Y/N?",shanchu);ch=getchar();fflush(stdin);if(ch=='y'||ch=='Y') zhichuhead=zhichuhead->next;else break;}}else{if(strcmp(zhichutail->,shanchu)==0){do{ m=p;p=p->next;}while(p!=zhichutail);m->next=NULL;}//删除尾巴else{do{m=p;p=p->next;n=p->next;}while(strcmp(p->,shanchu)!=0&&n->next!=NULL);if(strcmp(p->,shanchu)==0)m->next=n;}}Save_zhichu();//删除除头节点之外的节点,自己课后完成if(zhichuhead!=NULL){char panduan;printf("是否继续删除(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){Del_zhichu();}}}void xiugai_income(){xiugai_menu();int choice;printf(" 请输入你的选择:");scanf("%d",&choice);fflush(stdin);switch(choice){case 1: mingzi_xiugai_income();break;case 2: riqi_xiugai_income();break;case 3: money_xiugai_income();break;case 4: beizhu_xiugai_income();break;default: printf("输入错误");break;}}void xiugai_zhichu(){xiugai_menu();int choice;printf(" 请输入你的选择:");scanf("%d",&choice);fflush(stdin);switch(choice){case 1: mingzi_xiugai_zhichu();break;case 2: riqi_xiugai_zhichu();break;case 3: money_xiugai_zhichu();break;case 4: beizhu_xiugai_zhichu();break;default: printf("输入错误");break;}}void chaxun_income(){chaxun_menu();int choice;printf(" 请输入你的选择:");scanf("%d",&choice);fflush(stdin);switch(choice){case 1: mingzi();break;case 2: riqi();break;case 3: money();break;case 4: beizhu();break;default: printf("输入错误");break;}}void chaxun_zhichu(){chaxun_menu();int choice;printf(" 请输入你的选择:");scanf("%d",&choice);fflush(stdin);switch(choice){case 1: mingzi_zhichu();break;case 2: riqi_zhichu();break;case 3: money_zhichu();break;case 4: beizhu_zhichu();break;default: printf("输入错误");break;}}void Sho_income(){struct list *p = Inhead;while(p != NULL){printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("收入:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);p = p->next;}system("PAUSE");}void Sho_zhichu(){struct list *p = zhichuhead;while(p != NULL){fflush(stdin);printf("姓名:");puts(p->);printf("日期:");puts(p->info.riqi);printf("支出:");printf("%.4f\n",p->info.money);printf("备注:");puts(p->info.beizhu);p = p->next;}system("PAUSE");}void Income(){int choice;while(1){Income_menu();printf("请输入选择");scanf("%d",&choice);fflush(stdin);if(choice==0){break;}elseswitch(choice){case 1: Add_income(); Save_income();break;case 2: Del_income(); Save_income();break;case 3: chaxun_income(); Save_income();break;case 4: Sho_income(); Save_income();break;case 5: xiugai_income(); Save_income();break;}}}void zhichu(){int choice;while(1){zhichu_menu();printf("请输入选择");scanf("%d",&choice);fflush(stdin);if(choice==0){break;}elseswitch(choice){case 1: Add_zhichu(); Save_zhichu();break;case 2: Del_zhichu(); Save_zhichu();break;case 3: chaxun_zhichu(); Save_zhichu();break;case 4: Sho_zhichu(); Save_zhichu();break;case 5: xiugai_zhichu(); Save_zhichu();break;}}}void tongji_menu(){system("cls");printf("\n");printf("\n");printf("\n");printf("\n");printf("******************\n");printf("欢迎使用家庭财务管理系统\n");printf("******************\n");printf(" \n");printf(" 1.总收入\n");printf(" 2.总支出\n");printf(" 3.总资金\n");printf(" 0.返回上一级\n");}void zongshouru(){float shouru=0;struct list *linshi;linshi=Inhead;if(linshi!=NULL){do{shouru=linshi->info.money+shouru;linshi=linshi->next;}while(linshi!=NULL);printf("%.4f",shouru);system("PAUSE");}}void zongzhichu(){float zhichu=0;struct list *linshi;linshi=zhichuhead;if(linshi!=NULL){do{zhichu=linshi->info.money+zhichu;linshi=linshi->next;}while(linshi!=NULL);printf("%.4f",zhichu);system("PAUSE");}}void zongzijin(){float zhichu=0;float zongzijin;struct list *linshi;linshi=zhichuhead;if(linshi!=NULL){do{zhichu=linshi->info.money+zhichu;linshi=linshi->next;}while(linshi!=NULL);}float shouru=0;linshi=Inhead;if(linshi!=NULL){do{shouru=linshi->info.money+shouru;linshi=linshi->next;}while(linshi!=NULL);printf("%.4f",shouru-zhichu);system("PAUSE");}}void Tongji(){while(1){tongji_menu();int choice;printf(" 请输入你的选择:");scanf("%d",&choice);if(choice==0){break;}switch(choice){case 1: zongshouru();break;case 2: zongzhichu();break;case 3: zongzijin();break;default: printf("输入错误");break;}}}void Quit(){char panduan;printf("确认退出(Y/N)");panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){exit(0);}}int main(){Open();Openzhichu();system("color 72");while(1){Menu();int choice;printf(" 请输入你的选择:");scanf("%d",&choice);fflush(stdin);switch(choice){case 1: Income();break;case 2: zhichu();break;case 3: Tongji();break;case 0: Quit();break;default: printf("输入错误");break;}}return 0;}。

家庭财务管理系统源代码

家庭财务管理系统源代码

include<>include<>include<>include<>define LEN sizeofstruct financialdefine FFORMAT "%-8d%-15s%-10d%-10d%%%\n"define DATA memberi.num,,memberi.month,memberi.year,memberi.income,memberi.output, memberi.totalstruct financial 退出|\n";printf"| 1. 录入信息|\n";printf"| 2. 查找信息|\n";printf"| 3. 删除信息|\n";printf"| 4. 修改信息|\n";printf"| 5. 统计信息|\n";printf"|-------------------------------------------------|\n";printf"选择0-5:";}void in um; um == memberm.num{printf"该记录已经存在,按任意键继续";getch;fclosefp;return;}printf"家庭成员姓名:";scanf"%s",; onth; ear; ncome; utput; otal=memberm.income - memberm.output; ame;m++;}printf"是否继续y/n:";scanf"%s",ch;}fclosefp;printf"OK\n";}void show{FILE fp;int i,m=0;fp=fopen"家庭财务管理系统","ab+";whilefeoffp{iffread&memberm ,LEN,1,fp==1m++;}fclosefp;printf"编号成员月份年分收入支出总金额\t\n";fori=0;i<m;i++{printfFFORMAT,DATA;}}void del{FILE fp;int snum,i,j,m=0;char ch2;iffp=fopen"家庭财务管理系统","ab+"==NULL{printf"不能打开文件\n";return;}whilefeoffpiffread&memberm,LEN,1,fp==1m++;fclosefp;ifm==0{printf"没有记录\n";return;}printf"请输入编号:";scanf"%d",&snum;fori=0;i<m;i++ifsnum==memberi.numbreak;ifi==m{printf"没有找到";return;}printf"已经找到该记录,是否删除y/n";scanf"%s",ch;ifstrcmpch,"Y"==0||strcmpch,"y"==0 um{printf"已经找到该记录,是否显示y/n";scanf"%s",ch;ifstrcmpch,"Y"==0||strcmpch,"y"==0{printf"编号成员月份年份收入支出总金额\t\n";printfFFORMAT,DATA;break;}elsereturn;}ifi==mprintf"没有找到相应的记录\n";}void modify{FILE fp;int i,j,m=0,snum;char ch2;iffp=fopen"家庭财务管理系统","ab+"==NULL{printf"不能打开文件\n";return;}whilefeoffpiffread&memberm,LEN,1,fp==1m++;ifm==0{printf"没有记录\n";fclosefp;return;}printf"请输入要修改的记录信息的编号\n";scanf"%d",&snum;fori=0;i<m;i++ifsnum==memberi.num ame; onth; ear; ncome;utput; otal=memberi.income - memberi.output; //汇总printf"保存成功";}elsereturn;}else{printf"没有找到";return;}iffp=fopen"家庭财务管理系统","wb"==NULL{printf"不能打开文件\n";return;}forj=0;j<m;j++ //将新修改的信息写入指定的磁盘文件中iffwrite&memberj ,LEN,1,fp=1{printf"不能保存";}fclosefp;}void total // 统计{FILE fp;int m=0;iffp=fopen"家庭财务管理系统","ab+"==NULL{printf"不能打开记录\n";return;}whilefeoffpiffread&memberm,LEN,1,fp==1m++; //统计记录个数ifm==0{printf"没有记录\n";fclosefp;return;}printf"一共有%d 条记录\n",m; //将统计的个数输出fclosefp;}。

C语言课程设计——家庭财务管理系统

C语言课程设计——家庭财务管理系统

课程设计陈述之袁州冬雪创作课程设计题目:家庭财务管理系统学生姓名:专业:信息工程班级:指导教员:2018年 1月 8日1.需求分析根据家庭账务管理的需要,建立一个“家庭账务管理系统”,以方便对家庭日常收入及支出停止记录和管理.该系统要求:①家庭月收入管理②家庭月支出管理③统计家庭总收入/总支出④系统提供收入/支出的添加、删除和修改功能.2. 总体设计根据以上分析,本家庭账务管理系统主要包含:①从键盘键入家庭月收入、月支出数据;②查询月收入、月支出明细;③删除收入、支出数据;④修改收入、支出数据;⑤统计总收入/总支出;⑥退出系统.除main()函数之外,系统还定义了以下函数来实现各部分内容:①add_income():添加收入数据函数.②add_payout():添加支出数据函数.③search_data():查找数据函数.④initialize():初始化函数,读取文本数据.⑤show_info():显示数据函数.⑥count_total():统计函数,统计总收入、总支出.⑦update_data():修改信息函数.⑧delete_data():删除数据函数.⑨quit():退出函数.程序布局功能图如下:3.详细设计4.测试成果4.1 程序运行主菜单4.2 添加收入测试4.3 查询收入明细测试4.4 删除收入测试4.5 修改收入测试4.6 添加支出测试4.7 查询支出明细测试4.8 删除支出测试4.9 修改支出测试4.10 统计总收入/支出测试4.11 退出系统测试5.软件操纵使用说明书本系统采取饬令行对话方式停止操纵,运行后出现主界面(如下图所示),然后依照主界面菜单指引操纵即可.编写程序之前要有一个整体的思路,不克不及写到哪里算哪里.这样很容易遗漏,持续性也欠好.通过本次的课程设计让我对于数组、文件的存放、循环布局等知识有了更加透彻的懂得.希望在以后的课程设计中对于知识的运用可以更加的熟练.代码:#include <stdio.h>#include <stdlib.h>#include <string.h>#include <conio.h>#define MAXNAME 11 //家庭成员姓名的最大长度#define MAXDETAIL 21 //注最大长度//自定义列举类型fi_type,用来暗示收入与支出typedef enum _fi_type{income=1,//收入payout =-1 //支出} fi_type;// 家庭财务信息布局体typedef struct _fi_info{int year;int month;fi_type type;char name[9];float money;char detail[11];}fi_info;// 存储财务数据布局的布局体typedef struct _fi_data{fi_info info;struct _fi_data* next;} fi_data;fi_data *head;//财务数据的头结点 void menu();//菜单函数void add_income();void search_income();void delete_income();void update_income();void add_payout();void search_payout();void delete_payout();void update_payout();void count_total();void quit();//void search_data(fi_type type);void delete_data(fi_type type);void update_data(fi_type type);//void initialize();void save_to_file();void clear_data();fi_data *get_last();fi_data *get_previous(fi_data *p); void input_info(fi_info *info);void show_info(fi_data *p);void menu(){printf("\n");printf("\t\t~~~~~~~~~~~~~~~~~~~~~~\n");printf("\t\t~~~~~~~~~~~~~~~~~~~~~~\n");printf("\t\t\t 家庭财务管理系统\n");printf("\t\t~~~~~~~~~~~~~~~~~~~~~~\n");printf("\t\t~~~~~~~~~~~~~~~~~~~~~~\n");printf("\t\t*************************************** ****\n");printf("\t\t收入管理:");printf("1.添加收入");printf(" 2.查询收入明细\n");printf("\t\t\t 3.删除收入");printf(" 4.修改收入\n");printf("\t\t*************************************** ****\n");printf("\t\t支出管理:");printf("5.添加支出");printf(" 6.查询支出明细\n");printf("\t\t\t 7.删除支出");printf(" 8.修改支出\n");printf("\t\t*************************************** ****\n");printf("\t\t统计:");printf("9.统计总收入/总支出\n");printf("\t\t*************************************** ****\n");printf("\t\t退出:0.退出系统\n");printf("\t\t*************************************** ****\n\n\n");}void main(){int selected=0;initialize();while(selected>=0&&selected<=9){system("cls");menu();printf("\t\t>请选择要停止的操纵(0-9):");if(scanf("%d",&selected)!=1||selected<0||selected>9) {printf("\t\t>输入有误!请选择(0-9)之间的数字!按任意键重试");getchar();}else{switch(selected){case 0:exit(0);clear_data();break;case 1:add_income();save_to_file();break; case 2:search_income();break;case3:delete_income();save_to_file();break;case4:update_income();save_to_file();break;case 5:add_payout();save_to_file();break;case 6:search_payout();break;case7:delete_payout();save_to_file();break;case8:update_payout();save_to_file();break;case 9:count_total();break;}}}}void add_income()//添加收入{fi_data *p=(fi_data *)malloc(sizeof(fi_data)); p->next=NULL;input_info(&(p->info));p->info.type=income;if(head==NULL)head=p;elseget_last()->next=p;}void add_payout()//添加支出{fi_data *p=(fi_data *)malloc(sizeof(fi_data)); p->next=NULL;input_info(&(p->info));p->info.type=payout;if(head==NULL)head=p;elseget_last()->next=p;}//输入函数void input_info(fi_info *info){printf("\t\t>请输入年代(YYYY/M)");scanf("%d/%d",&(info->year),&(info->month));printf("\t\t>请输入家庭成员姓名(最大长度为%d):",MAXNAME-1);scanf("%s",info->name);printf("\t\t>输入金额:");scanf("%f",&(info->money));printf("\t\t>请输入备注(最大长度为%d):",20);scanf("%s",info->detail);}//查找数据函数void search_data(fi_type type){int year=0;int month=0;fi_data *p=NULL;int count=0;char input=' ';while(1){printf("\t\t>请输入要查询的年代(YYYY/M)"); if(scanf("%d/%d",&year,&month)!=2){printf("\t\t>输入有误\n");}else{p=head;count=0;while(p!=NULL){if((p->info.year==year)&&(p->info.month==month)&&(p->info.type==type)){show_info(p);system("PAUSE");count++;}p=p->next;}if(count==0){printf("\t\t>没有找到数据\n");}printf("\t\t>继续查找其他数据?(y or n)"); input=getchar();if(input=='y'||input=='Y')continue;elsebreak;}}}//初始化函数,读取文本数据void initialize(){FILE * fp=NULL;fi_data *p=NULL;fi_data *last=NULL;int count=0;fp=fopen("data.txt","rb");if(fp==NULL){fp=fopen("data.txt","w");fclose(fp);return;}p=(fi_data*)malloc(sizeof(fi_data));memset(p,0,sizeof(fi_data));p->next=NULL;while(fread(&(p->info),sizeof(fi_info),1,fp)==1) {if(head==NULL)head=p;else{last=get_last();last->next=p;}count++;fseek(fp,count*sizeof(fi_info),SEEK_SET);p=(fi_data *)malloc(sizeof(fi_data));memset(p,0,sizeof(fi_data));p->next=NULL;}free(p);p=NULL;fclose(fp);}//显示信息函数void show_info(fi_data *p){int i=0;printf("|\t\t|\t\t|\t\t|\t\t|\t\t|\t\t|\n");printf("|NO.\t |年/月\t\t|类型\t\t|姓名\t\t|金额\t\t|备注\t\t|\n");printf("|%5d\t|%4d/%02d\t|%4s\t|%10s\t|%10.2f|%20s| \n",i+1,p->info.year,p->info.month,p->info.type==income?"收入":"支出",p->,p->info.money,p->info.detail);printf("|\t\t|\t\t|\t\t|\t\t|\t\t|\t\t|\n");}//统计总收入、总支出void count_total(){float total_income=0.0;float total_payout=0.0;fi_data *p=head;while(p!=NULL){if(p->info.type==income){total_income+=p->info.money;}else{total_payout+=p->info.money;}p=p->next;}printf("\t\t+\t\t+\t\t+\n");printf("\t\t|合计收入\t|合计支出\t|节余\t|\n");printf("\t\t%12.2f|%12.2f|%12.2f|\n",total_income,t otal_payout,total_income-total_payout);printf("\t\t+\t\t+\t\t+\n");printf("\t\t>按任意键返回主菜单");getchar();getchar();}//保管到文件void save_to_file(){FILE *fp=fopen("data.txt","wb" );fi_data *p=head;while(p!=NULL){fwrite(&(p->info),sizeof(fi_info),1,fp);fseek(fp,0,SEEK_END);p=p->next;}fclose(fp);}//修改信息函数void update_data(fi_type type){ int year=0;int month=0;fi_data *p=NULL;fi_data *pre=NULL;char input;int count=0;int i=0;while(1){ printf("\t\t>请输入要查询的年代(YYYY/M)"); if(scanf("%d/%d",&year,&month)!=2){printf("\t\t>输入有误\n");}else{p=head;count=0;while(p!=NULL){if((p->info.year==year)&&(p->info.month==month)&&(p->info.type==type)){count++;show_info(p);input_info(&(p->info));printf("\t\t修改成功\n");p=get_previous(p);}p=p->next;}if(count==0)printf("\t\t>没有找到数据\n");printf("\t\t>继续查找其他数据?(y or n)"); input=getchar();if(input=='y'||input=='Y')continue;elsebreak;}}}void delete_data(fi_type type)//删除数据函数 {int year=0;int month=0;fi_data *p=NULL;fi_data *pre=NULL;int count=0;char input=' ';int i=0;while(1){ printf("\t\t>请输入要查询的年代(YYYY/M)"); if(scanf("%d/%d",&year,&month)!=2){printf("\t\t>输入有误\n");}else{p=head;count=0;while(p!=NULL){if((p->info.year==year)&&(p->info.month==month)&&(p->info.type==type)){count++;show_info(p);pre=get_previous(p);if(pre==NULL)head=head->next;elsepre->next=p->next;free(p);printf("\t\t>删除成功\n");}p=p->next;}if(count==0)printf("\t\t>没有找到数据\n");printf("\t\t>继续查找其他数据?(y or n)"); input=getchar();if(input=='y'||input=='Y')continue;elsebreak;}}}void clear_data()//清空链表数据 {fi_data *p=NULL;while(head!=NULL){if(head->next!=NULL){p=head;head=head->next;free(p);p=NULL;}else{free(head);head=NULL;}}fi_data *get_last() {fi_data * p=head;if(p==NULL)return p;while((p!=NULL)&&(p->next!=NULL))p=p->next;return p;}fi_data *get_previous(fi_data *p){fi_data *previous=head;while(previous!=NULL){if(previous->next==p)break;previous=previous->next;}return previous;void search_payout() {search_data(payout); }void delete_payout() {delete_data(payout); }void update_payout() {update_data(payout); }void search_income() {search_data(income); }void delete_income() {delete_data(income); }void update_income()update_data(income); }。

家庭财务管理系统

家庭财务管理系统

//家庭财务管理系统,本程序扩充至一个小型的集体。

由于水平有限不能调用数据库信息不能永久保存,正在致力于研究!//实现家庭的各种账单(水/电/煤气费,宽带/电话费等)的管理功能,//可以对各类账单及用户信息进行登记、修改、删除等。

#include<iostream>using namespace std;#include<string>#define error 0int cost_n=-1;const int M=100; //给系统设定人数限制class cost //费用类,定义抽象类,虚函数{public:double *s; //费用成员指针virtual int get_n()=0; //定义一个费用总个数虚函数virtual double get_cost()=0; //定义计算费用的虚函数cost(){s=new double[M];for(int i=0;i<M;i++){s[i]=0.0;}}virtual ~cost(){delete[] s;}};class water_rate:public cost //水费类继承费用类{public:double *t; //用水量int nT; //用户用水个数water_rate(); //构造函数~water_rate(); //析构函数void set(); //输入信息函数void set_water(); //显示水费函数int get_n(); //返回用户水费个数函数double get_cost(); //返回用户用水总费用函数};water_rate::water_rate() //给费用和用水量分配空间{nT=0;t=new double[M];for(int i=0;i<M;i++){t[i]=0.0;}}water_rate::~water_rate(){delete[] t;}void water_rate::set() //计算用户的水费{cout<<"\t请输入用水量(吨):注(1.95元/吨)"<<endl;cin>>t[cost_n];nT++;}void water_rate::set_water(){s[cost_n]=t[cost_n]*1.95;cout<<"水费:\t\t"<<"(1.95元/吨)\t\t"<<t[cost_n]<<"*1.95="<<s[cost_n]<<"元"<<endl; }int water_rate::get_n() //返回用户水费个数函数{return nT;}double water_rate::get_cost() //返回用户用水费总数用函数{double sum=0.0;for(int i=0;i<M;i++){sum=sum+s[i];}return sum;}class elec_rate:public cost //电费类继承费用类{public:double *d;int nT; //计算用电的用户个数elec_rate(); //电费类的构造~elec_rate(); //析构void set(); //输入用电度数函数void set_elec();//显示电费信息int get_n(); //返回用户电费费个数函数double get_cost(); //返回用户用电总费用函数};elec_rate::elec_rate(){nT=0;d=new double[M];for(int i=0;i<M;i++){d[i]=0.0;}}elec_rate::~elec_rate(){delete[] d;}void elec_rate::set(){cout<<"\t请输入用电度数:注(0.65元/度)"<<endl;cin>>d[cost_n];nT++;}void elec_rate::set_elec() //计算电费函数{s[cost_n]=d[cost_n]*0.65;cout<<"电费:\t\t"<<"(0.65元/度)\t\t"<<d[cost_n]<<"*0.65="<<s[cost_n]<<"元"<<endl; }int elec_rate::get_n() //返回用户电费费个数函数{return nT;}double elec_rate::get_cost() //返回用户用电总费用函数{double sum=0.0;for(int i=0;i<M;i++){sum=sum+s[i];}return sum;}//电费类定义完毕!class comm_rate:public cost //定义一个通信类函数{public:double *tp; //定义一个电话费用函数double *cp; //定义一个上网费用函数int nT; //计算通信用户个数comm_rate(); //通信类构造~comm_rate();//通信类析构void set(); //输入电话用和上网费用void set_comm(); //计算通信费用int get_n();double get_cost(); //计算通信总费用};comm_rate::comm_rate(){nT=0;tp=new double[M];cp=new double[M];for(int i=0;i<M;i++){tp[i]=0.0;cp[i]=0.0;}}comm_rate::~comm_rate(){delete[] tp;delete[] cp;}void comm_rate::set(){cout<<"请输入通信消费:注(元)"<<endl;cout<<"电话消费上网消费:"<<endl;cin>>tp[cost_n]>>cp[cost_n];nT++;}void comm_rate::set_comm(){s[cost_n]=tp[cost_n]+cp[cost_n];cout<<"通信费:\t\t"<<"(电话费+上网费)\t\t"<<tp[cost_n]<<"+"<<cp[cost_n]<<"="<<s[cost_n]<<"元"<<endl;}int comm_rate::get_n(){return nT;}double comm_rate::get_cost(){double sum=0.0;for(int i=0;i<M;i++){sum=sum+s[i];}return sum;}///通信类定义完毕!class shop_rate:public cost //定义一个购物类{public:double *sp; //衣服费用成员double *hp; //其他用品费用成员int nT; //计算购物用户个数shop_rate(); //购物类构造~shop_rate(); //析构void set(); //输入购物费用void set_shop(); //计算购物费用int get_n(); //返回购物用户个数double get_cost(); //返回购物总消费};shop_rate::shop_rate(){nT=0;sp=new double[M];hp=new double[M];for(int i=0;i<M;i++){sp[i]=0.0;hp[i]=0.0;}}shop_rate::~shop_rate(){delete[] sp;delete[] hp;}void shop_rate::set(){cout<<"请输入购物消费:(元)"<<endl;cout<<"衣服消费其他用品消费:"<<endl;cin>>sp[cost_n]>>hp[cost_n];nT++;}void shop_rate::set_shop(){s[cost_n]=sp[cost_n]+hp[cost_n];cout<<"购物费用:\t"<<"(衣服+其他用品)\t\t"<<sp[cost_n]<<"+"<<hp[cost_n]<<"="<<s[cost_n]<<"元"<<endl;}int shop_rate::get_n(){return nT;}double shop_rate::get_cost(){double sum=0.0;for(int i=0;i<M;i++){sum=sum+s[i];}return sum;}//购物类定义完毕!class gas_rate:public cost //定义一个煤气费类{public:double *g;int nT; //计算用煤气用户的个数gas_rate(); //构造~gas_rate(); //析构void set(); //输入煤气用量void set_gas(); //计算煤气费用int get_n(); //返回煤气用户个数double get_cost(); //返回煤气总费用};gas_rate::gas_rate(){nT=0;g=new double[M];for(int i=0;i<M;i++){g[i]=0.0;}}gas_rate::~gas_rate(){delete[] g;}void gas_rate::set(){cout<<"请输入煤气用量(立方米):注(2.05元/立方米)"<<endl;cin>>g[cost_n];nT++;}void gas_rate::set_gas(){s[cost_n]=g[cost_n]*2.05;cout<<"煤气费用:\t"<<"(2.05元/立方米)\t\t"<<g[cost_n]<<"*2.05="<<s[cost_n]<<"元"<<endl;}int gas_rate::get_n(){return nT;}double gas_rate::get_cost(){double sum=0.0;for(int i=0;i<M;i++){sum=sum+s[i];}return sum;}//煤气费用类定义完毕!class pin_rate:public cost //定义一个零用费类{public:double *pc; //定义一个吃饭费用成员double *pa; //定义一个其他成员int nT; //计算用户零用个数pin_rate(); //构造~pin_rate(); //析构void set(); //输入吃饭费用,其他费用函数void set_pin(); //显示零用费用int get_n(); //返回用户零用个数double get_cost(); //返回用户的零用总费用};pin_rate::pin_rate(){nT=0;pc=new double[M];pa=new double[M];for(int i=0;i<M;i++){pc[i]=0.0;pa[i]=0.0;}}pin_rate::~pin_rate(){delete[] pc;delete[] pa;}void pin_rate::set(){cout<<"请输入零用花费:"<<endl;cout<<"吃饭费用: 其他费用:"<<endl;cin>>pc[cost_n]>>pa[cost_n];nT++;}void pin_rate::set_pin(){s[cost_n]=pc[cost_n]+pa[cost_n];cout<<"零用花费:\t"<<"(吃饭+其他)\t\t"<<pc[cost_n]<<"+"<<pa[cost_n]<<"="<<s[cost_n]<<"元"<<endl;}int pin_rate::get_n(){return nT;}double pin_rate::get_cost(){double sum=0.0;for(int i=0;i<M;i++){sum=sum+s[i];}return sum;}//零用费用类定义完毕!class user{int *a; //用户的户号string *name; //用户姓名string *tel; //用户电话public:water_rate water_c; //定义一个水费类对象elec_rate elec_c; //定义一个电费类对象comm_rate comm_c; //定义一个通信费类对象shop_rate shop_c; //定义一个购物类对象gas_rate gas_c; //定义一个煤气费用类对象pin_rate pin_c; //定义一个零用费用类对象int N; //统计用户个数void set(int m); //初始化函数void inquire(); //查询用户函数int inquire1(); //查询用户水费函数void show(); //显示用户函数void show1(); //显示用户及费用函数void add(); //添加数据成员函数void cancel(); //删除函数double amount(int m); //一个用户的费用总计double all_amount(); //所有用户的所有账单总计};void user::set(int m) //初始化定义用户信息{N=m;a=new int[M];name=new string[M];tel=new string[M];for(int i=0;i<N;i++){cin>>name[i]>>tel[i];a[i]=i+1;}}void user::inquire() //类内部查询函数{cout<<"\t请输入要查找的用户名:"<<endl;string s;cin>>s;int j=0;for(int i=0;i<N;i++){if(s==name[i]){cout<<"用户编号:"<<a[i]<<" "<<" 用户名:"<<name[i]<<" "<<"电话号码:"<<tel[i]<<endl;j++;}}if(j==0){cout<<"用户不存在!"<<endl;}}int user::inquire1() //类内部查询用户水费清单函数{cout<<"\t请用户输入用户编号用户名:(如忘记可在用户管理里面查询!)"<<endl;cout<<"用户编号用户名:"<<endl;int n;string s;cin>>n>>s;int j=0;for(int i=0;i<N;i++){if(n==a[i]&&s==name[i]){cout<<"用户编号:"<<a[i]<<" "<<" 用户名:"<<name[i]<<" "<<"电话号码:"<<tel[i]<<endl;cost_n=i;j++;break;}}if(j==0){cout<<"用户不存在!"<<endl;}return cost_n;}void user::show() //类内部显示函数{cout<<"用户编号: 用户名: 电话号码:"<<endl;for(int i=0;i<N;i++){cout<<a[i]<<"\t"<<name[i]<<"\t"<<tel[i]<<endl;}}void user::show1(){cout<<"============================================================ =================="<<endl;cout<<"用户编号: 用户名: 电话: 水费: 电费: 通信费: 购物: 煤气费: 零用费: 总计:"<<endl;cout<<"============================================================ =================="<<endl;for(int i=0;i<N;i++){cout<<a[i]<<" "<<name[i]<<" "<<tel[i]<<"\t"<<water_c.s[i]<<"\t"<<elec_c.s[i]<<"\t"<<comm_c.s[i]<<"\t"<<shop_c.s[i]<<"\t"<<gas_c.s[i]<<"\t"<<pin_c.s[i]<<"\t"<<amount(i)<<endl;}cout<<"============================================================ =================="<<endl;cout<<"所有用户账单总计费用合计:\t"<<all_amount()<<endl;cout<<"============================================================ =================="<<endl;}void user::add() ////类内部添加数据成员函数{cout<<"\t请输入新增用户个数:"<<endl;int n;cin>>n;cout<<"\t请输入这"<<n<<"个用户信息:"<<endl;cout<<"用户名电话号码:"<<endl;for(int i=0;i<n;i++){cin>>name[N]>>tel[N];a[N]=N+1;N++;}if(N==M){cout<<"\t系统设置人数已满,请联系管理员!"<<endl;}}void user::cancel() //类内部删除函数(注销){int m;string s;cout<<"\t注销--->请输入用户编号用户名:"<<endl;cin>>m>>s;int k=0;for(int i=0;i<N;i++){if(m==a[i]&&s==name[i]){for(int j=i;j<N;j++){a[j]=a[j+1];name[j]=name[j+1];tel[j]=tel[j+1];water_c.t[j]=water_c.t[j+1];water_c.s[j]=water_c.s[j+1];elec_c.d[j]=elec_c.d[j+1];elec_c.s[j]=elec_c.s[j+1];comm_c.tp[j]=comm_c.tp[j+1];comm_c.cp[j]=comm_c.cp[j+1];comm_c.s[j]=comm_c.s[j+1];shop_c.sp[j]=shop_c.sp[j+1];shop_c.hp[j]=shop_c.hp[j+1];shop_c.s[j]=shop_c.s[j+1];gas_c.g[j]=gas_c.g[j+1];gas_c.s[j]=gas_c.s[j+1];pin_c.pc[j]=pin_c.pc[j+1];pin_c.pa[j]=pin_c.pa[j+1];pin_c.s[j]=pin_c.s[j+1];}k++;N--;cout<<"用户的信息已删除!"<<endl;break;}}if(k==0){cout<<"用户不存在!"<<endl;}}double user::amount(int m){int i=m;double sum=0.0;sum=water_c.s[i]+elec_c.s[i]+comm_c.s[i]+shop_c.s[i]+gas_c.s[i]+pin_c.s[i];return sum;}double user::all_amount() //所有用户的所有账单总计{double sum=0.0;for(int i=0;i<M;i++){sum=sum+amount(i);}return sum;}//类user外部定义成员函数结束class inter_f //定义一个界面类{public:inter_f(){}; //构造~inter_f(){}; //析构void display(); //声明显示用户信息界面函数///////////////////void check(user* p); //声明用户登记函数void seek(user* p); //声明用户查询函数void show(user* p); //声明显示用户信息函数void add(user* p); //声明用户新增函数void cancel(user* p); //声明用户注销函数void exit(); //声明用户退出函数void limit(user& ru); //声明用户操作界面函数void display2(); //消费明细界面函数///////////////////////void water_cost(user* p); //水费函数void elec_cost(user* p); //电费函数void comm_cost(user* p); //通信费函数void shop_cost(user* p); //购物费函数void gas_cost(user* p); //煤气费函数void pin_cost(user* p); //零用函数void exit2(); //声明退出消费明细函数void limit2(user& ru); //声明消费明细操作界面函数void display1(); //声明显示总信息界面//////////////////////void personal_bill(user* p); //声明个人账单函数void amount_bill(user* p); //账单总计函数void show1(user* p); //声明显示所有用户账务函数void exit1(); //声明财务退出函数void limit1(user& ru); ////总界面函数};void inter_f::display(){cout<<"|===========================|"<<endl;cout<<"|= 用户系统|"<<endl;cout<<"|===========================|"<<endl;cout<<"|= 1.登记! 2.查询! =|"<<endl;cout<<"|===========================|"<<endl;cout<<"|= 3.新增! 4.注销! =|"<<endl;cout<<"|===========================|"<<endl;cout<<"|= 5.显示! 0.退出! =|"<<endl;cout<<"|===========================|"<<endl;cout<<"欢迎进去用户系统!请根据指示操作:"<<endl;}void inter_f::check(user* p) //登记用户函数{cout<<"请输入用户的信息:"<<" (提示:输入0退出用户系统)"<<endl;cout<<"\t您要登记用户个数为:"<<endl;int i;cin>>i;if(i!=0){cout<<"\t请登记这"<<i<<"个用户的信息!"<<endl;cout<<"用户名电话号码:"<<endl;p->set(i);cout<<"用户信息已保存!(可查询查看)"<<endl;}if(error==0){cout<<endl;cout<<"\t退出登记系统,请根据大界面提示信息操作:"<<endl;cout<<endl;display();}}void inter_f::seek(user* p) //查找{p->inquire();if(error==0){cout<<endl;cout<<"\t退出查找系统,请根据大界面提示信息操作:"<<endl;cout<<endl;display();}}void inter_f::show(user* p) //显示{cout<<"\t用户的登记信息为:"<<endl;p->show();if(error==0){cout<<endl;cout<<"\t退出显示系统,请根据大界面提示信息操作:"<<endl;cout<<endl;display();}}void inter_f::add(user* p) //新增{p->add();if(error==0){cout<<"用户的信息已保存!(可查询查看)"<<endl;cout<<endl;cout<<"\t退出新增用户系统,请根据大界面提示信息操作:"<<endl;cout<<endl;display();}}void inter_f::cancel(user* p) //删除{p->cancel();if(error==0){cout<<endl;cout<<"\t退出注销用户系统,请根据大界面提示信息操作:"<<endl;cout<<endl;display();}}void inter_f::exit() //退出函数{cout<<"\t退出用户系统!谢谢使用!"<<endl;display1();}void inter_f::limit(user& ru) //用户系统界面{display();int n;for(;;){cin>>n;switch(n){case 1: check(&ru); break;case 2: seek(&ru); break;case 3: add(&ru); break;case 4: cancel(&ru); break;case 5: show(&ru); break;case 0: exit(); break;default:cout<<"操作错误!请重新输入:"<<endl;}if(n==0) break;}}void inter_f::display2() //消费明细界面{cout<<"|==================================|"<<endl;cout<<"|= 消费明细=|"<<endl;cout<<"|==================================|"<<endl;cout<<"|= 1.水费! 2.电费! =|"<<endl;cout<<"|==================================|"<<endl;cout<<"|= 3.通信费! 4.购物费! =|"<<endl;cout<<"|==================================|"<<endl;cout<<"|= 5.煤气费! 6.零用花费! =|"<<endl;cout<<"|==================================|"<<endl;cout<<"|= 0.退出! =|"<<endl;cout<<"|==================================|"<<endl;cout<<"欢迎进入消费明细,请根据指示操作:"<<endl;}void inter_f::water_cost(user* p) //水费函数{p->inquire1();if(cost_n!=-1){p->water_c.set();p->water_c.set_water();}cost_n=-1; //用完初始化if(error==0){cout<<endl;cout<<"\t退出水费查询,请根据提示操作:"<<endl;cout<<endl;display2();}}void inter_f::elec_cost(user* p) //电费函数{p->inquire1();if(cost_n!=-1){p->elec_c.set();p->elec_c.set_elec();}cost_n=-1; //用完初始化if(error==0){cout<<endl;cout<<"\t退出电费查询,请根据提示操作:"<<endl;cout<<endl;display2();}}void inter_f::comm_cost(user* p) //通信函数{p->inquire1();if(cost_n!=-1){p->comm_c.set();p->comm_c.set_comm();}cost_n=-1; //用完初始化if(error==0){cout<<endl;cout<<"\t退出通信费查询,请根据提示操作:"<<endl;cout<<endl;display2();}}void inter_f::shop_cost(user* p) //购物函数{p->inquire1();if(cost_n!=-1){p->shop_c.set();p->shop_c.set_shop();}cost_n=-1; //用完初始化if(error==0){cout<<endl;cout<<"\t退出购物费查询,请根据提示操作:"<<endl;cout<<endl;display2();}}void inter_f::gas_cost(user* p) //煤气函数{p->inquire1();if(cost_n!=-1){p->gas_c.set();p->gas_c.set_gas();}cost_n=-1; //用完初始化if(error==0){cout<<endl;cout<<"\t退出煤气费查询,请根据提示操作:"<<endl;cout<<endl;display2();}}void inter_f::pin_cost(user* p){p->inquire1();if(cost_n!=-1){p->pin_c.set();p->pin_c.set_pin();}cost_n=-1; //用完初始化if(error==0){cout<<endl;cout<<"\t退出煤气费查询,请根据提示操作:"<<endl;cout<<endl;display2();}}void inter_f::exit2(){cout<<"\t退出消费明细!"<<endl;display1();}void inter_f::limit2(user& ru) //消费明细界面{display2();int n;for(;;){cin>>n;switch(n){case 1:water_cost(&ru); break;case 2:elec_cost(&ru); break;case 3:comm_cost(&ru); break;case 4:shop_cost(&ru); break;case 5:gas_cost(&ru); break;case 6:pin_cost(&ru); break;case 0:exit2(); break;default:cout<<"操作错误!请重新输入:"<<endl;}if(n==0) break;}}void inter_f::display1() //财务管理系统界面{cout<<"\t\t|=====================================|"<<endl;cout<<"\t\t|= 财务管理系统=|"<<endl;cout<<"\t\t|=====================================|"<<endl;cout<<"\t\t|= 1.用户管理! 2.消费明细! =|"<<endl;cout<<"\t\t|=====================================|"<<endl;cout<<"\t\t|= 3.个人账单查询! 4.账单总计! =|"<<endl;cout<<"\t\t|=====================================|"<<endl;cout<<"\t\t|= 5.显示所有用户账单! =|"<<endl;cout<<"\t\t|=====================================|"<<endl;cout<<"\t\t|= 0.退出管理系统! =|"<<endl;cout<<"\t\t|=====================================|"<<endl;cout<<"欢迎进入财务管理系统,请根据系统指示操作:"<<endl;}void inter_f::personal_bill(user* p) //个人账单函数{p->inquire1();if(cost_n!=-1){cout<<"====================================================="<<endl;p->water_c.set_water();p->elec_c.set_elec();p->comm_c.set_comm();p->shop_c.set_shop();p->gas_c.set_gas();p->pin_c.set_pin();cout<<"总计消费:"<<p->amount(cost_n)<<"元"<<endl;cout<<"====================================================="<<endl;}cost_n=-1;if(error==0){cout<<endl;cout<<"\t退出个人账单,请根据指示操作:"<<endl;cout<<endl;display1();}}void inter_f::amount_bill(user* p) //账单总计函数{cout<<"========================================"<<endl;cout<<"水费总计:\t"<<p->water_c.get_cost()<<"元\t"<<"用水用户:"<<p->water_c.get_n()<<"个"<<endl;cout<<"电费总计:\t"<<p->elec_c.get_cost()<<"元\t"<<"用电用户:"<<p->elec_c.get_n()<<"个"<<endl;cout<<"通信费总计:\t"<<p->comm_c.get_cost()<<"元\t"<<"通信用户:"<<p->comm_c.get_n()<<"个"<<endl;cout<<"购物费总计:\t"<<p->shop_c.get_cost()<<"元\t"<<"购物用户:"<<p->shop_c.get_n()<<"个"<<endl;cout<<"煤气费总计:\t"<<p->gas_c.get_cost()<<"元\t"<<"煤气用户:"<<p->gas_c.get_n()<<"个"<<endl;cout<<"零用花费总计:\t"<<p->pin_c.get_cost()<<"元\t"<<"零用用户:"<<p->pin_c.get_n()<<"个"<<endl;cout<<"所有用户账单总计费用合计:\t"<<p->all_amount()<<"元"<<endl;cout<<"========================================"<<endl;if(error==0){cout<<endl;cout<<"\t退出账单总计,请根据指示操作:"<<endl;cout<<endl;display1();}}void inter_f::show1(user* p){p->show1();if(error==0){cout<<endl;cout<<"\t退出显示所有用户账单,请根据指示操作:"<<endl;cout<<endl;display1();}}void inter_f::exit1(){cout<<"\t退出财务管理系统!谢谢使用!"<<endl;}void inter_f::limit1(user& ru) //总界面函数{display1();int n;for(;;){cin>>n;switch(n){case 1: limit(ru); break;case 2:limit2(ru); break;case 3:personal_bill(&ru); break;case 4:amount_bill(&ru); break;case 5:show1(&ru); break;case 0:exit1(); break;default:cout<<"操作错误!请重新输入:"<<endl;}if(n==0) break;}}int main(){inter_f U; //定义一个界面类对象user u; //定义一个用户类对象U.limit1(u); //调用界面类对象的函数,包含用户对象}下面是在界面类中定义一个用户类://家庭财务管理系统,本程序扩充至一个小型的集体。

C语言财务管理系统(源代码)

C语言财务管理系统(源代码)

#include"stdio.h"#include"stdlib.h"#define MAX_NAME 11#define MAX_DETAIL 21 #define MENU_COUNT 9 #define DATA_FILE "fa.dat" typedef wnum_fi_type{income=1,payout=-1}fi_type;typedef struct_fi_info{int year;int month;fi_type type;char name[MAX_NAME]; float money;char detail[MAX_DETAIL]; }fi_info;typedef struct_fi_data{fi_info info;struct_fi_data *next;}fi_data;void add_income();void search_income();void delete_income();void update_income();void add_payout();void search_payout();void delete_payout();void update_payout();void count_total();void quit();void search_data(fi_type type);void delete_data(fi_type type);void update_data(fi_type type);void initialize();void save_to_file();void clear_data();fi_data *get_last();fi_data *get_previous(fi_data *p);void input_info(fi_info *info);void show_info(fi_data *p[],int count);fi_data *head;char menu[]="===============================================\n" "| 家庭财务管理系统|\n""+---------------------------------------------+\n" "| 收入管理|\n""| 1 添加收入|\n""| 2 查询收入明细|\n""| 3 删除收入|\n""| 4 修改收入|\n""| 支出管理|\n""| 5 添加支出|\n""| 6 查询支出明细|\n""| 7 删除支出|\n""| 8 修改支出|\n""| 统计|\n""| 9 统计总收入总支出|\n""----------------------------------------------+\n" "| 0 退出系统|\n""==============================================+\n"; void(*menu_fun[])()={quit,add_income,search_income,delete_income,update_income,add_payout,search_payout,delete_payout,update_payout,count_total};int main(){int selected=0;initialize();while(selected>=0 && selected<=MENU_COUNT){system("cls");printf(menu);printf(">请选择要进行的操作(%d - %d):",0,MENU_COUNT);if(scanf("%d",&selected)!=1||selected<0||selected>MENU_COUNT){printf(">输入错误!请选择[ %d - %d]之间的数字!按任意键重试...",0,MENU_COUNT); fflush(stdin);getchar();}else{menu_fun[selected]();}selected=0;}}void add_income(){fi_data *p=(fi_data *)malloc(sizeof(fi_data));memset(p,0,sizeof(fi_data));p->next=NULL;input_info(&(p->info));if(head==NULL){head=p;}else{get_last(head)->next=p;}}void search_income(){search_data(income);}void delete_income(){delete_data(income);}void update_income(){update_data(income);}void add_payout(){fi_data *p=(fi_data*)malloc(sizeof(fi_data)); memset(p,0,sizeof(fi_data));input_info(&(p->info));if(head==NULL){head=p;}else{get_last(head)->next=p; }}void search_payout() {search_data(payout); }void delete_payout() {delete_data(payout); }void update_payout() {update_data(payout); }void count_total(){float total_income=0.0; float total_payout=0.0; fi_data *p=head;while(p!=NULL){if(p->info.type==income){total_income+=p->info.money;}else{total_payout+=p->info.money;}p=p->next;}printf("+---------+---------+---------+\n");printf("| 合计收入| 合计支出| 结余|\n");printf("+---------+---------+---------+\n");printf("|%12.2f|%12.2f|%12.2f|\n", total_income, total_payout,total_income - total_payout); printf("+---------+---------+---------+\n");printf(">按任意键继续返回主菜单...");fflush(stdin);getchar();}void search_data(fi_type type){int year=0;int month=0;fi_data *p=NULL;fi_data *result[9]={NULL};char input=' ';while(1){printf(">请输入要查询的年月(例如:2009/1)");if(scanf("%d/%d",&year,&month)!=2){printf(">输入错误。

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

#include<stdio.h>#include<stdlib.h>#include<conio.h>#include<string.h>#define LEN sizeof(struct financial)#define FFORMAT "%-8d%-15s%-10d%-10d%-12.2f%-12.2f%-12.2f\n"#define DATA member[i].num,member[i].name,member[i].month,member[i].year,member[i].income,member[i ].output,member[i].totalstruct financial //定义家庭成员信息{int num; //编号char name[15]; //家庭成员姓名int month; //月份int year; //年份float income; //收入float output; //支出float total; //总金额};struct financial member[50]; //定义结构体数组void menu(); //主界面void in(); //录入家庭成员收支信息void show(); //显示家庭成员收支信息void del(); //删除家庭成员收支信息void modify(); //修改家庭成员收支信息void total(); //计算家庭成员总收入void search(); //查找家庭成员收支信息int main(){int n;menu();scanf("%d",&n); //输入数字选择功能while(n){switch(n){case 1:in(); //调用录入家庭成员信息函数break;case 2:search(); //查找家庭成员信息函数break;case 3:del(); //调用删除家庭成员信息函数break;case 4:modify(); //调用修改家庭成员信息函数break;case 5:total(); //调用汇总函数break;default:break;}printf("按任意键返回主菜单:\n");getch();menu(); //执行完功能再次显示菜单界面scanf("%d",&n);}return 0;}void menu(){system("cls");printf("|-------------------------------------------------|\n");printf("|--------------------家庭财务信息系统-------------|\n");printf("| 0. 退出|\n");printf("| 1. 录入信息|\n");printf("| 2. 查找信息|\n");printf("| 3. 删除信息|\n");printf("| 4. 修改信息|\n");printf("| 5. 统计信息|\n");printf("|-------------------------------------------------|\n");printf("选择(0-5):");}void in() //录入家庭成员信息{int i,m=0;char ch[2];FILE *fp;if((fp=fopen("家庭财务管理系统","ab+"))==NULL){printf("不能打开文件!\n");return;}while(!feof(fp)){if(fread(&member[m] ,LEN,1,fp)==1)m++; //统计当前记录条数fclose(fp);if(m==0)printf("没有找到!\n");else{//system("cls");show(); //调用show函数,显示原有信息}if((fp=fopen("家庭财务管理系统","wb"))==NULL){printf("不能打开文件!\n");return;}for(i=0;i<m;i++)fwrite(&member[i] ,LEN,1,fp); //向指定的磁盘文件写入信息printf("是否输入?(y/n):");scanf("%s",ch);while(strcmp(ch,"Y")==0||strcmp(ch,"y")==0) //判断是否要录入新信息{printf("编号:");scanf("%d",&member[m].num); //输入家庭成员编号for(i=0;i<m;i++)if(member[i].num == member[m].num){printf("该记录已经存在,按任意键继续!");getch();fclose(fp);return;}printf("家庭成员姓名:");scanf("%s",member[m].name); //输入家庭成员姓名printf("请输入月份:");scanf("%d",&member[m].month); //输入月份printf("请输入年份:");scanf("%d",&member[m].year); //输入年份printf("请输入收入:");scanf("%f",&member[m].income); //输入收入printf("请输入支出:");scanf("%f",&member[m].output); //输入支出member[m].total=member[m].income - member[m].output;if(fwrite(&member[m],LEN,1,fp)!=1) //将新录入的信息写入指定的磁盘文件{printf("不能保存!");getch();}else{printf("%s 已经保存!\n",member[m].name);m++;}printf("是否继续?(y/n):");scanf("%s",ch);}fclose(fp);printf("OK!\n");}void show(){FILE *fp;int i,m=0;fp=fopen("家庭财务管理系统","ab+");while(!feof(fp)){if(fread(&member[m] ,LEN,1,fp)==1)m++;}fclose(fp);printf("编号成员月份年分收入支出总金额\t\n");for(i=0;i<m;i++){printf(FFORMAT,DATA);}}void del(){FILE *fp;int snum,i,j,m=0;char ch[2];if((fp=fopen("家庭财务管理系统","ab+"))==NULL)printf("不能打开文件\n");return;}while(!feof(fp))if(fread(&member[m],LEN,1,fp)==1)m++;fclose(fp);if(m==0){printf("没有记录!\n");return;}printf("请输入编号:");scanf("%d",&snum);for(i=0;i<m;i++)if(snum==member[i].num)break;if(i==m){printf("没有找到!");return;}printf("已经找到该记录,是否删除?(y/n)");scanf("%s",ch);if(strcmp(ch,"Y")==0||strcmp(ch,"y")==0) //判断是否要进行删除{for(j=i;j<m;j++)member[j] = member[j+1]; //将后一个记录移到前一个记录的位置m--; //记录的总个数减1printf("成功删除!\n");}if((fp=fopen("家庭财务管理系统","wb"))==NULL){printf("不能打开!\n");return;}for(j=0;j<m;j++) //将更改后的记录重新写入指定的磁盘文件中if(fwrite(&member[j] ,LEN,1,fp)!=1){printf("不能保存!\n");getch();}fclose(fp);}void search(){FILE *fp;int snum,i,m=0;char ch[2];if((fp=fopen("家庭财务管理系统","ab+"))==NULL){printf("不能打开文件\n");return;}while(!feof(fp))if(fread(&member[m],LEN,1,fp)==1)m++;fclose(fp);if(m==0){printf("没有记录!\n");return;}printf("请输入编号:");scanf("%d",&snum);for(i=0;i<m;i++)if(snum == member[i].num){printf("已经找到该记录,是否显示?(y/n)");scanf("%s",ch);if(strcmp(ch,"Y")==0||strcmp(ch,"y")==0){printf("编号成员月份年份收入支出总金额\t\n");printf(FFORMAT,DATA);break;}elsereturn;}if(i==m)printf("没有找到相应的记录!\n");void modify(){FILE *fp;int i,j,m=0,snum;char ch[2];if((fp=fopen("家庭财务管理系统","ab+"))==NULL){printf("不能打开文件!\n");return;}while(!feof(fp))if(fread(&member[m],LEN,1,fp)==1)m++;if(m==0){printf("没有记录!\n");fclose(fp);return;}printf("请输入要修改的记录信息的编号!\n");scanf("%d",&snum);for(i=0;i<m;i++)if(snum==member[i].num) //检索记录中是否有要修改的信息{printf("已经找到该记录,是否修改?(y/n)\n");scanf("%s",ch);if(strcmp(ch,"Y")==0||strcmp(ch,"y")==0){printf("家庭成员姓名:");scanf("%s",member[i].name); //输入家庭成员姓名printf("请输入月份:");scanf("%d",&member[i].month); //输入月份printf("请输入年份:");scanf("%d",&member[i].year); //输入年份printf("请输入收入:");scanf("%f",&member[i].income); //输入收入printf("请输入支出:");scanf("%f",&member[i].output); //输入支出member[i].total=member[i].income - member[i].output; //汇总printf("保存成功!");}elsereturn;}else{printf("没有找到!");return;}if((fp=fopen("家庭财务管理系统","wb"))==NULL){printf("不能打开文件!\n");return;}for(j=0;j<m;j++) //将新修改的信息写入指定的磁盘文件中if(fwrite(&member[j] ,LEN,1,fp)!=1){printf("不能保存!");}fclose(fp);}void total() // 统计{FILE *fp;int m=0;if((fp=fopen("家庭财务管理系统","ab+"))==NULL){printf("不能打开记录!\n");return;}while(!feof(fp))if(fread(&member[m],LEN,1,fp)==1)m++; //统计记录个数if(m==0){printf("没有记录!\n");fclose(fp);return;}printf("一共有%d 条记录!\n",m); //将统计的个数输出fclose(fp); }。

相关文档
最新文档