USP_DATAFORMTEMPLATE_EDIT_DESIGNATIONLEVEL

The save procedure used by the edit dataform template "Fundraising Purpose Edit Form".

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN The input ID parameter indicating the ID of the record being edited.
@CURRENTAPPUSERID uniqueidentifier IN Input parameter indicating the ID of the current user.
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the procedure.
@NAME nvarchar(100) IN Name
@DESCRIPTION nvarchar(255) IN Description
@DESIGNATIONLEVELCATEGORYCODEID uniqueidentifier IN Category
@ADMINISTRATORID uniqueidentifier IN Administrator
@LOOKUPID nvarchar(100) IN Lookup ID
@DESIGNATIONREPORTCODE1ID uniqueidentifier IN Report code 1
@DESIGNATIONREPORTCODE2ID uniqueidentifier IN Report code 2
@SITEID uniqueidentifier IN Site

Definition

Copy


                CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_DESIGNATIONLEVEL
                    (
                        @ID uniqueidentifier,
                        @CURRENTAPPUSERID uniqueidentifier,
                        @CHANGEAGENTID uniqueidentifier = null,                
                        @NAME nvarchar(100),
                        @DESCRIPTION nvarchar(255),
                        @DESIGNATIONLEVELCATEGORYCODEID uniqueidentifier,
                        @ADMINISTRATORID uniqueidentifier,
                        @LOOKUPID nvarchar(100),
                        @DESIGNATIONREPORTCODE1ID uniqueidentifier,
                        @DESIGNATIONREPORTCODE2ID uniqueidentifier,
                        @SITEID uniqueidentifier
                    )
                as                
                begin                
                    set nocount on;
                    declare @CURRENTDATE datetime
                    set @CURRENTDATE = getdate()

                    if @SITEID is null
                        begin 
                        if dbo.UFN_SITEREQUIREDFORUSER(@CURRENTAPPUSERID) = 1 
                            begin
                            raiserror('Site is required.',13,1)
                            return
                            end
                        end

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

                        update 
                            dbo.DESIGNATIONLEVEL
                        set 
                            NAME= @NAME,
                            DESCRIPTION = @DESCRIPTION,
                            DESIGNATIONLEVELCATEGORYCODEID = @DESIGNATIONLEVELCATEGORYCODEID,
                            ADMINISTRATORID = @ADMINISTRATORID,
                            USERID = @LOOKUPID,
                            DESIGNATIONREPORT1CODEID = @DESIGNATIONREPORTCODE1ID,
                            DESIGNATIONREPORT2CODEID = @DESIGNATIONREPORTCODE2ID,
                            CHANGEDBYID = @CHANGEAGENTID,
                            DATECHANGED = @CURRENTDATE,
                            SITEID = @SITEID
                        where 
                            ID = @ID;

                        --update the associated hierarchy root if it exists

                        update 
                            dbo.DESIGNATION
                        set 
                            USERID = @LOOKUPID,
                            DESIGNATIONREPORT1CODEID = @DESIGNATIONREPORTCODE1ID,
                            DESIGNATIONREPORT2CODEID = @DESIGNATIONREPORTCODE2ID,
                            CHANGEDBYID = @CHANGEAGENTID,
                            DATECHANGED = @CURRENTDATE
                        where DESIGNATIONLEVEL1ID = @ID
                            and DESIGNATIONLEVEL2ID is null;

                    end try

                    begin catch
                        exec dbo.USP_RAISE_ERROR
                        return 1
                    end catch

                    return 0
                end