USP_DATAFORMTEMPLATE_ADD_SCHEDULEPROGRAMEVENTS_PRELOAD
The load procedure used by the edit dataform template "Schedule Program Events Add Data Form"
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@PROGRAMID | uniqueidentifier | IN | Input parameter indicating the context ID for the record being added. |
@NAME | nvarchar(100) | INOUT | Name |
@DESCRIPTION | nvarchar(255) | INOUT | Description |
@LOCATIONS | xml | INOUT | |
@CAPACITY | int | INOUT | Capacity |
@RESOURCES | xml | INOUT | Supplies/Equipment resources |
@STAFFRESOURCES | xml | INOUT | Staffing resources |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_ADD_SCHEDULEPROGRAMEVENTS_PRELOAD
(
@PROGRAMID uniqueidentifier,
@NAME nvarchar(100) = null output,
@DESCRIPTION nvarchar(255) = null output,
@LOCATIONS xml = null output,
@CAPACITY integer = null output,
@RESOURCES xml = null output,
@STAFFRESOURCES xml = null output
)
as
set nocount on;
declare @HASPRICES bit;
declare @ISPROGRAMACTIVE bit;
select @NAME = NAME,
@DESCRIPTION = DESCRIPTION,
@ISPROGRAMACTIVE = ISACTIVE,
@CAPACITY = CAPACITY,
@HASPRICES = case when exists (select 1 from dbo.PROGRAMPRICE where PROGRAMPRICE.PROGRAMID = PROGRAM.ID) then
1
else
0
end,
@RESOURCES = dbo.UFN_PROGRAMRESOURCE_GETRESOURCES_TOITEMLISTXML(ID),
@STAFFRESOURCES = dbo.UFN_PROGRAMSTAFFRESOURCE_GETRESOURCESWITHJOBS_TOITEMLISTXML(ID)
from dbo.PROGRAM
where ID = @PROGRAMID;
if @ISPROGRAMACTIVE = 0
raiserror('Program must be active to schedule events.', 13, 1);
if @HASPRICES = 0
raiserror('The program must have prices defined before it can be scheduled.', 13, 1);
set @LOCATIONS =
(
select newid() as ID,
EVENTLOCATIONID,
CAPACITY,
SEQUENCE
from dbo.UFN_PROGRAM_GETSEQUENCEDLOCATIONS(@PROGRAMID)
for xml raw ('ITEM'), type, elements, root('LOCATIONS'), BINARY BASE64
);
return 0;