早上好。我想问一些问题,但在此之前,我想先解释一下我目前的状况。
我有3张桌子,它们是。
Table: Receiving
Table: GeneralInventory
最后一个是 Table: item_master_list
我在VB.Net中有一个可以执行ff的程序。
1.基于Table: Receiving
我将选择一个RINo
,我将在上面的图片中使用示例(RI00000001
)
2.在选择了之后RI00000001
,Table: Receiving
我将按下按钮POST
,然后这就是我的代码所做的。
-The代码将检查是否从列中的数据ItemCode
的Table:Receiving
具有在列中的相同数据ItemCode
的Table: GeneralInventory
。
-Now if the Comparison is True or there's a same Data from both Tables the Column QtyPack
and QtyStan
from Table: Receiving
will be added/SUM in the Column Qty
of GeneralInventory
-Now if the Comparison is False or theres no comparison between two tables then the data will be inserted in GeneralInventory
.
I hope you get it but if not here is the sample image.
and now my code for that procedure is this.
Code for finding.
Select *
From
GeneralInventory GI
Inner Join
Receiving RE on GI.ItemCode = RE.ItemCode
Where RE.RINo = 'MyValue'
Now if the code above is true then this is the code for Updating
UPDATE GeneralInventory GI
INNER JOIN receiving RE ON GI.ItemCode = RE.ItemCode AND
GI.Qty = RE.QtyPack
SET GI.Qty = CAST(GI.Qty + RE.QtyPack + RE.QtyStan AS DECIMAL(6,2))
Where RE.RINo = 'MyValue'
or if it is false then this is the code for inserting.
INSERT INTO GeneralInventory(ItemCode, Qty)
SELECT RE.ItemCode, RE.QtyPack
FROM
Receiving RE LEFT JOIN
GeneralInventory GI ON GI.ItemCode = RE.ItemCode AND
GI.Qty =CAST(RE.QtyPack + Re.QtyStan AS DECIMAL(6,2))
WHERE RE.RINo = 'MyValue'
Now here is my Question and My Question is related to the Item_Master_List
and here it is.
我该如何实现这样的目标?首先在我将更新Table:GeneralInventory
使用Table: Receiving
我想要做一些计算Table: item_master_list
我的意思是在我更新或插入的数据generalinventory
我要加倍重视它item_masterlist
。
就像找到相同的值,item_master_list
然后在将其保存QtyperUoM
到receiving
之前使用使用该值的列将其相乘generalinventory
希望您能理解。
TYSM
UPDATE generalinventory gi
set gi.qty = (SELECT (r.QtyPack * r.QtyperUoM + r.QtySan)
from receiving r, item_master_list ml
where r.itemCode = ml.itemCode
and t.itemCode = gi.itemCode)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句