#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<malloc.h>
#include<windows.h>
#include<conio.h>
struct geshen_info
{
char shen_number[4];
char shen_name[20];
int guojia_number;
float guojia_jine;
int yidiao_number;
float yidiao_jie;
char tongji_date[11];
char tongji_name[10];
};
struct inc_zhangpeng_info
{
char shen_name[20];
char inc_number[12];
char inc_name[30];
int shen_number;
int inc_add_number;
float inc_add_jine;
int inc_diaochu_number;
float inc_diaochu_jine;
char tongji_date[11];
char tongji_name[10];
};
struct inc_mingxi_info
{
char inc_number[12];
int pici;
char diaochu_pinzhong[30];
int diaochu_number;
float diaochu_jine;
char diaochu_date[11];
char tongji_name[10];
};
void geshen_info_luru()
{
system("cls");
FILE *pf;
char flag='y';
struct geshen_info info;
pf=fopen("c:\\各省帐篷调出基本信息.txt","a");
while(flag=='y')
{
memset(info.shen_name,0,20);
memset(info.tongji_date,0,11);
memset(info.tongji_name,0,10);
printf("请输入省编号(三位):\n");
fflush(stdin);
fgets(info.shen_number,5,stdin);
printf("请输入省份名称:\n");
fflush(stdin);
fgets(info.shen_name,20,stdin);
printf("请输入国家分配帐篷总数:\n");
fscanf(stdin,"%d",&info.guojia_number);
printf("请输入国家分配总金额:\n");
fscanf(stdin,"%f",&info.guojia_jine);
printf("请输入已调出帐篷数量:\n");
fscanf(stdin,"%d",&info.yidiao_number);
printf("请输入已调出帐篷金额:\n");
fscanf(stdin,"%f",&info.yidiao_jie);
printf("请输入统计日期(年/月/日):\n");
fflush(stdin);
fgets(info.tongji_date,11,stdin);
printf("请输入统计员:\n");
fflush(stdin);
fgets(info.tongji_name,10,stdin);
fwrite(&info,sizeof(struct geshen_info),1,pf);
printf("是否继续[y/n]:\n");
fflush(stdin);
flag=getchar();
}
fclose(pf);
}
void inc_zhangpeng_info_luru()
{
system("cls");
FILE *pf;
char flag='y';
struct inc_zhangpeng_info info;
pf=fopen("c:\\省属企业帐篷生产调出汇总基本信息.txt","a");
while(flag=='y')
{
memset(info.inc_name,0,30);
memset(info.tongji_date,0,11);
memset(info.tongji_name,0,10);
memset(info.shen_name,0,20);
printf("请输入该企业所属省份:\n");
fflush(stdin);
fgets(info.shen_name,20,stdin);
printf("请输入企业编号\n");
fflush(stdin);
fgets(info.inc_number,12,stdin);
printf("请输入企业名称\n");
fflush(stdin);
fgets(info.inc_name,30,stdin);
printf("请输入省分配帐篷总数\n");
fscanf(stdin,"%d",&info.shen_number);
printf("请输入已生产帐篷数量\n");
fscanf(stdin,"%d",&info.inc_add_number);
printf("请输入已生产帐篷金额\n");
fscanf(stdin,"%f",&info.inc_add_jine);
printf("请输入已调出帐篷数量\n");
fscanf(stdin,"%d",&info.inc_diaochu_number);
printf("请输入已调出帐篷金额\n");
fscanf(stdin,"%f",&info.inc_diaochu_jine);
printf("请输入统计日期\n");
fflush(stdin);
fgets(info.tongji_date,11,stdin);
printf("请输入统计员\n");
fflush(stdin);
fgets(info.tongji_name,10,stdin);
fwrite(&info,sizeof(struct inc_zhangpeng_info),1,pf);
printf("是否继续[y/n]:\n");
fflush(stdin);
flag=getchar();
}
fclose(pf);
}
void inc_mingxi_info_luru()
{
system("cls");
FILE *pf;
char flag='y';
struct inc_mingxi_info info;
pf=fopen("c:\\企业帐篷调出明细基本信息.txt","a");
while(flag=='y')
{
memset(info.diaochu_pinzhong,0,30);
memset(info.diaochu_date,0,11);
memset(info.tongji_name,0,10);
printf("请输入企业编号\n");
fflush(stdin);
fgets(info.inc_number,12,stdin);
printf("请输入调出帐篷批次\n");
fscanf(stdin,"%d",&info.pici);
printf("请输入调出帐篷品种\n");
fflush(stdin);
fgets(info.diaochu_pinzhong,30,stdin);
printf("请输入调出帐篷数量\n");
fscanf(stdin,"%d",&info.diaochu_number);
printf("请输入调出帐篷金额\n");
fscanf(stdin,"%f",&info.diaochu_jine);
printf("请输入统计日期\n");
fflush(stdin);
fgets(info.diaochu_date,11,stdin);
printf("请输入统计员\n");
fflush(stdin);
fgets(info.tongji_name,10,stdin);
fwrite(&info,sizeof(struct inc_mingxi_info),1,pf);
printf("是否继续[y/n]:\n");
fflush(stdin);
flag=getchar();
}
fclose(pf);
}
void change_geshen_info()
{
system("cls");
printf("**********修改各省信息:**********\n");
struct geshen_info info[100];
FILE *pf;
int i=0;
int length;
int choose;
char flag='n';
memset(info,0,sizeof(info));
pf=fopen("c:\\各省帐篷调出基本信息.txt","r");
if(!pf)
{
printf("打开信息库失败!\n");
Sleep(1000);
return;
}
while(!feof(pf))
{
fread(&info[i],sizeof(struct geshen_info),1,pf);
i++;
}
length=i-1;
if(length==0)
{
printf("无信息:\n");
Sleep(1500);
return;
}
printf("共有%d条信息\n",length);
for(i=0;i<length;i++)
{
printf(" 省编号: %s 省名: %s\n 国家分配帐篷总数: %d\n 国家分配总金额: %10.3f\n 已调出帐篷数量: %d\n 已调出帐篷金额: %10.3f\n 统计日期: %s\n 统计员: %s\n ",
info[i].shen_number,info[i].shen_name,info[i].guojia_number,info[i].guojia_jine,info[i].yidiao_number,info[i].yidiao_jie,info[i].tongji_date,info[i].tongji_name);
}
fclose(pf);
FILE *changef;
changef=fopen("c:\\各省帐篷调出基本信息.txt","w");
while(flag=='n')
{
printf("请选择你要对那个信息进行修改:\n");
scanf("%d",&choose);
printf("你要修改的是否为[y/n]");
printf(" 省编号: %s 省名: %s\n 国家分配帐篷总数: %d\n 国家分配总金额: %10.3f\n 已调出帐篷数量: %d\n 已调出帐篷金额: %10.3f\n 统计日期: %s\n 统计员: %s\n ",
info[choose-1].shen_number,info[choose-1].shen_name,info[choose-1].guojia_number,info[choose-1].guojia_jine,info[choose-1].yidiao_number,info[choose-1].yidiao_jie,info[choose-1].tongji_date,info[choose-1].tongji_name);
fflush(stdin);
flag=getchar();
}
printf("进行修改:\n");
printf("请输入省编号(三位):\n");
fflush(stdin);
fgets(info[choose-1].shen_number,5,stdin);
printf("请输入省份名称:\n");
fflush(stdin);
fgets(info[choose-1].shen_name,20,stdin);
printf("请输入国家分配帐篷总数:\n");
fscanf(stdin,"%d",&info[choose-1].guojia_number);
printf("请输入国家分配总金额:\n");
fscanf(stdin,"%f",&info[choose-1].guojia_jine);
printf("请输入已调出帐篷数量:\n");
fscanf(stdin,"%d",&info[choose-1].yidiao_number);
printf("请输入已调出帐篷金额:\n");
fscanf(stdin,"%f",&info[choose-1].yidiao_jie);
printf("请输入统计日期(年/月/日):\n");
fflush(stdin);
fgets(info[choose-1].tongji_date,11,stdin);
printf("请输入统计员:\n");
fflush(stdin);
fgets(info[choose-1].tongji_name,10,stdin);
printf("修改成功\n");
printf("对文件进行写入:\n");
for(i=0;i<length;i++)
{
fwrite(&info[i],sizeof(struct geshen_info),1,changef);
}
fclose(changef);
}
void change_inc_zhangpeng_info()
{
system("cls");
printf("**********修改各省属企业信息:**********\n");
struct inc_zhangpeng_info info[100];
FILE *pf;
int length;
int i=0;
int choose;
char flag='n';
memset(info,0,sizeof(info));
pf=fopen("c:\\省属企业帐篷生产调出汇总基本信息.txt","r");
if(!pf)
{
printf("打开信息库失败!\n");
Sleep(1000);
return;
}
while(!feof(pf))
{
fread(&info[i],sizeof(struct inc_zhangpeng_info),1,pf);
i++;
}
length=i-1;
if(length==0)
{
printf("无信息:\n");
Sleep(1500);
return;
}
printf("共有%d条信息\n",length);
for(i=0;i<length;i++)
{
printf(" 企业编号: %s 企业名称: %s\n 省分配帐篷总数: %d\n 已生产帐篷总数: %d\n 已生产帐篷金额: %10.3f 已调出帐篷数量: %d\n 已调出帐篷金额: %10.3f\n 统计日期: %s\n 统计员: %s\n ",
info[i].inc_number,info[i].inc_name,info[i].shen_number,info[i].inc_add_number,info[i].inc_add_jine,info[i].inc_diaochu_number,info[i].inc_diaochu_jine,info[i].tongji_date,info[i].tongji_name);
}
fclose(pf);
FILE *changef;
changef=fopen("c:\\省属企业帐篷生产调出汇总基本信息.txt","w");
while(flag=='n')
{
printf("请选择你要对那个信息进行修改:\n");
scanf("%d",&choose);
printf("你要修改的是否为[y/n]");
printf(" 省名: %s 企业编号: %s 企业名称: %s\n 省分配帐篷总数: %d\n 已生产帐篷总数: %d\n 已生产帐篷金额: %10.3f 已调出帐篷数量: %d\n 已调出帐篷金额: %10.3f\n 统计日期: %s\n 统计员: %s\n ",
info[choose-1].shen_name,info[choose-1].inc_number,info[choose-1].inc_name,info[choose-1].shen_number,info[choose-1].inc_add_number,info[choose-1].inc_add_jine,info[choose-1].inc_diaochu_number,info[choose-1].inc_diaochu_jine,info[choose-1].tongji_date,info[choose-1].tongji_name);
fflush(stdin);
flag=getchar();
}
printf("进行修改:\n");
memset(info[choose-1].inc_name,0,30);
memset(info[choose-1].tongji_date,0,11);
memset(info[choose-1].tongji_name,0,10);
memset(info[choose-1].shen_name,0,20);
printf("请输入该企业所属省份:\n");
fflush(stdin);
printf("请输入企业编号\n");
fflush(stdin);
fgets(info[choose-1].inc_number,12,stdin);
printf("请输入企业名称\n");
fflush(stdin);
fgets(info[choose-1].inc_name,30,stdin);
printf("请输入省分配帐篷总数\n");
fscanf(stdin,"%d",&info[choose-1].shen_number);
printf("请输入已生产帐篷数量\n");
fscanf(stdin,"%d",&info[choose-1].inc_add_number);
printf("请输入已生产帐篷金额\n");
fscanf(stdin,"%f",&info[choose-1].inc_add_jine);
printf("请输入已调出帐篷数量\n");
fscanf(stdin,"%d",&info[choose-1].inc_diaochu_number);
printf("请输入已调出帐篷金额\n");
fscanf(stdin,"%f",&info[choose-1].inc_diaochu_jine);
printf("请输入统计日期\n");
fflush(stdin);
fgets(info[choose-1].tongji_date,11,stdin);
printf("请输入统计员\n");
fflush(stdin);
fgets(info[choose-1].tongji_name,10,stdin);
printf("修改成功\n");
printf("对文件进行写入:\n");
for(i=0;i<length;i++)
{
fwrite(&info[i],sizeof(struct geshen_info),1,changef);
}
fclose(changef);
}
下面的发布上来了,给我邮箱,我发给你
温馨提示:内容为网友见解,仅供参考