USP_DATAFORMTEMPLATE_EDIT_MERCHANDISE_VENDOR

The save procedure used by the edit dataform template "Merchandise Vendor 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.
@NAME nvarchar(100) IN Name
@DESCRIPTION nvarchar(255) IN Description
@WEBADDRESS UDT_WEBADDRESS IN Website
@PICTURE varbinary IN Image
@PICTURETHUMBNAIL varbinary IN Image thumbnail
@ISACTIVE bit IN Active
@PICTURECHANGED bit IN Picture changed

Definition

Copy

                CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_MERCHANDISE_VENDOR (
                    @ID uniqueidentifier,
                    @CHANGEAGENTID uniqueidentifier = null,
                    @NAME nvarchar(100),
                    @DESCRIPTION nvarchar(255),
                    @WEBADDRESS dbo.UDT_WEBADDRESS,
                    @PICTURE varbinary(max),
                    @PICTURETHUMBNAIL varbinary(max),
                    @ISACTIVE bit,
                    @PICTURECHANGED bit
                )
                as

                    set nocount on;

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

                    declare @CURRENTDATE datetime
                    set @CURRENTDATE = getdate()

                    begin try
                        if @PICTURECHANGED = 0
                        begin
                            set @PICTURE = null
                            set @PICTURETHUMBNAIL = null
                        end

                        -- Vendor record
                        update dbo.VENDOR set
                            DESCRIPTION = @DESCRIPTION,
                            CHANGEDBYID = @CHANGEAGENTID,
                            DATECHANGED = @CURRENTDATE
                        where ID = @ID

                        -- Constituent record
                        update dbo.CONSTITUENT set
                            KEYNAME = @NAME,
                            WEBADDRESS = @WEBADDRESS,
                            PICTURE = @PICTURE,
                            PICTURETHUMBNAIL = @PICTURETHUMBNAIL,
                            CHANGEDBYID = @CHANGEAGENTID,
                            DATECHANGED = @CURRENTDATE,
                            ISINACTIVE = ~@ISACTIVE
                        where ID = @ID
                    end try

                    begin catch
                        exec dbo.USP_RAISE_ERROR
                        return 1
                    end catch

                return 0;