spAddUpdate_CalendarEvent

Parameters

Parameter Parameter Type Mode Description
@PKID int INOUT
@EventCalendarID int IN
@Category nvarchar(100) IN
@BeginDate datetime IN
@EndDate datetime IN
@Title nvarchar(255) IN
@SubTitle nvarchar(255) IN
@Location nvarchar(255) IN
@Details ntext IN
@Fees nvarchar(255) IN
@MoreInfoURL nvarchar(255) IN
@ContactInfo nvarchar(255) IN
@CreatedUserID int IN
@CreateDate datetime IN
@ApprovedDate datetime IN
@ApprovedUserID int IN
@Deleted bit IN
@OccurenceGroupID int IN
@AllDayEvent bit IN
@UpdateDate datetime INOUT
@MapLocation int IN
@Cancelled bit IN
@TimeZoneID int IN
@RecurException bit IN
@AthleticEventID int IN

Definition

Copy

  CREATE    PROCEDURE [dbo].[spAddUpdate_CalendarEvent]
        (
            @PKID            int output,
            @EventCalendarID     int,
            @Category         nvarchar (100),

            @BeginDate         datetime,
            @EndDate         datetime,

            @Title             nvarchar(255),
            @SubTitle         nvarchar(255),
            @Location         nvarchar (255),
            @Details         ntext,
            @Fees             nvarchar(255),

            @MoreInfoURL         nvarchar(255),
            @ContactInfo         nvarchar (255),

            @CreatedUserID         int,
            @CreateDate         datetime,
            @ApprovedDate         datetime,
            @ApprovedUserID     int,

            @Deleted         bit,
            @OccurenceGroupID    int,
            @AllDayEvent        bit,
            @UpdateDate        datetime output,
            @MapLocation    int,
            @Cancelled        bit,
            @TimeZoneID        int,

            @RecurException        bit,
            @AthleticEventID    int

        )
        AS

        set nocount on
        begin transaction

        if @AthleticEventID <=0
            SET @AthleticEventID = null

        if (@PKID<=0)

            begin

            INSERT INTO CalendarEvent
            (

                EventCalendarID,
                Category,

                BeginDate,        
                EndDate,         

                Title,     
                SubTitle,
                Location,         
                Details,         
                Fees,             

                MoreInfoURL,         
                ContactInfo,         

                CreatedUserID,         
                CreateDate,         
                ApprovedDate,         
                ApprovedUserID,     

                Deleted,
                OccurenceGroupID,
                AllDayEvent,

                MapLocation,
                Cancelled,
                TimeZoneID,

                RecurException,
                AthleticEventID
            )

            VALUES
            (

                @EventCalendarID    ,
                @Category        ,

                @BeginDate         ,
                @EndDate         ,

                @Title             ,
                @SubTitle             ,
                @Location         ,
                @Details         ,
                @Fees             ,

                @MoreInfoURL         ,
                @ContactInfo         ,

                @CreatedUserID         ,
                getutcdate()        ,
                @ApprovedDate         ,
                @ApprovedUserID     ,

                @Deleted         ,
                @OccurenceGroupID    ,
                @AllDayEvent    ,

                @MapLocation,
                @Cancelled,
                @TimeZoneID,

                @RecurException,
                @AthleticEventID
            )

            SELECT
                @PKID = @@Identity

        end else begin

            UPDATE CalendarEvent SET

                EventCalendarID = @EventCalendarID,
                Category = @Category,

                BeginDate = @BeginDate,        
                EndDate = @EndDate,         

                Title = @Title,             
                SubTitle = @SubTitle,         
                Location = @Location,         
                Details = @Details,         
                Fees = @Fees,             

                MoreInfoURL = @MoreInfoURL,         
                ContactInfo = @ContactInfo,         

                CreatedUserID = @CreatedUserID,         

                ApprovedDate = @ApprovedDate,         
                ApprovedUserID = @ApprovedUserID,     

                Deleted = @Deleted,

                OccurenceGroupID = @OccurenceGroupID,

                AllDayEvent = @AllDayEvent,
                UpdateDate = getutcdate(),

                MapLocation = @MapLocation,
                Cancelled = @Cancelled,
                TimeZoneID    = @TimeZoneID,
                AthleticEventID = @AthleticEventID

                -- RecurException <- set the very 1st time we add an event as an exception to a recurring series, won't update


            WHERE ID=@PKID


        end

        SELECT @UpdateDate = UpdateDate FROM CalendarEvent WHERE ID = @PKID

        commit transaction