版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
C语言笔记本电脑销售系统课设项目说明本系统基于C语言开发,适用于刚入门的C语言新手项目课设,开发软件采用VC++6.0开发,VS,DEVC++等均可运行。(书生)项目运行截图开始界面新建笔记本信息删除笔记本信息退出系统代码界面截图完整源码#include<stdio.h>#include<stdlib.h>#include<string.h>#include<windows.h>structComputer{charName[100]; charBrand[100]; charType[100]; intSell_quantity; floatPurchase_price; intRemain_quantity; floatSell_price; floattotal_money; structComputer*next;};#defineLENsizeof(structComputer)voidCREAT(void);voidMENU(void);voidFIND(structComputer*head);voidSAVE(structComputer*head);voidADD(structComputer*head);voidCHANGE(structComputer*head);voidDELETe(structComputer*head);voidHIGH(structComputer*head);voidSEARCH(structComputer*head);voidSELL(structComputer*head);intmain(){ intnumber,count; FILE*fp; system("modeconcols=120lines=100");//行列 system("colorF0"); printf("\n欢迎进入笔记本电脑销售管理系统\n"); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xFC); printf("版本型号:V2.1.5\n");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF0); printf("·准备好后请按回车键开始(请不要乱按其他键,否则会造成程序错误)\n"); printf("·PleaseentertheEnterkeytostart!"); getchar(); if((fp=fopen("SellRecord.txt","rb"))==NULL) { printf("++\n\n"); printf("|提示:您是第一次使用该系统,请先录入笔记销售信息!|\n\n"); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF9); printf("|·服务编号:|\n\n"); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF2); printf("|1.新建笔记本电脑信息|\n\n"); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF6); printf("|2.退出系统|\n\n"); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF0); printf("++\n\n");printf("Input:"); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xFC); scanf("%d",&number); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF0); if(number==1)CREAT(); elseif(number==2)exit(0); else { printf("未查到此编号,回车键退出系统!"); getchar(); exit(0); } } else {fclose(fp); MENU();}return0;}voidMENU(void){ intnumber; FILE*fp; intt; structComputer*p1,*p2,*head; p1=(structComputer*)malloc(LEN); head=p1; if((fp=fopen("SellRecord.txt","rb"))==NULL) { printf("未找到该信息!回车键退出程序\n"); getchar(); exit(0); } while(!feof(fp)) { if(fread(p1,LEN,1,fp)!=1) break; p1->next=(structComputer*)malloc(LEN); if(p1->next==NULL) { printf("error:回车键退出程序\n"); getchar(); exit(0); } p2=p1; p1=p1->next; } p2->next=NULL; fclose(fp);system("CLS");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF0); printf("\n欢迎进入笔记本电脑销售管理系统\n");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xFC); printf("版本型号:V2.1.5\n");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF0); printf("++\n\n");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xFC); printf("|·服务编号:|\n\n");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF2); printf("|1.添加笔记本电脑信息|\n\n"); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF9); printf("|2.删除笔记本电脑信息|\n\n"); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF6); printf("|3.修改笔记本电脑信息|\n\n"); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xFC); printf("|4.查询笔记本库存现状|\n\n"); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF4); printf("|5.查询目前销量最高的笔记本|\n\n");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF1);printf("|6.查询某品牌笔记本库存|\n\n");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xFD); printf("|7.笔记本销售|\n\n");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF5); printf("|8.退出系统|\n\n");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF8); printf("|9.格式化系统|\n\n");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF0); printf("++\n");printf("Input:"); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xFC);scanf("%d",&number); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF0); if(number==1)ADD(head); elseif(number==2)DELETe(head); elseif(number==3)CHANGE(head); elseif(number==4)FIND(head); elseif(number==5)HIGH(head); elseif(number==6)SEARCH(head); elseif(number==7)SELL(head); elseif(number==8)exit(0); elseif(number==9) { getchar();remove("SellRecord.txt"); printf("请按回车键退出系统,并重新启动程序\n"); getchar(); exit(0); } else { printf("未查到此编号,回车键退出系统!\n"); getchar(); getchar(); exit(0); }}voidCREAT(void){ structComputer*p1,*p2,*head=NULL,*p=NULL; FILE*fp; p1=p2=(structComputer*)malloc(LEN); printf("\n"); fp=fopen("SellRecord.txt","wb+");printf("·请按如下格式输入来添加笔记本销售信息:\n\n");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF1); printf("产品名称产品品牌产品型号销售数量进价库存数量售价\n\n");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF0); printf("·当输入产品名称为0时则为停止录入!\n\n"); printf("Input:"); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xFC); scanf("%s",p1->Name); while(p1->Name[0]!='0') { scanf("%s%s%d",p1->Brand,p1->Type,&p1->Sell_quantity); scanf("%f%d%f",&p1->Purchase_price,&p1->Remain_quantity,&p1->Sell_price); p1->total_money=p1->Sell_quantity*p1->Sell_price; if(head==NULL) head=p1; else p2->next=p1; p2=p1; p1=(structComputer*)malloc(LEN); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF0);printf("Input:");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xFC); scanf("%s",p1->Name); } SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF0);fclose(fp); p2->next=NULL; free(p1);SAVE(head);}voidSAVE(structComputer*head){ structComputer*p; ints=0,k; FILE*fp; p=head; if((fp=fopen("SellRecord.txt","wb"))==NULL) { printf("未找到该信息!回车键退出程序\n"); getchar(); exit(0); } else { while(p!=NULL) { fwrite(p,LEN,1,fp); p=p->next; } fclose(fp); printf("保存成功!请按回车键继续!\n"); getchar(); getchar(); if((fp=fopen("SellRecord.txt","rb"))==NULL) { printf("未找到该信息!回车键退出程序\n"); getchar(); exit(0); } MENU();}}voidFIND(structComputer*head){ structComputer*p; system("CLS"); printf("\n");printf("请按回车键查看!");getchar();getchar(); p=head; if(head==NULL) { printf("未找到该信息!回车键退出程序\n"); getchar(); exit(0); } else { SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF2); printf("++\n"); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF0); printf("|产品名称产品品牌产品型号销售数量进价库存数量售价金额|\n"); while(p!=NULL) { p->total_money=p->Sell_quantity*p->Sell_price; SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF2); printf("++\n");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF0); printf("|%-16s%-16s%-16s%-6d%-12.2f%-6d%-12.2f%-12.2f|\n",p->Name,p->Brand,p->Type,p->Sell_quantity,p->Purchase_price,p->Remain_quantity,p->Sell_price,p->total_money);p=p->next; } SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF2); printf("++\n"); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF0); } printf("请按回车键继续"); getchar(); MENU();}voidADD(structComputer*head){ structComputer*p1,*p2; FILE*fp; printf("\n");printf("·请按如下格式输入来新增一条笔记本销售信息:\n\n");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF1); printf("产品名称产品品牌产品型号销售数量进价库存数量售价\n\n");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF0); p1=head; if(head==NULL) { printf("未找到该信息!回车键退出程序\n"); getchar(); exit(0); } else { while(p1->next!=NULL)p1=p1->next;p2=(structComputer*)malloc(LEN);SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF0);printf("Input:");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xFC); scanf("%s",p2->Name); printf("\n");scanf("%s%s%d",p2->Brand,p2->Type,&p2->Sell_quantity); scanf("%f%d%f",&p2->Purchase_price,&p2->Remain_quantity,&p2->Sell_price); p1->total_money=p1->Sell_quantity*p1->Sell_price; p1->next=p2; p2->next=NULL; }SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF0); fp=fopen("SellRecord.txt","wb+");fclose(fp); SAVE(head);}voidDELETe(structComputer*head){structComputer*p;charch1[100],ch2[100],ch3[100],flag=0;FILE*fp;p=head; printf("\n");printf("·请按如下格式输入来删除一条笔记本销售信息:\n\n");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF1); printf("产品名称产品品牌产品型号\n\n");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF0);printf("Input:"); getchar(); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xFC);scanf("%s%s%s",ch1,ch2,ch3);printf("\n");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF0);if(strcmp(ch1,p->Name)==0&&strcmp(ch2,p->Brand)==0&&strcmp(ch3,p->Type)==0){head=p->next;flag=1;}else{while(p->next!=NULL){ if(strcmp(ch1,(p->next)->Name)==0&&strcmp(ch2,(p->next)->Brand)==0&&strcmp(ch3,(p->next)->Type)==0) { p->next=(p->next)->next;flag=1;} if(flag==1)break; p=p->next; } }if(flag==0)printf("未找到该信息!\n"); fp=fopen("SellRecord.txt","wb+");fclose(fp); SAVE(head);}voidCHANGE(structComputer*head){structComputer*p;charch1[100],ch2[100],ch3[100];inta,b,flag=0; floatc,d; FILE*fp;p=head; printf("\n");printf("请按如下格式输入来修改一条笔记本销售信息:\n\n");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF1); printf("产品名称产品品牌产品型号销售数量(修改后)进价(修改后)库存数量(修改后)售价(修改后)\n\n");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF0); printf("Input:");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xFC);scanf("%s%s%s%d%f%d%f",ch1,ch2,ch3,&a,&c,&b,&d);printf("\n");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF0);while(p!=NULL){ if(strcmp(ch1,p->Name)==0&&strcmp(ch2,p->Brand)==0&&strcmp(ch3,p->Type)==0) { flag=1; p->Sell_quantity=a; p->Purchase_price=c; p->Remain_quantity=b; p->Sell_price=d; p->total_money=p->Sell_quantity*p->Sell_price; } if(flag==1)break; p=p->next; } if(flag==0)printf("未找到该信息!\n"); fp=fopen("SellRecord.txt","wb+");fclose(fp); SAVE(head);}voidHIGH(structComputer*head){ structComputer*p,temp; intmax; system("cls"); printf("\n"); getchar(); p=head; max=0; while(p!=NULL) { if(p->Sell_quantity>max) { temp=*p; max=p->Sell_quantity; } p=p->next; } p=head; printf("销售最多为");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xFC); printf("%d",max);SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF0); printf("台,品牌型号类型为:\n\n"); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF1); while(p!=NULL) { if(p->Sell_quantity==max) printf("%-16s%-16s%-16s\n\n",p->Name,p->Brand,p->Type); p=p->next; } SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF0); printf("\n"); printf("请按回车键继续"); getchar();MENU();}voidSEARCH(structComputer*head){structComputer*p;charch1[100];FILE*fp;system("cls");p=head; printf("\n");printf("·请输入要查询的笔记本品牌:\n\n"); printf("Input:"); getchar(); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xFC);scanf("%s",ch1);printf("\n"); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF2); printf("++\n"); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF0); printf("|产品名称产品品牌产品型号销售数量进价库存数量售价金额|\n");while(p!=NULL){ if(strcmp(ch1,p->Brand)==0) { p->total_money=p->Sell_quantity*p->Sell_price; SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0xF2); printf("++\n");SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年药品质量事故分级判定培训试卷(含答案)
- 2026年度小升初学生收心教育课件:告别假期综合症
- 初《规范助品德行为构人生》主题班会
- 动物生物学单细胞生物
- 仓储物料管理之仓库与物料管理实务培训
- 护理示范病房交流
- 初中物理实验课件比较不同物质的吸热能力
- 2026年教师节我的教育故事演讲课件
- 2026肉牛养殖场环境友好型改造技术方案白皮书
- 二年级劳动外研版暑假第一单元同步测试卷基础版A卷
- 如果历史是一群喵
- 民间借款和解协议书
- 土地使用权代持协议
- 金蝶云星空操作手册
- 《电脑基础操作》课件
- 卵巢纤维瘤疾病演示课件
- 素描(中职)PPT完整全套教学课件
- 四年级下册科学《谁在运动》-课件
- 城市安全问题与城市防灾减灾课件
- 光伏建设工艺流程教材课件
- 马工程西方经济学(第二版)教学课件-5
评论
0/150
提交评论