USP_DATAFORMTEMPLATE_EDITSAVE_WPNONPROFITAFFILIATION

The save procedure used by the edit dataform template "WealthPoint Nonprofit Affiliation 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.
@SOURCE nvarchar(100) IN Source
@FULLNAME nvarchar(150) IN Name
@TITLE nvarchar(100) IN Title
@SALARY money IN Salary
@DN_ORGANIZATION nvarchar(150) IN Organization
@EIN nvarchar(30) IN EIN
@LINE1 nvarchar(150) IN Address
@CITY nvarchar(50) IN City
@ZIP nvarchar(10) IN ZIP
@REVENUE money IN Revenue
@STATE nvarchar(100) IN State
@PHONE nvarchar(20) IN Phone
@CNOTES nvarchar(1024) IN Notes

Definition

Copy


                    CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDITSAVE_WPNONPROFITAFFILIATION (
                        @ID uniqueidentifier,
                        @CHANGEAGENTID uniqueidentifier = null,
                        @SOURCE nvarchar(100),
                        @FULLNAME nvarchar(150),
                        @TITLE nvarchar(100),
                        @SALARY money,
                        @DN_ORGANIZATION nvarchar(150),
                        @EIN nvarchar(30),
                        @LINE1 nvarchar(150),
                        @CITY nvarchar(50),
                        @ZIP nvarchar(10),
                        @REVENUE money,
                        @STATE nvarchar(100),
                        @PHONE nvarchar(20),
                        @CNOTES nvarchar(1024)
                    ) as begin

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

                        update dbo.WPNONPROFITAFFILIATION set
                            CHANGEDBYID = @CHANGEAGENTID,
                            DATECHANGED = getdate(),
                            SOURCE = @SOURCE,
                            FULLNAME = @FULLNAME,
                            TITLE = @TITLE,
                            SALARY = @SALARY,
                            DN_ORGANIZATION = @DN_ORGANIZATION,
                            EIN = @EIN,
                            LINE1 = @LINE1,
                            CITY = @CITY,
                            ZIP = @ZIP,
                            REVENUE = @REVENUE,
                            STATE = @STATE,
                            PHONE = @PHONE,
                            CNOTES = @CNOTES
                        where
                            ID=@ID;
                        if    (select
                                count(WEALTHSOURCE.SOURCE)
                            from
                                dbo.WEALTHSOURCE
                            where
                                WEALTHSOURCE.SOURCE = @SOURCE
                            ) = 0
                            begin
                                insert into dbo.WEALTHSOURCE (
                                    [SOURCE],
                                    [ISBUILTIN],
                                    [ADDEDBYID],
                                    [CHANGEDBYID]
                                )values(
                                    @SOURCE,
                                    0,
                                    @CHANGEAGENTID,
                                    @CHANGEAGENTID
                                );
                            end

                        declare @WEALTHID uniqueidentifier;
                        select @WEALTHID=WEALTHID from dbo.WPNONPROFITAFFILIATION where ID=@ID;

                        exec dbo.USP_WEALTHPOINT_UPDATEWEALTHSUMMARY_NONPROFITAFFILIATION @WEALTHID, @CHANGEAGENTID;
                        exec dbo.USP_WEALTHCAPACITY_UPDATE @WEALTHID, @CHANGEAGENTID;

                        return 0;
                    end;