您的位置:首页 > 其它

使用存储过程实现进销存系统中的先进先出算法(2)——存储过程调用

2014-12-25 17:16 561 查看
本文是我在前一篇文章提到的关于先进先出存储过程的调用演示.

有关数据库和存储过程的设计,请参阅使用存储过程实现进销存系统中的先进先出算法(1)——数据库与存储过程设计

本文共用了9个测试用例 下载

数据库初始化

650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic.php?refimg=" + this.src)' alt="" border="0" src="http://img1.51cto.com/attachment/201004/221852250.gif" />

调用存储过程



--no.1进行入货操作,商品编号为1004191104,(售出价0,售出量0),成本价12.5,进货量100

EXEC pro_ProductSM @SorM='S',@pId='1004191104',@marketPrice=0, @marketNum=0, @stockPrice=12.5, @stockNum=100650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic.php?refimg=" + this.src)' alt="" border="0" src="http://img1.51cto.com/attachment/201004/222306279.gif" />

数据库更新

650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic.php?refimg=" + this.src)' alt="" border="0" src="http://img1.51cto.com/attachment/201004/222437904.gif" />

注解:第一次进货,stockNo=>2, num1和cost1都变化了.



--no.2进行入货操作,商品编号为1004191104,(售出价0,售出量0),成本价13,进货量100

EXEC pro_ProductSM @SorM='S',@pId='1004191104',@marketPrice=0, @marketNum=0, @stockPrice=13, @stockNum=100
650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic.php?refimg=" + this.src)' alt="" border="0" src="http://img1.51cto.com/attachment/201004/222634202.gif" />



数据库更新

650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic.php?refimg=" + this.src)' alt="" border="0" src="http://img1.51cto.com/attachment/201004/222714968.gif" />



--no.3进行入货操作,商品编号为1004191104,(售出价0,售出量0),成本价13.5,进货量85

EXEC pro_ProductSM @SorM='S',@pId='1004191104',@marketPrice=0, @marketNum=0, @stockPrice=13.5, @stockNum=8

650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic.php?refimg=" + this.src)' alt="" border="0" src="http://img1.51cto.com/attachment/201004/222816651.gif" />

数据库更新

650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic.php?refimg=" + this.src)' height="114" alt="" width="893" border="0" src="http://img1.51cto.com/attachment/201004/222939649.gif" />





--no.4进行入货操作,商品编号为1004191104,(售出价0,售出量0),成本价14,进货量60

EXEC pro_ProductSM @SorM='S',@pId='1004191104',@marketPrice=0, @marketNum=0,@stockPrice=14, @stockNum=60
650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic.php?refimg=" + this.src)' alt="" border="0" src="http://img1.51cto.com/attachment/201004/223320159.gif" />

数据库更新

650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic.php?refimg=" + this.src)' alt="" border="0" src="http://img1.51cto.com/attachment/201004/223401978.gif" />





--no.5进行入货操作,商品编号为1004191104,(售出价0,售出量0),成本价12,进货量80

EXEC pro_ProductSM @SorM='S',@pId='1004191104',@marketPrice=0, @marketNum=0, @stockPrice=12, @stockNum=80
650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic.php?refimg=" + this.src)' alt="" border="0" src="http://img1.51cto.com/attachment/201004/223459629.gif" />

数据库更新

650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic.php?refimg=" + this.src)' alt="" border="0" src="http://img1.51cto.com/attachment/201004/223600592.gif" />







--no.6进行入货操作,商品编号为1004191104,(售出价0,售出量0),成本价20,进货量10

EXEC pro_ProductSM @SorM='S',@pId='1004191104',@marketPrice=0, @marketNum=0, @stockPrice=20, @stockNum=10
650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic.php?refimg=" + this.src)' alt="" border="0" src="http://img1.51cto.com/attachment/201004/223657171.gif" />

数据库更新

650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic.php?refimg=" + this.src)' alt="" border="0" src="http://img1.51cto.com/attachment/201004/223733509.gif" />

注解,至此,所有仓库已满.









--no.7进行入货操作,商品编号为1004191104,(售出价0,售出量0),成本价75,进货量85

EXEC pro_ProductSM @SorM='S',@pId='1004191104',@marketPrice=0, @marketNum=0, @stockPrice=75, @stockNum=85
650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic.php?refimg=" + this.src)' alt="" border="0" src="http://img1.51cto.com/attachment/201004/230018202.gif" />

数据库没有更新

650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic.php?refimg=" + this.src)' alt="" border="0" src="http://img1.51cto.com/attachment/201004/223939489.gif" />

注解,此时不能继续进货了.





--no.8进行售货操作,商品编号为1004191104,售出价13,售出量90,(成本价0,进货量0)

EXEC pro_ProductSM @SorM='M',@pId='1004191104',@marketPrice=13, @marketNum=90, @stockPrice=0, @stockNum=0
650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic.php?refimg=" + this.src)' alt="" border="0" src="http://img1.51cto.com/attachment/201004/224251974.gif" />

数据库更新

650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic.php?refimg=" + this.src)' alt="" border="0" src="http://img1.51cto.com/attachment/201004/230114625.gif" />

这是一个出售操作,由于第一个仓库中已经可以满足需求,所以第一个仓库拿出90件,剩余10件,

利润计算 (13-12.5)*90 = 45.00







--no.9进行售货操作,商品编号为1004191104,售出价13.5,售出量20,(成本价0,进货量0)

EXEC pro_ProductSM @SorM='M',@pId='1004191104',@marketPrice=13.5, @marketNum=20, @stockPrice=0, @stockNum=0

650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic.php?refimg=" + this.src)' alt="" border="0" src="http://img1.51cto.com/attachment/201004/224743489.gif" />

数据库更新

650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic.php?refimg=" + this.src)' alt="" border="0" src="http://img1.51cto.com/attachment/201004/224845993.gif" />

这次由于第一个仓库中只有10个了,没有满足所需的20件,所以先把第一个仓库中的10件卖掉,然后第二个仓库在卖10件,并且marketNo=>2

利润计算 (13.5-12)*10 +(13.5-13)*10 = 10.00+5.00



本文出自 “专栏:Paxos与ZooKeeper” 博客,请务必保留此出处http://nileader.blog.51cto.com/1381108/304224
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: