USP_DATAFORMTEMPLATE_EDIT_EVENTPRICELIST

The save procedure used by the edit dataform template "Event Price List Edit Data 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.
@ISCUSTOM bit IN Create custom prices for this event
@PRICES xml IN Prices

Definition

Copy


        CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_EVENTPRICELIST 
        (
            @ID uniqueidentifier,
            @CHANGEAGENTID uniqueidentifier = null,
            @ISCUSTOM bit,
            @PRICES xml
        )
        as

            set nocount on;

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

            declare @CURRENTDATE datetime
            set @CURRENTDATE = getdate()

            begin try
                update dbo.[EVENT] with (rowlock)
                set 
                    [DATECHANGED] = @CURRENTDATE,
                    [CHANGEDBYID] = @CHANGEAGENTID
                where [ID] = @ID

                if @ISCUSTOM = 0
                    begin
                    declare @contextCache varbinary(128);
                    declare @e int;

                    -- cache current context information 

                    set @contextCache = CONTEXT_INFO();

                    -- set CONTEXT_INFO to @CHANGEAGENTID 

                    if not @CHANGEAGENTID is null
                        set CONTEXT_INFO @CHANGEAGENTID;

                    -- delete any items that no longer exist in the XML table

                    delete from dbo.[PROGRAMEVENTPRICE] where [EVENTID] = @ID

                    select @e=@@error;

                    -- reset CONTEXT_INFO to previous value 

                    if not @contextCache is null
                        set CONTEXT_INFO @contextCache;

                    if @e <> 0
                        return 2;

                    end
                else
                    begin
                    exec dbo.USP_EVENT_GETEVENTPRICES_UPDATEFROMXML @ID, @PRICES, @CHANGEAGENTID;
                    end        
            end try
            begin catch
                exec dbo.USP_RAISE_ERROR
                return 1
            end catch

        return 0;