USP_EVENTDESIGNATIONS_COPY

Copies designations from one event to another

Parameters

Parameter Parameter Type Mode Description
@SOURCEEVENTID uniqueidentifier IN
@DESTINATIONEVENTID uniqueidentifier IN
@CHANGEAGENTID uniqueidentifier IN

Definition

Copy


 CREATE procedure dbo.USP_EVENTDESIGNATIONS_COPY
        (
          @SOURCEEVENTID uniqueidentifier,
          @DESTINATIONEVENTID uniqueidentifier,
          @CHANGEAGENTID uniqueidentifier = null
        )
            with execute as caller
            as
                set nocount on;

                -- Cannot copy if the source event does not exist

                if not exists (select ID from dbo.EVENT where ID = @SOURCEEVENTID)
                    raiserror('The source event specified does not exist.',13,1);

                declare @DESIGNATIONSONFEES bit
                select @DESIGNATIONSONFEES = DESIGNATIONSONFEES from dbo.EVENT where ID = @SOURCEEVENTID

                if @DESIGNATIONSONFEES = 0
                begin
                    --JamesWill 2010-10-18 If the source event doesn't allow designations on fees, there's nothing to do here.

                    return;
                    --raiserror('The source event does not allow designations on fees.',13,1)

                end


                declare @CURRENTDATE datetime;
                set @CURRENTDATE = getdate();

                if @CHANGEAGENTID is null
                    exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;

                --Need to set the event flag if it is still false

                update dbo.EVENT
                set DESIGNATIONSONFEES = 1
                where ID = @DESTINATIONEVENTID and DESIGNATIONSONFEES = 0

                insert into dbo.EVENTDESIGNATION
                (
                    ID,
                    EVENTID,
                    DESIGNATIONID,
                    [DEFAULT],
                    ADDEDBYID,
                    CHANGEDBYID,
                    DATEADDED,
                    DATECHANGED
                )
                select
                    newID(),
                    @DESTINATIONEVENTID,
                    DESIGNATIONID,
                    [DEFAULT],
                    @CHANGEAGENTID,
                    @CHANGEAGENTID,
                    @CURRENTDATE,
                    @CURRENTDATE
                from
                    dbo.EVENTDESIGNATION
                where
                    EVENTID = @SOURCEEVENTID;

                return 0;