USP_DATAFORMTEMPLATE_EDIT_REGISTRANT

The save procedure used by the edit dataform template "Registrant 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.
@ATTENDED bit IN Attended
@EVENTSEATINGNOTE nvarchar(250) IN Seating note

Definition

Copy


                    CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_REGISTRANT
                    (
                        @ID uniqueidentifier,
                        @CHANGEAGENTID uniqueidentifier = null,
                        @ATTENDED bit,
                        @EVENTSEATINGNOTE nvarchar(250)
                    )
                    as                    
                        set nocount on;

                        declare @CURRENTDATE datetime;

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

                        set @CURRENTDATE = getdate();

                        --USERMARKEDATTENDANCE - We want this to behave similarly to the logic from mark attended/not attended

                        --leave the field alone if the user did not check or uncheck attended

                        --if the user unchecked, do not mark "No-show", just make not attended

                        --if the user checked, set USERMARKEDATTENDANCE so options behave properly


                        begin try
                            update 
                                dbo.REGISTRANT
                            set
                                USERMARKEDATTENDANCE = case when @ATTENDED = ATTENDED then USERMARKEDATTENDANCE
                                                            else @ATTENDED end,
                                ATTENDED = @ATTENDED,
                                EVENTSEATINGNOTE = @EVENTSEATINGNOTE,
                                CHANGEDBYID = @CHANGEAGENTID,
                                DATECHANGED = @CURRENTDATE
                            where
                                ID = @ID;
                        end try

                        begin catch
                            exec dbo.USP_RAISE_ERROR;
                            return 1;
                        end catch

                        return 0;