|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册账号
×
采购申请单,第一行输入产品编码和数量,保存后,系统自动带出该产品的一阶BOM信息录入到采购申请单中只写了一阶,全阶没写 采购申请单,第一行输入产品编码和数量,保存后,系统自动带出该产品的一阶BOM信息录入到采购申请单中
只写了一阶,全阶没写 USE [UFDATA_003_2018]--用友年度账套号
GO
create trigger TR_PU_AppVouchs
on [dbo].[PU_AppVouchs]
for insert
as
if exists(select * from inserted where cInvCode like '2%') --成品机编号以2开头
begin
declare @ID int
select @ID =ID from inserted
DELETE FROM PU_AppVouchs where ID=@ID
insert into PU_AppVouchs(ID,cInvCode,fQuantity,cVenCode,dRequirDate,dArriveDate)
select ID=@ID,cpscode,fQuantity=iPSQuantity*(select CAST(fQuantity AS FLOAT) from inserted),cVenCode=(SELECT cVenCode FROM inserted),
dRequirDate=(SELECT dRequirDate FROM inserted),dArriveDate=(SELECT dArriveDate FROM inserted)
from ProductStructures where cPSPCode=(SELECT cinvcode from inserted)
DECLARE @cCode varchar(50),@cCodeD varchar(50)
SET @cCodeD=(select 'PR'+CONVERT(VARCHAR(20),MAX(convert(INT,RIGHT(cCode,10)))) from PU_AppVouch)
SET @cCode=(select 'PR'+CONVERT(VARCHAR(20),MAX(convert(INT,RIGHT(cCode,10)))+1) from PU_AppVouch)
INSERT INTO PU_AppVouch(ID,cCode,dDate,cBusType,cDepCode,cPersonCode,cPTCode,iVTid,cMaker,cMemo)
SELECT distinct ID=@ID+1,@cCode,GETDATE(),cBusType=(SELECT cBusType FROM PU_AppVouch WHERE cCode=@cCodeD),
cDepCode=(SELECT cDepCode FROM PU_AppVouch WHERE cCode=@cCodeD),cPersonCode=(SELECT cPersonCode FROM PU_AppVouch WHERE cCode=@cCodeD),
cPTCode=(SELECT cPTCode FROM PU_AppVouch WHERE cCode=@cCodeD),iVTid=(SELECT iVTid FROM PU_AppVouch WHERE cCode=@cCodeD),
cMaker=(SELECT cMaker FROM PU_AppVouch WHERE cCode=@cCodeD),cMemo=(SELECT cMemo FROM PU_AppVouch WHERE cCode=@cCodeD)
from PU_AppVouch
DELETE FROM PU_AppVouch where ID=@ID
update PU_AppVouch set ID=@ID,cCode=@cCode where ID=@ID+1
END
|
|