USE [Yolo880_Hotel] GO /****** Object: Trigger [dbo].[change_goods] Script Date: 2023-11-22 13:50:04 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO create trigger [dbo].[change_T_OrderClient] on [dbo].[T_OrderClient] AFTER update AS BEGIN Declare @name varchar(50); --姓名 Declare @add varchar(50); --地址 Declare @addnum varchar(50); --证件号码 Declare @tel varchar(50); --手机号 Declare @memo varchar(50); --客人喜好、备注 Declare @id varchar(50); --账单ID Declare @name1 varchar(50); --姓名 Declare @add1 varchar(50); --地址 Declare @addnum1 varchar(50); --证件号码 Declare @tel1 varchar(50); --手机号 Declare @memo1 varchar(50); --客人喜好、备注 Declare @user varchar(50); --当前在线人员 SELECT @id=F_OrderId,@name=F_LinkMan,@add=F_Address,@addnum=F_CardNumber,@tel=F_phone, @memo =F_Memo FROM deleted; --原数据 SELECT @name1=F_LinkMan,@add1=F_Address,@addnum1=F_CardNumber,@tel1=F_phone, @memo1 =F_Memo FROM inserted; --新数据 select @user=u.F_UserName from t_userpower u inner join( SELECT top 1 F_UserName, F_HostName, F_HostIP from T_LoginSysLog where f_hostname = HOST_NAME() and f_leaveinfo is null order by F_ID desc) t on u .F_UserName = t.F_UserName and u.F_Status = '上班' IF UPDATE(F_Address) and (@add<>@add1) BEGIN INSERT INTO dbo.T_Log_RoomSvrc (F_EventType ,F_Content,F_UserName, F_TableName, F_Table_FID) values('修改客人资料','地址:'+CAST(@add AS varchar)+'==>'+CAST(@add1 AS varchar),@user,'T_RoomOrder',@id) END --修改证件 IF UPDATE(F_CardNumber) and (@addnum<>@addnum1) BEGIN INSERT INTO dbo.T_Log_RoomSvrc (F_EventType ,F_Content,F_UserName, F_TableName, F_Table_FID) values('修改客人资料','证件:'+CAST(@addnum AS varchar)+'==>'+CAST(@addnum1 AS varchar),@user,'T_RoomOrder',@id) END --修改手机号 IF UPDATE(F_phone) and (@tel1<>@tel) BEGIN INSERT INTO dbo.T_Log_RoomSvrc (F_EventType ,F_Content,F_UserName, F_TableName, F_Table_FID) values('修改客人资料','手机:'+CAST(@tel AS varchar)+'==>'+CAST(@tel1 AS varchar),@user,'T_RoomOrder',@id) END --修改备注 IF UPDATE(F_Memo) and (@memo<>@memo1) BEGIN Declare @status varchar(50); --账单ID select @status = F_Status from T_RoomOrder where F_id = @id if(@status = '入住' or @status = '预订') begin INSERT INTO dbo.T_Log_RoomSvrc (F_EventType ,F_Content,F_UserName, F_TableName, F_Table_FID) values('修改客人资料','备注:'+CAST(@memo AS varchar)+'==>'+CAST(@memo1 AS varchar),@user,'T_RoomOrder',@id) end END END