服装销售管理系统—C语言课程设计_第1页
服装销售管理系统—C语言课程设计_第2页
服装销售管理系统—C语言课程设计_第3页
服装销售管理系统—C语言课程设计_第4页
服装销售管理系统—C语言课程设计_第5页
已阅读5页,还剩69页未读, 继续免费阅读

下载本文档

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

文档简介

1、精品文档c 语言课程设计实验报告一、 目的( 本次课程设计所涉及并要求掌握的知识点。)用户与商品信息要采用文件存储,因而要提供文件的输入输出操作;实现用户的添加、 修改、删除;商品信息的添加、修改、删除、查找等功能;实现商品浏览功能的实现,需要 实现显示操作;另外还要提供键盘式选择菜单以实现功能选择。二、使用环境 (本次上机实践所使用的平台和相关软件。 )microsoft visual c+三、内容与设计思想(1 设计思路 2 主要数据结构 3 主要代码结构 4 主要代码段分析 。 ) 1、设计思路服装销售系统管理员模块店长模块用户添加用户删除用户修改销售员模块商品添加商品删除商品修改商品模

2、块商品查找商品浏览商品出售2、主要数据结构/* 系统用户结构 */typedef struct systemuser char username20; /用户名,主键char password20; /用户密码int usertype; /用户类型(1:管理员;2:店长;3:销售员) struct systemuser *next; /指向下一个用户的指针 systemuser;/* 服装商品信息 */typedef struct products int productid; /商品编号,主键char productname20; /商品名称char producttype20; /商品型号

3、char productcompany20; /商品厂家.精品文档float productprice; /商品价格int productcount; /商品数量char memo50; /商品附加信息 struct products *next; /指向下一个商品的指针 products;/* 销售记录信息结构 */typedef struct sellinforecord int saleid; /销售编号,主键 char username20; /销售商品的用户名 int productid; /销售的商品编号 int sellcount; /销售数量int year; /销售商品年份i

4、nt month; /销售商品月份int day; /销售商品日期char memo50; /销售的附加信息struct sellinforecord *next; /下一条销售记录 sellinforecord;3、主要代码结构(一)添加打开文件,从键盘输入要添加的信息,若添加的信息与文件里的信息重复, 则调用系统暂停函数,返回界面;若添加的信息在文件里没有找到,则将添加的 信息输入到文件, 调用系统暂停函数,返回界面。(二)查询打开文件,从键盘输入要查询的信息,若在文件里找到要查询的信息,则在 界面输入信息,并调用系统暂停函数,返回界面;若没有找到查询的信息,调用 系统暂停函数,返回界面。

5、.精品文档(三)删除打开文件,从键盘输入要删除的信息,若在文件里找到要删除的信息存在, 则把文件里要删除的那条信息删除掉,并调用系统暂停函数,返回界面;若没有 找到删除的信息,调用系统暂停函数,返回界面。(四)修改打开文件,从键盘输入要修改的信息,若在文件里找到要修改的信息存在, 则按照提示信息依次输入要修改的信息,写入文件,并调用系统暂停函数,返回 界面;若没有找到修改的信息,调用系统暂停函数,返回界面。.精品文档4、主要代码段分析/* 对系统进行初始化 ,建立用户记录和商品记录 */void initsystem() file *fp;systemuser adminuser,bossus

6、er,selluser; /管理员,店长,销售员三个角色信息 products products2; /初始化两件服装商品信息sellinforecord sellinfo2; /初始化两条销售记录/初始化管理员用户名、密码与类型strcpy(adminuser.username,admin);strcpy(adminuser.password,admin);adminuser.usertype = admin_user_type;adminuser.next = null;/打开管理员用户信息文件 admin.txt,写入信息,并关闭文件fp = fopen(admin.txt, w);fp

7、rintf(fp, %st%s, adminuser.username, adminuser.password);fclose(fp);adduser(&adminuser);adduser(&bossuser);adduser(&selluser);/添加第一条商品信息strcpy(ductname,精品男装); strcpy(ducttype,m001); strcpy(ductcompany,精品服装制造厂); ductprice = 23.5;ductcou

8、nt = 100;strcpy(products0.memo,精品男装,您的第一选择);products0.next = null;/添加第二条商品信息.精品文档strcpy(ductname,时尚女装); strcpy(ducttype,w002); strcpy(ductcompany,时尚服装制造厂); ductprice = 25.5;ductcount = 150;strcpy(products1.memo,时尚女装,您的第一选择);products1.n

9、ext = null;addproduct(&products0);addproduct(&products1);/添加第一条销售报表记录sellinfo0.day = 16;strcpy(sellinfo0.memo,测试数据 1);sellinfo0.month = 7;sellinfo0.next = null;selliductid = 1;sellinfo0.sellcount = 8;strcpy(sellinfo0.username,sell);sellinfo0.year = 2008;/添加第二条销售报表记录sellinfo1.day = 17;strcpy(

10、sellinfo1.memo,测试数据 2);sellinfo1.month = 7;sellinfo1.next = null;selliductid = 2;sellinfo1.sellcount = 5;strcpy(sellinfo1.username,sell);sellinfo1.year = 2008;addsellinfo(&sellinfo0);addsellinfo(&sellinfo1);/添加商品信息void inputandaddproduct() products product;printf( 亲 爱 的 %s 朋 友 , 你 好 , 请 依 次

11、输 入 新 商 品 的 信息:n,currentuser);/输入商品名称、型号、制作商、价格、数量、附加信息,并把从键盘输入的值赋值 给结构体变量的商品名称型号、制作商、价格、数量、附加信息printf(商品名称:);scanf(%s,ductname);printf(商品型号:);scanf(%s,ducttype);printf(商品制造商:);scanf(%s,ductcompany);printf(商品价格:);scanf(%f,&ductprice);printf(商品数量:);scanf(%d

12、,&ductcount);printf(商品附加信息:);scanf(%s,product.memo);product.next = null;/若成功信息添加到结构体变量 product 里则提示添加成功if(function_success = addproduct(&product)printf(商品信息添加成功!n);.精品文档system(pause);/修改商品信息void modifyproduct() int productid; /待修改的商品编号 products *tmpproduct;printf( 亲 爱 的 %s 朋 友 , 你 好 , 你 现

13、 在 进 入 的 商 品 信 息 修 改 功能:n,currentuser);printf(请输入要修改的商品编号:);scanf(%d,&productid); /将从键盘接收到的商品编号赋值给变量 productid tmpproduct = pproducthead;if(null = tmpproduct) return ;while(null != tmpproduct) if(productid = tmpproduct-productid)/若从键盘输入的商品编号与文件中的一致,则修改商品信息printf(商品编号%d 的商品信息如下:n,productid);printf( 商

14、品名称: %sn,tmpproduct-productname);printf( 商品型号: %sn,tmpproduct-producttype);printf( 商品厂家: %sn,tmpproduct-productcompany); printf( 商品价格: %fn,tmpproduct-productprice); printf( 商品数量: %dn,tmpproduct-productcount); printf( 商品附加信息: %sn,tmpproduct-memo); printf(下面请对照修改该商品的相应信息:n); printf(新的商品名称: ); scanf(%s

15、,tmpproduct-productname); printf(新的商品型号: ); scanf(%s,tmpproduct-producttype); printf(新的商品厂家: ); scanf(%s,tmpproduct-productcompany); printf(新的商品价格: ); scanf(%f,&tmpproduct-productprice); printf(新的商品数量: ); scanf(%d,&tmpproduct-productcount); printf(新的商品附加信息: ); scanf(%s,tmpproduct-memo);printf(商品信息修改

16、成功!n);system(pause);break; tmpproduct = tmpproduct-next; ;/商品删除void deleteproduct() int productid = 0;products *tmpproducta,*tmpproductb;printf( 亲 爱 的 %s 朋 友 , 你 好 , 你 现 在 进 入 的 商 品 删 除 功能:n,currentuser);printf(请输入你要删除的商品编号:);scanf(%d,&productid);tmpproducta = tmpproductb = pproducthead; /tmpproduct

17、b 指向要删除的记录,tmpproducta 指向前一条记录if(null = tmpproductb) return ;while(null != tmpproductb)if(tmpproductb-productid = productid) if(tmpproductb = pproducthead & tmpproductb-next =.精品文档null) /如果系统只有一条商品信息free(pproducthead);pproducthead = null;printf(商品信息删除成功!n);system(pause);return ; tmpproducta-next = t

18、mpproductb-next;if(pproducthead = tmpproductb)pproducthead = tmpproductb-next;free(tmpproductb);printf(商品信息删除成功!n);system(pause);return ; else tmpproducta = tmpproductb;tmpproductb = tmpproductb-next; printf(对不起,不存在该商品编号的信息!);/商品查询void productfind() products *tmpproduct;int findway,productid;char pr

19、oductname20;printf( 亲 爱 的 %s 朋 友 , 你 好 , 你 现 在 进 入 的 商 品 查 询 功 能:n,currentuser);printf(请选择查询方式: 1-按商品编号查询 2-按商品名称查询:); scanf(%d,&findway);tmpproduct = pproducthead;switch(findway) case 1:printf(请输入查询的商品编号:);scanf(%d,&productid); /输入要查询的商品编号 while(null != tmpproduct) if(productid = tmpproduct-product

20、id) /若输入查询的商品编号与文件中的一致,则输出商品信息 printf(你查询的商品编号为%d 的商品信息如下:n,productid); printf( 商品名称: %sn,tmpproduct-productname); printf( 商品型号: %sn,tmpproduct-producttype); printf( 商品厂家: %sn,tmpproduct-productcompany); printf( 商品价格: %fn,tmpproduct-productprice); printf( 商品数量: %dn,tmpproduct-productcount); printf(

21、商品附加信息: %sn,tmpproduct-memo);system(pause);return ; tmpproduct = tmpproduct-next; printf(对不起,不存在该商品编号的商品!n); system(pause);case 2:printf(请输入查询的商品名称:); scanf(%s,productname); /输入要查询的商品名称 while(null != tmpproduct) if(0 = strcmp(tmpproduct-productname,productname) /若输入查询的商品名称与文件中的一致,则输出商品信息printf(你要查询的

22、商品名称为%s 的商品信息如下:n,productname);.精品文档printf( 商品名称: %sn,tmpproduct-productname); printf( 商品型号: %sn,tmpproduct-producttype); printf( 商品厂家: %sn,tmpproduct-productcompany); printf( 商品价格: %fn,tmpproduct-productprice); printf( 商品数量: %dn,tmpproduct-productcount); printf( 商品附加信息: %sn,tmpproduct-memo);system(

23、pause);return ; tmpproduct = tmpproduct-next; printf(对不起,不存在该商品编号的商品!n);system(pause);default:break; 四、调试过程 (1 测试数据设计 2 测试结果分析 )初始化用户名与密码管理员:admin admin 店 长:boss boss (一)主界面销售员:sell sell(二)以管理员方式登陆系统,输入正确的用户账号 admin 和密码 admin若登陆名或密码错误,则提示用户不存在.精品文档登陆成功,进入管理员界面选择“(1)自身密码修改”,修改管理员密码选择“(2)用户信息管理”,进行用户的

24、增、删、改、查功能选择“用户信息查看”,查看当前用户信息选择“用户信息添加”,添加用户信息.精品文档选择“用户信息删除”,删除用户返回管理员界面,选择“(3)商品信息管理”,进行商品的增、删、改、查功能。选择“用户信息查看”,查看当前商品信息。选择“商品信息查找”,根据商品编号及商品名称进行查找。首先,选择“按商 品编号查询”,若查询的编号存在,则显示查询的信息.精品文档若查询的商品编号不存在,则提示信息“对不起,不存在该商品编号的商品”选择“按商品名称查询”,输入正确的商品名称,显示查询信息若查询的商品名称不存在,则提示信息“对不起,不存在该商品编号的商品”选择“商品信息添加”,添加商品信息

25、选择“商品信息修改”,修改商品信息.精品文档选择“商品信息删除”,删除商品返回管理员界面,选择“商品报表显示”,进行销售报表功能选择“所有商品销售情况”,显示商品信息.精品文档选择“商品日销售报表”,查看符合条件的销售商品若查询的信息不符合条件,则显示没有符合条件的记录选择“商品月销售报表”,查看符合条件的销售商品选择“销售员销售报表”,查看符合条件的销售商品.精品文档(三)以店长方式登录系统选择“自身密码修改”,修改店长密码店长其他功能(商品信息管理,销售报表显示)与管理员类似。 (四)以销售员登陆系统.精品文档选择“商品销售”功能,进行产品销售若销售产品大于库存,则提示销售失败。销售员商品

26、浏览、查询、及报表查看功能与管理员功能类似 五、总结1 设计中遇到的问题及解决过程2 设计中产生的错误及原因分析3 设计体会和收获。六、附录1、原代码#include /标准输入输出函数#include /windows 头文件#include /日期和时间头文件.精品文档#define admin_user_type 1#define boss_user_type 2#define sell_user_type 3#define function_failed -1#define function_success 0 /如果函数成功执行,将返回 0/* 系统用户结构 */typedef st

27、ruct systemuser char username20; /用户名,主键char password20; /用户密码int usertype; /用户类型(1:管理员;2:店长;3:销售员) struct systemuser *next; /指向下一个用户的指针 systemuser;/* 服装商品信息 */typedef struct products int productid; /商品编号,主键char productname20; /商品名称char producttype20; /商品型号char productcompany20; /商品厂家float productpr

28、ice; /商品价格int productcount; /商品数量char memo50; /商品附加信息 struct products *next; /指向下一个商品的指针 products;/* 销售记录信息结构 */typedef struct sellinforecord int saleid; /销售编号,主键 char username20; /销售商品的用户名 int productid; /销售的商品编号 int sellcount; /销售数量int year; /销售商品年份int month; /销售商品月份int day; /销售商品日期char memo50; /销

29、售的附加信息struct sellinforecord *next; /下一条销售记录 sellinforecord;static char currentuser20; /系统全局变量,保存当前登陆用户名; static int currentusertype; /系统全局变量,保存当前登陆用户的用户类型static systemuser *psystemuserhead = null; /保存系统用户信息记录的头指针 static products *pproducthead = null; /保存系统商品信息记录的头指针 static sellinforecord *psellinfoh

30、ead = null;/保存系统销售记录的头指针 void initsystem(); /对系统用户信息和商品信息进行初始化int adduser(systemuser *); /向用户信息链表中加入用户信息int addproduct(products *ppro); /向商品信息链表中加入商品信息int addsellinfo(sellinforecord *);void userexit();void welcomemenu(); /系统欢迎菜单 void systemlogin(); /系统登陆void adminoperationmenu(); /系统管理员操作菜单 void bos

31、soperationmenu(); /店长操作菜单 void selloperationmenu(); /销售员操作菜单 void changepassword(); /修改密码 void usermanage(); /用户信息管理void userinfoview(); /用户信息查看.精品文档void userinfoadd(); /用户信息添加 void userinfomodify(); /用户信息修改 void userinfodelete(); /用户信息删除void productsmanage(); /产品信息管理void productsview(); /商品查看void p

32、roductfind();void inputandaddproduct(); /输入商品信息并添加 void modifyproduct(); /修改商品信息 void deleteproduct(); /删除商品信息 void productssell(); /商品销售void reportprint(); /报表显示void showallsellreport(); /显示所有商品销售情况 void showdaysellreport(); /显示某日的销售情况 void showmonthsellreport(); /显示某月的销售情况 void showemployeesellrep

33、ort(); /显示某个销售员的销售情况void exitsystem(); / 退出登陆系统 float getpricebyid(int ); / 通过商品编号查询 商品价格int getproductnamebyid(int,char *); / 通过商品编号查询 商品名称int getcountbyid(int); / 通过商品编号查询 商品库存数量void reduceproductcount(int,int); / 通过商品编号减少 商品数量/* 对系统进行初始化 ,建立用户记录和商品记录 */void initsystem() file *fp;systemuser adminu

34、ser,bossuser,selluser; /管理员,店长,销售员三个角色信息 products products2; /初始化两件服装商品信息 sellinforecord sellinfo2; /初始化两条销售记录/管理员strcpy(adminuser.username,admin);strcpy(adminuser.password,admin);adminuser.usertype = admin_user_type;adminuser.next = null;fp = fopen(admin.txt, w);fprintf(fp, %st%s, adminuser.usernam

35、e, adminuser.password);fclose(fp);/店长strcpy(bossuser.username,boss);strcpy(bossuser.password,boss);bossuser.usertype = boss_user_type;bossuser.next = null;fp = fopen(shopkeeper.txt, w);fprintf(fp, %st%s, bossuser.username, bossuser.password);fclose(fp);/销售员strcpy(selluser.username,sell);strcpy(sellu

36、ser.password,sell);selluser.usertype = sell_user_type;selluser.next = null;fp = fopen(seller.txt, w);fprintf(fp, %st%s, selluser.username, selluser.password);.精品文档fclose(fp);adduser(&adminuser);adduser(&bossuser);adduser(&selluser);/ductid = 1;strcpy(ductname,精品男装); strcpy(

37、ducttype,m001); strcpy(ductcompany,精品服装制造厂); ductprice = 23.5;ductcount = 100;strcpy(products0.memo,精品男装,您的第一选择); products0.next = null;/ductid = 2;strcpy(ductname,时尚女装); strcpy(ducttype,w002); strcpy(products

38、1.productcompany,时尚服装制造厂); ductprice = 25.5;ductcount = 150;strcpy(products1.memo,时尚女装,您的第一选择); products1.next = null;addproduct(&products0);addproduct(&products1);sellinfo0.day = 16;strcpy(sellinfo0.memo,测试数据 1);sellinfo0.month = 7;sellinfo0.next = null;selliductid

39、 = 1;sellinfo0.sellcount = 8;strcpy(sellinfo0.username,sell);sellinfo0.year = 2008;sellinfo1.day = 17;strcpy(sellinfo1.memo,测试数据 2);sellinfo1.month = 7;sellinfo1.next = null;selliductid = 2;sellinfo1.sellcount = 5;strcpy(sellinfo1.username,sell);sellinfo1.year = 2008;addsellinfo(&sellinfo0);

40、addsellinfo(&sellinfo1);/*函数功能: 向系统用户信息链表中加入用户信息 */int adduser(systemuser *puser) systemuser *psystemuser,*tempsystemuser;tempsystemuser = psystemuserhead;while(null != tempsystemuser) if(0 =strcmp(tempsystemuser-username,puser-username) printf(对不起,你要添加的用户已经存在);return function_failed; tempsystemuser

41、 = tempsystemuser-next; psystemuser = (systemuser *) malloc(sizeof(systemuser); / 在 堆空间中分配用户信息的内存if(null = psystemuser) printf(分配用户信息内存时发生错误);.精品文档rrrrrr function_failed; rrrrrr (psystemuser-username,puser-username); /拷贝用户信息到堆空间中 strcpy(psystemuser-password,puser-password);psystemuser-usertype = pus

42、er-usertype;psystemuser-next = puser-next;tempsystemuser = psystemuserhead;if(null = tempsystemuser) psystemuserhead = psystemuser; else while(null != tempsystemuser-next) /遍历到用户信息的最后一条记录tempsystemuser = tempsystemuser-next;tempsystemuser-next = psystemuser;/将用户信息加入到链表的最后return function_success;/*函数

43、功能: 向商品信息链表中加入商品信息*/int addproduct(products *ppro) int newproductid = 1; /新加入商品的商品编号从 1 开始 products *tempproduct,*pproduct;tempproduct = pproducthead; /生成编号,最后一件商品编号+1 while(null != tempproduct) newproductid = tempproduct-productid + 1;tempproduct = tempproduct-next;pproduct = (products *)malloc(siz

44、eof(products);if(null = pproduct) printf(对不器,添加商品信息时,堆内存分配失败!);return function_failed;pproduct-productid = newproductid; /拷贝商品信息 strcpy(pproduct-productname,ppro-productname);strcpy(pproduct-producttype,ppro-producttype);strcpy(pproduct-productcompany,ppro-productcompany);pproduct-productprice = ppr

45、o-productprice;pproduct-productcount = ppro-productcount;strcpy(pproduct-memo,ppro-memo);pproduct-next = ppro-next;tempproduct = pproducthead; /将商品信息加入到商品信息链表最后 if(null = tempproduct) pproducthead = pproduct; else while(null != tempproduct-next)tempproduct = tempproduct-next;tempproduct-next = pprod

46、uct;return function_success;/*函数功能: 向系统销售信息链表中加入销售信息 */int addsellinfo(sellinforecord *psellinfo) int newsellinfoid = 1; /新加入销售记录的编号从 1 开始 sellinforecord *tmpsellinfo,*psellinforecord;tmpsellinfo = psellinfohead; /生成编号,最后一个销售编号+1 while(null != tmpsellinfo) .精品文档newsellinfoid = tmpsellinfo-saleid + 1

47、;tmpsellinfo = tmpsellinfo-next;psellinforecord= (sellinforecord *)malloc(sizeof(sellinforecord);if(null = psellinforecord) printf(对不起,添加销售记录信息时,堆内存分配失败!);return function_failed;psellinforecord-saleid = newsellinfoid;psellinforecord-day = psellinfo-day;strcpy(psellinforecord-memo,psellinfo-memo);pse

48、llinforecord-month = psellinfo-month;psellinforecord-next = psellinfo-next;psellinforecord-productid = psellinfo-productid;psellinforecord-sellcount = psellinfo-sellcount;strcpy(psellinforecord-username,psellinfo-username);psellinforecord-year = psellinfo-year; tmpsellinfo=psellinfohead; /将销售信息加入到销售

49、记录信息链表最后 if(null = tmpsellinfo) psellinfohead = psellinforecord; else while(null != tmpsellinfo-next)tmpsellinfo = tmpsellinfo-next;tmpsellinfo-next = psellinforecord;return function_success;/*系统登陆函数 */void systemlogin() char username20,password20;int islogin = 0;systemuser *tmpuser;printf(请输入你的系统用户

50、帐号:);scanf(%s,username);printf(请输入你的系统用户密码:);scanf(%s,password);tmpuser = psystemuserhead;while(null != tmpuser) if(0 = strcmp(tmpuser-username,username) if(0 = strcmp(tmpuser-password,password) islogin = 1;strcpy(currentuser,tmpuser-username);currentusertype = tmpuser-usertype;switch(currentusertyp

51、e) case admin_user_type:adminoperationmenu();break;case boss_user_type:bossoperationmenu();break;case sell_user_type:selloperationmenu();.精品文档break;default:break; else printf(对不起,你输入的密码错误!n);systemlogin(); / 用户名正确,密码错误 tmpuser = tmpuser-next;if(islogin != 1) printf( 对不起 , 该用户不存在 n); / 遍 历了所有用户都没有找到用户systemlogin();/欢迎界面void welcomemenu() printf(* 欢 迎 光 临 服 装 销 售 管 理 系 统 *n);printf(系统功能说明:n);printf( 管理员功能:n);printf( (1)自身密码修改n);printf( (2)用户信息管理:添加,修改,删

温馨提示

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

评论

0/150

提交评论