数据库课程设计商品进销存管理系统.docx
《数据库课程设计商品进销存管理系统.docx》由会员分享,可在线阅读,更多相关《数据库课程设计商品进销存管理系统.docx(30页珍藏版)》请在冰豆网上搜索。
数据库课程设计商品进销存管理系统
课程设计
2008年9月23日
一.设计要求
1.信息要求
本系统至少应该包含超市所有货物管理相关的基本信息,包括进货信息和销售信息等。
它们都应该包括商品货物的基本信息(如员商品编号、商品名称、规格、产地、单位、进价、批发价、零售价等)和客户的基本信息(如客户编号、客户名称、联系人、联系电话、地址、客户信箱、银行帐号等)。
2.功能要求
本系统的基本功能要求如下:
进货商品的信息维护(包括简单查询、修改、删除和添加等功能);
销售商品的信息维护(包括简单查询、修改、删除和添加等功能);
客户的信息维护(包括简单查询、修改、删除和添加等功能);
系统用户的信息维护(包括简单查询、修改、删除、添加和权限分配等功能);
系统信息备份、还原;
二.软件环境及开发工具
1.个人电脑及WinXPPro
2.Delphi7.0
3.SQLServer2000
三.需求分析
对该超市销售管理系统进行深入的业务流程分析后画出数据流图。
由数据流图图可以看出来,每个操作员查看信息前必须先登录这个管理系统,每个操作员的信息保存在操作员信息表中。
用户登录系统后可以查看商品进销管理信息和客户信息,也可以通过查询选择自己希望得到的信息。
四.数据库设计
1.概念设计
根据需求分析的结果,得到的用ER图表示的概念设计结果如下图所示
2.逻辑设计
根据分析,整个销售系统系统需要的数据表如下:
商品信息:
商品编号、商品名称、规格、产地、单位、进价、批发价、零售价等;
客户信息:
客户编号、客户名称、联系人、联系电话、地址、客户信箱、银行帐号等;
操作员信息:
操作员编号、操作员姓名、操作员密码、操作员级别等;
销售信息:
销售号、客户编号、客户名、商品编号、商品名称、单价、数量、金额、销售时间等。
五.系统设计
由于这个超市销售信息管理系统是一个比较小型的数据库系统,只需要储存文本信息,都是小字段的问题,作为一个小型的数据库系统,数据量最多在百至千条左右,故采用微软的SQLServer作为后台数据库,使用SQL语言进行操作。
操作员信息表,包括了操作员编号、操作员姓名、操作员密码和操作员级别,其中操作员编号是主码:
商品信息表,商品编号、商品名称、规格、产地、单位、进价、批发价、零售价等,其中商品编号是主码:
客户信息表,包括客户编号、客户名称、联系人、联系电话、地址、客户信箱、银行帐号等。
其中客户编号是主码:
销售信息表,包括销售号、客户编号、客户名、商品编号、商品名称、单价、数量、金额、销售时间等,其中销售号是主码:
库存信息表,包括商品编号、商品名称、库存数量、库存金额等,其中商品编号是主码:
六.系统操作说明和运行结果
打开Project.exe,出现登陆界面:
输入正确用户名和密码后进入系统,否则出现错误提示:
系统主界面:
商品信息管理界面:
客户信息管理界面:
操作员信息管理界面:
销售查询界面:
销售管理界面:
库存量调整界面:
七.程序清单
由于系统是图形化的信息管理系统,故使用Delphi实现。
程序清单过于冗长,在此仅列出其中关键部分。
1.用户登录部分:
procedureTForm1.BitBtn1Click(Sender:
TObject);
var
username,userpass,sqlstr:
string;
begin
username:
=trim(edit1.Text);
userpass:
=trim(edit2.Text);
sqlstr:
='select*from操作员信息表where(操作员姓名='''+username+''')and(操作员密码='''+userpass+''')';
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add(sqlstr);
adoquery1.Open;
ifadoquery1.RecordCount>0then
begin
self.Visible:
=false;
b:
=true;
application.CreateForm(Tmainn,mainn);
mainn.ShowModal;
mainn.Free;
close;
end
else
begin
ifi<3then
begin
Application.MessageBox('用户名称或密码不正确,请重新输入。
','提示',0+64);
Edit1.Clear;
Edit2.Clear;
Edit1.SetFocus;
Inc(i);
end
else
begin
Application.MessageBox('对不起,您无权使用本系统。
','提示',0+64);
Application.Terminate;
end;
end;
end;
procedureTForm1.BitBtn2Click(Sender:
TObject);
begin
close;
end;
procedureTForm1.FormClose(Sender:
TObject);
begin
ifb=falsethen
application.Terminate;
end;
procedureTForm1.FormCreate(Sender:
TObject);
begin
end;
end.
2.商品信息管理代码:
var
spinfor:
Tspinfor;
implementation
{$R*.dfm}
proceduretspinfor.editvalue;
begin
edit1.Text:
=inttostr(adoquery1.fieldbyname('商品编号').Value);
edit2.Text:
=adoquery1.fieldbyname('商品名称').Value;
edit3.Text:
=adoquery1.fieldbyname('规格').Value;
edit4.Text:
=adoquery1.fieldbyname('产地').Value;
edit5.Text:
=adoquery1.fieldbyname('单位').Value;
edit6.Text:
=floattostr(adoquery1.fieldbyname('进价').Value);
edit7.Text:
=floattostr(adoquery1.fieldbyname('批发价').Value);
edit8.Text:
=floattostr(adoquery1.fieldbyname('零售价').Value);
end;
procedureTspinfor.formshow(Sender:
TObject);
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select*from商品基础信息表');
adoquery1.Open;
adoquery1.First;
editvalue;
bitbtn4.Enabled:
=false;
end;
proceduretspinfor.clearedit;
begin
edit1.Clear;
edit2.Clear;
edit3.Clear;
edit4.Clear;
edit5.Clear;
edit6.Clear;
edit7.Clear;
edit8.Clear;
end;
procedureTspinfor.BitBtn1Click(Sender:
TObject);
begin
ifnotadoquery1.bofthen
begin
adoquery1.Prior;
self.editvalue;
end
else
bitbtn1.Enabled:
=false;
bitbtn2.Enabled:
=true;
end;
procedureTspinfor.BitBtn2Click(Sender:
TObject);
begin
ifnotadoquery1.Eofthen
begin
adoquery1.Next;
editvalue;
end
else
bitbtn2.Enabled:
=false;
bitbtn1.Enabled:
=true;
end;
procedureTspinfor.BitBtn3Click(Sender:
TObject);
vari:
integer;
begin
clearedit;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('selectmax(商品编号)asssfrom商品基础信息表');
adoquery1.Open;
i:
=adoquery1.FieldByName('ss').Value+1;
edit1.Text:
=inttostr(i);
edit2.SetFocus;
bitbtn4.Enabled:
=true;
end;
procedureTspinfor.BitBtn4Click(Sender:
TObject);
begin
if(edit1.Text<>'')and(edit2.Text<>'')and(edit3.Text<>'')and(edit4.Text<>'')and
(edit5.Text<>'')and(edit6.Text<>'')and(edit7.Text<>'')and(edit8.Text<>'')then
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('insert商品基础信息表values(:
a,:
b,:
c,:
d,:
e,:
f,:
g,:
h)');
adoquery1.Parameters.ParamByName('a').Value:
=strtoint(edit1.Text);
adoquery1.Parameters.ParamByName('b').Value:
=edit2.Text;
adoquery1.Parameters.ParamByName('c').Value:
=edit3.Text;
adoquery1.Parameters.ParamByName('d').Value:
=edit4.Text;
adoquery1.Parameters.ParamByName('e').Value:
=edit5.Text;
adoquery1.Parameters.ParamByName('f').Value:
=strtofloat(edit6.Text);
adoquery1.Parameters.ParamByName('g').Value:
=strtofloat(edit7.Text);
adoquery1.Parameters.ParamByName('h').Value:
=strtofloat(edit8.Text);
adoquery1.ExecSQL;
showmessage('thesaveoperationissucceed!
!
!
');
self.formshow(sender);
end
else
showmessage('pleasefillintheblankcompletely!
!
!
');
end;
procedureTspinfor.BitBtn5Click(Sender:
TObject);
begin
if(edit1.Text<>'')and(edit2.Text<>'')and(edit3.Text<>'')and(edit4.Text<>'')and
(edit5.Text<>'')and(edit6.Text<>'')and(edit7.Text<>'')and(edit8.Text<>'')then
begin
adoquery1.Edit;
adoquery1.fieldbyname('商品编号').Value:
=strtoint(edit1.Text);
adoquery1.fieldbyname('商品名称').Value:
=edit2.Text;
adoquery1.fieldbyname('规格').Value:
=edit3.Text;
adoquery1.fieldbyname('产地').Value:
=edit4.Text;
adoquery1.fieldbyname('单位').Value:
=edit5.Text;
adoquery1.fieldbyname('进价').Value:
=strtofloat(edit6.Text);
adoquery1.fieldbyname('批发价').Value:
=strtofloat(edit7.Text);
adoquery1.fieldbyname('零售价').Value:
=strtofloat(edit8.Text);
adoquery1.Post;
showmessage('theamendoperationissucceed!
!
!
');
end
else
showmessage('pleasefillintheblankcompletely!
!
!
');
end;
procedureTspinfor.BitBtn6Click(Sender:
TObject);
begin
ifedit1.Text<>''then
begin
ifapplication.MessageBox('doyoureallywanttodeletetheitem?
?
','hint',mb_yesno)=id_yesthen
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('deletefrom商品基础信息表where商品编号=:
a');
adoquery1.Parameters.ParamByName('a').Value:
=strtoint(edit1.Text);
adoquery1.ExecSQL;
showmessage('thedeleteoperationissucceed!
!
!
');
self.formshow(sender);
end
end
else
showmessage('pleasefillinthecommoditynumberblank!
!
!
');
end;
procedureTspinfor.BitBtn7Click(Sender:
TObject);
begin
self.formshow(sender);
end;
procedureTspinfor.Panel3Click(Sender:
TObject);
begin
end;
end.
3.销售管理代码:
procedureTForm6.FormShow(Sender:
TObject);
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select*from销售表');
adoquery1.Open;
bitbtn2.Enabled:
=false;
end;
procedureTForm6.BitBtn1Click(Sender:
TObject);
vari:
integer;
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('selectmax(销售号)asssfrom销售表');
adoquery1.Open;
i:
=adoquery1.FieldByName('ss').Value+1;
edit1.Text:
=inttostr(i);
edit2.SetFocus;
self.FormShow(sender);
bitbtn2.Enabled:
=true;
end;
procedureTForm6.BitBtn2Click(Sender:
TObject);
begin
if(edit1.Text<>'')and(edit2.Text<>'')and(edit3.Text<>'')and(edit4.Text<>'')and
(edit5.Text<>'')and(edit6.Text<>'')and(edit7.Text<>'')and(edit8.Text<>'')
then
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('insert销售表values(:
a,:
b,:
c,:
d,:
e,:
f,:
g,:
h,:
i)');
adoquery1.Parameters.ParamByName('a').Value:
=strtoint(edit1.Text);
adoquery1.Parameters.ParamByName('b').Value:
=strtoint(edit2.Text);
adoquery1.Parameters.ParamByName('c').Value:
=edit3.Text;
adoquery1.Parameters.ParamByName('d').Value:
=strtoint(edit4.Text);
adoquery1.Parameters.ParamByName('e').Value:
=edit5.Text;
adoquery1.Parameters.ParamByName('f').Value:
=strtofloat(edit6.Text);
adoquery1.Parameters.ParamByName('g').Value:
=strtofloat(edit7.Text);
adoquery1.Parameters.ParamByName('h').Value:
=strtofloat(edit8.Text);
adoquery1.Parameters.ParamByName('i').Value:
=datetimepicker1.Date;
adoquery1.ExecSQL;
showmessage('thesaveoperationissucceed!
!
!
');
self.formshow(sender);
end
else
showmessage('pleasefillintheblankcompletely!
!
!
');
end;
procedureTForm6.BitBtn3Click(Sender:
TObject);
begin
if(edit1.Text<>'')and(edit2.Text<>'')and(edit3.Text<>'')and(edit4.Text<>'')and
(edit5.Text<>'')and(edit6.Text<>'')and(edit7.Text<>'')and(edit8.Text<>'')
then
begin
ifapplication.MessageBox('doyoureallywanttoamendtheitem','hint',mb_yesno)=id_yesthen
begin
adoquery1.Edit;
adoquery1.fieldbyname('销售号').Value:
=strtoint(edit1.Text);
adoquery1.fieldbyname('客户编号').Value:
=strtoint(edit2.Text);
adoquery1.fieldbyname('客户名').Value:
=edit3.Text;
adoquery1.fieldbyname('商品编号').Value:
=strtoint(edit4.Text);
adoquery1.fieldbyname('商品名称').Value:
=edit5.Text;
adoquery1.fieldbyname('单价').Value:
=strtofloat(edit6.Text);
adoquery1.fieldbyname('数量').Value:
=strtofloat(edit7.Text);
adoquery1.fieldbyname('金额').Value:
=strtofloat(edit8.Text);
adoquery1.fieldbyname('销售时间').Value:
=datetimepicker1.Date;
adoquery1.Post;
self.formshow(sender);
showmessage('theamendoperationissucceed!
!
!
');
end
end
else
showmessage('pleasefillintheblankcompletely!
!
!
');
end;
procedureTForm6.BitBtn4Click(Sender:
TObject);
begin
ifedit1.Text<>''then
begin
ifapplication.MessageBox('doyoureallywanttodeletetheitem','hint',mb_yesno)=id_yesthen
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('deletefrom销售表where销售号=:
a');
adoquery1.Parameters.ParamByName('a').Value:
=strtoint(edit1.Text);
adoquery1.ExecSQL;
self.formshow(sender);
end
end
else
showmessage('pleasefillinthesellnumberblank!
!
!
');
end;
procedureTForm6.BitBtn5Click(Sender:
TObject);
begin
self.FormShow(se