C语言 宠物商店管理系统 实训报告.doc_第1页
C语言 宠物商店管理系统 实训报告.doc_第2页
C语言 宠物商店管理系统 实训报告.doc_第3页
C语言 宠物商店管理系统 实训报告.doc_第4页
C语言 宠物商店管理系统 实训报告.doc_第5页
已阅读5页,还剩10页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

精品文档实 训 报 告实训项目:宠物商店管理系统院别专业:信息管理学院班级学号:学生姓名:煜指导教师:实训成绩:实验日期:2018年6月8日制信息管理学院实践教学中心一、 实训目的:1掌握C语法,函数,界面程序设计,文件操作。2掌握C文件编程方法。二、 实训内容及要求:用C语言设计基于文件的宠物商店管理系统。要求具有信息显示、录入、修改、查询和删除的界面并完成相关功能。三、实训方案:系统功能结构、主要界面与主要代码:1.功能结构如下:以下图仅供参考,以实际所做的系统功能为准!2.主要功能介绍:(1)添加宠物类型。(2)修改宠物类型。(3)显示添加的全部宠物类型。(4)显示宠物全部的交易记录。(5)显示宠物月度交易统计数据。(6)显示主功能菜单3主要代码:#include#include#include#define SIZE 3#define SIZET 100struct pettypeint typeId;char name20;int petstore;pettypesSIZE;struct pettransinfoint transId;int typeId;int num;int transtype;int year;int month;int day;pettransinfosSIZET;int getcurrenttypeindex();int getcurrenttypeinfoindex();int getcurrenttransinfoindex();/*添加宠物类型*/void tjcwlx();/*修改宠物类型*/void xgcwlx();/*显示全部的宠物类型*/void tjqbdcwlx();/*添加宠物进货记录*/void tjcwxsjl();/*添加宠物销售记录*/void xscwqbjyjl();/*显示宠物全部交易记录*/void xscwjytjxx();/*显示宠物交易统计信息*/void xszgncd();/*显示主功能菜单*/void showmenu();int istypeexistsbyId(int typeId);int updatepetstore(int typeId,int num);int main(int argc,const char * argv)showmenu();return 0;void showmenu()int n;do system(cls);printf( *n);printf( * 欢迎使用宠物商店 *n);printf( * = *n);printf( * 1.添加宠物类型 *n);printf( * 2.修改宠物类型 *n);printf( * 3.显示全部宠物类型 *n);printf( * 4.添加宠物进货记录 *n);printf( * 5.添加宠物销售记录 *n);printf( * 6.显示宠物全部交易记录 *n);printf( * 7.显示宠物月度交易统计数据 *n);printf( * 8.退出 *n);printf( *n);printf(请选择您需要的操作:);scanf(%d,&n);switch(n)case 1:tjcwlx();break;case 2:xgcwlx();break;case 3:tjqbdcwlx();break;case 4:tjcwxsjl();break;case 5:xscwqbjyjl();break;case 6:xscwjytjxx();break;case 7:xszgncd();break;case 8:printf(欢迎你再次使用宠物商店系统n);return;default:break; printf(按回车继续!n); fflush(stdin); getchar(); getchar();while(1);/*添加宠物类型*/void tjcwlx() int typeId;char typeName20;typeId=getcurrenttypeindex();if(typeId=-1)printf(当前宠物类型的数量已达上限,无法再次添加!n);return ;printf(请输入新增宠物类型:);scanf(%s,typeName);pettypestypeId-1.typeId=typeId;strcpy(pettypestypeI,typeName); pettypestypeId-1.petstore=0; printf(新宠物类型%s,已经添加成功!n, typeName);/*修改宠物类型*/void xgcwlx()int typeId; char typeName20;printf(请输入需要修改宠物类型编号:); scanf(%d,&typeId);if(istypeexistsbyId(typeId)=-1)printf(当前系统不存在您输入的宠物类型编号!n);return;elseprintf(名称:%sn, pettypestypeId - 1.name);printf(请输入修改后的宠物名称:);scanf(%s,typeName);strcpy(pettypestypeI,typeName);printf(编号是%d的宠物类型名称已经改成%s!n, typeId,typeName);/*显示全部的宠物类型*/void tjqbdcwlx()int i;printf(类型编号t类型名称n);for(i=0;iSIZE;i+)if(pettypesi.typeId=0)break;printf(%3dtt%sn,pettypesi.typeId,);/*添加宠物进货记录*/void tjcwxsjl()int transId;int typeId;int purchasenum;time_t tp;struct tm *p;time(&tp);p = localtime(&tp);transId=getcurrenttransinfoindex();if(transId=-1)printf(宠物交易记录次数已经达到上限,无法再次进货!);return ;printf(请输入本次进货的宠物类型编号:);scanf(%d,&typeId);if(istypeexistsbyId(typeId)=-1)printf(当前系统不存在您输入的宠物类型编号!n);return;printf(请输入本次宠物进货的数量:);scanf(%d,&purchasenum);if(purchasenumtm_year+1900;pettransinfostransId-1.month=p-tm_mon+1;pettransinfostransId-1.day=p-tm_mday; /strftime(pettransinfostransId - 1.data, sizeof(pettransinfostransId - 1.data), %Y-%m-%d, localtime(&tp);pettransinfostransId-1.transId=transId;pettransinfostransId-1.typeId=typeId;pettransinfostransId-1.num=purchasenum;pettransinfostransId-1.transtype=0;updatepetstore(typeId,purchasenum,1);printf(本次宠物进货完成记录!);/*添加宠物销售记录*/void xscwqbjyjl()int transId;int typeId;int purchasenum;time_t tp;struct tm *p;time(&tp);p = localtime(&tp);transId = getcurrenttransinfoindex();if (transId = -1)printf(宠物交易记录次数已经达到上限,无法再次销售!);return;printf(请输入本次销售的宠物类型编号:);scanf(%d, &typeId);if (istypeexistsbyId(typeId) = -1)printf(当前系统不存在您输入的宠物类型编号!n);return;printf(请输入本次销售的宠物数量:);scanf(%d, &purchasenum);if (purchasenumpettypestypeId-1.petstore)printf(当前该类型宠物的库存数量不足,无法进行销售!n);return;time(&tp);p = gmtime(&tp);pettransinfostransId - 1.year = p-tm_year + 1900;pettransinfostransId - 1.month = p-tm_mon + 1;pettransinfostransId - 1.day = p-tm_mday;/strftime(pettransinfostransId - 1.data, sizeof(pettransinfostransId - 1.data), %Y-%m-%d, localtime(&tp);pettransinfostransId - 1.transId = transId;pettransinfostransId - 1.typeId = typeId;pettransinfostransId - 1.num = purchasenum;pettransinfostransId - 1.transtype = 1;updatepetstore(typeId, purchasenum,2);printf(本次宠物销售完成记录!);/*显示宠物全部交易记录*/void xscwjytjxx()int i;char *name;printf(宠物编号t宠物名称t交易数量t交易日期t交易类型n);for (i = 0; iSIZET; i+)if (pettransinfosi.transId = 0)break;if (pettransinfosi.transtype = 0)name = 入库;else if(pettransinfosi.transtype = 1)name = 售出;elsename = 未知;printf(%3dtt%stt%3dtt%d-%d-%dt%sn, pettransinfosi.typeId, pettypespettransinfosi.typeI,pettransinfosi.num, pettransinfosi.year, pettransinfosi.month, pettransinfosi.day, name);/*显示宠物交易统计信息*/void xszgncd()const char * split = -;int i;char *name;int month;int j;int purchasenum=0;int salenum=0;printf(请输入需要查看的月份:);scanf(%d, &month);printf(类型编号t类型名称t入库数量t销售数量t库存数n);for (i = 0; iSIZE; i+)if (pettypesi.typeId = 0)break;for (j = 0; jSIZET; j+)if (pettransinfosj.transId = 0)break;if (pettransinfosj.month = month&pettransinfosj.typeId = pettypesi.typeId)if (pettransinfosj.transtype = 0)purchasenum += pettransinfosj.num;elsesalenum+= pettransinfosj.num;printf(%3dtt%stt%3dtt%3dtt%3dn, pettypesi.typeId, , purchasenum, salenum, purchasenum - salenum);int getcurrenttypeindex()int index=-1;int i;for(i=0;iSIZE;i+) if(pettypesi.typeId=0)index=i+1;break;return index;int getcurrenttransinfoindex()int index = -1;int i;for (i = 0; iSIZET; i+)if (pettransinfosi.transId = 0)index = i + 1;break;return index;int istypeexistsbyId(int typeId)if(typeIdSIZE | pettypestypeId-1.typeId=0)return -1;elsereturn 1;int updatepetstore(int typeId,int num,int recordtype)int count;count=pettypestypeId-1.petstore;if (recordtype = 1)count += num;else count -= num;if(count=0)pettypestypeId-1.petstore=count;return count;四、

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论