You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sql-tools/检查盘点单上的实际库存.sql

99 lines
2.0 KiB

1 year ago
IF object_id('dbo.PChangeMemberCardState','P') IS NOT NULL
BEGIN
DROP PROCEDURE dbo.PChangeMemberCardState
END
GO
CREATE PROCEDURE dbo.PChangeMemberCardState
(
@SessionId INT,
@MemId BIGINT,
@CardId BIGINT,
@State INT
)
AS
BEGIN
IF @MemId = 0
BEGIN
RAISERROR('<EFBFBD><EFBFBD>ԱID<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0',18,1)
RETURN -1
END
IF @CardId = 0
BEGIN
RAISERROR('<EFBFBD><EFBFBD>ID<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0',18,1)
RETURN -1
END
IF @State != 4
BEGIN
RAISERROR('ֻ֧<EFBFBD><EFBFBD>ͣ<EFBFBD><EFBFBD>',18,1)
RETURN -1
END
DECLARE @MemNo VARCHAR(50)
DECLARE @CardNo VARCHAR(100)
SELECT @MemNo = FNo FROM TMember WITH(NOLOCK) WHERE FId = @MemId
IF @MemNo IS NULL
BEGIN
RAISERROR('<EFBFBD><EFBFBD>ԱID<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',18,1)
RETURN -1
END
IF @CardId = 6
BEGIN
SELECT @CardNo = '<EFBFBD>Ƴ̿<EFBFBD>';
END
ELSE IF @CardId = 1
BEGIN
SELECT @CardNo = 'ȫ<EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD>';
END
ELSE
BEGIN
SELECT @CardNo = FNo FROM TMemberCard WHERE FId = @CardId
END
DECLARE @LogDesc VARCHAR(20)
DECLARE @LogFunc VARCHAR(20)
DECLARE @LogText VARCHAR(1024)
DECLARE @LogIndexes VARCHAR(200)
DECLARE @StateName VARCHAR(20)
IF @State = 4
BEGIN
SET @StateName = '<EFBFBD><EFBFBD>ͣ<EFBFBD><EFBFBD>';
END
SELECT @LogFunc = 'WMember';
SELECT @LogDesc = '<EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD>״̬';
SELECT @LogText = '<EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:'+@MemNo + ',<EFBFBD><EFBFBD>Ա<EFBFBD>ӿ<EFBFBD>:' + @CardNo + '̬:' + @StateName;
SELECT @LogIndexes = 'MemNo=' + @MemNo;
IF @CardId = 6 OR @CardId = 1
BEGIN
print ''
--UPDATE TMemberCourse
END
IF @CardId != 6 OR @CardId = 1
BEGIN
UPDATE TMemberCard
SET FState = @State
WHERE FMemId = @MemId
END
EXEC PAddBizLogEx @SessionId=@SessionId,@Function=@LogFunc,@Operation='Modify',@Description=@LogDesc,
@ContentType='Text',@Content=@LogText,@Version=1,@Indexes=@LogIndexes
END
GO
UPDATE TMemberCard
SET FTypeId = (SELECT FId FROM TMemberCardType WHERE FNo = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
WHERE FNo = '<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'