USP_DATAFORMTEMPLATE_EDIT_EVENTAPPEAL
The save procedure used by the edit dataform template "Event Appeal Edit Form".
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | IN | The input ID parameter indicating the ID of the record being edited. |
@CHANGEAGENTID | uniqueidentifier | IN | Input parameter indicating the ID of the change agent invoking the procedure. |
@APPEALID | uniqueidentifier | IN | Appeal |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_EVENTAPPEAL
(
@ID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier = null,
@APPEALID uniqueidentifier
)
as
begin
set nocount on;
declare @CURRENTDATE datetime;
set @CURRENTDATE = getdate();
declare @PREVIOUSAPPEALID uniqueidentifier = (select APPEALID from dbo.EVENT where ID = @ID)
--Only attempt to update the data if the appeal chosen is not the one that already exists on the record
if @PREVIOUSAPPEALID is null or @APPEALID <> @PREVIOUSAPPEALID
begin
begin try
if @CHANGEAGENTID is null
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;
if exists
(
select
ID
from
dbo.TEAMFUNDRAISER
where
TEAMFUNDRAISER.APPEALID = @APPEALID
)
raiserror('EVENTAPPEALEDIT_ERR_TEAMFUNDRAISERSEXIST', 13, 1);
if not dbo.UFN_EVENT_TEAMFUNDRAISINGAPPEAL_VALIDCURRENCY(@ID, @APPEALID) = 1
raiserror('ERR_EVENT_APPEAL_BASECURRENCYMUSTMATCH', 13, 1);
update
dbo.EVENT
set
APPEALID = @APPEALID,
CHANGEDBYID = @CHANGEAGENTID,
DATECHANGED = @CURRENTDATE
where
ID = @ID;
end try
begin catch
exec dbo.USP_RAISE_ERROR;
return 1;
end catch
end
return 0;
end