销售管理系统 计算机课程设计(C语言)

更新时间:2024-01-20 07:58:01 阅读量: 教育文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

目 录

1 需求分析说明…………………………………………………………1

2 概要设计说明…………………………………………………………2 3 详细设计说明…………………………………………………………3 4 调试分析…………………………………………………………4 5 用户使用说明………………………………………………………5 6 测试结果………………………………………………………5 7 主程序………………………………………………………12

需求分析说明

产品进销存管理系统总体功能要求:

产品进销存管理系统总体目标:在TURBO C2.0 的开发环境下,利用所学C语言和数据结构的相关知识,开发一个小程序,实现商店日常基本操作,通过其显示结果对本系统的性能有一个直观的了解。 基本功能如下:

(1)界面友好,易与操作。采用菜单进行选择。

(2)实现各种基本操作。包括商品产品的存储,销售,查询,更改,已达到为商家减少日常不必要的麻烦。 以下是各功能模块的功能描述:

1.主函数模块

本模块的主要功能是初始化图形界面,调用各模块,实现系统功能。

2.初始化模块

本模块的主要功能是初始化本系统,进行系统基本操作的演示。

3.添加模块

本模块的主要功能是可进行商品类的添加,产品的添加。

4.查询模块

本模块的主要功能是能够查询库房每种产品的总量,进货日期,销售数量,产品单价,销售日期,销售收益 ,产品剩余库存量。

5.删除模块

1

本模块的主要功能是能够进行商品类的删除,产品的删除。

6.库存模块

本模块的主要功能是使商家随时随地的查看商店的整体运作情况。例如每一种商品的销售数量,销售收益等。

7.更改模块

本模块的主要功能是能够更改库房每种产品的总量,进货日期,销售数量,产品

单价,销售日期,销售收益 ,产品剩余库存量。

8.密码模块

概要设计说明

本模块的主要功能是使本系统更趋于安全。

#define ok 1 #define error 0 #define overflow 0

#define SQMOUTLINK_INIT_SIZE 100 #define SQMOUTLINKINCREMENT 10

/***********************日期*******************/ typedef struct date

{ int year; int month; int day; }date;

/***********************产品******************/ typedef struct productnode {

char product_name[40]; //产品名称 int product_quantity; //产品总量 int sales_quantity; //销售数量 double product_price; //产品单价 double product_income; //销售收益 int product_stock; //产品库存 date buy_time; //进货日期 date sales_time; //销售日期 struct productnode *next; }productnode,*plinklist;

/*********************货物种类**************/ typedef struct kindnode {

productnode * first_product; //头指针 char pkindname[40]; //商品名称 int kind_number; //产品种类个数 }kindnode;

/*****************销售链表****************/

2

typedef struct {

kindnode* kindelem; int length; int listsize; }sqlist;

int Init(sqlist &L)/*初始化L*/ int Add(sqlist &L) /*添加*/ void Alter(sqlist &L)/*更改*/ int Create(sqlist &L)/*创建*/ void Delete(sqlist &L)/*删除*/ void Display(sqlist &L)/*输出*/ void View(sqlist &L)/*查询*/ void password()/*设置密码*/

void check_password()/*验证密码*/ void menu_operation()/*菜单栏*/ void main(void)/*功能调用*/

详细设计说明

1主函数模块

首先是调用password()和check_password()函数进行安全设置,设置密码,当再次登录系统时需输入密码进行身份确认。再次调用Init(L)函数进行初始化。然后是功能选择性操作菜单,进行需要的添加,删除,更改,查询等操作,需调用Create(L),Add(L),Alter(L),View(L),Delete(L),Display(L)函数。

2.初始化模块 3.添加模块

对系统的容量,长度,首地址进行初次预设。

输入你所要添加的商品,之后需要从第一个商品偏历。如果有该商品则进行插入操作,插入一 个产品。如果没有,则插入一个商品。 4.查询模块

首先从众多商品中选出你所要进行操作的商品类。从第一个商品进行遍历,直到找到该

价,销售日期,销售收益 ,产品剩余库存量 5.删除模块

首先从众多商品中选出你所要进行操作的商品类。从第一个商品进行遍历,直到找到该商品。如果没找到则返回相应未找到信息。如果找到,需要进行产品的遍历,找到要操作的产品,删除该产品。。 6.库存模块

从第一个商品进行遍历,输出所有产品的信息。 7.更改模块

商品。如果没找到则返回相应未找到信息。如果找到,有两种情况:第一种是该商品下已有产品,另一种情况是该商品下没有产品。有产品时需要进行产品的遍历,找到要操作的产品。找到产品,switch()选择,选择查询选项,产品的总量,进货日期,销售数量,产品单

首先从众多商品中选出你所要进行操作的商品类。从第一个商品进行遍历,直到找到该商品。如果没找到则返回相应未找到信息。如果找到,需要进行产品的遍历,找到要操作的产品,更改产品的属性。

8.密码模块

如果没有设置密码,则通过文件读入的方式进行密码设置。设置完成后如登录系统需输入密码,进行身份验证。输入的密码字符串与文件读出的密码通过strcmp()比较。利用getch的性质进行输入隐藏用*遮蔽。

调试分析

我遇到的问题:

1:混淆C++中的&引用与C语言中的*指针。 2:指针指向问题。

用户使用说明

3

这时你可以创建你的密码。登录界面:

测试结果 首先进行初始化操作1

4

操作2:

5

操作6:

6

操作3:

选择0反回的主界面;

操作6查看更改情况:

7

操作4:

8

操作5:

操作6查看删除情况:

9

操作0退出。

主程序

#include#include#include#include #include#define ok 1#define error 0#define overflow 0 #define SQMOUTLINK_INIT_SIZE 100 #define SQMOUTLINKINCREMENT 10

/***********************日期*******************/ typedef struct date {

int year; int month; int day; }date;

/***********************产品******************/ typedef struct productnode {

char product_name[40]; //产品名称 int product_quantity; //产品总量 int sales_quantity; //销售数量 double product_price; //产品单价 double product_income; //销售收益 int product_stock; //产品库存 date buy_time; //进货日期 date sales_time; //销售日期 struct productnode *next; }productnode,*plinklist;

/*********************货物种类**************/ typedef struct kindnode

10

{

productnode * first_product; //头指针

char pkindname[40]; //商品名称 int kind_number; //产品种类个数 }kindnode;

/*****************销售链表****************/ typedef struct {

kindnode* kindelem; int length; int listsize; }sqlist;

/*******************初始化L************/ int Init(sqlist &L) {int i;

L.kindelem=(kindnode*)malloc(SQMOUTLINK_INIT_SIZE*sizeof(kindnode)); if(!L.kindelem) exit(overflow); L.length=0;

L.listsize=SQMOUTLINK_INIT_SIZE; for(i=0;i

{(L.kindelem[i]).first_product=NULL; (L.kindelem[i]).kind_number=0; }

return ok; }

/********************创建商品和产品**************************/ int Create(sqlist &L) {plinklist p,q; int i,j,k,n;

printf(\请输入商品类数量:\\n\ do

{scanf(\ if(n<0)

{printf(\对不起,你输入有误!请重新选择(n>=0)\\n\ }while(n<0); for(i=0;i

{printf(\请输入第%d个商品类的名称:\\n\ scanf(\

printf(\请输入这类商品含有的产品种类数量:\\n\ do

{scanf(\ if(k<0) {printf(\对不起,你输入有误!请重新选择(k>=0)\\n\ }while(k<0);

L.kindelem[i].kind_number=k; if(k>=1)

{p=(plinklist)malloc(sizeof(productnode)); printf(\请输入第%d个产品名称:\\n\ scanf(\ printf(\请输入产品总量:\\n\ scanf(\ printf(\请输入产品进货日期(年-月-日):\\n\

scanf(\_time).day)); printf(\请输入产品单价:\\n\ scanf(\ printf(\请输入产品销售数量:\\n\ scanf(\

11

printf(\请输入产品销售时间(年-月-日):\\n\scanf(\ime).day)); p->product_income=(p->product_price)*(p->sales_quantity); p->product_stock=(p->product_quantity)-(p->sales_quantity); L.kindelem[i].first_product=p; p->next=NULL; }

for(j=1;j

{q=(plinklist)malloc(sizeof(productnode));

printf(\请输入第%d个产品名称:\\n\ scanf(\ printf(\请输入产品总量:\\n\

scanf(\

printf(\请输入产品进货日期(年-月-日):\\n\scanf(\e).day));

printf(\请输入产品单价:\\n\ scanf(\ printf(\请输入产品销售数量:\\n\ scanf(\

printf(\请输入产品销售时间(年-月-日):\\n\

scanf(\ime).day));

q->product_income=(q->product_price)*(q->sales_quantity); q->product_stock=(q->product_quantity)-(q->sales_quantity); q->next=p->next; p->next=q; p=q; }L.length++; }return ok; }

/***********************添加***********************************/ int Add(sqlist &L) {plinklist p,q; int k,j,n;

char pkindname[20];

printf(\请输入添加产品所属的商品类:\\n\ scanf(\

for(k=0;k

if(strcmp((L.kindelem[k]).pkindname,pkindname)==0) { printf(\请输入所要添加的产品类数量(个):\\n\ scanf(\ L.kindelem[k].kind_number=L.kindelem[k].kind_number+n; if(L.kindelem[k].first_product==NULL)//商品下没产品 {q=(plinklist)malloc(sizeof(productnode)); printf(\请输入需添加产品的名称:\\n\ scanf(\ printf(\请输入产品总量:\\n\

scanf(\ printf(\请输入进货日期(年-月-日):\\n\

scanf(\e).day));

printf(\请输入产品单价:\\n\

12

scanf(\ printf(\请输入销售数量:\\n\ scanf(\

printf(\请输入销售时间(年-月-日):\\n\

scanf(\ime).day)); q->product_income=(q->product_price)*(q->sales_quantity); q->product_stock=(q->product_quantity)-(q->sales_quantity); q->next=NULL;

L.kindelem[k].first_product=q; p=L.kindelem[k].first_product; for(j=1;j

scanf(\ printf(\请输入进货日期(年-月-日):\\n\

scanf(\e).day));

printf(\请输入产品单价:\\n\ scanf(\ printf(\请输入销售数量:\\n\ scanf(\

printf(\请输入销售时间(年-月-日):\\n\

scanf(\ime).day)); q->product_income=(q->product_price)*(q->sales_quantity); q->product_stock=(q->product_quantity)-(q->sales_quantity); /************************添加***********************************/

q->next=p->next;p->next=q;p=q; } } else//商品下有产品 {p=L.kindelem[k].first_product; for(j=0;j

scanf(\ printf(\请输入进货日期(年-月-日):\\n\

scanf(\e).day));

printf(\请输入产品单价:\\n\ scanf(\ printf(\请输入销售数量:\\n\

13

scanf(\

printf(\请输入销售时间(年-月-日):\\n\

scanf(\ime).day)); q->product_income=(q->product_price)*(q->sales_quantity); q->product_stock=(q->product_quantity)-(q->sales_quantity); /************************添加***********************************/

for(p=L.kindelem[k].first_product;(p->next)!=NULL;p=p->next); q->next=p->next; p->next=q; p=q; }//for }//else break; }//if }//for

if(k>=L.length)//没有该商品类 { strcpy(L.kindelem[k].pkindname,pkindname); L.length++; printf(\请输入所要添加的产品类数量(个):\\n\ scanf(\ L.kindelem[k].kind_number=n; for(j=0;j

printf(\请输入此产品类所含产品的产品名称:\\n\ scanf(\ printf(\请输入产品总量:\\n\ scanf(\ printf(\请输入产品的进货日期(年-月-日):\\n\

scanf(\e).day)); printf(\请输入产品的产品单价:\\n\ scanf(\ printf(\请输入产品的销售数量:\\n\ scanf(\ printf(\请输入产品的销售时间(年-月-日):\\n\

scanf(\ime).day)); p->product_income=(p->product_price)*(p->sales_quantity); p->product_stock=(p->product_quantity)-(p->sales_quantity); L.kindelem[k].first_product=p; p->next=NULL; }//for }//if

return ok; }

/*************************更改***************************/ void Alter(sqlist &L) {

int i,buy_number,order,sales_number,flag=0; double price;

14

char pkindname[10],product_name[10]; plinklist p;

printf(\请输入你所要修改的商品类:\\n\ scanf(\ for(i=0;inext)//产品匹配 { m++; if(strcmp(p->product_name,product_name)==0)//找到产品 { printf(\……………………………………………\\n\ printf(\修改选项:\\n\ printf(\进货日期\\n\ printf(\进货\\n\ printf(\销售\\n\ printf(\单价变动\\n\ printf(\返回\\n\

printf(\……………………………………………\\n\loop:

printf(\请进行选择:(0-7)\\n\ scanf(\ switch(order) { case 1: printf(\新的进货日期(年-月-日):\\n\

scanf(\e).day)); goto loop; case 2: printf(\进货(个):\\n\ scanf(\ p->product_quantity=p->product_quantity+buy_number; p->product_stock=(p->product_stock+buy_number); goto loop; case 3:

printf(\销售(个):\\t\ scanf(\ p->sales_quantity=p->sales_quantity+sales_number; p->product_stock=(p->product_stock)-sales_number; goto loop; case 4:

printf(\新单价(元):\\t\ scanf(\ p->product_price=price;

p->product_income=(p->sales_quantity)*(p->product_price); goto loop; case 0: system(\ flag=1; break;

15

default: printf(\对不起,你输入有误!\ goto loop; }//switch break;//找到就跳出 }//if }//for if(m>=L.kindelem[i].kind_number&&flag==0) { printf(\对不起,你要修改的产品没有找到!\\n\ } break;//找到就跳出 }//if }//for

if(i>=L.length) { printf(\对不起,你所要修改的商品没找到!\\n\ } }

/***************************查询************************************/ void View(sqlist &L) {

int i,k,order,flag=0;

char pkindname[20],product_name[20]; plinklist p;

printf(\请输入待查询产品所商品类:\\n\ scanf(\

for(i=0;i

{ if(strcmp((L.kindelem[i]).pkindname,pkindname)==0)//找到商品 { int m=0; printf(\输入待查询的产品:\\n\ scanf(\ for(p=L.kindelem[i].first_product;p!=NULL;p=p->next)//进行产品的匹配 { m++; if(strcmp(p->product_name,product_name)==0)//找到产品 {

printf(\查询选项:\\n\ printf(\进货日期\\n\ printf(\产品总量\\n\ printf(\销售数量\\n\ printf(\产品单价\\n\ printf(\产品库存\\n\ printf(\产品销售收益\\n\ printf(\全部信息\\n\ printf(\返回\\n\loop: printf(\请进行选择:(0-7)\\n\ scanf(\ switch(order) { case 1: printf(\进货日期\\t\

printf(\ printf(\………………………………………\\n\ goto loop; case 2:

16

printf(\产品总量\\t\ printf(\ printf(\………………………………………\\n\ goto loop; case 3: printf(\销售数量\\t\ printf(\ printf(\………………………………………\\n\ goto loop; case 4: printf(\产品单价\\t\ printf(\ printf(\………………………………………\\n\ goto loop; case 5: printf(\产品库存\\t\ printf(\ goto loop; case 6: printf(\销售收益\\t\ printf(\ printf(\………………………………………\\n\ goto loop; case 7: printf(\查询信息如下:\\n\ printf(\ printf(\产品的名称\\t\ printf(\ printf(\进货日期\\t\

printf(\ printf(\ printf(\产品总量\\t\

printf(\ printf(\销售数量\\t\ printf(\ printf(\ printf(\产品单价\\t\ printf(\ printf(\销售日期\\t\

printf(\y); printf(\ printf(\产品库存\\t\ printf(\ printf(\产品销售收益\\t\ printf(\

printf(\………………………………………………………………………\\n\ goto loop; case 0: system(\ flag=1; break; default: printf(\对不起,你输入有误!\ goto loop;

17

}//switch break; }//if }//for if(m>=L.kindelem[i].kind_number&&flag==0) { printf(\对不起,你所查询的产品不存在!\\n\ } break;//找到就跳出 }//if }//for

if(i>=L.length)//没找到商品

{ printf(\对不起,你所查询的商品不存在\\n\}

/**************************输出********************************/ void Display(sqlist &L) {

int i; plinklist p;

if(L.length<=0)//没商品

{ printf(\全部抛售!\\n…………………………………………\\n\ else//有商品

{ printf(\本店共有%d种商品\\t\ for(i=0;i

for(i=0;i

{ if(L.kindelem[i].first_product) { int number=1; printf(\商品%d:\\t\ printf(\ printf(\该商品下有%d个产品\\n\ for(p=L.kindelem[i].first_product;p!=NULL;p=p->next) { printf(\第%d个产品\\t\ printf(\ printf(\进货日期\\t\

printf(\ printf(\产品总量\\t\

printf(\ printf(\销售数量\\t\ printf(\ printf(\产品单价\\t\ printf(\ printf(\销售日期\\t\

printf(\y); printf(\产品库存\\t\ printf(\ printf(\销售收益\\t\ printf(\ printf(\……………………………………………………\\n\ number++;} } else { printf(\商品类:\\t\ printf(\ printf(\没有该商品了,谢谢你的光顾!\\n\ } }

18

/****************************删除********************************/ void Delete(sqlist &L)

{ plinklist p,q; char pkindname[20],product_name[20]; int i;

printf(\请输入待删除产品所属的商品类:\\n\ scanf(\ for(i=0;i

{ if(strcmp((L.kindelem[i]).pkindname,pkindname)==0) { printf(\输入待删除的产品:\\n\ scanf(\ L.kindelem[i].kind_number=L.kindelem[i].kind_number-1; if(L.kindelem[i].first_product==NULL)//该商品下没产品 { printf(\对不起,该商品下产品已全卖光了,谢谢惠顾!\\n\} else//该商品下有产品 { p=L.kindelem[i].first_product; while(strcmp(p->product_name,product_name)&&p->next!=NULL) { q=p; p=p->next; } if(!(strcmp(p->product_name,product_name)))//找到该产品 { if(p==L.kindelem[i].first_product) { L.kindelem[i].first_product=p->next; } Else {q->next=p->next;} printf(\该产品已被删除\\n……………………………………\\n\ } else { printf(\对不起,该产品不存在\\n………………………………\\n\ }//else break; }//if }//for

if(i>=L.length)//没找到商品

{ printf(\对不起,没找到该商品!\\n\ } }

/*********************定义密码*********************/ void password() {

FILE *fp,*fp1; char ch[20],c; fp1=fopen(\密码.txt\ if(!fp1)

{ printf(\对不起,没有找到密码文件!请及时检查!\ } else

{ fscanf(fp1,\ if(ch[0]<0) { printf(\ 销售管理系统\\n……………………………………………………\\n\ printf(\对不起,你还没有设置密码!\\n请创建密码:\\n\ fp=fopen(\密码.txt\ for(int i=0;(c=getch())!=13;i++) { if(c==8) { system(\ printf(\请输入密码:\\n\ for(int j=0;j

printf(\ ch[i]='\\0'; if(fp)

19

{ fprintf(fp,\ } fclose(fp); } }

fclose(fp1); }

/*************************核对密码*********************/ void check_password() { FILE* fp;

char password[20],m1[20],m2[20],c;//m1 新输入的密码 password 注册密码 system(\ printf(\进入管理系统之前请先登录\\n\ fp=fopen(\密码.txt\ if(fp)

{ fscanf(fp,\ } printf(\输入密码:\ for(int i=0;(c=getch())!=13;i++) { if(c==8) { system(\ printf(\进入管理系统之前请先登录\\n\ printf(\输入密码:\ for(int j=0;j

printf(\ m1[i]='\\0';

if(strcmp(m1,password))//从这里开始判断密码是否正确 { while(strcmp(m2,password))//密码错误 { system(\ printf(\对不起,你输入的密码有误,请重新输入:\\n\ for(int i=0;(c=getch())!=13;i++)//输入密码 { if(c==8) { system(\ printf(\对不起,你输入的密码有误,请重新输入:\\n\ for(int j=0;j

else if(!strcmp(m1,password))//密码正确进入系统 { system(\ printf(\ 欢迎进入销售管理系统\\n\

20

printf(\………………………………………………\\n\ } }

/************************菜单栏********************************/ void menu_operation() {

printf(\菜单\\n\

printf(\………………………………………………\\n\ printf(\ printf(\初始化添加\\n\\\n\ printf(\更改\\n\ printf(\查询\\n\ printf(\删除\\n\ printf(\}

printf(\库存退出\\n\\\n\void main(void) {

int order; password(); loop:

check_password(); menu_operation();

printf(\可以操作了\\n\ scanf(\ switch(order) {

case 1: system(\ Create(L); goto loop; case 2: system(\Add(L); goto loop; case 3: system(\ Alter(L); goto loop; case 4: system(\View(L); goto loop; case 5: system(\ Delete(L); goto loop; case 6: system(\printf(\本店产品库存管理表: Display(L); \\n\ case 0: goto loop; exit(0); }

}

21

sqlist L; Init(L);

22

本文来源:https://www.bwwdw.com/article/xqbo.html

Top