销售管理系统源代码

合集下载

销售管理系统源文件

销售管理系统源文件

#define N 30#define person-name name1#define object-name name2#include<stdio.h>#include<string.h>struct production/*定义产品信息结构体*/{int number;/*产品编号*/char name1[20];/*销售人名称*/char name2[20];/*产品名称*/int inprice;/*进价*/int outprice;/*售价*/int quantity;/*产品数量*/} production[N];/*结构体数组*/void welcome();/*主菜单*/void input();/*输入函数*/void input1(int i);/*辅助输入函数*/save();/*保存数据*/void output();/*读出已保存数据*/int insert();/*插入数据*/delete();/*删除数据*/void change();/*修改数据*/void display();/*显示数据*/void search_number();/*按号码搜索*/void search_name1();/*按姓名搜索*/void profit();/*计算收益*/void sort();/*利润排序*/void welcome()/*欢迎界面*/{int c;printf(" ^^^^^^^ ^^^^^^^\n");printf(" --------------------welcome--------------------\n");printf(" #* *#\n");printf(" #* sale of production management system *#\n");/*销售管理系统*/printf(" #* *#\n");printf(" ---------=====!what do you want to do!=====---------\n");printf("\n");printf(" **~~ 1 input ~~**\n");/*输入新数据*/printf(" **~~ 2 insert ~~**\n");/*插入一组新数据*/printf(" **~~ 3 delete ~~**\n");/*删除数据*/ printf(" **~~ 4 change ~~**\n");/*修改数据*/ printf(" **~~ 5 display ~~**\n");/*列出所有数据*/printf(" **~~ 6 search_number ~~**\n");/*按产品编号查找数据*/printf(" **~~ 7 search_name1 ~~**\n");/*按人员名称查找数据*/printf(" **~~ 8 profit ~~**\n");/*统计各产品的收益及总收益*/printf(" **~~ 9 sort ~~**\n");/*按产品销售额从小到大排序并输出排序后的结果*/printf(" **~~ 10 exit ~~**\n");/*退出*/printf("\n");printf("--------<~><~><~><~><~><~><~><~><~><~><~><~>--------\n");printf("\n");printf("please input you choice(A number between 1 and 10):\n");}void input1(int i)/*输入单组数据*/{printf("Please input the data:\n");/*输入数据*/printf("please input the number:\n");/*输入产品编号*/scanf("%d",&production[i].number);printf("please input the name1:\n");/*输入人员名称*/scanf("%s",&production[i].name1);printf("please input the name2:\n");/*输入产品名称*/scanf("%s",&production[i].name2);printf("please input the inprice:\n");/*输入产品进价*/scanf("%d",&production[i].inprice);printf("please input the outprice:\n");/*输入产品售价*/scanf("%d",&production[i].outprice);printf("please input the quantity:\n");/*输入产品数量*/scanf("%d",&production[i].quantity);save();}save()/*保存数据到文件*/{FILE *fp;int i,m=0;fp=fopen("production","w");/*打开要保存数据的文件*/for(i=0;i<N;i++)if(strlen(production[i].name1)!=0)/*计算已有的数据个数*/m++;for(i=0;i<m;i++)if(fwrite(&production[i],sizeof(struct production),1,fp)!=1)/*读入数据*/printf("file write error\n");fclose(fp);/*关闭文件*/}void input()/*连续输入多组数据*/{int i,m=0;char x;for(i=0;i<N;i++)if(strlen(production[i].name1)!=0)/*计算已有的数据个数*/m++;for(i=m;i<N-1;i++){input1(i);printf("Do you want to continue inputing new data(Y/N)\n");/*是否继续输入*/x=getch();if(x=='y'||x=='Y')/*继续输入*/continue;if(x=='n'||x=='N')/*中断输入*/break;save();}}void output()/*读取保存的数据*/{int i;FILE *fp;fp=fopen("production","r");/*打开文件*/for(i=0;i<N;i++){fread(&production[i],sizeof(struct production),1,fp);/*读取数据*/ }fclose(fp);/*关闭文件*/}int insert()/*插入一组新数据*/{int i,m=0;for(i=0;i<N;i++)if(strlen(production[i].name1)!=0)/*计算已有的数据个数*/m++;input1(m);/*输入此数据*/save();}delete()/*删除数据*/{char n[10];int i,j,k,b=0,m=0;output();for(i=0;i<N;i++)if(strlen(production[i].name1)!=0)/*计算已有的数据个数*/m++;printf("Enter the name of the production which you want to delete!\n");/*输入要删除的数据的名称*/scanf("%s",&n);printf("Display the original date you want todelete\n");for(i=0;i<m;i++)if(strcmp(production[i].name1,n)==0)/*校验名称*/{ printf("The number: %d\n",production[i].number);/*输出编号*/printf("Thename1: %s\n",production[i].name1);/*输出人员名称*/printf("The name2: %s\n",production[i].name2);/*输出产品名称*/printf("The inprice: %d\n",production[i].inprice);/*输出产品进价*/printf("The outprice: %d\n",production[i].outprice);/*输出产品售价*/printf("The quantity: %d\n",production[i].quantity);/*输出产品数量*/printf("\n");break;}printf("Do really want todelete it,press 1,if not,press 0\n");scanf("%d",&k);if(k==1){for(j=i;j<=m;j++)production[j]=production[j+1];/*删除数据*/b=1;}if(k==0)printf("Y ou may enter 0 to back to Welcome to look you choices!\n");if(b==0)printf("Not find you data!\n");/*没有要找的数据*/if(b==1)printf("Succeed!The data has been deleted!\n");/*成功删除数据*/save();display();}void change()/*修改数据*/{char n[10];char cname1;char cname2;int cinprice;/*定义局部变量*/int coutprice;int cquantity;int i,j,r,k,c,t,m=0;output();for(i=0;i<N;i++)if(strlen(production[i].name1)!=0)/*计算已有的数据个数*/m++;printf("Enter the name of the person whose date you want to change!\n");/*输入要修改的数据的人员名称*/scanf("%s",&n);printf("Display the original date you want to change\n");for(i=0;i<m;i++)if(strcmp(production[i].name1,n)==0)/*校验名称*/{ printf("The name1: %s\n",production[i].name1);/*输出人员名称*/printf("The name2: %s\n",production[i].name2);/*输出产品名称*/printf("The inprice: %d\n",production[i].inprice);/*输出产品进价*/printf("The outprice: %d\n",production[i].outprice);/*输出产品售价*/printf("The quantity: %d\n",production[i].quantity);/*输出产品数量*/printf("\n");break;}printf("Do really want to change it,press 1,if not,press 0\n");scanf("%d",&k);if(k==1){printf("\nwhich do you want to change\n 1 2 3. inprice4.outprice 5.quantity \n");printf("please choose your chioce:\n");scanf("%d",&c);if(c>5||c<1)printf("\nnot find please go on!\n"); /*超出选择范围*/}do{switch(c) /*选择要修改的项,并进行修改*/{case 1:printf("the person name is: ");scanf("%",&cname1);strcpy(production[i].name1,cname1);break;case 2:printf("the objection's name is: ");scanf("%s",&cname2);strcpy(production[i].name2,cname2);break;case 3:printf("the inprice is: ");scanf("%d",&cinprice);production[i].inprice=cinprice;break;case 4:printf("the outprice is: ");scanf("%d",&coutprice);production[i].outprice=coutprice;break;case 5:printf("the quantity is: ");scanf("%d",&cquantity);production[i].quantity=cquantity;break;}printf("\n");printf("\nDo you really want to change?\n Y please press 1 ; N,repeat to change press 2: \n");/*是否确认修改*/scanf("%d",&t);}while (t==2);save();printf("\nDisplay the changed date:");/*输出修改后的结果*/printf("The number:%d\n",production[i].number);/*输出编号*/printf("The name1: %s\n",production[i].name1);/*输出人员名称*/printf("The name2: %s\n",production[i].name2);/*输出产品名称*/printf("The inprice: %d\n",production[i].inprice);/*输出产品进价*/printf("The outprice: %d\n",production[i].outprice);/*输出产品售价*/printf("The quantity: %d\n",production[i].quantity);/*输出产品数量*/printf("\n");printf("\nGo on to change press 1,stop press 0\n");scanf("%d",&r);switch(r){case 1:change();break;case 0:break;default :break;}save();}void display()/*输出全部数据*/{int i,m=0;output();for(i=0;i<N;i++)if(strlen(production[i].name1)!=0)/*计算已有的数据个数*/m++;printf("Disply all the data below:\n");for(i=0;i<m;i++){printf("The number: %d\n",production[i].number);/*输出编号*/printf("The name1: %s\n",production[i].name1);/*输出人员名称*/printf("The name2: %s\n",production[i].name2);/*输出产品名称*/printf("The inprice: %d\n",production[i].inprice);/*输出产品进价*/printf("The outprice: %d\n",production[i].outprice);/*输出产品售价*/printf("The quantity: %d\n",production[i].quantity);/*输出产品数量*/printf("\n");}}void search_number()/*按产品编号查找*/{int number,i,flag=0;printf("Please enter number which you want to search:");/*输入要查找的产品的编号*/scanf("%d",&number);for(i=0;i<N;i++)if(production[i].number==number)/*校验产品编号*/{printf("the information of this number:\n");printf("Number: %d\nName: %s\nInprice: %d\nOutprice: %d\nQuantity: %d\n",production[i].number,production[i].name1,production[i].inprice,pro duction[i].outprice,production[i].quantity);/*输出要查找的数据的编号、品名、进价、售价、数量*/flag=1;}if(flag==0)printf("The number is not exist !\n");/*所输入的编号不存在*/}void search_name1()/*按人名查找*/{char name[20];int i,flag=0;printf("Please enter name1 which you want to search:");/*输入要查找的人的名字*/scanf("%s",&name);for(i=0;i<N;i++)if(strcmp(production[i].name1,name)==0)/*校验人名*/{printf("the information of this name:\n");printf("Number: %d\nName: %s\nInprice: %d\nOutprice: %d\nQuantity: %d\n",production[i].number,production[i].name1,production[i].inprice,pro duction[i].outprice,production[i].quantity);/*输出要查找的数据的编号、品名、进价、售价、数量*/flag=1;}if(flag==0)printf("The name is not exist !\n");/*所输入的品名不存在*/}void profit()/*统计各产品的收益及总收益的函数*/{int p[N],pr=0,i,m=0;for(i=0;i<N;i++)if(strlen(production[i].name1)!=0)/*计算已有的数据个数*/m++;for(i=0;i<m;i++){p[i]=(production[i].outprice-production[i].inprice)*production[i].quantity;/*计算产品i的收益*/pr=pr+p[i];printf("Name: %-7s\tNumber: %-7d\tprofit: %-10d\n",production[i].name1,production[i].nu mber,p[i]);/*输出产品i的收益*/}printf("Total Profit: %d\n",pr);/*输出总收益*/}void sort()/*按销售利润排序*/{int i,j,t,s,m=0,b[N],a[N];for(i=0;i<N;i++)if(strlen(production[i].name1)!=0)/*计算已有的数据个数*/m++;for(i=0;i<m;i++){b[i]=production[i].outprice*production[i].quantity;/*将产品销售利润放入数组b[i]*/a[i]=production[i].number;/*将编号放入数组a[i]*/}printf("Before sorted:\n");for(i=0;i<m;i++) /*输出排序前的结果,编号和销售利润*/printf("Number: %-5d\tProfit: %-10d\n",a[i],b[i]);for(i=1;i<m;i++)for(j=0;j<m-i;j++)if(b[j]>b[j+1]){t=b[j];b[j]=b[j+1];b[j+1]=t;/*冒泡法排序*/s=a[j];a[j]=a[j+1];a[j+1]=s;}printf("After sorted:\n"); /*输出排序后的结果,编号和销售利润*/for(i=0;i<m;i++)printf("Number: %-5d\tProfit: %-10d\n",a[i],b[i]);}main()/*主函数*/{int c;welcome();while(1){scanf("%d",&c);/*输入选择项*/switch(c){case 0:clrscr();welcome();break;/*清屏并显示欢迎界面*/case 1:input();printf("Y ou may enter 0 to back to Welcome to look you choices!\n");break;/*输入数据并保存,提示输入0以返回欢迎界面查看选项*/case 2:insert();printf("Y ou may enter 0 to back to Welcome to look you choices!\n");break;/*插入一组新数据并提示输入0以返回欢迎界面查看选项*/case 3:delete();printf("Y ou may enter 0 to back to Welcome to look you choices!\n");break;/*删除数据并提示输入0以返回欢迎界面查看选项*/case 4:change();printf("Y ou may enter 0 to back to Welcome to look you choices!\n");break;/*修改数据并提示输入0以返回欢迎界面查看选项*/case 5:display();printf("Y ou may enter 0 to back to Welcome to look you choices!\n");break;/*输出全部数据并提示输入0以返回欢迎界面查看选项*/case 6:search_number();printf("Y ou may enter 0 to back to Welcome to look you choices!\n");break;/*按编号查找并提示输入0以返回欢迎界面查看选项*/case 7:search_name1();printf("Y ou may enter 0 to back to Welcome to look you choices!\n");break;/*按人名查找并提示输入0以返回欢迎界面查看选项*/case 8:profit();printf("Y ou may enter 0 to back to Welcome to look you choices!\n");break;/*统计各产品的收益及总收益并提示输入0以返回欢迎界面查看选项*/ case 9:sort();printf("Y ou may enter 0 to back to Welcome to look you choices!\n");break;/*按销售利润从小到大排序并提示输入0以返回欢迎界面查看选项*/ case 10:return;/*返回初始界面*/}} }。

课设—销售系统代码

课设—销售系统代码
{
int i;
FILE *fp;
if((fp=fopen("record.txt","r"))==NULL)/*如果函数带回一个空指针值*/
{
printf("不能打开文件\n");/*不能打开文件*/
exit(1);
}
fscanf(fp,"%d",&n);
for(i=0;i<n;i++)
头文件
#include "stdio.h"/*输入输出函数*/
#include "stdlib.h"/*通用应用程序函数*/
#include "string.h"/*字符串函数*/
#include "ctype.h"/*字符操作函数*/
typedef struct /*定义结构体变量*/
printf("请输入要查询的销售员的代号(1-4): \n");
scanf("%d",&s); /*输入所要查看的售货员的代号*/
for(i=0;i<n;i++) /*对每种产品的销售额求和*/
if(t[i].number==s)
return n;
}
/*清单输入*/
int enter(RECODE t[])
{
int i,num;
system("cls"); /*清屏*/
printf("请输入要写的便条条数:\n");
scanf("%d",&num);/*输入所要写入的清单的条数*/

销售管理系统源码

销售管理系统源码

销售管理系统源码本文将介绍销售管理系统的源码实现。

销售管理系统是一款集成化的企业管理软件,功能涵盖了销售业务的各个环节,包括客户管理、订单管理、库存管理、进销存管理、报价管理等等。

本篇文章主要介绍系统源码的开发思路和实现方式。

一、开发技术选型1.后端语言:Java2.前端框架:Bootstrap、jQuery3.数据库:MySQL4.开发工具:IntelliJ IDEA、Navicat Premium5.版本控制工具:Git二、系统架构设计系统采用三层架构设计,将模块分为表示层、业务逻辑层和数据访问层。

其中,表示层负责用户的界面展示和数据的呈现,业务逻辑层负责对用户请求进行逻辑处理,数据访问层负责对数据库进行操作和数据管理。

三、系统功能模块1.登录模块用户可以通过输入用户名和密码进行登录系统。

在登录成功后,系统会对用户身份进行验证,根据用户的角色权限展示对应模块。

2.客户管理模块系统可以对客户信息进行管理,包括添加、修改、查询和删除客户信息。

用户可以根据客户类型、客户名称等多个条件查询客户信息,并对查询结果进行导出。

3.订单管理模块系统支持对订单进行管理,包括订单的添加、修改、查询和删除操作。

用户可以根据订单编号、客户名称、订单状态等条件查询订单信息,并支持导出查询结果。

4.库存管理模块系统支持对库存进行管理,包括库存商品的添加、修改和查询操作。

用户可以根据商品的类别、名称、库存数量等条件进行查询,并支持导出查询结果。

5.进销存模块系统支持对进销存的管理,包括入库管理、出库管理和库存盘点等操作。

用户可以对入库和出库的商品进行管理,包括商品类型、价格、数量等信息,并支持导出查询结果。

6.报价管理模块系统支持对客户的报价进行管理。

用户可以根据客户和商品进行报价管理,并可以对报价的有效期进行设置。

在报价管理界面,用户可以查询历史报价记录和导出查询结果。

四、系统要点技术实现1.登录模块在登录模块中,系统采用MD5加密算法对用户输入的密码进行加密和验证,提高了用户的账号安全性。

楼盘销售系统源代码

楼盘销售系统源代码
}
for(i=0;i<sum;i++)
if(fwrite(&loupan[i],sizeof(struct loupans_type),1,fp)!=1)
printf("写文件错误\n");
fclose(fp);
}
int print1(void) //*登录菜单打印
{
printf("\n");
printf("\n");
printf("\n\n\n\n");
while(flag)
{
system("cls");
printf("\n\n\n\n");
switch(m)
{
case 1:
printf("\t\t\t★!注册小提示: \n\n");
printf("\t\t\t用户名和密码不得超过15个字符!\n\n");
printf("\n\n");
char price[20]; /*价格(/㎡)*/
char chaoxiang[20]; /*面向*/
int area; /*面积*/
struct chaoxiang_type weizhi; /*单元信息*/
struct chaoxiang_type kind; /*类型*/
};
struct user_type//用户信息结构体
printf("\t\t\t★注册成功!\n\t\t\t");
getch();
system("cls");
break;
case 2://未注册直接登录

python实现简单的超市商品销售管理系统

python实现简单的超市商品销售管理系统

python实现简单的超市商品销售管理系统本⽂实例为⼤家分享了python超市商品销售管理系统的具体代码,供⼤家参考,具体内容如下class Goods(object):def __init__(self, id, name, price):self.id = id = nameself.price = pricedef __str__(self):info = "编号:%s\t商品名称:%s\t\t价格:%d" % (self.id, , self.price)return infoclass ShopManager(object):def __init__(self, path):# path:表⽰读取⽂件的路径 shopdic:表⽰存放内存的容器self.path = pathself.shopdic = self.readFileToDic()def readFileToDic(self):# 读取⽂件,写⼊到字典中f = open(self.path, 'r', encoding='utf-8')clist = f.readlines()f.close()index = 0shopdic = {}while index < len(clist):# 将每⼀⾏的字符串进⾏分割,存放到新的列表中ctlist = clist[index].replace('\n', "").split("|")# 将每⾏的内容存放到⼀个对象中good = Goods(ctlist[0], ctlist[1], int(ctlist[2]))# 将对向存放到集合中shopdic[good.id] = goodindex = index + 1return shopdicdef writeContentFile(self):# 将内存当中的信息写⼊到⽂件当中str1 = ''for key in self.shopdic.keys():good = self.shopdic[key]ele = good.id + "|" + + "|" + str(good.price) + "\n"str1 = str1 + elef = open(self.path, 'w', encoding='utf-8')f.write(str1)f.close()def addGoods(self):# 添加商品的⽅法id = input("请输⼊添加商品编号:>")if self.shopdic.get(id):print("商品编号已存在,请重新选择!")returnname = input("请输⼊添加商品名称:>")price = int(input("请输⼊添加商品价格:>"))good = Goods(id, name, price)self.shopdic[id] = goodprint("添加成功!")def deleteGoods(self):# 删除商品的⽅法id = input("请输⼊删除商品编号:>")if self.shopdic.get(id):del self.shopdic[id]print("删除成功!")else:print("商品编号不存在!")def showGoods(self):# 展⽰所有商品信息print("=" * 40)for key in self.shopdic.keys():good = self.shopdic[key]print(good)print("=" * 40)def adminWork(self):info = """==========欢迎进⼊好海哦购物商场==========输⼊功能编号,您可以选择以下功能:输⼊“1”:显⽰商品的信息输⼊“2”:添加商品的信息输⼊“3”:删除商品的信息输⼊“4”:退出系统功能=========================================="""print(info)while True:code = input("请输⼊功能编号:>")if code == "1":self.showGoods()elif code == "2":self.addGoods()elif code == "3":self.deleteGoods()elif code == "4":print("感谢您的使⽤,正在退出系统!!")self.writeContentFile()breakelse:print("输⼊编号有误,请重新输⼊!!")def userWork(self):print(" ==============欢迎进⼊好海哦购物商场==============") print("您可输⼊编号和购买数量选购商品,输⼊编号为n则结账")self.showGoods()total = 0while True:id = input("请输⼊购买商品编号:>")if id == "n":print("本次购买商品共消费%d元,感谢您的光临!" % (total))breakif self.shopdic.get(id):good = self.shopdic[id]num = int(input("请输⼊购买数量:>"))total = total + good.price * numelse:print("输⼊商品编号有误,请核对后重新输⼊!")def login(self):# 登录功能print("==========欢迎登录好海哦购物商场==========")uname = input("请输⼊⽤户名:>")password = input("请输⼊密码:>")if uname == "admin":if password == "123456":print("欢迎您,admin管理员")self.adminWork()else:print("管理员密码错误,登录失败!")else:print("欢迎你,%s⽤户" % (uname))# 执⾏⽤户的购买功能erWork()if __name__ == '__main__':shopManage = ShopManager("shop.txt")shopManage.login()更多学习资料请关注专题《》。

c语言销售管理系统

c语言销售管理系统

C语言销售管理系统—课设满分作品带报表和折线图显示#include<stdio.h>#include<windows.h>#include<wincon.h>#include<string.h>#include<stdlib.h>#include<conio.h>#include<math.h>#define NULL 0CONSOLE_SCREEN_BUFFER_INFO csbiInfo;extern WINBASEAPI HWND WINAPI GetConsoleWindow();void input();//实现手动输入销售信息void menu();//程序菜单主界面显示void daoru(); //函数声明void seek();//销售信息查询void save();//销售信息保存void del();//销售信息删除void def();//销售信息初始化void history(people);//实现销售历史查询void clear();//实现清屏void filepath();//判断是否为默认文件位置,及询问是否要求修改文件位置void baobiao();//打印报表void txt(zx);//折线图void sxt(g1, g2, g3, g4, g5);//扇形图int ghj = 1;int file_choose = 0;//文件导入初始状态 //全局变量char filename[30] = "sell.txt";//默认文件位置int price[5] = { 2, 2, 2, 2, 2 }; //默认商品价格struct good{int num;//产品编号int f_name[10];//产品名称float price;//产品价格商品属性int date;//销售日期int sum;//销售数量} good[5]; // 定义商品属性结构体,及五个商品struct seller{int num;//销售员编号char name[8];//销售员姓名char sex;//销售员性别struct good good[5]; //五种商品} sell[4]; //定义销售员结构体,及四个销售员struct day{struct seller sell[4];} d[31];struct year{struct day d[31];} m[12];int main(int argc, char* argv[]){int x = 0;x = MessageBox(NULL, "欢迎使用销售管理系统\n作者:xx\n班级:xxxx", "欢迎", MB_YESNO);if (x == 6) menu();return 0;}/************************************************************函数名:daoru()*描述:从文件导入数据*入口参数:无;*出口参数:无;******************************************************************/void daoru(){FILE *fp;int i, day, month;if ((fp = fopen(filename, "r")) == NULL){printf("文件不存在!");return;}for (month = 0; month<12; month++)for (day = 0; day<31; day++) //把文件读取到内存中for (i = 0; i<4; i++)fscanf(fp, "%6d%6d%6d%6d%6d\n", &m[month].d[day].sell[i].good[0].sum,&m[month].d[day].sell[i].good[1].sum, &m[month].d[day].sell[i].good[2].sum,&m[month].d[day].sell[i].good[3].sum, &m[month].d[day].sell[i].good[4].sum);fclose(fp);}/************************************************************函数名:inpit()*描述:数据的手动输入*入口参数:无;*出口参数:无;******************************************************************/void input(){int i = 0, day = 0, x = 0, month = 0;filepath();daoru();//文件导入及判断printf("请输入要查找的日期如1 1即一月一日:");scanf("%d%d", &month, &day);month--;day--;////保持实际时间与数组一致printf("请输入销售人员编号:\n1:xx 2:xx 3:xx 4:xx:");scanf("%d", &i);i--;printf("请输入具体要录入的商品种类1~5对应商品1-5:"); //用于查找所需的具体数据scanf("%d", &x);x--;printf("输入销售数量:");scanf("%d", &m[month].d[day].sell[i].good[x].sum);printf("完成!");save();}/************************************************************函数名:seek()*描述:查找*入口参数:无;*出口参数:无;******************************************************************/void seek(){char ch;int i = 0, j = 0, choose = 0, day = 0, t = 0, all = 0, month;filepath();daoru();printf("请输入要查找的日期如1 1即一月一日:");scanf("%d%d", &month, &day);month--;day--;//保持实际时间与数组一致printf("请输入销售人员编号:\n1:xx 2:xx 3:xx 4:xx:");scanf("%d", &i);i--;printf("请选择1,当天具体商品销售情况 2,当天该销售员销售情况:");scanf("%d", &choose);switch (choose){case 1:{printf("请输入具体要查找的商品种类1~5对应商品1-5\n");scanf("%d", &t);t--;printf("该销售员这天销售本商品的数量为:%d",m[month].d[day].sell[i].good[t].sum);}break;case 2:{printf(" 产品代号\n");printf("1.牛奶 2.西瓜 3.苹果 4.白菜 5.萝卜销售之和\n");for (j = 0; j<5; j++) all += m[month].d[day].sell[i].good[j].sum;printf("%-8d%-8d%-8d%-8d%-8d%-10d\n", m[month].d[day].sell[i].good[0].sum, m[month].d[day].sell[i].good[1].sum, m[month].d[day].sell[i].good[2].sum,m[month].d[day].sell[i].good[3].sum, m[month].d[day].sell[i].good[4].sum, all);}default:break;}}/************************************************************函数名:baobiao()*描述:打印报表*入口参数:无;*出口参数:无;******************************************************************/void baobiao(){char choose = 'y';int i, j, x = 0, a = 0, b = 0, mo = 0, th = 0, partsum = 0, month = 0, sj = 0;int day = 0, alldat = 0, partallsum[5] = { 0 };int mx[4][5] = { 0 }, mxsum = 0; //用于存放明细filepath();daoru(); //读取数据及判断printf("请选择1销售数量报表 2销售额报表:");scanf("%d", &i);if (i == 1){for (i = 0; i<5; i++)price[i] = 1;//利用价格为1时计算数量}else{sj = 1;x = MessageBox(NULL, "是否使用内置价格?", "提示", MB_YESNO);if (x == 7){printf("请依次输入五种商品价格:");scanf("%d%d%d%d%d", &price[0], &price[1], &price[2], &price[3], &price[4]);//上次输入作为内置价格}}printf("输入两个月份及日期:例如3 15 12 6(前者早上到后者晚上):");scanf("%d%d%d%d", &mo, &a, &th, &b);a--;b--;//保持实际时间与数组一致mo--;th--;clear();if (sj == 0){printf("时间段:%d月%d日--%d月%d日的销售数量汇总报表\n", mo + 1, a + 1, th + 1, 1 + b);}else{printf("时间段:%d月%d日--%d月%d日的销售额汇总报表\n", mo + 1, a + 1, th + 1, 1 + b);printf("五种商品对应价格为:%d %d %d %d %d\n", price[0], price[1], price[2], price[3], price[4]);}printf("\n 产品代号及名称\n");printf("姓名编号\t1.牛奶\t2.西瓜\t3.苹果\t4.白菜\t5.萝卜\t销售之和\n");//计算间隔整月if (th - mo>0){for (month = mo + 1; month <= (th - 1); month++){for (day = 0; day<31; day++){for (i = 0; i<4; i++){for (j = 0; j <= 4; j++){mx[i][j] = mx[i][j] + m[month].d[day].sell[i].good[j].sum*price[j];//累加计算所有他的所有销售情况}}for (i = 0; i<5; i++){for (j = 0, partsum = 0; j<4; j++){partsum += m[month].d[day].sell[j].good[i].sum*price[i];}//统计同种商品数目,一维数组当天4个销售员同种商品数目partallsum[i] += partsum;}}}//间隔整月前一段for (day = a; day<31; day++){for (i = 0; i<4; i++){for (j = 0; j <= 4; j++){mx[i][j] = mx[i][j] + m[mo].d[day].sell[i].good[j].sum*price[j]; //累加计算所有他的所有销售情况}}for (i = 0; i<5; i++){for (j = 0, partsum = 0; j<4; j++){partsum += m[mo].d[day].sell[j].good[i].sum*price[i];}partallsum[i] += partsum; //统计同种商品数目,一维数组当天4个销售员同种商品数目}}//间隔整月后一段for (day = 0; day <= b; day++){for (i = 0; i<4; i++){for (j = 0; j <= 4; j++){mx[i][j] = mx[i][j] + m[th].d[day].sell[i].good[j].sum*price[j]; //累加计算所有他的所有销售情况}}for (i = 0; i<5; i++){for (j = 0, partsum = 0; j<4; j++){partsum += m[th].d[day].sell[j].good[i].sum*price[i];}partallsum[i] += partsum; //统计同种商品数目,一维数组当天4个销售员同种商品数目}}}else if ((th - mo) == 0){for (day = a; day <= b; day++){for (i = 0; i<4; i++){for (j = 0; j <= 4; j++){mx[i][j] = mx[i][j] + m[mo].d[day].sell[i].good[j].sum*price[j]; //累加计算所有他的所有销售情况}}for (i = 0; i<5; i++){for (j = 0, partsum = 0; j<4; j++){partsum += m[mo].d[day].sell[j].good[i].sum*price[i];}partallsum[i] += partsum; //统计同种商品数目,一维数组当天4个销售员同种商品数目}}}//输出报表for (i = 0; i<4; i++){printf("%-6s ", sell[i].name);//销售员姓名for (j = 0; j<5; j++){printf("\t%d", mx[i][j]);mxsum += mx[i][j];//二维数组记录销售员}mxsum = 0;//用于下次循环的初始化}//输出表格同类商品总计printf("同类商品");for (i = 0; i<5; i++){printf("\t%d", partallsum[i]);//统计同种商品数目,一维数组alldat += partallsum[i];//合计所有的商品}printf("\t合计:%d", alldat);//所有商品合计x = MessageBox(NULL, "是否打印扇形形图?", "提示", MB_YESNO);if (x == 6){clear();printf("时间段:%d月%d日--%d月%d日", mo + 1, a + 1, th + 1, 1 + b);printf(" 销售扇形图");sxt(partallsum[0], partallsum[1], partallsum[2], partallsum[3], partallsum[4]);}}/************************************************************函数名:del()*描述:删除*入口参数:无;*出口参数:无;******************************************************************/void del(){int i = 0, day = 0, x = 0, month;int choose;filepath();daoru();printf("请输入要查找日期如1月1日输入1 1:");scanf("%d%d", &month, &day);month--;day--;//保持实际时间与数组一致printf("请输入销售人员编号:\n1:xx 2:xx 3:xx 4:xx:");scanf("%d", &i);i--;printf("请选择1.删除该销售员整天的销售信息 2.具体商品销售信息:");scanf("%d", &choose);switch (choose){case 1:{for (x = 0; x<5; x++) m[month].d[day].sell[i].good[x].sum = 0;}break;case 2:{printf("请输入具体要删除的商品种类1~5对应商品1-5 :");x--;m[month].d[day].sell[i].good[x].sum = 0;}break;default:break;}printf("已删除指定销售员信息");save();}/************************************************************函数名:def()*描述:销售数据初始化*入口参数:无;*出口参数:无;******************************************************************/void def(){FILE *fp;int i, day, month;filepath();fp = fopen(filename, "w");for (month = 0; month<12; month++)for (day = 0; day<31; day++){for (i = 0; i<4; i++) //保存信息到文件fprintf(fp, "%-6d%-6d%-6d%-6d%-6d\n", m[month].d[day].sell[i].good[0].sum = 0, m[month].d[day].sell[i].good[1].sum = 0, m[month].d[day].sell[i].good[2].sum = 0,m[month].d[day].sell[i].good[3].sum = 0, m[month].d[day].sell[i].good[4].sum = 0);fprintf(fp, "\n");//日期间隔}printf("初始化操作完成!");fclose(fp);}/************************************************************函数名:filepath()*描述:判断及修改文件位置*入口参数:无;*出口参数:无;******************************************************************/void filepath(){char choose;int x;clear();if (file_choose == 0){x = MessageBox(NULL, "现在为默认文件\n是否使用?", "提示", MB_YESNO);if (x == 7){printf("请输入文件绝对路径:");fflush(stdin);gets(filename);file_choose = 1;//其他位置文件标志}else{x = MessageBox(NULL, "不在提醒?", "提示", MB_YESNO);if (x == 6){file_choose = 2;//其他位置文件标志printf("设置成功\n");}}}}/************************************************************函数名:save()*描述:保存数据*入口参数:无;*出口参数:无;******************************************************************/void save(people){FILE *fp;int day, i, month;fp = fopen(filename, "w");for (month = 0; month<12; month++)for (day = 0; day<31; day++){for (i = 0; i<4; i++)fprintf(fp, "%-6d%-6d%-6d%-6d%-6d\n", m[month].d[day].sell[i].good[0].sum, m[month].d[day].sell[i].good[1].sum, m[month].d[day].sell[i].good[2].sum,m[month].d[day].sell[i].good[3].sum, m[month].d[day].sell[i].good[4].sum);fprintf(fp, "\n");}//写入文件fclose(fp);}/************************************************************函数名:clear()*描述:清屏*入口参数:无;*出口参数:无;******************************************************************/void clear(){int i;HWND hwnd;HANDLE hOut;HDC hdc, hdc1;HPEN ypn, p_pn, p1_pn, p2_pn, p3_pn, p4_pn, p5_pn;HPEN hPen, hOldPen;HBRUSH hBrush, hOldBrush, hbr;COORD pos = { 1, 4 };hwnd = GetConsoleWindow();hdc = GetDC(hwnd);hOut = GetStdHandle(STD_OUTPUT_HANDLE);hbr = CreateSolidBrush(RGB(0, 0, 0));SelectObject(hdc, hbr);Rectangle(hdc, 0, 65, 670, 470);SetConsoleCursorPosition(hOut, pos);for (i = 0; i<19; i++)printf(" \n ");SetConsoleCursorPosition(hOut, pos);Rectangle(hdc, 0, 65, 670, 470);ReleaseDC(hwnd, hdc);}/************************************************************函数名:history()*描述:历史销售查询*入口参数:people;*出口参数:无;******************************************************************/void history(people){int i, j, x = 0, a = 0, b = 0, mo = 0, th = 0, partsum = 0, month = 0;int day = 0, sumall = 0, more = 1;int mx[6] = { 0 }; //用于存放明细char choose;filepath();daoru();clear();printf("输入两个月份及日期:例如7 15 12 6(前者早上到后者晚上):");scanf("%d%d%d%d", &mo, &a, &th, &b);a--;b--;//保持实际时间与数组一致mo--;th--;printf("销售员:%s 时间段:%d月%d日--%d月%d日\n", sell[people].name, mo + 1, a + 1, th +1, 1 + b);printf("日期 \t1.牛奶\t2.西瓜\t3.苹果\t4.白菜\t5.萝卜\t销售之和\n");if (th - mo>0){//间隔整月前一段for (day = a; day<31; day++){if (more >= 16){x = MessageBox(NULL, "是否显示更多?", "提示", MB_YESNO);if (x == 6){clear();printf("日期 \t1.牛奶\t2.西瓜\t3.苹果\t4.白菜\t5.萝卜\t销售之和\n");}else goto end;}printf("%d月%d日 ", mo + 1, day + 1);for (j = 0; j <= 4; j++){sumall += m[mo].d[day].sell[people].good[j].sum;printf("\t%d", m[mo].d[day].sell[people].good[j].sum);mx[j] += m[mo].d[day].sell[people].good[j].sum;}printf("\t%d\n", sumall);more++;mx[5] += sumall;sumall = 0;}//计算间隔整月for (month = mo + 1; month <= (th - 1); month++){for (day = 0; day<31; day++){if (more >= 16){x = MessageBox(NULL, "是否显示更多?", "提示", MB_YESNO);if (x == 6){clear();printf("日期 \t1.牛奶\t2.西瓜\t3.苹果\t4.白菜\t5.萝卜\t销售之和\n");more = 0;}else goto end;}printf("\n%d月%d日 ", month + 1, day + 1);for (j = 0; j <= 4; j++){sumall += m[month].d[day].sell[people].good[j].sum;printf("\t%d", m[month].d[day].sell[people].good[j].sum);mx[j] += m[month].d[day].sell[people].good[j].sum;}printf("\t%d", sumall);more++;mx[5] += sumall;sumall = 0;}}//间隔整月后一段for (day = 0; day <= b; day++){{x = MessageBox(NULL, "是否显示更多?", "提示", MB_YESNO);if (x == 6){clear();printf("日期 \t1.牛奶\t2.西瓜\t3.苹果\t4.白菜\t5.萝卜\t销售之和\n");more = 0;}else goto end;}printf("\n%d月%d日 ", th + 1, day + 1);for (j = 0; j <= 4; j++){sumall += m[th].d[day].sell[people].good[j].sum;printf("\t%d", m[th].d[day].sell[people].good[j].sum);mx[j] += m[th].d[day].sell[people].good[j].sum;}printf("\t%d", sumall);more++;mx[5] += sumall;sumall = 0;}}//一个月内时间段else if ((th - mo) == 0){for (day = a; day <= b; day++){if (more >= 18){x = MessageBox(NULL, "是否显示更多?", "提示", MB_YESNO);if (x == 6){clear();printf("日期 \t1.牛奶\t2.西瓜\t3.苹果\t4.白菜\t5.萝卜\t销售之和\n");more = 0;}else goto end;}printf("%d月%d日 ", mo + 1, day + 1);for (j = 0; j <= 4; j++){sumall += m[mo].d[day].sell[people].good[j].sum;printf("\t%d", m[mo].d[day].sell[people].good[j].sum);mx[j] += m[mo].d[day].sell[people].good[j].sum;}printf("\t%d\n", sumall);more++;mx[5] += sumall;sumall = 0;}}end:printf("\n合计: ");for (j = 0; j <= 4; j++){printf("\t%d", mx[j]);}printf("\t总计:%d\n完成!", mx[5]);x = MessageBox(NULL, "是否打印条形图?", "提示", MB_YESNO);if (x == 6){clear();printf("销售员:%s 时间段:%d月%d日--%d月%d日\n", sell[people].name, mo + 1, a + 1, th + 1, 1 + b);printf("\n\n\n\n 历史销售统计条形图");for (j = 0; j <= 4; j++){txt(mx[j]);}}x = MessageBox(NULL, "是否打印扇形形图?", "提示", MB_YESNO);if (x == 6){clear();printf("销售员:%s 时间段:%d月%d日--%d月%d日", sell[people].name, mo + 1, a + 1, th + 1, 1 + b);printf(" \t销售扇形图");sxt(mx[0], mx[1], mx[2], mx[3], mx[4]);}}/************************************************************函数名:txt(zx)*描述:绘制折线图*入口参数:zx;*出口参数:无;******************************************************************/void txt(zx){static int i = 1;float sum;HWND hwnd;//窗口句柄HANDLE hOut;HDC hdc, hdc1;HPEN ypn, p_pn, p1_pn, p2_pn, p3_pn, p4_pn, p5_pn;HPEN hPen, hOldPen; //画笔HBRUSH hBrush, hOldBrush; //画刷hwnd = GetConsoleWindow();hdc = GetDC(hwnd);hOut = GetStdHandle(STD_OUTPUT_HANDLE);//得到标准的输出设备句柄(显示器等) ypn = CreatePen(PS_SOLID, 5, RGB(0, 200, 255));p_pn = CreatePen(PS_DASHDOTDOT, 1, RGB(255, 0, 0));p1_pn = CreatePen(PS_SOLID, 15, RGB(255, 0, 0));p2_pn = CreatePen(PS_SOLID, 15, RGB(0, 255, 0));p3_pn = CreatePen(PS_SOLID, 15, RGB(0, 0, 255));p4_pn = CreatePen(PS_SOLID, 15, RGB(255, 255, 0));p5_pn = CreatePen(PS_SOLID, 15, RGB(255, 0, 255));if (i == 1){hPen = CreatePen(PS_SOLID, 1, RGB(255, 0, 0)); //画笔hOldPen = (HPEN)SelectObject(hdc, hPen);hBrush = CreateHatchBrush(HS_CROSS, RGB(0, 100, 0)); //方格刷hOldBrush = (HBRUSH)SelectObject(hdc, hBrush);RoundRect(hdc, 20, 170, 530, 350, 5, 5); //画矩形}if (i == 1){SelectObject(hdc, p1_pn);}else if (i == 2){SelectObject(hdc, p2_pn);}else if (i == 3){SelectObject(hdc, p3_pn);}else if (i == 4){SelectObject(hdc, p4_pn);}else SelectObject(hdc, p5_pn);MoveToEx(hdc, i * 100, 344, NULL);LineTo(hdc, i * 100, 350 - zx * 30);SelectObject(hdc, p_pn);LineTo(hdc, 20, 350 - zx * 30);i++;SetTextColor(hdc, RGB(255, 0, 0));////设颜色TextOut(hdc, 1, 320, TEXT("1"), 1);//输出文本TextOut(hdc, 2, 290, TEXT("2"), 1);//输出文本TextOut(hdc, 2, 260, TEXT("3"), 1);//输出文本TextOut(hdc, 2, 230, TEXT("4"), 1);//输出文本TextOut(hdc, 2, 200, TEXT("5"), 1);//输出文本TextOut(hdc, 85, 360, TEXT("牛奶"), 4);//输出文本TextOut(hdc, 185, 360, TEXT("西瓜"), 4);//输出文本TextOut(hdc, 285, 360, TEXT("苹果"), 4);//输出文本TextOut(hdc, 385, 360, TEXT("白菜"), 4);//输出文本TextOut(hdc, 485, 360, TEXT("萝卜"), 4);//输出文本SelectObject(hdc, ypn);MoveToEx(hdc, 20, 170, NULL);LineTo(hdc, 20, 350);LineTo(hdc, 530, 350);ReleaseDC(hwnd, hdc);ReleaseDC(hwnd, hdc1);}/************************************************************函数名:sxt(zx)*描述:绘制扇形图*入口参数:g1,g2,g3,g4,g5;//五种商品数量*出口参数:无;******************************************************************/void sxt(g1, g2, g3, g4, g5){int sellsum = 0;//定义弧度统计总数量int time = 0, x = 0, y = 0, radian = 0;//int ex, ey, radius;//定义圆心半径int i, a, b, c, d, cx = 3;int smx1 = 450, smx2 = 500, smx3 = 510, smy = 175;//图解说明位置COORD pos = { 0, 5 };HWND hwnd;HANDLE hOut;HDC hdc;HPEN gpn, rpn, bpn, blue, yellow;hwnd = GetConsoleWindow();hdc = GetDC(hwnd);hOut = GetStdHandle(STD_OUTPUT_HANDLE);//得到标准的输出设备句柄(显示器等)rpn = CreatePen(PS_SOLID, cx, RGB(255, 0, 0));blue = CreatePen(PS_SOLID, cx, RGB(0, 0, 255));bpn = CreatePen(PS_SOLID, cx, RGB(255, 255, 255));gpn = CreatePen(PS_SOLID, cx, RGB(0, 255, 0));yellow = CreatePen(PS_SOLID, cx, RGB(255, 255, 0));sellsum = g1 + g2 + g3 + g4 + g5;a = g1 * 360 / sellsum;b = (g1 + g2) * 360 / sellsum;c = (g1 + g2 + g3) * 360 / sellsum;d = (g1 + g2 + g3 + g4) * 360 / sellsum;radius = 140;//半径ex = 240;ey = 240;time = 1;SelectObject(hdc, gpn);while (radian <= a){y = radius*sin(radian / 180.0*3.14);x = radius*cos(radian / 180.0*3.14);MoveToEx(hdc, ex, ey, NULL);LineTo(hdc, ex + x, ey + y);radian++;Sleep(time);}SelectObject(hdc, blue);while (radian <= b){y = radius*sin(radian / 180.0*3.14);x = radius*cos(radian / 180.0*3.14);MoveToEx(hdc, ex, ey + 1, NULL);LineTo(hdc, ex + x, ey + y);radian++;Sleep(time);}SelectObject(hdc, rpn);while (radian <= c){y = radius*sin(radian / 180.0*3.14);x = radius*cos(radian / 180.0*3.14);MoveToEx(hdc, ex, ey, NULL);LineTo(hdc, ex + x, ey + y);radian++;Sleep(time);}SelectObject(hdc, bpn);while (radian <= d){y = radius*sin(radian / 180.0*3.14);x = radius*cos(radian / 180.0*3.14);MoveToEx(hdc, ex, ey, NULL);LineTo(hdc, ex + x, ey + y);radian++;Sleep(time);}SelectObject(hdc, yellow);while (radian <= 359){y = radius*sin(radian / 180.0*3.14);x = radius*cos(radian / 180.0*3.14);MoveToEx(hdc, ex, ey - 2, NULL);LineTo(hdc, ex + x, ey + y);radian++;Sleep(time);}SelectObject(hdc, gpn);MoveToEx(hdc, smx1, smy, NULL);LineTo(hdc, smx2, smy);TextOut(hdc, smx3, smy, TEXT("牛奶"), 4);//输出文本SelectObject(hdc, blue);MoveToEx(hdc, smx1, smy += 40, NULL);LineTo(hdc, smx2, smy);TextOut(hdc, smx3, smy, TEXT("西瓜"), 4);//输出文本SelectObject(hdc, rpn);MoveToEx(hdc, smx1, smy += 40, NULL);LineTo(hdc, smx2, smy);TextOut(hdc, smx3, smy, TEXT("苹果"), 4);//输出文本SelectObject(hdc, bpn);MoveToEx(hdc, smx1, smy += 40, NULL);LineTo(hdc, smx2, smy);TextOut(hdc, smx3, smy, TEXT("白菜"), 4);//输出文本SelectObject(hdc, yellow);MoveToEx(hdc, smx1, smy += 40, NULL);LineTo(hdc, smx2, smy);TextOut(hdc, smx3, smy, TEXT("萝卜"), 4);//输出文本TextOut(hdc, smx3, smy, TEXT("萝卜"), 4);//输出文本SetConsoleCursorPosition(hOut, pos); // 设置光标位置printf("牛奶:%d %%%2.1f西瓜:%d %%%2.1f苹果:%d %%%2.1f白菜:%d %%%2.1f萝卜:%d %%%2.1f", g1, g1*100.0 / sellsum, g2, g2*100.0 / sellsum, g3, g3*100.0 / sellsum, g4, g4*100.0 / sellsum, g5, g5*100.0 / sellsum);ReleaseDC(hwnd, hdc);}/************************************************************函数名:menu()*描述:显示菜单*入口参数:无;*出口参数:无;******************************************************************/void menu(){int d1, d2, d, x, xy = 0, i, k;struct re{int top;int left;int right;int bottom;} rt[7];HWND hwnd;//窗口句柄HDC hdc, dc;//画图设备HBRUSH hbr;COORD pos3_1 = { 1, 4 }, pos2_1 = { 1, 4 }, pos2_2 = { 1, 5 }, pos2_3 = { 1, 6 }, pos2_4= { 1, 7 };INPUT_RECORD mouseRec;DWORD state = 0, res = 0;POINT pt;HPEN pn;HANDLE hOut, hIn;COLORREF c;//颜色c = RGB(0, 255, 0);hbr = CreateSolidBrush(c);hwnd = GetConsoleWindow();//得到控制台窗口句柄hdc = GetDC(hwnd); //得到画图设备句柄dc = GetDC(hwnd);//画刷hbr = CreateSolidBrush(RGB(255, 0, 0));SelectObject(dc, hbr);for (rt[1].left = 20, i = 2; i <= 6; i++) rt[i].left = rt[i - 1].left + 110;for (rt[1].right = 82, i = 2; i <= 6; i++) rt[i].right = rt[i - 1].right + 112; //绘制窗口for (i = 0; i <= 6; i++) rt[i].top = 40;for (i = 0; i <= 6; i++) rt[i].bottom = 60;strcpy(sell[0].name, "1 xx");sell[0].sex = 'M';strcpy(sell[1].name, "2xx");sell[1].sex = 'M';strcpy(sell[2].name, "3xx");sell[2].sex = 'M'; //初始化销售员姓名strcpy(sell[3].name, "4xx");sell[3].sex = 'M';hOut = GetStdHandle(STD_OUTPUT_HANDLE);//得到标准的输出设备句柄(显示器等)hIn = GetStdHandle(STD_INPUT_HANDLE);//得到标准的输入设备句柄(鼠标、键盘等)pn = CreatePen(PS_SOLID, 1, RGB(255, 0, 255));GetClientRect(hwnd, &rt);//得到控制台客户区的大小SelectObject(hdc, pn);//选画笔SetBkMode(hdc, TRANSPARENT);//设置背景保持方式MoveToEx(hdc, 1, 35, NULL);LineTo(hdc, 650, 35);LineTo(hdc, 650, 62);LineTo(hdc, 1, 62);LineTo(hdc, 1, 35);hbr = CreateSolidBrush(c);SelectObject(dc, hbr);for (i = 1; i <= 6; i++)Rectangle(dc, rt[i].left, rt[i].top, rt[i].right, rt[i].bottom);SetTextColor(hdc, RGB(255, 255, 0));////设颜色TextOut(hdc, 280, 10, TEXT("销售管理系统"), 12);//输出文本SetTextColor(hdc, RGB(255, 0, 0));////设颜色TextOut(hdc, 20, 40, TEXT("数据导入"), 8);//输出文本TextOut(hdc, 130, 40, TEXT(" 初始化"), 8);//输出文本TextOut(hdc, 240, 40, TEXT("数据查询"), 8);//输出文本TextOut(hdc, 350, 40, TEXT("删除修改"), 8);//输出文本TextOut(hdc, 460, 40, TEXT("打印报表"), 8);//输出文本TextOut(hdc, 570, 40, TEXT(" 退出"), 8);//输出文本TextOut(hdc, 8, 64, TEXT("若首次使用先点击初始化"), 22);//输出文本ShowWindow(hwnd, SW_SHOW);for (;;) // 循环{//读取输入的信息SetConsoleTextAttribute(hOut, 10);ReadConsoleInput(hIn, &mouseRec, 1, &res);Sleep(100);if (mouseRec.EventType == MOUSE_EVENT){//if (mouseRec.Event.MouseEvent.dwEventFlags == DOUBLE_CLICK) break; // 双击鼠标退出循环if (mouseRec.Event.MouseEvent.dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED){GetCursorPos(&pt);ScreenToClient(hwnd, &pt);if (pt.x>rt[1].left && pt.x<rt[1].right &&pt.y>rt[1].top &&pt.y<rt[1].bottom){clear();printf("输入数据方式:1手动输入,2文件导入其他:返回");scanf("%d", &x);if (x == 1) input();else if (x == 2){printf("请输入要导入的文件及其位置:");fflush(stdin);gets(filename);daoru();file_choose = 1;//指定文件导入成功的标志printf("导入成功");}continue;}else if (pt.x>rt[2].left && pt.x<rt[2].right &&pt.y>rt[2].top &&pt.y<rt[2].bottom){clear();def();continue;}else if (pt.x>rt[3].left && pt.x<rt[3].right &&pt.y>rt[3].top &&pt.y<rt[3].bottom){clear();printf("输入数据查询方式:1具体查询,2报表输出 ,3历史查询,其他:返回:");scanf("%d", &x);if (x == 1) seek();if (x == 2) baobiao();if (x == 3){printf("请输入销售人员编号:\n1:xx 2:xx 3:xx 4:xx:");scanf("%d", &i);i--;history(i);};continue;}else if (pt.x>rt[4].left && pt.x<rt[4].right &&pt.y>rt[4].top && pt.y<rt[4].bottom){clear();printf("数据修改:1.删除 2.修改,其他:返回:");scanf("%d", &x);if (x == 1) del();else if (x == 2) input();continue;}else if (pt.x>rt[5].left && pt.x<rt[5].right &&pt.y>rt[5].top && pt.y<rt[5].bottom){clear();baobiao();continue;}else if (pt.x>rt[6].left && pt.x<rt[6].right &&pt.y>rt[6].top && pt.y<rt[6].bottom){x = MessageBox(NULL, "确定退出?", "是否退出", MB_YESNO);if (x == 6)break;if (x = 7)continue;}};}}ReleaseDC(hwnd, hdc);}。

湖北汽车工业学院C语言课程设计——商品销售信息管理系统源代码

湖北汽车工业学院C语言课程设计——商品销售信息管理系统源代码

C语言课程设计商品销售信息管理系统#include<stdio.h>#include<stdlib.h>#include<string.h>#include<malloc.h>struct product //定义商品数据结构{int num; //商品编号char productname[20]; //商品名称float price; //商品售价char place[30]; //商品产地int storage; //商品库存struct product *next;}*head,*p1,*p2; //定义主结构体数组和备用结构体数组及指针struct time //定义时间结构体{int year;int month;int day;};struct sell //定义销售数据结构{int ID; //顾客代码char customername[20]; //顾客姓名int num; //商品编号int count; //销售数量char date[10]; //日期struct sell * next1;}*head1; //定义头指针head,缓冲指针p1,以及尾指针p2/*************************函数申明****************************/ void Enter_productmessage(); //导入商品信息void Creat(); //输入销售记录void Search_num(); //按编号查询销售历史void Search_customername(); //按顾客姓名查询购买历史void Printf_customername(); //显示顾客信息void Search_date(); //计算时间段内销售总额void Save_product(); //保存销售信息void Save_customername(); //保存顾客信息void Exit(); //退出程序/***************************主菜单******************************/ int select(){int c;printf("\t\t************欢迎使用商品销售管理程序**************\n");printf("\t\t T1123-5班胡军一分耕耘一分收获\n");printf("\n--------------------------------------------------------------------------------\n");printf("\n");printf("\t\t********************************************\n");printf("\t\t**********欢迎使用商品销售管理系统**********\n");printf("\t\t** **\n");printf("\t\t** 1:导入商品信息**\n");printf("\t\t** 2:输入销售记录**\n");printf("\t\t** 3:按编号查询销售历史**\n");printf("\t\t** 4: 按顾客姓名查询购买历史**\n");printf("\t\t** 5:计算时段内各销售总额**\n");printf("\t\t** 6:显示顾客信息**\n");printf("\t\t** 7:保存销售信息**\n");printf("\t\t** 8:保存顾客信息**\n");printf("\t\t** 0:退出**\n");printf("\t\t********************************************\n");printf("\n--------------------------------------------------------------------------------\n");printf("\t\t请输入您的选择(0~8的整数): ");scanf("%d",&c);return c;}/********************************主函数***************************/int main(){for(;;){switch(select()){case 1:system("cls");Enter_productmessage();break;case 2:system("cls");Creat();break;case 3:system("cls");Search_num();break;case 4:system("cls");Search_customername();break;case 5:system("cls");Search_date();break;case 6:system("cls");Printf_customername();break;case 7:system("cls");Save_product();break;case 8:system("cls");Save_customername();break;case 0:system("cls");Exit();break;default :{ system("cls");printf("\n\n\n\n\n\n");printf("\t\t*******************************************************\n");printf("\t\t** 输入错误!!!请重新输入您的选择(0~8的整数)**\n");printf("\t\t** 请按Enter键返回!!! **\n");printf("\t\t*******************************************************\n");getchar();getchar();system("cls");}}}return 0;}/****************************************************************/int judgech(char *a) //判断是否为汉字{int i,flag;for(i=0;a[i]!='\0';i++)if(a[i]>=0){flag=0;break;}elseflag=1;return flag;}int judgedate(char date[10]) //判断日期是否合法{int i,year,month,day,s1=0; //日期格式输入正确则s1=1,否则s1=0for(i=0;i<10;i++)if(date[i]=='\0'){s1=0;break;}if(date[4]=='-'&&date[7]=='-'){if(strlen(date)==10){year=1000*(date[0]-48)+100*(date[1]-48)+10*(date[2]-48)+(date[3]-48);//年月日month=10*(date[5]-48)+(date[6]-48);day=10*(date[8]-48)+(date[9]-48);}}if(i==10){if(year%4==0&&month==2&&day>0&&day<=29) s1=1;else if(year%4!=0&&month==2&&day>0&&day<=28) s1=1;elseif((month==1||month==3||month==5||month==7||month==8||month==10||month==12)&&d ay>0&&day<=31) s1=1;else if((month==4||month==6||month==9||month==11)&&day>0&&day<=30) s1=1;}return s1;}void file() //读入文件操作{int i=0,m=0,k=1,j=1,c=1,o=1,v=1;FILE *fp;char filename[30];printf("请输入读入文件路径:");rewind(stdin);gets(filename);rewind(stdin);p1=p2=head=(struct product*)malloc(sizeof(struct product));if((fp=fopen(filename,"r+"))==NULL){printf("\t\t********************************************\n");printf("\t\t** 导入信息文件错误!请检查文件路径!!! **\n");printf("\t\t********************************************\n");getchar();system("cls");Enter_productmessage();}printf("********************************商品信息***********************************\n");printf("编号(1-10的整数) 名称(汉字) 价格(数字) 产地(汉字) 库存数量\n");printf("************************************************************************* **\n");while(!feof(fp)){p1=(struct product*)malloc(sizeof(struct product));p2->next=p1;p1->next=NULL;p2=p1;fscanf(fp,"%d%s%f%s%d",&p2->num,p2->productname,&p2->price,p2->place,&p2->storage );while(k==1){if(p2->num>10||p2->num<=0){printf("\t*******************************************************\n");printf("\t\t第%d个商品编码!请重新输入(1-10):",i+1);rewind(stdin);scanf("%d",&p2->num);k=1;}else k=0;}while(j==1){if(judgech(p2->productname)==0){printf("\t\t第%d个商品名称错误!请重新输入(汉字):",i+1);rewind(stdin);scanf("%s",p2->productname);j=1;}else j=0;}while(o==1){if(p2->price<=0){printf("\t\t第%d个商品价格错误!请重新输入价格(>0):",i+1);rewind(stdin);scanf("%f",&p2->price);o=1;}else o=0;}while(c==1){if(judgech(p2->place)==0){printf("\t\t第%d个商品产地格式错误!请重新输入(汉字):",i+1);rewind(stdin);scanf("%s",p2->place);c=0;}else c=0;}while(v==1){if(p2->storage!=1000){printf("\t*******************************************************\n");printf("\t\t第%d个商品数量错误!请输入1000:",i+1);rewind(stdin);scanf("%d",&p2->storage);v=1;}else v=0;}printf("\t%-12d%-15s %-15.2f%-15s%-12d\n",p2->num,p2->productname,p2->price,p2->pla ce,p2->storage);}fclose(fp);}void comp(){FILE *fp;int i=0,n,k=1,m=1,c=1,l=1,d=1;char filename[20],a;printf("\t请输入商品信息保存路径:");rewind(stdin);gets(filename);p1=p2=head=(struct product*)malloc(sizeof(struct product));if((fp=fopen(filename,"a+"))==NULL){printf("\t\t********************************************\n");printf("\t\t** 不能打开文件!请检查文件路径!!! **\n");printf("\t\t********************************************\n");getchar();system("cls");Enter_productmessage();}printf("\n\n\n");printf("\t\t********************************************\n");printf("\t\t** 若输入路径与从文件导入商品信息路径相同!**\n");printf("\t\t** 并已导入十个商品信息,请不要再导入!!! **\n");printf("\t\t** 注意商品编号不要和已导入的编码重复!!! **\n");printf("\t\t********************************************\n");printf("\n\n\n");getchar();system("cls");printf("\t已从文件导入的个数和要输入的个数和不超过十!!!\n\n");printf("\t请输入要导入的销售记录个数:");scanf("%d",&n);if(n>0){do{p1=(struct product*)malloc(sizeof(struct product));p2->next=p1;p1->next=NULL;p2=p1;printf("***********************************商品信息*****************************\n");printf(" 编号(整数) 名称(汉字) 价格(数字) 产地(汉字) 库存数量\n");scanf("%d%s%f%s%d",&p2->num,p2->productname,&p2->price,p2->place,&p2->storage);while(k==1){if(p2->num>10||p2->num<=0){printf("\t*******************************************************\n");printf("\t\t 商品编码!请重新输入(1-10):");rewind(stdin);scanf("%d",&p2->num);k=1;}else k=0;}while(m==1){if(judgech(p2->productname)==0){printf("\t\t商品名称错误!请重新输入(汉字):");rewind(stdin);scanf("%s",p2->productname);m=1;}else m=0;}while(l==1){if(p2->price<=0){printf("\t\t商品价格错误!请重新输入价格(>0):");rewind(stdin);scanf("%f",&p2->price);l=1;}else l=0;}while(c==1){if(judgech(p2->place)==0){printf("\t\t商品产地格式错误!请重新输入(汉字):");rewind(stdin);scanf("%s",p2->place);c=1;}else c=0;}while(d==1){if(p2->storage!=1000){printf("\t*******************************************************\n");printf("\t\t 商品数量错误!请输入1000:");rewind(stdin);scanf("%d",&p2->storage);d=1;}else d=0;}p2=head->next;fprintf(fp,"\n%-6d%-6s%-6.2f%-6s%-6d\n",p2->num,p2->productname,p2->price,p2->place, p2->storage);printf("\n%-6d%-6s%-6.2f%-6s%-6d\n",p2->num,p2->productname,p2->price,p2->place,p2->storage);printf("\t\t是否继续输入信息(Y/N)?\n");getchar();a=getchar();}while(a=='Y'||a=='y');}fclose(fp); //关闭文件夹if(n==0){printf("\t\t不从键盘输入入信息!!!");getchar();getchar();system("cls");}fclose(fp); //关闭文件夹}void Enter_productmessage() //导入销售信息{int a;printf("\t************************************************************\n");printf("\t** 请输入10种产品的信息--编号、名称、价格、产地、数量: **\n");printf("\t** 1:通过文件导入(推荐)! **\n");printf("\t** 2: 通过键盘输入! **\n");printf("\t************************************************************\n");printf("\t 请输入您的选择(1或2): ");scanf("%d",&a);getchar();system("cls");if(a!=1&&a!=2){printf("\t\t输入错误!!!请重新输入您的选择(1或2):");scanf("%d",&a);}switch(a){case 1:system("cls"); file();break;case 2:system("cls"); comp();break;}printf("************************************************************************* \n");printf("\t*******************************************************\n");printf("\t** 数据类信息操作成功!请按Enter键继续!!! **\n");printf("\t*******************************************************\n");getchar();getchar();system("cls");}void Creat() //输入销售信息函数{int i=0,k=1,code;char a;struct sell *p3,*p4;srand(0);code=1+rand()%90;p3=p4=head1=(struct sell *)malloc(sizeof(struct sell));p3=head1;printf("\t\t请输入销售记录:\n"); //提示输入记录printf("--------------------------------------------------------------------------------\n");do{p3=(struct sell *)malloc(sizeof(struct sell));p4->next1=p3;p3->next1=NULL;p4=p3;printf(" 顾客姓名(汉字) 商品编号(1-10的整数) 销售数量(数字) 销售日期(YYYY-MM-DD)\n");printf("--------------------------------------------------------------------------------\n");scanf("%s%d%d%s",p4->customername,&p4->num,&p4->count,p4->date); //输入记录do{if(judgech(p4->customername)==0){printf("\t*******************************************************\n");printf("\t\t顾客名字输入错!请重新输入顾客名字(汉字):");scanf("%s",p4->customername);rewind(stdin);k=1;}elsek=0;}while(k==1);do{if(p4->num>10||p4->num<=0){printf("\t*******************************************************\n");printf("\t\t 商品编码!请重新输入(1-10):");scanf("%d",&p4->num);rewind(stdin);k=1;}else k=0;}while(k==1);do{if(p4->count>1000||p4->count<0){printf("\t*******************************************************\n");printf("\t 销售商品数量错误!请输入(0-1000):");scanf("%d",&p4->count);rewind(stdin);}else k=0;}while(k==1);do{if(judgedate(p4->date)!=1){printf("\t*******************************************************\n");printf("\t 输入日期不合法!请重新输入(YYYY-MM-DD):");scanf("%s",p4->date);rewind(stdin);k=1;}else k=0;}while(k==1);p4->ID=code+i;i++;printf("\n\n");printf("是否继续输入销售记录(Y/N)?\n");getchar();a=getchar();}while(a=='Y'||a=='y');system("cls");printf("\n\n\n\n");printf("\t*******************************************************\n");printf("\t** 销售信息输入成功!按Enter键继续!!! **\n");printf("\t*******************************************************\n");getchar();getchar();system("cls");return;}void Search_num() //根据产品编号查询产品的销售历史{int num,flag=1,i=0;struct sell *p3;struct product *p;printf("\t\t请输入商品编号(1-10的整数):");scanf("%d",&num);getchar();system("cls");printf(" 顾客姓名商品编号销售数量销售总额销售日期\n");printf(" ------------------------------------------------------------------------------\n");p=head;while(p3!=NULL){if(p3->num==num){p=head;while(p!=NULL){if(p->num==num)break;elsep=p->next;}printf(" %-15s%-13d%-13d%-13.2f%-10s\n",p3->customername,p3->num,p3->count,p->pric e*p3->count,p3->date);flag=0;}p3=p3->next1;}if(flag==1){printf("\t\t*******************************************************\n");printf("\t\t** 无此编码商品销售记录!请查实后再输入!!! **\n");printf("\t\t** 请按Enter键返回!!! **\n");printf("\t\t*******************************************************\n");getchar();system("cls");return;}printf("-------------------------------------------------------------------------------\n");printf("\t\t********************************************\n");printf("\t\t** 销售记录查询完毕!请按Enter键返回!!! **\n");printf("\t\t********************************************\n");getchar();getchar();system("cls");return;}void Search_customername() //根据顾客姓名查询购买历史{int k=1,m=0;float a=0;char name[20],b;struct product *p;struct sell *p3;p3=head1;p=head;printf("\t\t********************************************\n");printf("\t\t\t请输入顾客姓名(汉字):");scanf("%s",name);getchar();system("cls");if(head1->next1==NULL){printf("\t\t*******************************************************\n");printf("\t\t** 销售记录为空!请按Enter键返回!!! **\n");printf("\t\t*******************************************************\n");getchar();getchar();system("cls");return ;}do{if(judgech(name)==0){printf("\t*******************************************************\n");printf("\t\t顾客名字输入错!请重新输入顾客名字(汉字):");rewind(stdin);scanf("%s",name);rewind(stdin);k=1;}elsek=0;}while(k==1);if(judgech(name)==1){printf("顾客姓名(汉字) 顾客代码商品编号购买数量购买总额购买日期(YYYY-MM-DD)\n");printf("-----------------------------------------------------------------------------\n");while(m!=1){if(strcmp(name,p3->customername)==0){m=1;while(p!=NULL){if(p3->num==p->num){printf("%5s%15d%10d%10d%15.2f%14s\n",p3->customername,p3->ID,p3->num,p3->count, p3->count*p->price,p3->date);break;}else p=p->next;}}else p3=p3->next1;if(p3==NULL)break;}}if(m==1){printf("------------------------------------------------------------------------------\n");printf("\t*******************************************************\n");printf("\t** 查询完毕!请按Enter键返回!!! **\n");printf("\t*******************************************************\n");getchar();system("cls");return;}if(m==0){printf("\t\t*******************************************************\n");printf("\t\t** 不存在此顾客!!!请按Enter键继续!!! **\n");printf("\t\t*******************************************************\n");printf("\t\t是否记录该顾客销售记录!!\n");printf("\t\t请输入选择(Y/N):");rewind(stdin);b=getchar();if(b=='n'||b=='N'){getchar();system("cls");return;}if(b=='y'||b=='Y')getchar();Creat();}}void Search_date() //计算时间段内各个商品的销售总额{int n=0;float temp=0;char a[10],b[10],c[10];struct sell *p3;struct product *p;p3=head1->next1;p=head->next;getchar();system("cls");if(head1->next1==NULL){printf("\t\t*******************************************************\n");printf("\t\t** 无销售记录!请按Enter键返回!!! **\n");printf("\t\t*******************************************************\n");getchar();system("cls");return ;}printf("\t\t请输入开始日期(YYYY-MM-DD):");gets(a);do{if(judgedate(a)!=1){printf("\t\t********************************************\n");printf("\t\t 输入日期不合法!请重新输入(YYYY-MM-DD):");gets(a);system("cls");n=1;}elsen=0;}while(n==1);printf("\t\t********************************************\n");printf("\t\t 请输入结束日期(YYYY-MM-DD):");gets(b);system("cls");do{if(judgedate(b)!=1){printf("\t\t********************************************\n");printf("\t\t 输入日期不合法,请重新输入(YYYY-MM-DD):");gets(b);system("cls");n=1;}elsen=0;}while(n==1);do{if((strcmp(a,p3->date)<=0)&&(strcmp(b,p3->date)>=0)){n=1;break;}else p3=p3->next1;if(p3==NULL)break;}while(n!=1);while(1){p3=head1->next1;if((strcmp(a,p3->date)>0&&strcmp(b,p3->date)>0)||(strcmp(a,p3->date)<0&&strcmp(b,p3-> date)<0)||(strcmp(a,b)>0)){printf("时间断不包括销售日期!!!");Search_date();getchar();return;}else p3=p3->next1;if(p3==NULL)break;}if(n==1){printf("\t\t销售记录如下:\n");printf("\t\t时间: %s至%s\n",a,b);printf("\t商品编号(1-10的整数) 商品名(汉字) 销售总额\n");printf("\n--------------------------------------------------------------------------------\n");}while(p!=NULL){p3=head1->next1;if(p3->num==p->num){temp+=(int)p3->count*(float)p->price;strcpy(c,p->productname);printf("\t\t%-20d%-20s%.2f\n",p3->num,c,temp);}p=p->next;}printf("\n--------------------------------------------------------------------------------\n");printf("\t\t**********************************************\n");printf("\t\t** 查询完毕!请按Enter键继续!! **\n");printf("\t\t**********************************************\n");getchar();getchar();system("cls");return;}void Printf_customername() //显示所有顾客的姓名{int n=1;struct sell *p3;p3=head1->next1;if(p3!=NULL){printf("\t\t顾客姓名如下:\n"); //用来显示所有顾客的姓名printf("\t\t*******************************************************\n");printf("\t\t\t\t\t姓名:\n");do{printf("\t\t\t\t\t %s\n",p3->customername);p3=p3->next1;}while(p3!=NULL);printf("\t\t*******************************************************\n");printf("\t\t*******************************************************\n");printf("\t\t**顾客姓名查询完毕!请按Enter键继续!!!**\n");printf("\t\t*******************************************************\n");getchar();getchar();system("cls");return;}else{printf("\t\t*******************************************************\n");printf("\t\t**顾客链表为空!!!没有顾客销售记录!!!**\n");printf("\t\t*******************************************************\n");getchar();system("cls");return;}}void Save_product() //保存销售信息记录{FILE *fp;//定义文件指针char filename[30];struct product *p;struct sell *p3;p3=head1->next1;p=head->next;printf("请输入保存路径:\n");rewind(stdin);gets(filename);rewind(stdin);if((fp=fopen(filename,"a+"))==NULL)//打开文件{printf("\t\t*******************************************************\n");printf("\t\t** 保存文件失败!按Enter键返回!!! **\n");printf("\t\t*******************************************************\n");getchar();getchar();system("cls");Save_product();}printf("\n--------------------------------------------------------------------------------\n");printf("\t商品编码商品品名字销售量剩余库存销售日期\n");while(p3!=NULL){if(p3->num==p->num){fprintf(fp,"%-5d%-20s%-8d%-8d%s\n",p3->num,p->productname,p3->count,p->storage-p3-> count,p3->date);printf("\t %-10d%-15s%-10d%-5d%15s\n",p3->num,p->productname,p3->count,p->storage-p3->c ount,p3->date);p3=p3->next1;}elsep=p->next;}printf("\n--------------------------------------------------------------------------------\n");printf("\t*******************************************************\n");printf("\t** 销售信息保存完毕!按Enter键返回!!! **\n");printf("\t*******************************************************\n");getchar();fclose(fp);getchar();system("cls");return;}void Save_customername(){FILE *fp;//定义文件指针char filename[30];struct sell *p3;p3=head1->next1;printf("请输入保存路径:\n");rewind(stdin);gets(filename);rewind(stdin);if((fp=fopen(filename,"a+"))==NULL)//打开文件{printf("\t\t*************************************************\n");printf("\t\t** 顾客信息保存失败!按Enter键返回!!! **\n");printf("\t\t*************************************************\n");getchar();getchar();system("cls");Save_customername();}else{while(p3!=NULL){fprintf(fp," %d %s \n",p3->ID,p3->customername);printf("\t\t*************************************************\n");printf("\t\t\t顾客编码:%d\t\t顾客名字:%s\n",p3->ID,p3->customername);printf("\t\t*************************************************\n");p3=p3->next1;}printf("\t\t*************************************************\n");printf("\t\t** 数据库中顾客信息保存完毕,按Enter键返回!!! **\n");printf("\t\t*************************************************\n");getchar();fclose(fp);getchar();system("cls");return;}}void Exit(){ printf("\n\n\n\n\n\n");printf("\t\t**********************************************\n");printf("\t\t**** 谢谢使用!!!请按Enter键退出!!! ****\n");printf("\t\t**********************************************\n");printf("\n\n");getchar();exit(0);}。

销售管理系统相关代码

销售管理系统相关代码

--销售管理系统相关代码班级:计科学061 学号:061004103 姓名:方爽--创建数据库IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'销售管理系统')DROP DATABASE [销售管理系统]GOCREATE DATABASE [销售管理系统] ON (NAME = N'销售管理系统_Data', FILENAME = N'F:\销售管理系统_SQL\销售管理系统_Data.MDF' ,SIZE = 2, FILEGROWTH = 10%)LOG ON (NAME = N'销售管理系统_Log', FILENAME = N'F:\销售管理系统_SQL\销售管理系统_Log.LDF' ,SIZE = 1, FILEGROWTH = 10%)COLLATE Chinese_PRC_CI_ASGOexec sp_dboption N'销售管理系统', N'autoclose', N'false'GOexec sp_dboption N'销售管理系统', N'bulkcopy', N'false'GOexec sp_dboption N'销售管理系统', N'trunc. log', N'true'GOexec sp_dboption N'销售管理系统', N'torn page detection', N'false' GOexec sp_dboption N'销售管理系统', N'read only', N'false'GOexec sp_dboption N'销售管理系统', N'dbo use', N'false'GOexec sp_dboption N'销售管理系统', N'single', N'false'GOexec sp_dboption N'销售管理系统', N'autoshrink', N'true'GOexec sp_dboption N'销售管理系统', N'ANSI null default', N'false'GOexec sp_dboption N'销售管理系统', N'recursive triggers', N'false'GOexec sp_dboption N'销售管理系统', N'ANSI nulls', N'false'GOexec sp_dboption N'销售管理系统', N'concat null yields null', N'false' GOexec sp_dboption N'销售管理系统', N'cursor close on commit', N'false' GOexec sp_dboption N'销售管理系统', N'default to local cursor', N'false' GOexec sp_dboption N'销售管理系统', N'quoted identifier', N'false'GOexec sp_dboption N'销售管理系统', N'ANSI warnings', N'false'GOexec sp_dboption N'销售管理系统', N'auto create statistics', N'true' GOexec sp_dboption N'销售管理系统', N'auto update statistics', N'true'if( (xxmicrosoftversion / power(2, 24) = 8) and (xxmicrosoftversion & 0xffff >= 724) )exec sp_dboption N'销售管理系统', N'db chaining', N'false'GOuse [销售管理系统]GO--检查当前数据库是否已存在相应表if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_客户订货表_商品基础信息表]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)ALTER TABLE [dbo].[客户订货表] DROP CONSTRAINT FK_客户订货表_商品基础信息表GOif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_库存表_商品基础信息表]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)ALTER TABLE [dbo].[库存表] DROP CONSTRAINT FK_库存表_商品基础信息表GOif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_销售表_商品基础信息表]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)ALTER TABLE [dbo].[销售表] DROP CONSTRAINT FK_销售表_商品基础信息表GOif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_销售退货表_商品基础信息表]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)ALTER TABLE [dbo].[销售退货表] DROP CONSTRAINT FK_销售退货表_商品基础信息表GOif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_客户订货表_客户基础信息表]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)ALTER TABLE [dbo].[客户订货表] DROP CONSTRAINT FK_客户订货表_客户基础信息表if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_客户结款表_客户基础信息表]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)ALTER TABLE [dbo].[客户结款表] DROP CONSTRAINT FK_客户结款表_客户基础信息表GOif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_客户订货表_订货票号表]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)ALTER TABLE [dbo].[客户订货表] DROP CONSTRAINT FK_客户订货表_订货票号表GOif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_销售表_销售票号表2]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)ALTER TABLE [dbo].[销售表] DROP CONSTRAINT FK_销售表_销售票号表2 GOif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_销售退货表_销售退单票号表]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)ALTER TABLE [dbo].[销售退货表] DROP CONSTRAINT FK_销售退货表_销售退单票号表GOif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_客户结款记录表_客户结款表]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)ALTER TABLE [dbo].[客户结款记录表] DROP CONSTRAINT FK_客户结款记录表_客户结款表GOif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[销售管理视图]') and OBJECTPROPERTY(id, N'IsView') = 1)drop view [dbo].[销售管理视图]GOif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[客户结款记录表]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)drop table [dbo].[客户结款记录表]GOif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[客户结款表]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)drop table [dbo].[客户结款表]if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[客户订货表]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)drop table [dbo].[客户订货表]GOif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[库存表]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)drop table [dbo].[库存表]GOif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[销售表]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)drop table [dbo].[销售表]GOif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[销售退货表]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)drop table [dbo].[销售退货表]GOif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[商品基础信息表]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)drop table [dbo].[商品基础信息表]GOif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[客户基础信息表]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)drop table [dbo].[客户基础信息表]GOif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[操作员信息表]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)drop table [dbo].[操作员信息表]GOif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[订货票号表]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)drop table [dbo].[订货票号表]GOif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[销售票号表]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)drop table [dbo].[销售票号表]GOif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[销售退单票号表]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)drop table [dbo].[销售退单票号表]GO--创建用户if not exists (select * from master.dbo.syslogins where loginname = N'山')BEGINdeclare xlogindb nvarchar(一三2), xloginlang nvarchar(一三2) select xlogindb = N'销售管理系统', xloginlang = N'简体中文'if xlogindb is null or not exists (select * from master.dbo.sysdatabases where name = xlogindb)select xlogindb = N'master'if xloginlang is null or (not exists (select * from master.dbo.syslanguages where name = xloginlang) and xloginlang <> N'us_english')select xloginlang = xxlanguageexec sp_addlogin N'山', null, xlogindb, xloginlangENDGOif not exists (select * from dbo.sysusers where name = N'guest' and hasdbaccess = 1) EXEC sp_grantdbaccess N'guest'GOif not exists (select * from dbo.sysusers where name = N'山')EXEC sp_grantdbaccess N'山', N'山'GO--创建数据库表CREATE TABLE [dbo].[商品基础信息表] ([商品编号] [varchar] (30) COLLATE Chinese_PRC_CI_AS NOT NULL ,[商品名称] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,[简称] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,[规格] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,[产地] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,[单位] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,[保质期] [char] (5) COLLATE Chinese_PRC_CI_AS NULL ,[进价] [money] NULL ,[批发价] [money] NULL ,[零售价] [money] NULL ,[备注] [varchar] (60) COLLATE Chinese_PRC_CI_AS NULL) ON [PRIMARY]GOCREATE TABLE [dbo].[客户基础信息表] ([客户编号] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL , [客户全称] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,[简称] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,[地址] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,[传真] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,[联系人] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,[联系人电话] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,[开户银行] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,[纳税人] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,[邮箱网址] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,[邮政编码] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,[银行账号] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL) ON [PRIMARY]GOCREATE TABLE [dbo].[操作员信息表] ([操作员编号] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL , [操作员姓名] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,[操作员密码] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,[操作员级别] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,[时间] [datetime] NOT NULL) ON [PRIMARY]GOCREATE TABLE [dbo].[订货票号表] ([订单号] [varchar] (30) COLLATE Chinese_PRC_CI_AS NOT NULL ,[品种数] [int] NULL ,[数量] [int] NULL ,[应付金额] [money] NULL ,[订货时间] [datetime] NULL ,[经手人] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,[操作员] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,[是否可用] [int] NULL) ON [PRIMARY]GOCREATE TABLE [dbo].[销售票号表] ([销售票号] [varchar] (30) COLLATE Chinese_PRC_CI_AS NOT NULL ,[品种数] [int] NULL ,[数量] [int] NULL ,[应付金额] [money] NULL ,[付款方式] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,[实付金额] [money] NULL ,[销售时间] [datetime] NULL ,[经手人] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,[操作员] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL) ON [PRIMARY]GOCREATE TABLE [dbo].[销售退单票号表] ([销售退单票号] [varchar] (30) COLLATE Chinese_PRC_CI_AS NOT NULL , [品种数] [int] NULL ,[数量] [int] NULL ,[应付金额] [money] NULL ,[付款方式] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,[实付金额] [money] NULL ,[退货时间] [datetime] NOT NULL ,[经手人] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,[操作员] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL) ON [PRIMARY]GOCREATE TABLE [dbo].[客户结款表] ([客户编号] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,[客户全称] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,[金额小计] [money] NULL ,[欠款记账] [money] NULL ,[付款合计] [money] NULL ,[结款时间] [datetime] NULL) ON [PRIMARY]GOCREATE TABLE [dbo].[客户订货表] ([客户编号] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,[客户名称] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,[商品编号] [varchar] (30) COLLATE Chinese_PRC_CI_AS NOT NULL ,[商品名称] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,[数量] [int] NULL ,[金额] [money] NULL ,[折扣] [float] NULL ,[订货票号] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL) ON [PRIMARY]GOCREATE TABLE [dbo].[库存表] ([商品编号] [varchar] (30) COLLATE Chinese_PRC_CI_AS NOT NULL , [商品名称] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,[库存数量] [int] NULL ,[库存金额] [money] NULL ,[盘点] [int] NULL) ON [PRIMARY]GOCREATE TABLE [dbo].[销售表] ([商品编号] [varchar] (30) COLLATE Chinese_PRC_CI_AS NOT NULL , [商品名称] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,[客户编号] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,[客户全称] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,[数量] [int] NULL ,[金额] [money] NULL ,[折扣] [float] NULL ,[销售票号] [varchar] (30) COLLATE Chinese_PRC_CI_AS NOT NULL) ON [PRIMARY]GOCREATE TABLE [dbo].[销售退货表] ([商品编号] [varchar] (30) COLLATE Chinese_PRC_CI_AS NOT NULL , [商品名称] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,[客户编号] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,[客户全称] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,[数量] [int] NULL ,[金额] [money] NULL ,[折扣] [float] NULL ,[销售退单票号] [varchar] (30) COLLATE Chinese_PRC_CI_AS NOT NULL ) ON [PRIMARY]GOCREATE TABLE [dbo].[客户结款记录表] ([客户编号] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL , [客户全称] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,[结款金额] [money] NULL ,[结款时间] [datetime] NULL ,[操作员] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL) ON [PRIMARY]GO--创建主键约束ALTER TABLE [dbo].[商品基础信息表] WITH NOCHECK ADD CONSTRAINT [PK_商品基础信息表] PRIMARY KEY CLUSTERED ([商品编号]) ON [PRIMARY]GOALTER TABLE [dbo].[客户基础信息表] WITH NOCHECK ADD CONSTRAINT [PK_客户基础信息表] PRIMARY KEY CLUSTERED ([客户编号]) ON [PRIMARY]GOALTER TABLE [dbo].[操作员信息表] WITH NOCHECK ADD CONSTRAINT [PK_操作员信息表] PRIMARY KEY CLUSTERED ([操作员编号]) ON [PRIMARY]GOALTER TABLE [dbo].[订货票号表] WITH NOCHECK ADDCONSTRAINT [PK_订货票号表] PRIMARY KEY CLUSTERED([订单号]) ON [PRIMARY]GOALTER TABLE [dbo].[销售票号表] WITH NOCHECK ADDCONSTRAINT [PK_销售票号表] PRIMARY KEY CLUSTERED([销售票号]) ON [PRIMARY]GOALTER TABLE [dbo].[销售退单票号表] WITH NOCHECK ADDCONSTRAINT [PK_销售退单票号表] PRIMARY KEY CLUSTERED ([销售退单票号]) ON [PRIMARY]GOALTER TABLE [dbo].[客户结款表] WITH NOCHECK ADDCONSTRAINT [PK_客户结款表] PRIMARY KEY CLUSTERED([客户编号]) ON [PRIMARY]GOALTER TABLE [dbo].[客户订货表] WITH NOCHECK ADDCONSTRAINT [PK_客户订货表] PRIMARY KEY CLUSTERED([客户编号],[商品编号]) ON [PRIMARY]GOALTER TABLE [dbo].[库存表] WITH NOCHECK ADDCONSTRAINT [PK_库存表] PRIMARY KEY CLUSTERED([商品编号]) ON [PRIMARY]GOALTER TABLE [dbo].[销售表] WITH NOCHECK ADDCONSTRAINT [PK_销售表] PRIMARY KEY CLUSTERED([销售票号]) ON [PRIMARY]GOALTER TABLE [dbo].[销售退货表] WITH NOCHECK ADDCONSTRAINT [PK_销售退货表] PRIMARY KEY CLUSTERED([销售退单票号]) ON [PRIMARY]GOALTER TABLE [dbo].[客户结款记录表] WITH NOCHECK ADD CONSTRAINT [PK_客户结款记录表] PRIMARY KEY CLUSTERED([客户编号]) ON [PRIMARY]GO--创建默认值约束ALTER TABLE [dbo].[操作员信息表] ADDCONSTRAINT [DF_操作员信息表_时间] DEFAULT (getdate()) FOR [时间] GOALTER TABLE [dbo].[销售票号表] ADDCONSTRAINT [DF_销售票号表_销售时间] DEFAULT (getdate()) FOR [销售时间]GOALTER TABLE [dbo].[销售退单票号表] ADDCONSTRAINT [DF_销售退单票号表_退货时间] DEFAULT (getdate()) FOR [退货时间]GO--创建默认值约束ALTER TABLE [dbo].[客户结款表] ADDCONSTRAINT [DF_客户结款表_结款时间] DEFAULT (getdate()) FOR [结款时间],CONSTRAINT [IX_客户结款表] UNIQUE NONCLUSTERED([客户编号]) ON [PRIMARY]GO--创建默认值约束ALTER TABLE [dbo].[库存表] ADDCONSTRAINT [DF_库存表_盘点] DEFAULT (0) FOR [盘点]GOALTER TABLE [dbo].[客户结款记录表] ADDCONSTRAINT [DF_客户结款记录表_结款时间] DEFAULT (getdate()) FOR[结款时间]GOALTER TABLE [dbo].[客户结款表] ADDCONSTRAINT [FK_客户结款表_客户基础信息表] FOREIGN KEY ([客户编号]) REFERENCES [dbo].[客户基础信息表] ([客户编号])GOALTER TABLE [dbo].[客户订货表] ADDCONSTRAINT [FK_客户订货表_订货票号表] FOREIGN KEY([订货票号]) REFERENCES [dbo].[订货票号表] ([订单号]),CONSTRAINT [FK_客户订货表_客户基础信息表] FOREIGN KEY ([客户编号]) REFERENCES [dbo].[客户基础信息表] ([客户编号]),CONSTRAINT [FK_客户订货表_商品基础信息表] FOREIGN KEY ([商品编号]) REFERENCES [dbo].[商品基础信息表] ([商品编号])GOALTER TABLE [dbo].[库存表] ADDCONSTRAINT [FK_库存表_商品基础信息表] FOREIGN KEY([商品编号]) REFERENCES [dbo].[商品基础信息表] ([商品编号])GOALTER TABLE [dbo].[销售表] ADDCONSTRAINT [FK_销售表_商品基础信息表] FOREIGN KEY([商品编号]) REFERENCES [dbo].[商品基础信息表] ([商品编号]),CONSTRAINT [FK_销售表_销售票号表2] FOREIGN KEY([销售票号]) REFERENCES [dbo].[销售票号表] ([销售票号])GOALTER TABLE [dbo].[销售退货表] ADDCONSTRAINT [FK_销售退货表_商品基础信息表] FOREIGN KEY ([商品编号]) REFERENCES [dbo].[商品基础信息表] ([商品编号]),CONSTRAINT [FK_销售退货表_销售退单票号表] FOREIGN KEY ([销售退单票号]) REFERENCES [dbo].[销售退单票号表] ([销售退单票号])GOALTER TABLE [dbo].[客户结款记录表] ADDCONSTRAINT [FK_客户结款记录表_客户结款表] FOREIGN KEY ([客户编号]) REFERENCES [dbo].[客户结款表] ([客户编号])GOSET QUOTED_IDENTIFIER ONGOSET ANSI_NULLS ONGO--创建视图CREATE VIEW dbo.销售管理视图ASSELECT dbo.订货票号表.订单号, dbo.库存表.商品编号, dbo.销售退货表.销售退单票号,dbo.商品基础信息表.商品编号AS Expr1, dbo.客户订货表.客户编号,dbo.客户订货表.商品编号AS Expr2, dbo.客户基础信息表.客户编号AS Expr3,dbo.销售表.销售票号, dbo.销售票号表.销售票号AS Expr4,dbo.客户结款表.客户编号AS Expr5, dbo.客户结款记录表.客户编号AS Expr6,dbo.销售退单票号表.销售退单票号AS Expr7FROM dbo.订货票号表INNER JOINdbo.客户订货表ON dbo.订货票号表.订单号= dbo.客户订货表.订货票号INNER JOINdbo.客户基础信息表ONdbo.客户订货表.客户编号= dbo.客户基础信息表.客户编号INNER JOIN dbo.客户结款表ONdbo.客户基础信息表.客户编号= dbo.客户结款表.客户编号INNER JOIN dbo.客户结款记录表ONdbo.客户结款表.客户编号= dbo.客户结款记录表.客户编号INNER JOIN dbo.库存表ON dbo.客户订货表.商品编号= dbo.库存表.商品编号INNER JOINdbo.商品基础信息表ONdbo.客户订货表.商品编号= dbo.商品基础信息表.商品编号ANDdbo.库存表.商品编号= dbo.商品基础信息表.商品编号INNER JOINdbo.销售表ON dbo.商品基础信息表.商品编号= dbo.销售表.商品编号INNER JOINdbo.销售票号表ON dbo.销售表.销售票号= dbo.销售票号表.销售票号INNER JOINdbo.销售退货表ONdbo.商品基础信息表.商品编号= dbo.销售退货表.商品编号INNER JOIN dbo.销售退单票号表ONdbo.销售退货表.销售退单票号= dbo.销售退单票号表.销售退单票号GOSET QUOTED_IDENTIFIER OFFGOSET ANSI_NULLS ONGO--创建触发器create trigger tri11on 库存表for insert,update,deleteas print '数据修改成功!'goinsert into 库存表values('S20081228003','饼干',50,500,0) gocreate trigger tri2on 操作员信息表for insert,update,deleteas print '数据修改成功!'gocreate trigger tri3on 订货票号表for insert,update,deleteas print '数据修改成功!'gocreate trigger tri4on 客户订货表for insert,update,deleteas print '数据修改成功!'gocreate trigger tri5on 客户基础信息表for insert,update,deleteas print '数据修改成功!'gocreate trigger tri6on 销售表for insert,update,deleteas print '数据修改成功!'go--创建触发器use 销售管理系统gocreate trigger 商品信息_tron 商品基础信息表for insert,update,deleteas print'提示:商品进行了相应的变动,您进行了插入,更新或删除了等相关操作,请留意!'go--创建触发器use 销售管理系统gocreate trigger 商品信息_tron 客户基础信息表for insert,update,deleteas print'提示:客户进行了相应的调整,您进行了插入,更新或删除了等相关操作,请留意!'go--插入数据insert into 商品基础信息表values ('S20081228005','锅巴','绿豆沙拉','50包/箱','南阳','箱','1个月',12.5,14.5,16,'好锅巴')goselect * from 商品基础信息表goinsert into 客户基础信息表values ('K20081228005','胖东来','东来','平原路','3637633','赵山','3637633','中国银行','东来','2348879xqqx','453002','29384238462349698')goselect * from 客户基础信息表go--删除数据delete from 商品基础信息表where 商品名称='锅巴'godelete from 客户基础信息表where 客户名称='胖东来'go--创建多表连接select 商品基础信息表.商品名称,销售表.数量as 已售出,库存表.库存数量as 库存剩余from 商品基础信息表inner join销售表on 商品基础信息表.商品编号=销售表.商品编号inner join库存表on 库存表.商品编号=销售表.商品编号go--创建存储过程use 销售管理系统gocreate proc 第一个存储过程asselect 商品编号,商品名称from 商品基础信息表go第一个存储过程go--创建存储过程create proc proc1asselect 客户编号,商品编号,数量,金额from 客户订货表goexec proc1gocreate proc proc2asselect * from 操作员信息表goexec proc2go--创建数量规则create rule rule1as x库存数量>=0gocreate rule rule2as x数量>=0go--创建视图create view view1asselect 商品编号,客户编号,数量,金额,销售退单票号from 销售退货表goselect * from view1gocreate view view2asselect 客户编号,sum(欠款记账) as 欠款from 客户结款表group by 客户编号goselect * from view2go--创建索引create index ind1on 操作员信息表(操作员编号asc)gosp_helpindex 操作员信息表go-------创建登陆帐户--------exec sp_addlogin 'aaa','bbb','销售管理系统'go2020年3月16日星期一07:36:343.16.202007:3607:36:3420.3.167时36分7时36分34秒Mar. 16, 2016 March 20207:36:34 AM07:36:34。

新华书店进销存管理系统部分程序源代码(doc 31页)

新华书店进销存管理系统部分程序源代码(doc 31页)

新华书店进销存管理系统部分程序源代码(doc 31页)部门: xxx时间: xxx整理范文,仅供参考,可下载自行编辑附录2新华书店进销存管理系统部分程序源代码1、主程序MAIN.PRG程序代码SET DEFAULT TO C:\毕业设计PUBLIC nkfgl,nxsgl,ncggl,nkcgl,nxtglSTORE .f. TO nkfgl,nxsgl,ncggl,nkcgl,nxtglPUBLIC nname,ndepartmentSTORE "" TO nname,ndepartmentDo Form loginfRead EventsDo Form mainRead EventsQuit2、主表单MAIN.SCX代码2.1 表单Init过程程序代码do mmenu.mpr with this,.T.bel2.caption = nnamebel4.caption = ndepartment3.1 表单登入按钮Click事件程序代码SELECT userGO TOP*检查用户名和密码是否输入If empty(thisform.text1.value) thenbel3.caption = "请输入用户名"returnelseif empty(thisform.text2.value) thenbel3.caption = "请输入密码"returnendifendif*操作USER表,查询满足条件记录locate for name = alltrim(thisform.text1.value)if !found()bel3.caption="用户不存在"returnelseif user.password != alltrim(thisform.text2.value) then bel3.caption="密码错误"returnendifendifnname = ndepartment = user.departmentnkfgl = user.kfglnxsgl = user.xsglncggl = user.cgglnkcgl = user.kcglnxtgl = user.xtglthisform.releaseclear events4.1 表单Init过程程序代码thisform.text1.enabled = .f. thisform.text2.enabled = .f. thisform.text3.enabled = .f. bo1.enabled = .f. thisform.check1.enabled = .f. thisform.check2.enabled = .f. thisform.check3.enabled = .f. thisform.check4.enabled = .f. thisform.check5.enabled = .f. bel5.visible = .f. thisform.text3.visible = .f. mand10.enabled = .f. mand11.enabled = .f. thisform.dis_recordthisform.dis_reccommand4.2 表单自定义过程DIS_RECORD程序代码PUBLIC newcommandSTORE .f. TO newcommandif reccount("user") = 0thisform.text1.value = ""thisform.text2.value = ""bo1.value = ""thisform.check1.value = 0thisform.check2.value = 0thisform.check3.value = 0thisform.check4.value = 0thisform.check5.value = 0elsethisform.text1.value = thisform.text2.value = user.passwordbo1.value = user.department if user.kfgl thenthisform.check1.value = 1elsethisform.check1.value = 0endifif user.xsgl thenthisform.check2.value = 1elsethisform.check2.value = 0endifif user.cggl thenthisform.check3.value = 1elsethisform.check3.value = 0endifif user.kcgl thenthisform.check4.value = 1elsethisform.check4.value = 0endifif user.xtgl thenthisform.check5.value = 1elsethisform.check5.value = 0endifendifthisform.refresh4.3 表单自定义过程DIS_RECCOMMAND程序代码private nstore 0 to nn = reccount("user")if n=1 .or. n=0 thenmand1.enabled = .f.mand2.enabled = .f.mand3.enabled = .f.mand4.enabled = .f.elseif recno("user")=1 thenmand1.enabled = .f.mand2.enabled = .f.mand3.enabled = .t.mand4.enabled = .t.elseif recno("user")=n thenmand1.enabled = .t.mand2.enabled = .t.mand3.enabled = .f.mand4.enabled = .f.elsemand1.enabled = .t.mand2.enabled = .t.mand3.enabled = .t.mand4.enabled = .t.endifendifendifthisform.refresh4.4 表单保存按钮Click事件程序代码if empty(thisform.text1.value) then=messagebox("请输入用户名",0+48+0,"出错") thisform.text1.setfocusthisform.refreshreturnendifif empty(thisform.text2.value) then=messagebox("请输入密码",0+48+0,"出错") thisform.text2.setfocusthisform.refreshreturnendifif .not.(alltrim(thisform.text2.value) == alltrim(thisform.text3.value)) then=messagebox("密码重复错误,请重新输入",0+48+0,"出错")thisform.text2.value = ""thisform.text3.value = ""thisform.text2.setfocusthisform.refreshreturnendifif empty(bo1.value) then=messagebox("请选择所属部门",0+48+0,"出错")bo1.setfocusthisform.refreshreturnendififthisform.check1.value=0.and.thisform.check2.value=0.and.thisform .check3.value=0.and.thisform.check4.value=0.and.thisform.check5. value=0 then=messagebox("至少选择一个用户权限",0+48+0,"出错")thisform.check1.setfocusthisform.refreshreturnendififthisform.check1.value=1.and.thisform.check2.value=1.and.thisform .check3.value=1.and.thisform.check4.value=1.and.thisform.check5. value=1 thenmesbox=messagebox("此用户将具有全部权限,请确认",4+48+0,"警告") if mesbox=7 thenthisform.check1.setfocusthisform.refreshreturnendifendif。

c语言图书销售系统(源代码)

c语言图书销售系统(源代码)

#include <stdio.h>#include <string。

h〉#include <malloc.h〉#include 〈stdlib。

h〉#include 〈time.h〉#include <conio。

h>#define LEN sizeof(struct book)#define VLEN sizeof(struct vip)#define SLEN sizeof(struct sales)struct vip *vhead=NULL;struct vip *v1,*v2;struct sales *shead=NULL;struct sales *s1,*s2;int V,S;/*结构体定义*/struct book{char bnum [12];/*书号*/char bname [41];/*书名*/char author [20];/*作者*/float price; /*书价*/int acount; /*书存在本数*/struct book *next;};struct sales{float count;struct sales *snext;};struct vip{char vnum[12];char vname[41];int level;float persum;float discount;struct vip *vnext;};/*函数声明*/void loadbook(); /*自动读入书库信息*/void welcome();/*欢迎界面显示*/ void inputbook();/*增加书本信息*/void loadvip();void loadsales(); /*自动录入销售信息*/void daysales(); /*日销售额*/void monthsales();/*月销售额*/void yearsales(); /*年销售额*/void search();/*查询书数量*/void search_by_bnum(); /*通过书号查询*/void search_by_bname();/*通过书名查询*/void search_by_author();/*通过作者查询*/void buy(); /*购买书籍*/void list(); /*列出书库信息*/void listvip();void listsales();/*列出销售信息*/void delet();/*删除书目*/void delet_by_bnum();/*通过书号删除*/void delet_by_bname();/*通过书名删除*/void delet_by_author();/*通过作者删除*/void save();/*保存记录*/void redef(); /*修改密码*/void bover(); /*显示已售完的书*/void buy_by_huiyuan();/*会员买书*/void buy_by_feihuiyuan();/*非会员买书*/void exit0(); /*退出*/int menu();/*主菜单*/void print2(); /*显示查询菜单*/void printdelete();/*显示删除菜单*/struct book *head=NULL,*head2=NULL;/*head和head2分别用于书库的头指针和已购书的头指针*/struct book *p1,*p2,*p3,*p4,*p5,*p6; /*p1、p2、p3用于操作书库图书,p4、p5、p6用于操作已购书*/int save_flag=0; /*图书信息变动标志*/int buy_flag=0;/*买书时,是否调用过查询功能标志*/int shan_flag=0;/*删书时,是否调用过显示已售完书功能标志*/int T=0;/*记录导入的书本数*/char mima[11]=”123456”;/*初始密码*/void bookmanage();void salesmanage(); /*销售统计*/int main() /*主函数*/{welcome(); /*欢迎界面显示*/loadbook();loadsales();loadvip(); /*自动导入书库信息*/while(1){switch(menu()){case 1:system(”cls”);bookmanage();break;case 2:system(”cls");buy();break;case 3:system("cls");listvip();break;case 4:system("cls”);;salesmanage();break;case 5:system(”cls");;break;case 0:system(”cls”);exit0();break;default:{printf("\n选择错误,请按主菜单提示输入您的正确选择(0~8)\n”);printf("按任意键返回继续:");rewind(stdin);/*清空缓冲区*/getch();}}}return 0;}/*菜单*/int menu(){int choice;system(”cls");/*系统清屏*/printf(”\n *************************主菜单*************************\n\n”);printf(” 1.图书管理\n\n”);printf(" 2。

书店销售管理系统源代码

书店销售管理系统源代码
var
i:integer;
begin
for i:=0 to frm_main.MDIChildCount-1 do
begin
if frm_main.MDIChildren[i]=frm_out then
begin
frm_out.PageControl1.ActivePageIndex:=0;
exit;
Application.Run;
end.
unit uni_main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, ComCtrls, ToolWin, ImgList;
N9: TMenuItem;
N10: TMenuItem;
ToolBar1: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
uni_in in 'uni_in.pas' {frm_in},
uni_book in 'uni_book.pas' {frm_book};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(Tfrm_main, frm_main);
end;
procedure Tfrm_main.N3Click(Sender: TObject);

销售管理C语言源代码

销售管理C语言源代码
for(i=0;i<q*l;i++)
{
if(tiao[i].zhigong==1)
a[0]=a[0]+tiao[i].xiaoliang;
else if(tiao[i].zhigong==2)
a[1]=a[1]+tiao[i].xiaoliang;
else if(tiao[i].zhigong==3)
case 2:liulan();break;
case 3:gerenxiaoshou();break;
case 4:xiaoshouyuanpaixu();break;
case 5:xiaoliangpaixu();break;
case 6:exit(0);
}
} save(ຫໍສະໝຸດ ; menu(); }
void liulan()
{
int i,j;
for(j=1;j<=l;j++)
{
printf("\n在%d号的销售信息是:\n",j);
for(i=0;i<q*l;i++)
if(tiao[i].date==j)
printf(" %d号推销员 推销%d号商品 共%d件\n",tiao[i].zhigong,tiao[i].chanpin,tiao[i].xiaoliang);
} menu();
}
void gerenxiaoshou()
{
int j,i,m,sum;
for(j=1;j<=4;j++)
{
for(i=1;i<=5;i++)

C语言编程销售管理系统

C语言编程销售管理系统

C语言编程销售管理系统#include#include#include#include#define NULL 0#define LEN sizeof(struct records)struct sellers_list /*销售员信息结构体*/ {int snum;char sname[20];char sex[10];}sellers[4];struct products_list /*产品信息结构体*/ {int pnum;char pname[20];float price;}products[5];struct records /*销售记录结构体*/{int snum;int pnum;int amount;char time[10];struct recoreds *next;};struct records *head=NULL;struct date /*日期结构体*/{int year;int month;int day;}d[100];int tab[2][13]={{0,31,28,31,30,31,30,31,31,30,31,30,31},{0,31,29,31,30,31,30,31,31,30,31,30,31}};int n=0,choice;char c[100];void menu_select();void create_sellers();void create_products();void create_records(int n);void display();void insert(int m);void del();void find();void report(struct records *head);int main(){printf("\n\n\n\n\n\n\t\t\t欢迎您使用该销售管理平台!\n");printf("\n\n\n\t\t\t\t按任意键进入销售管理菜单、、、\n"); getch();system("cls");menu_select();}void menu_select() /*主菜单*/{int x;printf("****************销售管理菜单********************\n"); printf("* 1.输入销售员信息 *\n");printf("* 2.输入产品的信息 *\n");printf("* 3.输入销售的记录 *\n");printf("* 4.浏览所有的信息 *\n");printf("* 5.插入销售的记录 *\n");printf("* 6.删除销售的记录 *\n");printf("* 7.查询销售的记录 *\n");printf("* 8.导出销售的报表 *\n");printf("* 9.退出 *\n");printf("************************************************\n"); printf("请输入1-9选择相应操作:");do{scanf("%s",&c);choice=atoi(c);if(choice<1||choice>9)printf("输入错误!请输入1-9选择相应操作:");}while(choice<1||choice>9);do{switch(choice){case 1:create_sellers();getch();system("cls");menu_select();break;case 2:create_products();getch();system("cls");menu_select();break;case 3:if(head!=NULL){printf("\n你已经创建了链表,按任意键返回主菜单!\n"); getch();system("cls");menu_select();break;}else{system("cls");printf("请输入要建立的销售记录条数:");scanf("%d",&n);if(n>0)create_records(n);elseprintf("\n输入的数据有问题,请重新输入!\n");}getch();system("cls");menu_select();break;case 4:display();getch();system("cls");menu_select();break;case 5:system("cls");if(head==NULL)printf("现在是空链表,请先去创建链表!\n");else{do{printf("请正确输入要插入销售记录的位置(范围是 1--%d):",n); scanf("%d",&x);} while(x<1 || x>n);insert(x);}getch();system("cls");menu_select();break;case 6:system("cls");del();getch();system("cls");menu_select();break;case 7:system("cls");find();getch();system("cls");menu_select();break;case 8:system("cls");report(head);system("cls");menu_select();break;}}while(choice!=9);system("cls");printf("\n\n\n\n\n\n\n 谢谢使用!欢迎下次使用、、、、、、\n");getch();}void create_sellers() /*输入销售员信息*/{int i,ch;system("cls");printf("*******************选择界面*********************\n");printf("* 1.从键盘输入销售员信息 *\n");printf("* 2.从文件中读取销售员信息 *\n");printf("************************************************");printf("\n请输入1或2选择需要的操作:");do{scanf("%s",&c);ch=atoi(c);if(ch<1||ch>2)printf("输入错误!请输入1或2选择需要的操作:\n");}while(ch<1||ch>2);if(ch == 2){FILE *fp;if((fp=fopen("sellers.txt","r"))==NULL){printf("\nCannot open file strike any key exit!\n\n");exit(1);}ch=getchar();printf("销售员的编号姓名性别 \n");for(i=0;i<4;i++){fscanf(fp,"%d %s %s",&sellers[i].snum,sellers[i].sname,sellers [i].sex);printf(" %d %s %s\n",sellers[i].snum,sellers[i].sname,sellers[i] .sex);}fclose(fp);printf("销售员信息读取成功,按任意键返回主菜单!\n");}else{printf("\n 销售员的编号姓名性别 (空格隔开)\n");for(i=0;i<4;i++){scanf("%d%s%s",&sellers[i].snum,sellers[i].sname,sellers[i].s ex);}}}void create_products() /*输入产品信息*/{int j,ch;system("cls");printf("*******************选择界面*********************\n");printf("* 1.从键盘输入销售产品信息 *\n");printf("* 2.从文件中读取销售产品信息 *\n");printf("************************************************");printf("\n请输入1或2选择需要的操作:");do{scanf("%s",&c);ch=atoi(c);if(ch<1||ch>2)printf("输入错误!请输入1或2选择需要的操作:\n");}while(ch<1||ch>2);if(ch == 2){FILE *fp;if((fp=fopen("products.txt","r"))==NULL){printf("\nCannot open file strike any key exit!\n\n");exit(1);}ch=getchar();printf("产品的编号名称价格\n");for(j=0;j<5;j++){fscanf(fp,"%d %s %f",&products[j].pnum,products[j].pname, &products[j].price);printf(" %d %s %f\n",products[j].pnum,products[j].pname,pr oducts[j].price);}fclose(fp);printf("销售产品信息读取成功,按任意键返回主菜单!\n");}else{printf("\n产品的编号名称价格 (逗号隔开)\n");for(j=0;j<5;j++){scanf("%d,%s,%f",&products[j].pnum,products[j].pname,&p roducts[j].price);}}}void create_records(int n) /*创建销售记录链表*/{struct records *p;int i,j,flag,leap,ch;char a[3],b[2],c[2];printf("*******************选择界面*********************\n");printf("* 1.从键盘输入销售的记录 *\n");printf("* 2.从文件中读取销售的记录 *\n");printf("************************************************");printf("\n请输入1或2选择需要的操作:");do{scanf("%s",&c);ch=atoi(c);if(ch<1||ch>2)printf("输入错误!请输入1或2选择需要的操作:\n");}while(ch<1||ch>2);if(ch==1){printf("*********************请输入销售记录*************************\n\n");printf("销售员编号产品代号销售数量日期(YYYY-MM-DD)(空格隔开)\n");for(i=0; i{p=(struct records *)malloc(LEN);do{flag=1;scanf("%d%d%d%s",&p->snum,&p->pnum,&p->amount,p ->time);for(j=0;j<4;j++){a[j]=p->time[j];}a[4]=' ';b[0]=p->time[5];b[1]=p->time[6];c[0]=p->time[8];c[1]=p->time[9];d[i].year=atoi(a);d[i].month=atoi(b);d[i].day=atoi(c);for(j=0;j<4;j++){if(p->snum==sellers[j].snum)break;}if(j==4){printf("销售员不存在!请重新输入!\n");flag=0;continue;}for(j=0;j<5;j++){if(p->pnum==products[j].pnum)break;}if(j==5){printf("该产品不存在!请重新输入!\n");flag=0;continue;}if(p->time[4]!='-'||p->time[7]!='-'||strlen(p->time)!=10){ printf("日期格式错误!请重新输入!\n");flag=0;continue;}if(d[i].year%4==0||d[i].year%100==0||d[i].year%400==0) leap=0;elseleap=1;if(leap=1){if(d[i].day>tab[1][d[i].month]||d[i].day<0){printf("天数错误!请重新输入!\n");flag=0;continue;}}else{if(d[i].day>tab[0][d[i].month]||d[i].day<0){ printf("天数错误!请重新输入!\n");flag=0;continue;}}}while(flag==0);p->next=head;head=p;}printf("\n成功输入%d条销售记录,按任意键返回主菜单!\n",n);}else{FILE *fp;if((fp=fopen("records.txt","r"))==NULL){printf("\nCannot open file strike any key exit!\n\n");exit(1);}ch=getchar();printf("销售员编号产品代号销售数量日期(YYYY-MM-DD)\n");for(i=0;i<n;i++){p=(struct records *)malloc(LEN);fscanf(fp,"%d %d %d %s",&p->snum,&p->pnum,&p->amo unt,p->time);printf(" %d %d %d %s\n",p->snum,p->pnum,p->amount,p->time);p->next=head;head=p;}fclose(fp);printf("销售记录读取成功,按任意键返回主菜单!\n");}}void display() /*浏览所有信息*/{int i;struct records *p;system("cls");printf("*********************销售员信息*********************\n");printf("编号姓名性别 \n");for(i=0;i<4;i++)printf("%d %s %s\n",sellers[i].snum,sellers[i].sname,sellers[i]. sex);printf("*********************销售产品信息*******************\n");printf("编号名称价格\n");for(i=0;i<5;i++)printf("%d %s %f\n",products[i].pnum,products[i].pname,pr oducts[i].price);printf("**********************销售记录**********************\n");printf("销售员编号产品代号销售数量日期\n");p=head;while(p!=NULL){printf("%d %d %d %s\n",p->snum,p->pnum,p->amount,p->time);p=p->next;}printf("\n所有信息显示完毕,按任意键返回主菜单!\n");}void insert(int m) /*插入销售记录*/{struct records *p1,*p2;int i=1,j,flag,leap;char a[3],b[2],c[2];p1=head;while(i<m){p1=p1->next; i++;}printf("*********************请插入销售记录*************************\n");printf("销售员编号产品代号销售数量日期(YYYY-MM-DD) (空格隔开)\n");p2=(struct records *)malloc(LEN);do{flag=1;scanf("%d%d%d%s",&p2->snum,&p2->pnum,&p2->amou nt,p2->time);for(j=0;j<4;j++){a[j]=p2->time[j];}a[4]=' ';b[0]=p2->time[5];b[1]=p2->time[6];c[0]=p2->time[8];c[1]=p2->time[9];d[i].year=atoi(a);d[i].month=atoi(b);d[i].day=atoi(c);for(j=0;j<4;j++){if(p2->snum==sellers[j].snum)break;}if(j==4){printf("销售员不存在!请重新输入!\n");flag=0;continue;}for(j=0;j<5;j++){if(p2->pnum==products[j].pnum)break;}if(j==5){printf("该产品不存在!请重新输入!\n");flag=0;continue;}if(p2->time[4]!='-'||p2->time[7]!='-'||strlen(p2->time)!=10){ printf("日期格式错误!请重新输入!\n");flag=0;continue;if(d[i].year%4==</m)</n;i++){0||d[i].year%100==0||d[i].year%400==0)leap=0;elseleap=1;if(leap=1){if(d[i].day>tab[1][d[i].month]||d[i].day<0){printf("天数错误!请重新输入!\n");flag=0;continue;}}else{if(d[i].day>tab[0][d[i].month]||d[i].day<0){ printf("天数错误!请重新输入!\n");flag=0;continue;}}}while(flag==0);p2->next=p1->next;p1->next=p2;n++;printf("成功插入销售记录,按任意键返回主菜单!\n");}void del() /*删除指定销售记录*/{struct records *p1,*p2;int ch,m;char t[10];p1=p2=head;printf("*******************选择界面*********************\n"); printf("* 1.删除指定销售员的销售记录 *\n");printf("* 2.删除指定产品的销售记录 *\n");printf("* 3.删除指定日期的销售记录 *\n");printf("************************************************"); printf("\n请输入1-3选择需要的操作:");do{scanf("%s",&c);ch=atoi(c);if(ch<1||ch>3)printf("输入错误!请输入1-3选择需要的操作:\n");}while(ch<1||ch>3);if(ch==1){printf("请输入指定销售员的编号:");scanf("%d",&m);while(p1!=NULL && p1->snum!=m){p2=p1; p1=p1->next;}if(p1==NULL)printf("没有找到您要删除的销售记录,按任意键返回主菜单!\n");else{printf("成功删除编号为 %d的销售员的销售记录,按任意键返回主菜单!\n",m);if(p1==p2)head=p1->next;elsep2->next=p1->next;free(p1);n--;}if(n==0)head=NULL;}else if(ch==2){printf("请输入指定产品的代号:\n");scanf("%d",&m);while(p1!=NULL && p1->pnum!=m){p2=p1; p1=p1->next;}if(p1==NULL)printf("没有找到您要删除的销售记录,按任意键返回主菜单!\n");else{printf("成功删除代号为 %d的产品的销售记录,按任意键返回主菜单!\n",m);if(p1==p2)head=p1->next;elsep2->next=p1->next;free(p1);n--;}if(n==0)head=NULL;}else{printf("请输入指定的日期(YYYY-MM-DD):");scanf("%s",&t);while(p1!=NULL && strcmp(p1->time,t)!=0){p2=p1; p1=p1->next;}if(p1==NULL)printf("没有找到您要删除的销售记录,按任意键返回主菜单!\n");else{printf("成功删除日期为%s的销售记录,按任意键返回主菜单!\n",t);if(p1==p2)head=p1->next;elsep2->next=p1->next;free(p1);n--;}if(n==0)head=NULL;}}void find() /*查询指定销售员的销售记录*/{struct records *p;int flag=0,m;printf("请输入要查询的销售员编号:");scanf("%d",&m);p=head;while(p!=NULL){if(p->snum==m){flag=1;printf("销售员编号产品代号销售数量日期(YYYY-MM-DD)\n");printf(" %d %d %d %s\n",p->snum,p->pnum,p->amount,p->time);}p=p->next;}if(flag==1)printf("查询信息显示完毕,按任意键返回主菜单!\n");if(flag==0)printf("没有找到您要查找的销售记录,按任意键返回主菜单!\n");}void report(struct records *head) /*显示销售报表*/{int i,j,flag,leap;char s1[10],s2[10],a[4],b[2],c[2];int report[5][6]={0};struct records *ptr=head;struct sellers_list *p=sellers;struct products_list *q=products;system("cls");printf("请输入您要查询的起止时间与截止时间(格式为YYYY-XX-DD)(回车间隔)\n");getchar();do{flag=1;gets(s1);for(j=0;j<4;j++){a[j]=s1[j];}a[4]=' ';b[0]=s1[5];b[1]=s1[6];c[0]=s1[8];c[1]=s1[9];d[0].year=atoi(a);d[0].month=atoi(b);d[0].day=atoi(c);if(s1[4]!='-'||s1[7]!='-'||strlen(s1)!=10){printf("日期格式错误!请重新输入!\n");flag=0;continue;}if(d[0].year%4==0||d[0].year%100==0||d[0].year%400==0) leap=0;elseleap=1;if(leap=1){if(d[0].day>tab[1][d[0].month]||d[0].day<0){printf("天数错误!请重新输入!\n");flag=0;continue;}}else{if(d[0].day>tab[0][d[0].month]||d[0].day<0){ printf("天数错误!请重新输入!\n");flag=0;continue;}}}while(flag==0);do{flag=1;gets(s2);for(j=0;j<4;j++){a[j]=s2[j];}a[4]=' ';b[0]=s2[5];b[1]=s2[6];c[0]=s2[8];c[1]=s2[9];d[1].year=atoi(a);d[1].month=atoi(b);d[1].day=atoi(c);if(s2[4]!='-'||s2[7]!='-'||strlen(s2)!=10){printf("日期格式错误!请重新输入!\n");flag=0;continue;}if(d[1].year%4==0||d[1].year%100==0||d[1].year%400==0) leap=0;elseleap=1;if(leap=1){if(d[1].day>tab[1][d[1].month]||d[1].day<0){printf("天数错误!请重新输入!\n");flag=0;continue;}}else{if(d[1].day>tab[0][d[1].month]||d[1].day<0){ printf("天数错误!请重新输入!\n");flag=0;continue;}}}while(flag==0);while(ptr!=NULL){/*将对应日期内销售数量累加到报表相应位置*/s2[0]=a[0];if((strcmp(ptr->time,s1)>=0)&&(strcmp(ptr->time,s2)<=0)) {for(i=0;i<4;i++){if(ptr->snum == sellers[i].snum)break;}for(j=0;j<5;j++){if(ptr->pnum ==products[j].pnum)break;}report[i][j] += ptr->amount;}ptr=ptr->next;}/*横竖向汇总*/for(i=0;i<5;i++){for(j=0;j<4;j++)report[4][i]+=report[j][i];}for(i=0;i<5;i++){for(j=0;j<5;j++)report[i][5] +=report[i][j];}printf("****************************销售统计报表****************************************\n");printf(" 产品代号销售之和 \n");printf("销售员代号 ");for(i=0;i<5;i++)printf("%10d",products[i].pnum);printf("\n");for(i=0;i<5;i++){if(i<4)printf("%10d ",sellers[i].snum);elseprintf("每种产品之和 ");for(j=0;j<6;j++){printf("%10d",report[i][j]);}if(i<4)printf("\n");elseprintf(" 总和\n");}printf("\n按任意键返回主菜单!\n"); getchar();}。

C课程设计-销售管理系统

C课程设计-销售管理系统

任务书一、设计题目销售管理系统二、主要内容本课程设计某公司有四个销售员(编号:1-4),负责销售五种产品(编号:1-5)。

每个销售员都将当天出售的每种产品各写一张便条交上来。

每张便条包含内容:销售员的代号、产品的代号、这种产品的当天的销售额。

每位销售员每天可能上缴0-5张便条。

假设,收集到了上个月的所有便条,编写一个处理系统,读取上个月的销售情况(自己设定),进行如下处理。

1)计算上个月每个人每种产品的销售额。

2)按销售额对销售员进行排序,输出排序结果(销售员代号)3)统计每种产品的总销售额,对这些产品按从高到底的顺序,输出排序结果(需输出产品的代号和销售额)4)输出统计报表如下:产品代号销售之和销售员代号1 2 ……………………………………………………………… 每种产品之和总和三、具体要求及应提交的材料设计要求:1. 分析设计要求,给出解决方案(要说明设计实现所用的原理,采用的数据结构); 2. 模块化程序设计,画出程序的基本结构框图和流程图; 3. 对程序的每一部分要有详细的设计分析说明; 4. 程序执行的每个步骤要有具体的提示内容或输出; 5. 源代码格式规范(锯齿型书写格式),注释不少于三分之一;销售管理系统 6. 设计合适的测试用例,对得到的运行结果要有分析; 7. 设计中遇到的问题,设计的心得体会。

设计结束后,每位同学必须上交如下材料: 1. 《课程设计说明书》打印稿一份; 2. 《课程设计说明书》电子文档及课程设计的程序源代码刻盘四、主要技术路线提示首先根据要解决的问题进行分析和总体设计,得到要定义的数据结构(可使用链表或结构数组存储数据)和函数,然后进行详细编码,在主函数中对各功能函数进行测试。

五、进度安排一周完成。

1天查阅资料和分析,3天编程,2天写出课程设计报告并上交。

六、推荐参考资料(不少于3篇) 摘要随着计算机技术的飞速发展和激烈的市场竞争,销售管理系统在企业结构中已经占据主导地位,而使用计算机来进行销售管理不仅错误少、灵活度高,并且效率高、操作简便。

C语言设计实现销售管理系统源代码

C语言设计实现销售管理系统源代码

#include"stdio.h"#include"string.h"#include"stdlib.h"struct goods{char name[20];int price;char pro[20];int kc;int xs;}s[30];void add();void select();void update();void center(){int k;printf("----------------------欢迎登陆销售管理系统--------------------\n");printf(" \n");printf(" \n");printf(" \n");printf("请输入您要操作的功能:\n");printf("1,添加商品信息2,查找商品信息3,修改商品信息4,退出系统\n"); scanf("%d",&k);switch(k){case 1:system("CLS");add();break;case 2:system("CLS");select();break;case 3:system("CLS");update();break;case 4:exit(0);break;}}void add()FILE *fp;fp=fopen("goods.txt","a");printf("请输入商品名称单价生产厂家库存量销售量\n"); scanf("%s%d%s%d%d",&s[0].name,&s[0].price,&s[0].pro,&s[0].kc,&s[0].xs); fwrite(&s[0],sizeof(struct goods),1,fp);printf("添加成功\n");fclose(fp);center();}void select(){int i;char name[20];int money,k;FILE *fp;fp=fopen("goods.txt","rb");printf("您是要查找1;按商品名称2;生产厂家:\n");scanf("%d",&k);switch(k){case 1:printf("请输入商品名称:\n");scanf("%s",&name);for(i=0;i<30;i++){fread(&s[i],sizeof(struct goods),1,fp);if(strcmp(s[i].name,name)==0){printf("销售量金额库存量为:\n");money=s[i].price*s[i].xs;printf("%d\t%d\t%d\n",s[i].xs,money,s[i].kc);}}break;case 2:printf("请输入生产厂家:\n");scanf("%s",&name);for(i=0;i<30;i++){fread(&s[i],sizeof(struct goods),1,fp);if(strcmp(s[i].pro,name)==0){printf("销售量金额库存量为:\n");money=s[i].price*s[i].xs;printf("%d\t%d\t%d\n",s[i].xs,money,s[i].kc);}break;}fclose(fp);center();}void update(){int i;char name[20];int up,k;FILE *fp;fp=fopen("goods.txt","rb");for(i=0;i<30;i++){fread(&s[i],sizeof(struct goods),1,fp);}fclose(fp);if((fp=fopen("goods.txt","wb"))!=NULL)printf("请输入您要修改的商品名称:\n"); scanf("%s",name);printf("您要修改:1,库存量2,销售量\n"); scanf("%d",&k);switch(k){case 1:for(i=0;i<30;i++){if(strcmp(s[i].name,name)==0){printf("请输入您要修改的值:\n");scanf("%d",&up);s[i].kc=up;printf("修改成功\n");}fwrite(&s[i],sizeof(struct goods),1,fp);}break;case 2:for(i=0;i<30;i++){if(strcmp(s[i].name,name)==0){printf("请输入您要修改的值:\n");scanf("%d",&up);s[i].xs=up;printf("修改成功\n");}fwrite(&s[i],sizeof(struct goods),1,fp); }break;}fclose(fp);center();}int main(){center();}。

销售管理系统相关代码

销售管理系统相关代码

销售管理系统相关代码以下是一个简单的销售管理系统的代码示例:```pythonclass Product:def __init__(self, name, price, quantity): = nameself.price = priceself.quantity = quantitydef get_total_price(self):return self.price * self.quantityclass SalesManager:def __init__(self):self.products = []def add_product(self, product):self.products.append(product)def remove_product(self, product):self.products.remove(product)def calculate_total_revenue(self):total_revenue = 0for product in self.products:total_revenue += product.get_total_price() return total_revenue# 示例用法if __name__ == "__main__":manager = SalesManager()# 添加产品product1 = Product("iPhone", 999, 2)manager.add_product(product1)product2 = Product("iPad", 599, 3)manager.add_product(product2)# 计算总收入total_revenue = manager.calculate_total_revenue()print("总收入:", total_revenue)# 移除产品manager.remove_product(product1)# 重新计算总收入total_revenue = manager.calculate_total_revenue()print("调整后总收入:", total_revenue)```上述代码包括两个类:`Product`和`SalesManager`。

JAVA商品销售管理系统(ER图+源代码)-课程设计

JAVA商品销售管理系统(ER图+源代码)-课程设计

JAVA商品销售管理系统(ER图+源代码)-课程设计JAVA商品销售管理系统(ER图+源代码)目录1 相关技术简介 31.1 SQL Server 2005简介 31.2 Eclipse简介 32 销售信息管理系统需求分析 32.1 数据流图 42.2 数据字典 42.2.1产品信息 52.2.2客户信息 52.2.3销售信息 62.2.4售后服务信息 72.2.5策略公告信息 82.3 安全性与完整性 92.3.1安全性 93 概念结构设计 94 逻辑结构设计 104.1 关系数据模型: 104.2 系统结构图: 124.3 安全性和完整性设计 124.3.1 安全性 124.3.2 完整性 125 数据库物理结构设计 135.1 数据库存放位置 135.2 数据库系统配置 136 数据库实施 136.1 创建数据库 136.2 创建基本表 146.3 修改各表外键: 156.4 创建存储过程 166.5 数据库备份和恢复方案 16 6.6.1登录界面 176.6.2销售人员工作界面 176.6.3售后服务人员工作界面 18 6.6.4市场部经理工作界面 18 6.6.5管理员界面 186.6.6程序加密方法 197 系统测试方案和报告 228 系统的使用功能和使用说明 26 8.1 登录模块 268.2 客户信息管理模块 268.3 销售信息管理模块 278.4 售后服务信息管理模块 27 8.5 策略公告模块 278.6 统计报表管理模块 279 系统安装说明 279.1 附加数据库 279.2 Java,Eclipse的安装 2710 心得与体会 281 相关技术简介1.1 SQL Server 2005简介SQL Server是一个全面的、集成的、端到端的数据解决方案,它为企业中的用户提供了一个安全、可靠和高效的平台用于企业数据管理和商业智能应用。

SQL Server 2005 为IT专家和信息工作者带来了强大的、熟悉的工具,同时减少了在从移动设备到企业数据系统的多平台上创建、部署、管理及使用企业数据和分析应用程序的复杂度。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
{ FILE *fp;
char fname[10];
int i,j,sum[Z+1]={0};
system("cls"); /*清屏命令*/
printf("您想计算哪个月?\n");
printf("请输入月份:"); /*实为输入一个文件名,这样可以进行各个月份的信息读入*/
for(i=0;i<Z;) /*用于存储商品编号*/
bianhao[i]=i++;
for(i=0;i<Z;i++)
printf("%3d",bianhao[i]);
for(i=0;i<Z;i++) /*对产品从高到低排序,选择法排序*/
for(i=0;i<R;i++) /*按K种产品对销售员排序,选择法3;1;j<R;j++)
if((x+bianhao[t])->shangpin[k]<(x+bianhao[j])->shangpin[k])/*调用职工各自对应的结构体内的产品数量*/ t=j;
for(i=0;i<Z;i++)
printf(" 产品%-7d%-1d\n",bianhao[i]+1,sum[i]);
printf("\n\n\n\t\t\t按任意键返回主菜单!");
getch();
fclose(fp); /*关闭读入的文件*/
}
void f4(data *x) /*输出统计报表*/
{ system("cls"); /*清屏命令*/
printf("\n\n");
printf("\t ┏━━━━━━━━━━━━主菜单━━━━━━━━━━┓\n");
printf("\t ┃ 1.计算上个月每个人每种产品的销售额 ┃\n");
printf("\t ┃ 2.按销售额对销售员进行排序,输出排序结果 ┃\n");
if(fread(x+i,sizeof(data),1,fp)!=1)
printf("读入信息出错!");
for(i=0;i<Z;i++) /*对各种商品求和*/
for(j=0;j<R;j++)
sum[i]=sum[i]+(x+j)->shangpin[i];
if(t!=i)
{ z=bianhao[i];
bianhao[i]=bianhao[t];
bianhao[t]=z;
}
}
printf("\t\t\t按%d产品对销售员排序为:\n",k+1);
printf("━━━━━━━━━━━━━━━━━━━━━\n");
{ FILE *fp;
char fname[10];
int i,j,sum[Z]={0},bianhao[Z]={0},z,t,k;
system("cls"); /*清屏命令*/
printf("您想计算哪个月的?\n");
printf("请输入月份:"); /*输入文件名,这样可以进行各个月份信息读入*/
for(i=0;i<R;) /*用于存储职工编号*/
bianhao[i]=i++;
printf("请输入按何种产品排序\n");
scanf("%d",&k);
k=k-1; /*便于与结构体中的数组值对应*/
system("cls"); /*清屏命令*/
printf("你要哪个月的?\n");
printf("请输入月份:"); /*输入文件名,这样可以进行各个月份信息读入*/
scanf("%s",fname);
strcat(fname,".dat");
if((fp=fopen(fname,"rb"))==NULL) /*打开文件*/
printf("\n\n\n\n\n\n\t\t\t保存成功,按任意键返回主菜单!");
getch();
}
void f2(data *x) /*按销售额对销售员进行排序,输出排序结果*/
{ FILE *fp;
char fname[10];
int i,k,j,t,bianhao[R]={0},z;
for(i=0;i<R;i++)
printf("\t\t\t第%d名是: 员工%d\n",i+1,bianhao[i]+1);
printf("\n\n\n\t\t\t按任意键返回上一主菜单!");
getch();
fclose(fp); /*关闭读入的文件*/
}
void f3(data *x) /*统计每种产品的总销售额,输出排序结果*/
scanf("%s",fname);
strcat(fname,".dat");
if((fp=fopen(fname,"rb"))==NULL) /*打开文件*/
{ printf("不能打开文件!!!\n");
exit(0);
}
for(i=0;i<R;i++) /*读出信息*/
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <stdlib.h>
#define Z 5
#define R 4 /*定义宏常量便于程序的一般化*/ /*R表示销售员个数*/
printf("\t ┃ 3.统计每种产品的总销售额,输出排序结果 ┃\n");
printf("\t ┃ 4.输出统计报表 ┃\n");
printf("\t ┃ 5.结束操作 ┃\n");
if(fread(x+i,sizeof(data),1,fp)!=1)
printf("读入信息出错!");
for(i=0;i<Z;i++) /*对各种商品求和*/
for(j=0;j<R;j++)
sum[i]=sum[i]+(x+j)->shangpin[i];
}
for(j=0;j<R;j++) /*对商品数量清零*/
for(t=0;t<Z;t++)
(x+j)->shangpin[t]=0;
printf("请输入:\n职工编号 产品编号 销售数量\n"); /*提示用户写入信息的格式*/
{ t=i;
for(j=i+1;j<Z;j++) /*产品变化时,产品编号也随之变化,便于输出*/
if(sum[t]<sum[j])
t=j;
if(t!=i)
{ k=sum[i];
sum[i]=sum[t];
sum[t]=k;
z=bianhao[i];
bianhao[i]=bianhao[t];
bianhao[t]=z;
}
}
printf("输出产品排序\n");
printf("产品编号 数量\n");
printf("━━━━━━━━━━━━━\n");
{ printf("不能打开文件!!!\n");
exit(0);
}
for(i=0;i<R;i++) /*读出信息*/
if(fread(x+i,sizeof(data),1,fp)!=1)
printf("读入信息出错!"); /*读入信息提示*/
for(j=0;hitkey!=27;j++)
{ scanf("%d%d%d",&i,&k,&s);
if(i>R||i<0||k>Z||k<0)
{ printf("信息错误!\n"); /*提示语,避免输入信息出错*/
continue;
}
else
(x+i-1)->shangpin[k-1]=(x+i-1)->shangpin[k-1]+s; /*统计各个人的各种产品的数量,-1为了和数组中的序号相匹配*/
scanf("%s",fname);
strcat(fname,".dat");
if((fp=fopen(fname,"rb"))==NULL) /*打开文件*/
{ printf("不能打开文件!!!\n");
exit(0);
}
for(i=0;i<R;i++) /*读出信息*/
相关文档
最新文档