跳至主要內容

采购订单:非创建用户无法修改订单

五六零网校小于 1 分钟

示例代码

--采购订单:非创建用户无法修改订单
IF @object_type = '22'
	BEGIN
		IF @transaction_type = 'U'
			BEGIN
				DECLARE @userid varchar(20);
				DECLARE @username varchar(20);
				SELECT @userid = c.[userid], @username = c.[U_NAME]
				FROM [master].[dbo].[sysprocesses] a
					INNER JOIN [dbo].[USR5] b
					ON a.[spid] = b.[SessionID]
						AND a.[hostprocess] = b.[ProcessID]
					INNER JOIN [dbo].[OUSR] c ON b.[UserCode] = c.[USER_CODE]
				WHERE a.[spid] = @@spid
					AND b.[Action] = 'I'
				ORDER BY b.[Date] DESC;
				IF EXISTS (
					SELECT T0.[UserSign]
					FROM OPOR T0
					WHERE T0.[UserSign] <> @userid
						AND t0.docentry = @list_of_cols_val_tab_del
				)
					BEGIN
						SET @error = 1;
						SET @error_message = N'非创建用户无法修改单据'
					END;
			END;
	END