服装管理系统
while(NULL != tmpProduct) {
printf(\第%d件商品信息如下:\\n\
printf(\商品编号: %d\\n\ printf(\商品名称: %s\\n\ printf(\商品型号: %s\\n\ printf(\商品厂家: %s\\n\ printf(\商品价格: %f\\n\ printf(\商品数量: %d\\n\ printf(\商品附加信息: %s\\n\
tmpProduct = tmpProduct->next; i++; } } };
运算显示如下(图4-11):
图4-11 //商品查找函数// void ProductFind() {
Products *tmpProduct; int findWay,productId; char productName[20];
printf(\亲爱的%s朋友,你好,你现在进入的商品查询功能:\\n\ printf(\请选择查询方式: 1--按商品编号查询 2--按商品名称查询\\n\ scanf(\ tmpProduct = pProductHead; switch(findWay) { case 1:
printf(\请输入查询的商品编号:\ scanf(\ while(NULL != tmpProduct) {
if(productId == tmpProduct->productId) {
printf(\你查询的商品编号为%d的商品信息如下:\\n\
16
服装管理系统
printf(\ 商品名称: %s\\n\ printf(\ 商品型号: %s\\n\ printf(\ 商品厂家: %s\\n\ printf(\ 商品价格: %f\\n\ printf(\ 商品数量: %d\\n\ printf(\ 商品附加信息: %s\\n\ return ; }
tmpProduct = tmpProduct->next; }
printf(\对不起,不存在该商品编号的商品!\\n\ break; case 2:
printf(\请输入查询的商品名称:\ scanf(\ while(NULL != tmpProduct) {
if(0 == strcmp(tmpProduct->productName,productName)) {
printf(\你要查询的商品名称为%s的商品信息如下:\\n\ printf(\ 商品名称: %s\\n\ printf(\ 商品型号: %s\\n\ printf(\ 商品厂家: %s\\n\ printf(\ 商品价格: %f\\n\ printf(\ 商品数量: %d\\n\ printf(\ 商品附加信息: %s\\n\ return ; }
tmpProduct = tmpProduct->next; }
printf(\对不起,不存在该商品编号的商品!\\n\ break; default: break; }
}运算显示如下(图4-12):
图4-12
17
服装管理系统
//商品添加函数//
void InputAndAddProduct() { Products product;
printf(\亲爱的%s朋友,你好,请依次输入新商品的信息:\\n\ printf(\商品名称:\
scanf(\ printf(\商品型号:\
scanf(\ printf(\商品制造商:\
scanf(\ printf(\商品价格:\
scanf(\ printf(\商品数量:\
scanf(\ printf(\商品附加信息:\ scanf(\ product.next = NULL;
if(FUNCTION_SUCCESS == AddProduct(&product)) printf(\商品信息添加成功!\\n\};
运算显示如下(图4-15):
图4-15 //商品修改函数// void ModifyProduct() {
int productId; //待修改的商品编号 Products *tmpProduct;
printf(\亲爱的%s朋友,你好,你现在进入的商品信息修改功能:\\n\ printf(\请输入要修改的商品编号:\ scanf(\ tmpProduct = pProductHead; if(NULL == tmpProduct) return ; while(NULL != tmpProduct) {
18
服装管理系统
if(productId == tmpProduct->productId){
printf(\商品编号%d的商品信息如下:\\n\ printf(\ 商品名称: %s\\n\ printf(\ 商品型号: %s\\n\ printf(\ 商品厂家: %s\\n\ printf(\ 商品价格: %f\\n\ printf(\ 商品数量: %d\\n\ printf(\ 商品附加信息: %s\\n\
printf(\下面请对照修改该商品的相应信息:\\n\ printf(\新的商品名称: \
scanf(\ printf(\新的商品型号: \
scanf(\ printf(\新的商品厂家: \
scanf(\ printf(\新的商品价格: \
scanf(\ printf(\新的商品数量: \
scanf(\ printf(\新的商品附加信息: \ scanf(\
printf(\商品信息修改成功!\\n\
break; }
tmpProduct = tmpProduct->next; } };
//商品删除函数// void DeleteProduct() { int productId = 0;
Products *tmpProductA,*tmpProductB;
printf(\亲爱的%s朋友,你好,你现在进入的商品删除功能:\\n\ printf(\请输入你要删除的商品编号:\\n\ scanf(\
tmpProductA = tmpProductB = pProductHead; //tmpProductB指向要删除的记录,tmpProductA指向前一条记录
if(NULL == tmpProductB) return ;
19
服装管理系统
while(NULL != tmpProductB){
if(tmpProductB->productId == productId) {
if(tmpProductB == pProductHead && tmpProductB->next == NULL){ //如果系统只有一条商品信息
free(pProductHead); pProductHead = NULL; printf(\商品信息删除成功!\\n\ return ; }
tmpProductA->next = tmpProductB->next; if(pProductHead == tmpProductB) pProductHead = tmpProductB->next; free(tmpProductB);
printf(\商品信息删除成功!\\n\ return ; } else {
tmpProductA = tmpProductB; tmpProductB = tmpProductB->next; } }
printf(\对不起,不存在该商品编号的信息!\};
4.
店长功能模块(图4-16)
店长模块 1.自身密码修改 2.商品信息管理:添加,修改,查询,删除 3.销售报表显示:日销售报表,月销售报表,销售员销售报表 4.退出系统 5.
图4-16
20