22,210
社区成员
发帖
与我相关
我的任务
分享
declare
@fid int, --------------声明变量获取当前单据内码
@FEntryID int, --分录行
@ftrantype int,
@FQty_Base int,
@FQty int,
@FDecimal dec(20,10),
@FCoefficient dec(20,10)
begin
select @fid=fid,@FQty_Base=FQty_Base,@FQty=FQty,@FDecimal=FDecimal,@FEntryID=FEntryID from inserted -----------获取内码存入@finterid
select @FCoefficient=FCoefficient from t_MeasureUnit
if @FQty_Base>@FQty begin update t_BOStbsqEntry set FDecimal1=@FDecimal where t_BOStbsqEntry.FEntryID=@FEntryID end
else if @FQty_Base=@FQty begin update t_BOStbsqEntry set FDecimal1=@FDecimal/@FCoefficient from
t_BOStbsqEntry a left join t_ICItemCore b on a.FBase2=b.FItemID
left join t_ICItemBase c on b.FItemID = c.FItemID
left join t_MeasureUnit d on c.FSaleUnitID=d.FMeasureUnitID
where a.FEntryID=@FEntryID end
end
-------------修改范围为:
END
ALTER TRIGGER [dbo].[t_BOStbsqEntry_ins]
ON [dbo].[t_BOStbsqEntry]
AFTER INSERT,UPDATE
AS
BEGIN
SET NOCOUNT ON;
declare
@fid int, --------------声明变量获取当前单据内码
@FEntryID int, --分录行
@ftrantype int,
@FQty_Base int,
@FQty int,
@FDecimal dec(20,10),
@FCoefficient dec(20,10)
begin
select @fid=fid,@FQty_Base=FQty_Base,@FQty=FQty,@FDecimal=FDecimal,@FEntryID=FEntryID from inserted -----------获取内码存入@finterid
select @FCoefficient=FCoefficient from t_MeasureUnit
print @FDecimal
print @FQty
print @FQty_Base
print @FCoefficient
if @FQty_Base>@FQty begin update t_BOStbsqEntry set FDecimal1=@FDecimal where t_BOStbsqEntry.FEntryID=@FEntryID end
else if @FQty_Base=@FQty begin update t_BOStbsqEntry set FDecimal1=@FDecimal/@FCoefficient from
t_BOStbsqEntry a left join t_ICItemCore b on a.FBase2=b.FItemID
left join t_ICItemBase c on b.FItemID = c.FItemID
left join t_MeasureUnit d on c.FSaleUnitID=d.FMeasureUnitID
where a.FEntryID=@FEntryID end
else begin update t_BOStbsqEntry set FDecimal1=0 end
end
-------------修改范围为:
END