数据库课程设计-医药销售管理系统

  • 格式:doc
  • 大小:271.00 KB
  • 文档页数:28

09信计2011-2012(一)《数据库原理及应用》课程设计设计题目医药销售管理系统设计时间2011.12.29至2012.1.4学生姓名学生学号所在班级指导教师医药销售管理系统一可行性性研究近年来,中国医药行业迅速发展,药店企业多业态经营,仓储式大型超市、中等规模超市、便利连锁综合发展。

随着规模的扩大,传统的医药管理已经不能适应发展的需要,很难在激烈的竞争中生存。

通过对从事医药产品的零售、批发等工作企业的深入调查,发现其业务主要包括企业药品销售、出入库管理、企业的财务、人事管理等。

医药管理是一项琐碎、复杂而又十分细致的工作。

手工进行企业日常的药品销售、出入库的工作,容易出现“开空单”的现象,且呆账、错账时有发生,而且费时费力。

本系统在设计中考虑和克服了上述问题,实现了企业管理工作的系统化、规范化和自动化。

二系统需求分析2.1.1 系统目标与要求要求本系统能够投入实际的使用并且满足基本的功能要求。

要求具有较高的可靠性、安全性和易维护性,具有较高的可移植性。

本系统实现了以下的功能:(1)基本信息模块:包括药品信息、员工信息、客户信息、供应商信息四个子模块。

(2)进货管理模块:包括入库登记、入库登记查询二个子模块。

(3)库房管理模块:包括库存查询、库存盘点、退货处理三个子模块。

(4)销售管理模块:包括销售登记、销售退货、销售报表查询三个子模块。

(5)财务统计模块:包括当日统计、当月统计二个子模块。

(6)系统维护模块:包括数据安全管理、操作员管理、权限设置三个模块。

说明:根据对现实中医药销售管理业务,将用户分为二类超级管理员(经理)、普通管理员(操作员)。

2.1.2 系统分析用户活动及活动图(1)经理主要参与活动有:①查询销售情况和财务状况以便了解本企业的经营状况,作出相应的决策;②管理员工,了解不同员工的上班时间和他的相关的业绩;③客户的管理,了解客户的数量,注销有问题的客户;④供应商的管理,了解供应信息,选择最合适的供应商。

(2)营业员主要活动有:①医药销售管理是指对药品信息的录入、更新、修改和删除;②查询药品信息,以了解是否有该药品和库存等信息;③销售药品,出库记录;④退还药品,入库记录;⑤现金收支是指对进出帐目的记录统计。

(3)顾客主要活动:①查询药品信息;②选购药品。

2.1.3 业务流程图2.2 系统逻辑方案系统分析的主要成果是系统的逻辑模型。

本系统的逻辑模型主要是以系统的数据流图和数据字典为主要描述工具。

即在无纸化网络考试系统管理方式和业务流程进行认真分析和研究的基础上,排除现有组织机构和业务分工所造成的信息障碍。

2.2.1 数据流程图(DFD):数据流图是组织中信息运动的抽象。

是在调研的基础上,从系统的科学性、管理的合理性、实际运动的可行性角度出发。

将信息处理功能和彼此之间的联系自顶向下,逐层分解,从逻辑上精确地描述系统应具有的数据加工功能、数据输入、数据输出、数据存储及数据来源和去向(外部实体)等项目。

在数据流程图中可以很清楚的看到数据的流向,药品信息的数据分别能够流向经理、员工和顾客。

药品销售信息的信息也流经理。

药品销售信息记录的是药品销售和退还的信息。

顾客表信息从顾客流出又可以流回到顾客和员工、经理。

2.2.2 数据字典(简称DD)绘制DFD,只是对数据处理和彼此之间的联系进行了说明。

为进一步明确数据的详细内容和数据加工过程,应将数据流图中的全部数据流及其组成部分的数据元素,数据存储,数据加工,通过数据字典描述清楚,以便于此后系统设计的进行。

这就需要开发人员编写详细的数据字典,来描述系统开发过程的细节。

下面列出本系统中的数据项、数据流、数据存储、加工处理和数据结构的数据字典。

数据字典可采用图表格式或较紧凑的记录格式描述,本文采用的是图表格式。

数据项的DD表列举如下:表2.1 药品编号的数据字典表2.2 药品名称表2.3 密码三数据库系统结构设计3.1软件系统总体结构设计软件系统总体结构设计的主要任务就是将整个系统合理的划分成各个功能模块,正确处理模块之间与模块内部的联系及它们之间的调用关系和数据联系,定义各模块的内部结构等,本系统的软件总体结构按分解-协调的原则,信息隐蔽抽象的原则,自顶向下的原则,一致性原则,面向用户的原则进行设计。

3.2数据存储的总体设计按用途分类可把本系统文件分成以下几种:(1)主文件:系统中的主文件是最重要的共享文件,主要存放具有固定值属性的数据。

它需要长期保存,并不断更新。

(2)处理文件:处理文件包含下一次更新文件所需要的全部记录,本系统中的处理文件如新闻登录日志文件、待审核项目信息文件。

3.3系统功能模块设计通过对系统的数据流图进行分析,进一步进行功能分解,直到分解成含义明确,功能单一的功能模块,从而得到系统的功能模块结构图。

3.4数据库详细设计3.4.1数据库设计数据库的设计是指对一个给定的应用环境,构造数据库模式,建立数据库及其应用系统,满足各种用户需求。

作为信息资源开发、管理和服务的一种有效的手段,数据库技术的应用已越来越广泛,从小型的单项事务处理系统到大型的信息系统大都用先进的数据库技术来保持系统数据的安全性、完整性和共享性。

对一个实际的系统来说,数据库表的设计在遵循数据库理论的同时,必须能用开发工具来实现用户在各方面提出的功能要求。

⑴ E-R图:在系统的数据库设计中,先要对系统分析得到的数据字典中的数据存储进行分析,分析各数据存储之间的关系,然后才能得出系统的关系模式。

可以采用E-R图的方法来进行数据结构分析,E-R设计方法是一种通过E-R图来描述现实世界信息结构的DB设计方法。

E-R图由实体、属性、联系三部分组成。

各分E-R 图说明如下:①经理E-R图:②供应商E-R图:③员工E-R图:④药品销售清单E-R图:⑤客户E-R图:E-R图:⑥药品⑦整体E-R图:⑵关系模式与码:药品信息(药品编号,药品名称,药品类别代号,售价,进价,库存量,供应商,有效期)外码:药品类别代号、供应商药品分类索引信息(药品类别代号,类别说明)员工信息(员工号,姓名,用户名,密码,职位,权限)客户信息(客户号,客户名称,联系人,联系方式,客户所在城市)供应商信息(供应商号,供应商名称,联系人,联系方式,供应商所在城市)药品销售信息(销售编码,销售日期,药品编码,药品名称,单价,数量,供应商,总额,销售员编码)外码:销售员编码、药品编码⑶关系模式优化:在上述关系模式中,每一个分量都是不可分割的数据项所以都符合第一范式;而且前四个关系模式都是单个属性作为码,没有任何非主属性对码部分函数依赖,在药品销售信息内虽由三个属性作为码,但也不存在非主性对码的部分函数依赖,所以上都符合第二范式;药品信息、药品类别索引、客户信息、供应商信息四个关系模式中都不存在非主属性对码的传递函数依赖,都属于第三范式。

在员工信息关系模式中,员工是按照权限分类的,职位不同权限也不同,这样该关系模式就存在了非主属性对码的传递依赖:职工号->职位,职位->权限,所以就将用员工信息分解为如下现个模式:①员工信息(员工号,姓名,用户名,用户口令,职位)②职位权限信息(职位,权限)本系统不考虑职工信息的管理,为了使销售员编号与销售员的职工号连系起来,并能通过职工姓名和职位来修改用户信息所以把员工的部分信息(职工号,姓名,职位)和经理(用户名,密码)合成了员工信息(员工号,姓名,用户名,密码,职位,权限)以便系统功能的实现,所以在此不采用模式分解。

药品销售信息中有大量的数据冗余,表达不明确,将其分解为如下两个模式:①药品销售主表(销售编码,销售日期,销售员编号,总金额)②药品销售子表(销售编码,销售日期,药品编码,药品名称,单价,数量,供应商)⑷数据库设计对上述E-R图所需的实体需要的几个关键表的设计如下:3.4.2 数据库的完整性和安全性⑴数据库的完整性数据库的完整性是指数据的正确性和相容性。

数据库管理系统(DBMS)用一定的机制来检查数据库中的数据是否满足规定的条件——完整性约束条件,数据的约束条件是语义的体现,将作为模式的一部分存入数据库中。

本系统中定义了表与表之间的联系有助于实现完整性规则,一般在程序中实现具体的完整性控制。

实体完整性例如:CREATE TABLE MedInfor/*创建药品信息表*/(MedicineCode char(6) constraint M_PRIM PRIMARY KEY,MedicineName varchar(8) NOT NULL,MedKindeCode char(10) FOREIGN KEY REFERENCES MedID(MedKindeCode),Price Money(8),ListPrice Money(8),Number Int(4),FirmCode char(10) FOREIGN KEY REFERENCES FirmInfor(FirmCode),Userfulllife Datetime)参照完整性例如:create table sellMain/*创建医药销售主表*/(SaleNo int constraint SM_PRIM PRIMARY KEY,WorkNo char(10) FOREIGN KEY REFERENCES WorkInfor(WorkNo), SaleDate DateTime,Amount Money)⑵数据库的安全性数据库的安全性是指保护数据库以防止不合法的使用所造成的数据泄漏、更改或破坏。

在数据库系统中,大量的数据集中存放,而且为许多用户直接共享,是宝贵的信息资源,系统的安全保护措施就显得更为重要,它保护数据库防止恶意的破坏和非法的存取。

本系统包括数据库的安全和服务器的安全。

采用管理员表示和鉴定的方法实现数据库的安全,此安全管理措施并不在前台开发工具中实现,而是在后台数据库中实现。

在登录数据库时,系统让管理员户表示自己的身份,不同的管理员权限不同,系统进行核实,鉴别此管理员是否为合法用户,若是,系统进一步核实用户,通常要求用户输入口令,系统和对用户口令以鉴别用户身份。

服务器的安全也是通过用户在登录服务器时输入合法的用户名和密码来实现的。

这是一种简单可行的方法,实现起来比较方便。

没有采用更加复杂的系统安全管理措施是因为本管理系统一般是应用在校园网中,采用安全管理措施主要是为了防止没有修改权限的用户无意间修改了数据,因此采用用户标识和鉴定的安全管理措施就能够保障数据库的安全性。

四数据库的运行(SQL Server2000语句完成)4.1创建医药销售管理系统create database MedicalManagerSystem/*创建医药销售管理系统*/use MedicalManagerSystem4.2创建药品类别索引信息表create table MedID//创建药品类别索引信息表(MedKindeCode char(10) constraint MI_PRI PRIMARY KEY,KindExplanation varchar(12) NOT NULL)4.3建立存储过程向表中插入、修改、删除数据⑴插入数据的存储过程create proc MedID_proc@MedKindeCode char(10),@KindExplanation varchar(12)asinsert into MedID (MedKindeCode,KindExplanation) values(@MedKindeCode ,@KindExplanation )exec MedID_proc '0001','口腔溃疡'exec MedID_proc '0002','感冒'exec MedID_proc '0003','发烧'exec MedID_proc '0004','拉肚子'exec MedID_proc '0005' ,'外伤'其余略⑵删除数据的存储过程create proc MedID_delete_proc@MedKindeCode char(10)asdelete from MedIdwhere MedKindeCode=@MedKindeCodeexec MedID_delete_proc '0002'其余略⑶修改数据的存储过程create proc MedID_update_proc@MedKindeCode char(10),@KindExplanation varchar(12),@MedKindeCode1asupdate MedIDset MedKindeCode=@MedKindeCode,KindExplanation=@KindExplanation where MedKindeCode=@MedKindeCode1其余略4.4建立存储过程实现单表查询/*建立名为“单表查询1”的存储过程,用来查询某种药品的信息*/create proc 单表查询1@MedicineCode char(6)ASselect *from MedInforwhere MedicineCode=@MedicineCode建立存储过程实现连接查询/*建立名为“连接查询1”的存储过程,用来查询某个药品名称对应的药品类型的信息*/create proc 连接查询1@MedicineName varchar(8)asselect MedicineName ,KindExplanationfrom MedInfor,MedIDwhere MedID.MedKindeCode=MedInfor.MedKindeCode andMedicineName=@MedicineName/建立存储过程实现嵌套查询/*建立名为“嵌套查询1”的存储过错,用来查询某类药品的销售量*/create proc 嵌套查询1@KindExplanation varchar(12)asselect Numberfrom sellChildwhere MedicineCode In(select MedicineCodefrom MedIDwhere KindExplanation=@KindExplanation) /*建立名为“嵌套查询2”的存储过错,用来查询某个供应商提供的商品*/ create proc 嵌套查询2@FirmName varchar(16)asselect MedicineNamefrom MedInforwhere FirmCode In (select FirmCodefrom FirmInforwhere FirmName=@FirmName)建立存储过程实现集合查询/*建立名为“集合查询1”的存储过错,用来查询提供某类商品的供应商数*/ create proc 集合查询1@MedicineName varchar(8)asselect avg(FirmCode)from FrimInforwhere FirmCode in(select FirmCodefrom MedInfor,FrimInforwhere MedInfor.FirmCode=FrimInfor.FirmCode andMedicineName=@MedicineName)4.5视图建立由供应商信息表“FirmInfor”建立一个视图,该视图由供应商信息表的所有列构成*/create view 供应商信息(供应商编码,供应商名称,联系人,联系电话,所在城市)asselect* from FirmInfor4.6建立INSERT触发器/*建立INSERT触发器*/create trigger MedID_insert on MedIDfor insertas if(select count(*)from MedID_med,insertedwhere MedID_med.MedKindeCode=inserted.MedKindeCode)=0rollback transaction4.7建立DELETE触发器create trigger delete_MedID on MedIDfor deleteasselect* from MedIDdeclare @MedKindeCode char(10)select @MedKindeCode=MedKindeCode from deleteddelete from MedIDwhere MedKindeCode=@MedKindeCodeselect*from MedID4.8建立UPDATE触发器create trigger MedID_update on MedIDfor updateasif update(MedKindeCode)beginraiserror('you can not modify this column',16,1)rollback transactionend五数据库系统程序医药销售管理系统SQL语句,如下:create database MedicalManagerSystem/*创建医药销售管理系统*/use MedicalManagerSystemcreate table MedID/*创建药品类别索引信息*/(MedKindeCode char(10) constraint MI_PRI PRIMARY KEY,KindExplanation varchar(12) NOT NULL)create table MedInfor/*创建药品信息表*/(MedicineCode char(6) constraint M_PRIM PRIMARY KEY,MedicineName varchar(8) NOT NULL,MedKindeCode char(10) FOREIGN KEY REFERENCES MedID(MedKindeCode),Price Money,ListPrice Money,Number Int,FirmCode char(10) FOREIGN KEY REFERENCES FirmInfor(FirmCode),Userfulllife Datetime)create table GueInfor/*创建客户信息表*/(GuestCode char(10) constraint G_PRIM PRIMARY KEY,GuestName varchar(16) NOT NULl,GLink varchar(12),GLinkTell varchar(11),City varchar(8))create table FirmInfor/*创建供应商信息表*/(FirmCode char(10) constraint F_PRIM PRIMARY KEY,FirmName varchar(16) NOT NULL,Link varchar(12),LinkTell varchar(11),City varchar(8))create table WorkInfor/*创建员工信息表*/(WorkNo char(10) constraint W_PRIM PRIMARY KEY,Name varchar(12),UserRegName char(6) NOT NULL,Password char(10) NOT NULL,Position char(10),Power Int)create table sellMain/*创建医药销售主表*/(SaleNo int constraint SM_PRIM PRIMARY KEY,WorkNo char(10) FOREIGN KEY REFERENCES WorkInfor(WorkNo),SaleDate DateTime,Amount Money)create table sellChild/*创建医药销售子表*/(SaleNo int constraint SC_PRIM PRIMARY KEY,MedicineCode char(6) FOREIGN KEY REFERENCES MedInfor(MedicineCode),MedicineName varchar(32) NOT NULL,Price Money,Number Int,Uint char(8),Amount Money)/*插入数据的存储过程*/create proc MedID_proc@MedKindeCode char(10),@KindExplanation varchar(12)asinsert into MedID (MedKindeCode,KindExplanation) values(@MedKindeCode ,@KindExplanation )exec MedID_proc '0001','口腔溃疡'exec MedID_proc '0002','感冒'exec MedID_proc '0003','发烧'exec MedID_proc '0004','拉肚子'exec MedID_proc '0005' ,'外伤'create proc MedInfor_proc@MedicineCode char(6),@MedicineName varchar(8),@MedKindeCode char(10),@Price money,@ListPrice money,@Number int,@FirmCode char(10),@Userfulllife Datetimeasinsert into MedInfor(MedicineCode ,MedicineName,MedKindeCode,Price,ListPrice, Number,Supplicer,Userfulllife)values(@MedicineCode,@MedicineName,@MedKindeCode,@Price,@ListPrice,@Number,@FirmCode,@Userfulllife)exec MedInfor_proc '1001','板蓝根','0002',5,3,'100','014','2010-12-5'exec MedInfor_proc '2002','四季感康','0002',14,10.5,'150','051','2010-12-12'exec MedInfor_proc '2003','银黄颗粒','0002',12,8.8, '120 ','014','2012-10-6'exec MedInfor_proc '2004','感冒清热软胶囊','0002',17,12, '150','015', '2011-11-1' exec MedInfor_proc '3001','阿斯匹林','0003',15,11,'100','014','2010-12-1'exec MedInfor_proc '3002','布洛芬','0003',21,17.5,'120','051','2010-6-5'exec MedInfor_proc '4001','泻利挺','0004',25,20,'120','015','2012-10-2'exec MedInfor_proc '4002','诺氟沙星胶囊','0004',15,12,'100','015','2012-9-16' exec MedInfor_proc '5001','碘酒','0005',5,2.5,'50' ,'051','2012-10-12'exec MedInfor_proc '5002','创口贴','0005',2,1,'250','014','2015-5-1'create proc GueInfor_proc@GuestCode char(10),@GuestName varchar(16),@GLink varchar(12),@GLinkTell varchar(11),@City varchar(8)asinsert into GueInfor(GuestCode,GuestName,GLink,GLinkTell,City) values(@GuestCode,@GuestName,@GLink,@GLinkTell,@City)exec GueInfor_proc '015112','zhangsan','xiaozhang','668401','jiaxing'exec GueInfor_proc '065114','lisi','xiaofang','614425','yuyao'exec GueInfor_proc '052114','wangwu','xiaowu','659024','wenzhou'exec GueInfor_proc '043115','zhaoliu','xiaowu','615874','shangyu'exec GueInfor_proc '014221','awu','xiaozhang','651283','linan'exec GueInfor_proc '025471','asha','xiaofang','691472','dongyang'create proc FirmInfor_proc@FirmCode char(10),@FirmName varchar(16),@Link varchar(12),@LinkTell varchar(11),@City varchar(8)asinsert into FirmInfor(FirmCode,FirmName,Link,LinkTell,City)values(@FirmCode,@FirmName,@Link,@LinkTell,@City)exec FirmInfor_proc '015','yangshengtang','xiaotai','681472','huzhou'exec FirmInfor_proc '014','baozhilin','zhangqing','658421','deqing'exec FirmInfor_proc '051','pinmingdayaofang','oudan','65417','xiangshan'create proc WorkInfor_proc@WorkNo char(10),@Name varchar(12),@UserRegName char(6),@Passwordchar(10),@Position char(10),@Power Intasinsert into WorkInfor(WorkNo,Name,UserRegName,Password,Position,Power) values(@WorkNo,@Name,@UserRegName,@Password,@Position,@Power)exec WorkInfor_proc '075101','ZKL','zkl01','456789','jingli',''exec WorkInfor_proc '075201','ZJM','zjm01','123789','dongshi',''exec WorkInfor_proc '075215','WMX','wmx05','147258','xiaomi',''exec WorkInfor_proc '075120','ZZW','zzm20','123456','buzhang',''create proc sellMain_proc@SaleNo int,@WorkNo char(10),@SaleDate DateTime,@Amount Moneyasinsert into sellMain(SaleNo,WorkNo,SaleDate,Amount)values(@SaleNo,@WorkNo,@SaleDate,@Amount)exec sellMain_proc '12','075101','2009-1-1',1000exec sellMain_proc '13','075201','2009-1-1',1500exec sellMain_proc '15','075215','2009-1-1',800exec sellMain_proc '20','075120','2009-1-1',1200alter proc sellChild_proc@SaleNo int,@MedicineCode char(6),@MedicineName varchar(32),@Price Money,@Number Int,@Uint char(8),@Amount Moneyasinsert into sellChild(SaleNo,MedicineCode,MedicineName,Price,Number,Uint,Amount) values(@SaleNo,@MedicineCode,@MedicineName,@Price,@Number,@Uint,@Am ount)exec sellChild_proc '13','1001','板蓝根',5,'20','bao',100exec sellChild_proc '15','2002','四季感康',14,'15','he',210exec sellChild_proc '20','3001','阿斯匹林',15,'20','he',300/*删除数据的存储过程*/create proc MedID_delete_proc@MedKindeCode char(10)asdelete from MedIdwhere MedKindeCode=@MedKindeCodeexec MedID_delete_proc '0002'create proc MedInfor_delete_proc@MedicineName varchar(8)asdelete from MedInforwhere MedicineName=@MedicineName create proc GueInfor_delete_proc@GuestCode char(10)asdelete from GueInforwhere GuestCode=@GuestCodecreate proc FirmInfor_delete_proc@FirmCode char(10)asdelete from FirmInforwhere FirmCode=@FirmCodecreate proc WorkInfor_delete_proc@WorkNo char(10)asdelete from WorkInforwhere WorkNo=@WorkNocreate proc sellMain_delete_proc@SaleNo intasdelete from sellMainwhere SaleNo=@SaleNocreate proc sellChild_delete_proc@SaleNo intasdelete from sellChildwhere SaleNo=@SaleNo/*修改数据的存储过程*/create proc MedID_update_proc@MedKindeCode char(10),@KindExplanation varchar(12),@MedKindeCode1 char(10)asupdate MedIDset MedKindeCode=@MedKindeCode,KindExplanation=@KindExplanationwhere MedKindeCode=@MedKindeCode1exec MedID_update_proc '0002','感冒','0001'create proc MedInfor_update_proc@MedicineCode1 char(6),@MedicineName varchar(8),@MedKindeCode char(10),@Price money,@ListPrice money,@Number int,@FirmCode char(10),@Userfulllife Datetime,@MedicineCode char(6)asupdate MedInforsetMedicineCode=@MedicineCode1,MedicineName=@MedicineName,MedKindeCode =@MedKindeCode,Price=@Price,ListPrice=@ListPrice,Number=@Number,FirmCode=@FirmCode,Userfulllife=@Us erfulllife,MedicineCode=@MedicineCodewhere MedKindeCode=@MedKindeCodecreate proc GueInfor_update_proc@GuestCode1 char(10),@GuestName varchar(16),@GLink varchar(12),@GLinkTell varchar(11),@City varchar(8),@GuestCode char(10)asupdate GueInforsetGuestCode=@GuestCode1,GuestName=@GuestName,GLink=@GLink,GLinkTell= @GLinkTell,City=@Citywhere GuestCode=@GuestCodecreate proc FirmInfor_update_proc@FirmCode1 char(10),@FirmName varchar(16),@Link varchar(12),@LinkTell varchar(11),@City varchar(8),@FirmCode char(10)asupdate FirmInforsetFirmCode=@FirmCode1,FirmName=@FirmName,Link=@Link,LinkTell=@LinkTell ,City=@Citywhere FirmCode=@FirmCodecreate proc WorkInfor_update_proc@WorkNo1 char(10),@Name varchar(12),@UserRegName char(6),@Password char(10),@Position char(10),@Power Int,@WorkNo char(10)asupdate WorkInforsetWorkNo=@WorkNo1,Name=@Name,UserRegName=@UserRegName,Password=@ Password,Position=@Position,Power=@Powerwhere WorkNo=@WorkNocreate proc sellMain_update_proc@SaleNo1 int,@WorkNo char(10),@SaleDate DateTime,@Amount Money,@SaleNo intasupdate sellMainsetSaleNo=@SaleNo1,WorkNo=@WorkNo,SaleDate=@SaleDate,Amount=@Amount where SaleNo=@SaleNocreate proc sellChild_update_proc@SaleNo1 int,@MedicineCode char(6),@MedicineName varchar(32),@Price Money,@Number Int,@Uint char(8),@Amount Money,@SaleNo intasupdate sellChildsetSaleNo=@SaleNo1,MedicineCode=@MedicineCode,MedicineName=@MedicineNa me,Price=@Price,Number=@Number,Amount=@Amountwhere SaleNo=@SaleNo/*建立存储过程实现单表查询*//*建立名为“单表查询1”的存储过程,用来查询某种药品的信息*/create proc 单表查询1@MedicineCode char(6)ASselect *from MedInforwhere MedicineCode=@MedicineCode/*建立名为“单表查询2”的存储过程,用来查询某个客户的信息*/create proc 单表查询2@GuestCode char(10)ASselect *from GueInforwhere GuestCode=@GuestCode/*建立名为“单表查询3”的存储过程,用来查询某个员工的信息*/create proc 单表查询3@WorkNo char(10)ASselect *from WorkInforwhere WorkNo=@WorkNo/*建立名为“单表查询4”的存储过程,用来查询某个供应商的信息*/create proc 单表查询4@FirmCode char(10)ASselect *from FirmInforwhere FirmCode=@FirmCode/*建立名为“单表查询5”的存储过程,用来查询某个药品代码对应的药品类型的信息*/create proc 单表查询5@MedKindeCode char(10)ASselect *from MedIDwhere MedKindeCode=@MedKindeCode/*建立存储过程实现连接查询*//*建立名为“连接查询1”的存储过程,用来查询某个药品名称对应的药品类型的信息*/create proc 连接查询1@MedicineName varchar(8)asselect MedicineName ,KindExplanationfrom MedInfor,MedIDwhere MedID.MedKindeCode=MedInfor.MedKindeCode andMedicineName=@MedicineName/*建立名为“连接查询2”的存储过程,用来查询某个供应商提供的药品类型*/ create proc 连接查询2@FirmName varchar(16)asselect FirmName,KindExplanationfrom MedInfor,MedID,FirmInforwhere MedID.MedKindeCode=MedInfor.MedKindeCode andMedInfor.FirmCode=FirmInfor.FirmCode andFirmName=@FirmName/*建立名为“连接查询3”的存储过程,用来查询某个销售员销售某种药品的数量*/create proc 连接查询3@Name varchar(12),@MedicineName varchar(8)asselect name ,MedInfor.MedicineName,sellChild.Numberfrom WorkInfor,sellChild,MedInfor,sellMainwhere WorkInfor.WorkNo=sellMain.WorkNo andsellMain.SaleNo=sellChild.SaleNo andsellChild.MedicineCode=MedInfor.MedicineCode andname=@Name andMedInfor.MedicineName=@MedicineName/*建立名为“连接查询4”的存储过程,用来查询某类药品的销售量*/create proc 连接查询4@KindExplanation varchar(12)asselect KindExplanation,sellChild.Numberfrom sellChild,MedID,MedInforwhere MedID.MedKindeCode=MedInfor.MedKindeCode andMedInfor.MedicineCode=sellChild.MedicineCode andKindExplanation=@KindExplanation/*建立名为“连接查询5”的存储过程,用来查询某个员工销售的药品类型*/ create proc 连接查询5@Name varchar(12)asselect Name,KindExplanationfrom sellChild,MedID,MedInfor,sellMain,WorkInforwhere MedInfor.MedicineCode=sellChild.MedicineCode andMedID.MedKindeCode=MedInfor.MedKindeCode andWorkInfor.WorkNo=sellMain.WorkNo andsellMain.SaleNo=sellChild.SaleNo andName=@Name建立存储过程实现嵌套查询/*建立名为“嵌套查询1”的存储过错,用来查询某类药品的销售量*/create proc 嵌套查询1@KindExplanation varchar(12)asselect Numberfrom sellChildwhere MedicineCode In(select MedicineCodefrom MedIDwhere KindExplanation=@KindExplanation)/*建立名为“嵌套查询2”的存储过错,用来查询某个供应商提供的商品*/ create proc 嵌套查询2@FirmName varchar(16)asselect MedicineNamefrom MedInforwhere FirmCode In (select FirmCodefrom FirmInforwhere FirmName=@FirmName)/*建立存储过程实现集合查询*//*建立名为“集合查询1”的存储过错,用来查询提供某类商品的供应商数*/ create proc 集合查询1@MedicineName varchar(8)asselect avg(FirmCode)from FrimInforwhere FirmCode in(select FirmCodefrom MedInfor,FrimInforwhere MedInfor.FirmCode=FrimInfor.FirmCode andMedicineName=@MedicineName)/*建立名为“集合查询2”的存储过错,用来查询药品种类数*/create proc 集合查询2asselect count(MedKindeCode)from MedID/*视图建立*//*1,由药品类别表“MedID”建立一个视图,该视图由药品类别表的所有列构成*/create view 药品类别(药品类别代码,类别说明)asselect* from MedID/*2,由客户信息表“GueInfor”建立一个视图,该视图由客户信息表的所有列构成*/create view 客户信息(客户编码,客户名称,联系人,联系电话,所在城市)asselect* from GueInfor/*3,由供应商信息表“FirmInfor”建立一个视图,该视图由供应商信息表的所有列构成*/create view 供应商信息(供应商编码,供应商名称,联系人,联系电话,所在城市)asselect* from FirmInfor/*建立INSERT触发器*/create trigger MedID_insert on MedIDfor insertas if(select count(*)from MedID_med,insertedwhere MedID_med.MedKindeCode=inserted.MedKindeCode)=0rollback transaction/*建立DELETE触发器*/create trigger delete_MedID on MedIDfor deleteasselect* from MedIDdeclare @MedKindeCode char(10)select @MedKindeCode=MedKindeCode from deleteddelete from MedIDwhere MedKindeCode=@MedKindeCodeselect*from MedID*/建立UPDATE触发器*/create trigger MedID_update on MedIDfor updateasif update(MedKindeCode)beginraiserror('you can not modify this column',16,1)rollback transactionend六总结这次的课程设计可以说看起来比较容易,真的做起来却困难重重,深刻体会到要做好一个项目,真的不容易!本次课程设计调查从事医药产品的零售、批发等工作的企业,根据其具体情况,设计医药销售管理系统。