USP_DATAFORMTEMPLATE_EDIT_CONSTITUENTRECOGNITIONDECLINEDLEVELS

The save procedure used by the edit dataform template "ConstituentRecognitionDeclinedLevels 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.
@DECLINEDRECOGNITIONLEVELS xml IN Declined recognition program levels
@REASONCODEID uniqueidentifier IN
@DECLINEPROGRAM bit IN

Definition

Copy

            CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_CONSTITUENTRECOGNITIONDECLINEDLEVELS
            (
                @ID uniqueidentifier,
                @CHANGEAGENTID uniqueidentifier = null,
                @DECLINEDRECOGNITIONLEVELS xml,
              @REASONCODEID uniqueidentifier,
              @DECLINEPROGRAM bit
            )
            as
                set nocount on;


              declare @CONSTITUENTID as uniqueidentifier;
              declare @RECOGNITIONPROGRAMID as uniqueidentifier;

              select @CONSTITUENTID=CONSTITUENTID,
                     @RECOGNITIONPROGRAMID=RECOGNITIONPROGRAMID
              from dbo.CONSTITUENTRECOGNITION
              where @ID = ID

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

                declare @CURRENTDATE datetime
                set @CURRENTDATE = getdate()

              if @DECLINEPROGRAM = 1
              begin
              insert into dbo.CONSTITUENTRECOGNITIONDECLINEDPROGRAM (CONSTITUENTID,RECOGNITIONPROGRAMID,ADDEDBYID,CHANGEDBYID,DATEADDED,DATECHANGED,REASONCODEID) 
              values
              (@CONSTITUENTID,@RECOGNITIONPROGRAMID,@CHANGEAGENTID,@CHANGEAGENTID,@CURRENTDATE,@CURRENTDATE,@REASONCODEID

              declare @CRID uniqueidentifier = (select ID from dbo.CONSTITUENTRECOGNITION WHERE CONSTITUENTID = @CONSTITUENTID and RECOGNITIONPROGRAMID = @RECOGNITIONPROGRAMID)
              exec USP_CONSTITUENTRECOGNITION_DELETE @CRID, @CHANGEAGENTID

              delete from dbo.CONSTITUENTRECOGNITIONDECLINEDLEVEL where CONSTITUENTID = @CONSTITUENTID and RECOGNITIONPROGRAMID = @RECOGNITIONPROGRAMID
              end

                begin try
                    exec USP_CONSTITUENTRECOGNITION_GETDECLINEDLEVELS_UPDATEFROMXML @CONSTITUENTID,@RECOGNITIONPROGRAMID,@DECLINEDRECOGNITIONLEVELS,@CHANGEAGENTID,@CURRENTDATE,@REASONCODEID
                end try
                begin catch
                    exec dbo.USP_RAISE_ERROR
                    return 1
                end catch

            return 0;