USP_DATAFORMTEMPLATE_ADD_BENEFITPCT

The save procedure used by the add dataform template "Percent Benefit Add Form".

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier INOUT The output parameter indicating the ID of the record added.
@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
@BENEFITCATEGORYCODEID uniqueidentifier IN Category
@VALUEPERCENT numeric(20, 2) IN Percent
@SENDBENEFITCODE tinyint IN Send benefit when pledge is
@SITES xml IN Sites

Definition

Copy


                    CREATE procedure dbo.USP_DATAFORMTEMPLATE_ADD_BENEFITPCT
                    (
                        @ID uniqueidentifier = null output,
                        @CHANGEAGENTID uniqueidentifier = null,    
                        @NAME nvarchar(100) = '',
                        @DESCRIPTION nvarchar(255) = '',
                        @BENEFITCATEGORYCODEID uniqueidentifier = null,
                        @VALUEPERCENT numeric(20,2) = 0,
                        @SENDBENEFITCODE tinyint = 0,
            @SITES xml =null
                    )
                    as
                    begin
                        set nocount on;

                        declare @CURRENTDATE datetime                                        

                        IF @ID is null
                            set @ID = newid()

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

                        set @CURRENTDATE = getdate()

                        begin try                                   
                            insert into dbo.BENEFIT
                                (ID,NAME,DESCRIPTION,BENEFITCATEGORYCODEID,VALUE,USEPERCENT,VALUEPERCENT,SENDBENEFITCODE,ADDEDBYID,CHANGEDBYID,DATEADDED,DATECHANGED)
                            VALUES
                                (@ID,@NAME,@DESCRIPTION,@BENEFITCATEGORYCODEID,0,1,@VALUEPERCENT,@SENDBENEFITCODE,@CHANGEAGENTID,@CHANGEAGENTID,@CURRENTDATE,@CURRENTDATE)

              exec dbo.USP_BENEFITSITE_GETSITES_ADDFROMXML @ID, @SITES, @CHANGEAGENTID;  
                        end try

                        begin catch
                            exec dbo.USP_RAISE_ERROR
                            return 1
                        end catch

                        return 0

                    end