当前位置:首页 > 服装销售管理系统—C语言课程设计 - 图文
C语言课程设计实验报告 void UserInfoAdd(); //用户信息添加 void UserInfoModify(); //用户信息修改 void UserInfoDelete(); //用户信息删除 void ProductsManage(); //产品信息管理 void ProductsView(); //商品查看 void ProductFind(); void InputAndAddProduct(); //输入商品信息并添加 void ModifyProduct(); //修改商品信息 void DeleteProduct(); //删除商品信息 void ProductsSell(); //商品销售 void ReportPrint(); //报表显示 void ShowAllSellReport(); //显示所有商品销售情况 void ShowDaySellReport(); //显示某日的销售情况 void ShowMonthSellReport(); //显示某月的销售情况 void ShowEmployeeSellReport(); //显示某个销售员的销售情况 void ExitSystem(); // 退出登陆系统 float getPriceById(int ); //通过商品编号查询商品价格 int getProductNameById(int,char *); //通过商品编号查询商品名称 int getCountById(int); //通过商品编号查询商品库存数量 void ReduceProductCount(int,int); //通过商品编号减少商品数量 /** 对系统进行初始化,建立用户记录和商品记录 **/ void InitSystem() { FILE *fp; SystemUser adminUser,bossUser,sellUser; //管理员,店长,销售员三个角色信息 Products products[2]; //初始化两件服装商品信息 SellInfoRecord sellInfo[2]; //初始化两条销售记录 //管理员 strcpy(adminUser.userName,\ strcpy(adminUser.password,\ adminUser.userType = ADMIN_USER_TYPE; adminUser.next = NULL; fp = fopen(\ fprintf(fp, \ fclose(fp); //店长 strcpy(bossUser.userName,\ strcpy(bossUser.password,\ bossUser.userType = BOSS_USER_TYPE; bossUser.next = NULL; fp = fopen(\ fprintf(fp, \ fclose(fp); //销售员 strcpy(sellUser.userName,\ strcpy(sellUser.password,\ sellUser.userType = SELL_USER_TYPE; sellUser.next = NULL; fp = fopen(\ fprintf(fp, \第 17 页 共 37 页 C语言课程设计实验报告 fclose(fp); AddUser(&adminUser); AddUser(&bossUser); AddUser(&sellUser); //products[0].productId = 1; strcpy(products[0].productName,\精品男装\ strcpy(products[0].productType,\ 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,\ 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,\ 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,\ sellInfo[1].year = 2008; AddSellInfo(&sellInfo[0]); AddSellInfo(&sellInfo[1]);}; /**函数功能: 向系统用户信息链表中加入用户信息**/ int AddUser(SystemUser *pUser) { SystemUser *pSystemUser,*tempSystemUser; tempSystemUser = pSystemUserHead; while(NULL != tempSystemUser) { if(0 ==strcmp(tempSystemUser->userName,pUser->userName)) { printf(\对不起,你要添加的用户已经存在\ return FUNCTION_FAILED; } tempSystemUser = tempSystemUser->next; } pSystemUser = (SystemUser *) malloc(sizeof(SystemUser)); //在堆空间中分配用户信息的内存 if(NULL == pSystemUser) { printf(\分配用户信息内存时发生错误\第 18 页 共 37 页 C语言课程设计实验报告 return FUNCTION_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;//将用户信息加入到链表的最后 } return FUNCTION_SUCCESS; }; /**函数功能: 向商品信息链表中加入商品信息**/ 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(sizeof(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 = 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; } return FUNCTION_SUCCESS; }; /**函数功能: 向系统销售信息链表中加入销售信息**/ int AddSellInfo(SellInfoRecord *pSellInfo) { int newSellInfoId = 1; //新加入销售记录的编号从1开始 SellInfoRecord *tmpSellInfo,*pSellInfoRecord; tmpSellInfo = pSellInfoHead; //生成编号,最后一个销售编号+1 while(NULL != tmpSellInfo) { 第 19 页 共 37 页 C语言课程设计实验报告 newSellInfoId = tmpSellInfo->saleId + 1; 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); 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; } return FUNCTION_SUCCESS; }; /*系统登陆函数*/ void SystemLogin() { char userName[20],password[20]; int isLogin = 0; SystemUser *tmpUser; printf(\请输入你的系统用户帐号:\ scanf(\ printf(\请输入你的系统用户密码:\ scanf(\ 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) { case ADMIN_USER_TYPE: AdminOperationMenu(); break; case BOSS_USER_TYPE: BossOperationMenu(); break; case SELL_USER_TYPE: SellOperationMenu(); 第 20 页 共 37 页
共分享92篇相关文档