USP_DATAFORMTEMPLATE_EDIT_VOLUNTEERSCREENPLANSTEP
The save procedure used by the edit dataform template "Volunteer Screening Plan Step 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. |
@STEPCODEID | uniqueidentifier | IN | Action |
@STATUSCODE | tinyint | IN | Status |
@DUEDATE | datetime | IN | Due date |
@DATECOMPLETE | datetime | IN | Completed on |
@COMMENTS | nvarchar(max) | IN | Comments |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_VOLUNTEERSCREENPLANSTEP
(
@ID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier,
@STEPCODEID uniqueidentifier,
@STATUSCODE tinyint,
@DUEDATE datetime,
@DATECOMPLETE datetime,
@COMMENTS nvarchar(MAX)
)
as
set nocount on;
declare @CURRENTDATE datetime;
declare @SCREENPLANID uniqueidentifier;
declare @ORIGINALSTATUSCODE tinyint;
IF @ID is null
set @ID = newid();
if @CHANGEAGENTID is null
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;
set @CURRENTDATE = getdate();
begin try
--if step is complete then get original step
if @STATUSCODE = 1 --complete
select
@ORIGINALSTATUSCODE = STATUSCODE,
@SCREENPLANID = SCREENPLANID
from dbo.VOLUNTEERSCREENPLANSTEP
where ID = @ID;
update dbo.VOLUNTEERSCREENPLANSTEP
set STEPCODEID = @STEPCODEID,
STATUSCODE = @STATUSCODE,
DUEDATE = @DUEDATE,
DATECOMPLETE = @DATECOMPLETE,
COMMENTS = @COMMENTS,
CHANGEDBYID = @CHANGEAGENTID,
DATECHANGED = @CURRENTDATE
where ID = @ID
--if step status was changed to step
if @STATUSCODE = 1 and @ORIGINALSTATUSCODE <> 1
exec dbo.USP_VOLUNTEER_CHECKSTEPSCOMPLETE @SCREENPLANID, @CHANGEAGENTID
end try
begin catch
exec dbo.USP_RAISE_ERROR;
return 1;
end catch
return 0;