USP_DATAFORMTEMPLATE_EDIT_CALENDARITEM

The save procedure used by the edit dataform template "Calendar Item Edit Form".

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN The input ID parameter indicating the ID of the record being edited.
@STARTDATE date IN Start date
@ENDDATE date IN End date
@NAME nvarchar(100) IN Name
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the procedure.

Definition

Copy


CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_CALENDARITEM (
    @ID uniqueidentifier,
    @STARTDATE date,
    @ENDDATE date,
    @NAME nvarchar(100),
    @CHANGEAGENTID uniqueidentifier = null
) as begin

    set nocount on;

    begin try

        if @ID is null
            set @ID = newid();

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

        declare @CURRENTDATE datetime;
        set @CURRENTDATE = getdate();

        update 
            dbo.CALENDARITEM
        set
            STARTDATE = dbo.UFN_DATE_GETEARLIESTTIME(@STARTDATE),
            ENDDATE = dbo.UFN_DATE_GETEARLIESTTIME(@ENDDATE),
            NAME = @NAME,
            CHANGEDBYID = @CHANGEAGENTID,
            DATECHANGED = @CURRENTDATE
        where
            CALENDARITEM.ID = @ID;

    end try
    begin catch
        exec dbo.USP_RAISE_ERROR;
        return 1;
    end catch

    return 0;

end