C语言 服装销售管理系统.docx
- 文档编号:8083809
- 上传时间:2023-01-28
- 格式:DOCX
- 页数:39
- 大小:29.26KB
C语言 服装销售管理系统.docx
《C语言 服装销售管理系统.docx》由会员分享,可在线阅读,更多相关《C语言 服装销售管理系统.docx(39页珍藏版)》请在冰豆网上搜索。
C语言服装销售管理系统
#include h〉 #include h〉 #include〈time.h〉//日期和时间头文件 #defineADMIN_USER_TYPE1 #defineBOSS_USER_TYPE2 #defineSELL_USER_TYPE3 #defineFUNCTION_FAILED—1 #defineFUNCTION_SUCCESS0//如果函数成功执行,将返回0 /**系统用户结构**/ typedefstructSystemUser{ charuserName[20];//用户名,主键 charpassword[20];//用户密码 intuserType;//用户类型(1: 管理员;2: 店长;3: 销售员) structSystemUser*next;//指向下一个用户的指针 }SystemUser; /**服装商品信息**/ typedefstructProducts{ intproductId;//商品编号,主键 charproductName[20];//商品名称 charproductType[20];//商品型号 charproductCompany[20];//商品厂家 floatproductPrice;//商品价格 intproductCount;//商品数量 charmemo[50];//商品附加信息 structProducts*next;//指向下一个商品的指针 }Products; /**销售记录信息结构**/ typedefstructSellInfoRecord{ intsaleId;//销售编号,主键 charuserName[20];//销售商品的用户名 intproductId;//销售的商品编号 intsellCount;//销售数量 intyear;//销售商品年份 intmonth;//销售商品月份 intday;//销售商品日期 charmemo[50];//销售的附加信息 structSellInfoRecord*next;//下一条销售记录 }SellInfoRecord; staticcharcurrentUser[20];//系统全局变量,保存当前登陆用户名; staticintcurrentUserType;//系统全局变量,保存当前登陆用户的用户类型 staticSystemUser*pSystemUserHead=NULL;//保存系统用户信息记录的头指针 staticProducts*pProductHead=NULL;//保存系统商品信息记录的头指针 staticSellInfoRecord*pSellInfoHead=NULL;//保存系统销售记录的头指针 voidInitSystem();//对系统用户信息和商品信息进行初始化 intAddUser(SystemUser*);//向用户信息链表中加入用户信息 intAddProduct(Products*pPro);//向商品信息链表中加入商品信息 intAddSellInfo(SellInfoRecord*); voidUserExit(); voidWelcomeMenu();//系统欢迎菜单 voidSystemLogin();//系统登陆 voidAdminOperationMenu();//系统管理员操作菜单 voidBossOperationMenu();//店长操作菜单 voidSellOperationMenu();//销售员操作菜单 voidChangePassword();//修改密码 voidUserManage();//用户信息管理 voidUserInfoView();//用户信息查看 voidUserInfoAdd();//用户信息添加 voidUserInfoModify();//用户信息修改 voidUserInfoDelete();//用户信息删除 voidProductsManage();//产品信息管理 voidProductsView();//商品查看 voidProductFind(); voidInputAndAddProduct();//输入商品信息并添加 voidModifyProduct();//修改商品信息 voidDeleteProduct();//删除商品信息 voidProductsSell();//商品销售 voidReportPrint();//报表显示 voidShowAllSellReport();//显示所有商品销售情况 voidShowDaySellReport();//显示某日的销售情况 voidShowMonthSellReport();//显示某月的销售情况 voidShowEmployeeSellReport();//显示某个销售员的销售情况 voidExitSystem();//退出登陆系统 floatgetPriceById(int);//通过商品编号查询商品价格 intgetProductNameById(int,char*);//通过商品编号查询商品名称 intgetCountById(int);//通过商品编号查询商品库存数量 voidReduceProductCount(int,int);//通过商品编号减少商品数量 /**对系统进行初始化,建立用户记录和商品记录**/ voidInitSystem(){ FILE*fp; SystemUseradminUser,bossUser,sellUser;//管理员,店长,销售员三个角色信息 Productsproducts[2];//初始化两件服装商品信息 SellInfoRecordsellInfo[2];//初始化两条销售记录 //管理员 strcpy(adminUser。 userName,"admin”); strcpy(adminUser。 password,"admin”); adminUser。 userType=ADMIN_USER_TYPE; adminUser.next=NULL; fp=fopen("Admin。 txt”,”w”); fprintf(fp,”%s\t%s”,adminUser。 userName,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,"%s\t%s”,bossUser。 userName,bossUser。 password); fclose(fp); //销售员 strcpy(sellUser.userName,”sell”); strcpy(sellUser。 password,”sell"); sellUser.userType=SELL_USER_TYPE; sellUser。 next=NULL; fp=fopen("Seller。 txt”,"w”); fprintf(fp,"%s\t%s”,sellUser。 userName,sellUser。 password); fclose(fp); AddUser(&adminUser); AddUser(&bossUser); AddUser(&sellUser); //products[0].productId=1; strcpy(products[0].productName,"精品男装"); strcpy(products[0].productType,”m001"); strcpy(products[0]。 productCompany,”精品服装制造厂"); products[0].productPrice=23。 5; products[0].productCount=100; strcpy(products[0]。 memo,”精品男装,您的第一选择"); products[0].next=NULL; //products[1]。 productId=2; strcpy(products[1].productName,"时尚女装"); strcpy(products[1].productType,”w002"); strcpy(products[1]。 productCompany,”时尚服装制造厂"); products[1].productPrice=25.5; products[1]。 productCount=150; strcpy(products[1]。 memo,”时尚女装,您的第一选择”); products[1]。 next=NULL; AddProduct(&products[0]); AddProduct(&products[1]); sellInfo[0]。 day=16; strcpy(sellInfo[0]。 memo,"测试数据1"); sellInfo[0]。 month=7; sellInfo[0]。 next=NULL; sellInfo[0]。 productId=1; sellInfo[0]。 sellCount=8; strcpy(sellInfo[0]。 userName,"sell”); sellInfo[0].year=2008; sellInfo[1]。 day=17; strcpy(sellInfo[1]。 memo,"测试数据2”); sellInfo[1]。 month=7; sellInfo[1]。 next=NULL; sellInfo[1].productId=2; sellInfo[1].sellCount=5; strcpy(sellInfo[1]。 userName,”sell”); sellInfo[1].year=2008; AddSellInfo(&sellInfo[0]); AddSellInfo(&sellInfo[1]); }; /**函数功能: 向系统用户信息链表中加入用户信息**/ intAddUser(SystemUser*pUser){ SystemUser*pSystemUser,*tempSystemUser; tempSystemUser=pSystemUserHead; while(NULL! =tempSystemUser){ if(0==strcmp(tempSystemUser—〉userName,pUser—〉userName)){ printf(”对不起,你要添加的用户已经存在”); returnFUNCTION_FAILED; } tempSystemUser=tempSystemUser—>next; } pSystemUser=(SystemUser*)malloc(sizeof(SystemUser));//在堆空间中分配用户信息的内存 if(NULL==pSystemUser){ printf(”分配用户信息内存时发生错误”); returnFUNCTION_FAILED; } strcpy(pSystemUser—〉userName,pUser—〉userName);//拷贝用户信息到堆空间中 strcpy(pSystemUser->password,pUser—〉password); pSystemUser—>userType=pUser—>userType; pSystemUser—〉next=pUser—>next; tempSystemUser=pSystemUserHead; if(NULL==tempSystemUser){ pSystemUserHead=pSystemUser; }else{ while(NULL! =tempSystemUser—〉next)//遍历到用户信息的最后一条记录 tempSystemUser=tempSystemUser—〉next; tempSystemUser->next=pSystemUser;//将用户信息加入到链表的最后 } returnFUNCTION_SUCCESS; }; /**函数功能: 向商品信息链表中加入商品信息**/ intAddProduct(Products*pPro){ intnewProductId=1;//新加入商品的商品编号从1开始 Products*tempProduct,*pProduct; tempProduct=pProductHead;//生成编号,最后一件商品编号+1 while(NULL! =tempProduct){ newProductId=tempProduct—>productId+1; tempProduct=tempProduct->next; } pProduct=(Products*)malloc(sizeof(Products)); if(NULL==pProduct){ printf("对不器,添加商品信息时,堆内存分配失败! ”); returnFUNCTION_FAILED; } pProduct—>productId=newProductId;//拷贝商品信息 strcpy(pProduct->productName,pPro->productName); strcpy(pProduct—>productType,pPro->productType); strcpy(pProduct-〉productCompany,pPro—>productCompany); pProduct—>productPrice=pPro—>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=pProduct; } returnFUNCTION_SUCCESS; }; /**函数功能: 向系统销售信息链表中加入销售信息**/ intAddSellInfo(SellInfoRecord*pSellInfo){ intnewSellInfoId=1;//新加入销售记录的编号从1开始 SellInfoRecord*tmpSellInfo,*pSellInfoRecord; tmpSellInfo=pSellInfoHead;//生成编号,最后一个销售编号+1 while(NULL! =tmpSellInfo){ newSellInfoId=tmpSellInfo-〉saleId+1; tmpSellInfo=tmpSellInfo-〉next; } pSellInfoRecord=(SellInfoRecord*)malloc(sizeof(SellInfoRecord)); if(NULL==pSellInfoRecord){ printf("对不起,添加销售记录信息时,堆内存分配失败! "); returnFUNCTION_FAILED; } pSellInfoRecord-〉saleId=newSellInfoId; pSellInfoRecord—〉day=pSellInfo—>day; strcpy(pSellInfoRecord-〉memo,pSellInfo—〉memo); pSellInfoRecord-〉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;//将销售信息加入到销售记录信息链表最后 if(NULL==tmpSellInfo){ pSellInfoHead=pSellInfoRecord; }else{ while(NULL! =tmpSellInfo->next) tmpSellInfo=tmpSellInfo—〉next; tmpSellInfo->next=pSellInfoRecord; } returnFUNCTION_SUCCESS; }; /**函数功能: 向商品信息链表中加入商品信息**/ /*系统登陆函数*/ voidSystemLogin(){ charuserName[20],password[20]; intisLogin=0; SystemUser*tmpUser; printf("请输入你的系统用户帐号: ”); 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(currentUserType){ caseADMIN_USER_TYPE: AdminOperationMenu(); break; caseBOSS_USER_TYPE: BossOperationMenu(); break; caseSELL_USER_TYPE: SellOperationMenu(); break; default: break; } }else{ printf("对不起,你输入的密码错误! \n”); SystemLogin();//用户名正确,密码错误 } } tmpUser=tmpUser—〉next; } if(isLogin! =1){ printf(”对不起,该用户不存在\n”);//遍历了所有用户都没有找到用户 SystemLogin(); } } voidWelcomeMenu(){ 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("店长功能: \n"); printf(” (1)自身密码修改\n"); printf(” (2)商品信息管理: 添加,修改,查询,删除\n”); printf("(3)销售报表显示: 日销售报表,月销售报表,销售员销售报表\n”); printf(”(4)返回主界面\n”); printf(”(5)退出系统\n"); printf("销售员功能: \n”); printf(" (1)商品浏览,查询,商品销售\n"); printf(" (2)自己商品销售报表显示: 日销售报表,月销售报表\n”); printf(”(3)返回主界面\n"); printf("(4)退出系统\n”); printf(”*************************欢迎使用本系统**************************\n”); }; voidAdminOperationMenu(){ intselect; while (1){ system("cls”); printf(”亲爱的管理员%s同志,欢迎使用本系统,你拥有下面所有功能: \n”,currentUser); printf(” (1)自身密码修改\n"); printf(" (2)用户信息管理: 添加,修改,查询,删除\n”); printf(”(3)商品信息管理: 添加,修改,查询,删除\n”); printf("(4)销售报表显示: 日报表,月报表,商品销售量报表,销售员业绩报表\n”); printf(”(5)返回主界面\n"); printf("(6)退出系统\n”); printf(”请输入上面功能对应的序号进行功能选择: ");
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- C语言 服装销售管理系统 语言 服装 销售 管理 系统