create trigger t_tjc on ICStockBill
for insert
as
set nocount on
BEGIN
DECLARE @FInterID int
select @FInterID=FInterID from inserted
if exists(select * from ICStockBill where FInterID=@FInterID)
update A
set A.FQty=A.FQty-B.FQty
from tjc A
left outer join t_ICItemCore E on A.FNumber=E.FNumber
left outer join ICStockBillEntry B on E.FItemID=B.FItemID
left outer join ICStockBill C on B.FInterID=C.FInterID
where B.FInterID=@FInterID and B.FSourceTranType=85 and B.FPPBomEntryID=0
end
set nocount off
FInterID为入库单据内码,同一入库单据本来在前台界面单击“保存”一次后,更新一次库存就行了,但如果再在前台界面再点击“保存”一次,库存又会更新?想不明白,咋回事
create trigger t_tjc on ICStockBill
for insert
as
set nocount on
BEGIN
DECLARE @FInterID int
select @FInterID=FInterID from inserted
if exists(select * from ICStockBill where FInterID=@FInterID)beginupdate A
set A.FQty=A.FQty-B.FQty from tjc A
left outer join t_ICItemCore E on A.FNumber=E.FNumber
left outer join ICStockBillEntry B on E.FItemID=B.FItemID
left outer join ICStockBill C on B.FInterID=C.FInterID
where B.FInterID=@FInterID and B.FSourceTranType=85 and B.FPPBomEntryID=0endend
set nocount off---
--不行,用after 试试!
create trigger t_tjc on ICStockBill
after insert
但是K3的功能里有这样一个字段FWhenSaveUpdate当为0时就是保存时更新库存,为1时就是不保存
搞不懂这个逻辑是什么