34,590
社区成员
发帖
与我相关
我的任务
分享
alter TRIGGER NFD_2
ON t_BOS200000000
for update
AS
begin
SET NOCOUNT ON
declare @fcheckstatus int
select @fcheckstatus=fmulticheckstatus from inserted
if (@fcheckstatus=16)
begin
update t1 set fauxqty=t4.fqtynow from PORequestEntry as t1 --采购申请
inner join PORequest as t2 on t1.finterid=t2.finterid
inner join inserted as t3 on t2.fbillno=t3.fbillno_src
inner join t_BOS200000000Entry2 as t4 on t3.fid=t4.fid
where t1.fitemid=t4.fitemid
update t1 set fneedauxqty=t2.fauxqty from ICSMInquiryMtrlEntry as t1 --询价单关联采购申请
inner join PORequestEntry as t2 on t1.fid_src=t2.finterid
where t1.fitemid=t2.fitemid
update t1 set fneedauxqty =t2.fauxqty from ICSMQuotationEntry as t1 --报价单关联采购申请
inner join PORequestEntry as t2 on t1.fprinterid=t2.finterid
where t1.fitemid=t2.fitemid
update t1 set fquantity =t2.fneedauxqty from t_rpContractEntry as t1 -- 合同关联询价单
inner join ICSMInquiryMtrlEntry as t2 on t1.fid_src=t2.fid
where t1.fproductid=t2.fitemid
update t1 set fauxqty=t2.fauxqty from POOrderEntry as t1 --关联采购订单
inner join PORequestEntry as t2 on t1.fsourceinterid=t2.finterid
where t1.fitemid=t2.fitemid
end
if (@fcheckstatus=4)
begin
update t1 set fauxqty=t4.FDecimal from PORequestEntry as t1
inner join PORequest as t2 on t1.finterid=t2.finterid
inner join inserted as t3 on t2.fbillno=t3.fbillno_src
inner join t_BOS200000000Entry2 as t4 on t3.fid=t4.fid
where t1.fitemid=t4.fitemid
update t1 set fneedauxqty=t2.fauxqty from ICSMInquiryMtrlEntry as t1 --询价单关联采购申请
inner join PORequestEntry as t2 on t1.fid_src=t2.finterid
where t1.fitemid=t2.fitemid
update t1 set fneedauxqty =t2.fauxqty from ICSMQuotationEntry as t1 --报价单关联采购申请
inner join PORequestEntry as t2 on t1.fprinterid=t2.finterid
where t1.fitemid=t2.fitemid
update t1 set fquantity =t2.fneedauxqty from t_rpContractEntry as t1 -- 合同关联询价单
inner join ICSMInquiryMtrlEntry as t2 on t1.fid_src=t2.fid
where t1.fproductid=t2.fitemid
update t12 set fauxqty=t2.fauxqty from POOrderEntry as t1 --关联采购订单
inner join PORequestEntry as t2 on t1.fsourceinterid=t2.finterid
where t1.fitemid=t2.fitemid
end
end