USP_DATAFORMTEMPLATE_EDIT_SESSION
The save procedure used by the edit dataform template "Session 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. |
| @SESSIONNAMECODEID | uniqueidentifier | IN | Name |
| @MARKINGCOLUMNSETID | uniqueidentifier | IN | Marking columns |
| @SUNDAY | bit | IN | Sunday |
| @MONDAY | bit | IN | Monday |
| @TUESDAY | bit | IN | Tuesday |
| @WEDNESDAY | bit | IN | Wednesday |
| @THURSDAY | bit | IN | Thursday |
| @FRIDAY | bit | IN | Friday |
| @SATURDAY | bit | IN | Saturday |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_SESSION (
@ID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier = null,
@SESSIONNAMECODEID uniqueidentifier,
@MARKINGCOLUMNSETID uniqueidentifier,
@SUNDAY bit,
@MONDAY bit,
@TUESDAY bit,
@WEDNESDAY bit,
@THURSDAY bit,
@FRIDAY bit,
@SATURDAY bit
)
as
set nocount on
if @CHANGEAGENTID is null
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output
declare @CURRENTDATE datetime
set @CURRENTDATE = getdate()
begin try
-- handle updating the data
update dbo.SESSION set
SESSIONNAMECODEID = @SESSIONNAMECODEID,
MARKINGCOLUMNSETID = @MARKINGCOLUMNSETID,
SUNDAY = @SUNDAY,
MONDAY = @MONDAY,
TUESDAY = @TUESDAY,
WEDNESDAY = @WEDNESDAY,
THURSDAY = @THURSDAY,
FRIDAY = @FRIDAY,
SATURDAY = @SATURDAY,
CHANGEDBYID = @CHANGEAGENTID,
DATECHANGED = @CURRENTDATE
where ID = @ID
--generate calendar entries
declare @TempTbl table (
[ROWID] int identity(1,1),
[TERMID] uniqueidentifier)
insert into @TempTbl (TERMID)
select [ID]
from
dbo.[TERM]
where
SESSIONID = @ID
declare @rowId int
declare @maxRowId int
declare @TERMID uniqueidentifier = null
select
@rowId = min(ROWID),
@MaxRowId = max(ROWID)
from @TempTbl
while @RowId <= @MaxRowId
begin
select
@TERMID = TERMID
from
@TempTbl
where
ROWID = @RowId
exec dbo.USP_SCHEDULEDATE_ADJUSTENTRIES @TERMID, null, null, null, @CHANGEAGENTID
set @RowId = @RowId + 1
end
end try
begin catch
exec dbo.USP_RAISE_ERROR
return 1
end catch
return 0