如何处理从不同位置出售的相同股票? [英] How can i handle to sell same stock from different location ?

查看:114
本文介绍了如何处理从不同位置出售的相同股票?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我不知道如何处理从不同柜台出售的相同股票.
如何检查库存是否存在,因为可以同时从其他柜台出售.

例如
我有一个商品001.
我按批号将库存保留在某个项目的记录中.

Hi all,

I don''t know how to handle to sell same stock from different Counter.
How can i check that stock is in store or not because that can sell from different Counter at the same time.

e.g.
I have an Item 001.
I keep Stock In record of an Item by Batch No. .

Stock In
          Item Code      Batch No.        Qty
             001             1               10
             001             2               30


并按批号保存项目的销售记录.


And also keep Sales record of an Item by Batch No. .

Sales 
          Sales ID    Item Code      Batch No.        Qty
             1            001             1            5



我想知道如何检查商店中剩余的数量.

* **要点是我无法从其他柜台处理库存检查.当"CounterA"插入5数量的要出售的商品001时,同时"CounterB"插入5数量的要卖的商品001.

当"CounterA"检查商店数量"项时,商店返回批号.还剩下1个,因为已发行的"CounterB"未完成.并且,当"CounterB"检查商店数量项目"时,商店退回批号.还剩下1个,因为已发行的"CounterA"未完成.

柜台插入要出售的物品,我只需检查并在每个表格的DataTable上插入销售数量即可.

插入所有销售项目之后,我将该DataTable添加到MS SQL DB.所以我获得了两个批号为1的销售记录.



I wanna know how can i check which batch is how many left qty in store.

* **Main point is i can''t handle of Stock Checking from different Counter. When ''CounterA'' insert 5 qty of Item 001 to sell, at the same time ''CounterB'' insert 5 qty of Item 001 to sell.

When ''CounterA'' check that Item of Store Qty, Store returns batch no. 1 is 5 left because ''CounterB'' is not Complete in sales issued. And also When ''CounterB'' check that Item of Store Qty, Store return batch no. 1 is 5 left because ''CounterA'' is not Complete in sales issued.

A Counter insert an item to sell, I just check and insert sales qty on DataTable of each Form.

After insert all sales items then i add that DataTable to MS SQL DB. So I got Two Sales Records with Batch No.1 .

Sales 
          Sales ID     Item Code      Batch No.        Qty
          2             001             1               5
          3             001             1               5



事实是第1批中只有5数量,因为我已经卖出了5数量.

希望大家能给我一些建议.

问候,
nway nge



The fact is there''s only 5 qty of Batch No.1 because i''ve already sold 5 qty.

Hope you all can give me an advice on my post.

regards,
nway nge

推荐答案

据我所知,计数器之间出现的race使您陷入麻烦. 要解决此问题,您需要将所有操作捆绑到transaction中并将其类型设置为serializable一个.
这将为您保证客户端操作不会彼此重合,并且不会发生进一步的竞争.

您可以在应用程序级别或SQL级别进行事务.因此由您决定.
如果您更喜欢SQL,则编写一个存储过程,该存储过程获取参数并在begin和commit事务块中进行操作.
因此您将拥有类似这样的内容:

As I understood your problem, the race that occurs between counters ran you into a trouble.
To solve this problem you need to bundle all operations into a transaction and set its type to a serializable one.
It will guarantee for you that client operations do not coincide with each other and no further race will happen.

You can do the transaction in application level or SQL level. so its up to you to decide.
If you prefer SQL then write a stored procedure that get the parameters and do its operation in begin and commit transaction block.
so you will have something like this :

begin transaction 
  see how much items have remained
  save its sale quntity if its possible 
commit transaction



要了解有关交易的更多信息,请阅读以下资源:
http://msdn.microsoft.com/en-us/library/ms188929.aspx [ ^ ]

http://msdn.microsoft.com/en-us/library/ms173763.aspx [ ^ ]

http://msdn.microsoft.com/en-us/library/2k2hy99x%28v = vs.71%29.aspx [ ^ ]


希望对您有所帮助.



to learn more about transaction read these resources :
http://msdn.microsoft.com/en-us/library/ms188929.aspx[^]

http://msdn.microsoft.com/en-us/library/ms173763.aspx[^]

http://msdn.microsoft.com/en-us/library/2k2hy99x%28v=vs.71%29.aspx[^]


Hope it helps.


这篇关于如何处理从不同位置出售的相同股票?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆