USP_DATAFORMTEMPLATE_ADD_PREREGISTEREDPROGRAMEVENTTICKET
The save procedure used by the add dataform template "Preregistered Program Event Ticket Add Data Form".
Parameters
| Parameter | Parameter Type | Mode | Description |
|---|---|---|---|
| @ID | uniqueidentifier | INOUT | The output parameter indicating the ID of the record added. |
| @SALESORDERID | uniqueidentifier | IN | Input parameter indicating the context ID for the record being added. |
| @CHANGEAGENTID | uniqueidentifier | IN | Input parameter indicating the ID of the change agent invoking the procedure. |
| @CURRENTAPPUSERID | uniqueidentifier | IN | Input parameter indicating the ID of the current user. |
| @EVENTID | uniqueidentifier | IN | |
| @CONSTITUENTID | uniqueidentifier | IN | Host |
| @REGISTRANTS | xml | IN | Registrants |
| @MARKREGISTRANTSATTENDED | bit | IN | Mark registrants as attended |
| @ALLOWPASTEVENTS | bit | IN | Allow sales to past events |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_ADD_PREREGISTEREDPROGRAMEVENTTICKET
(
@ID uniqueidentifier = null output,
@SALESORDERID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier = null,
@CURRENTAPPUSERID uniqueidentifier,
@EVENTID uniqueidentifier = null,
@CONSTITUENTID uniqueidentifier = null,
@REGISTRANTS xml = null,
@MARKREGISTRANTSATTENDED bit = 0,
@ALLOWPASTEVENTS bit = 0
)
as
set nocount on;
-- Multiple tickets could be added.
--if @ID is null
-- set @ID = newid();
if @CHANGEAGENTID is null
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;
declare @SALESMETHODTYPECODE tinyint;
select @SALESMETHODTYPECODE = SALESMETHODTYPECODE from dbo.SALESORDER where ID = @SALESORDERID;
declare @CURRENTDATE datetime;
set @CURRENTDATE = getdate();
begin try
exec dbo.USP_SALESORDER_ISCOMPLETE_RAISERROR @SALESORDERID, @EXCLUDEGROUPSALES = 1;
if exists (
select 1
from dbo.[CONSTITUENT]
where
[ISGROUP] = 1 and
[ID] = @CONSTITUENTID
)
begin
raiserror('BBERR_HOST_INVALIDGROUPCONSTITUENT', 13, 1);
end
exec dbo.USP_SALESORDER_PREREGISTEREDPROGRAMEVENTTICKET_ADD
@SALESORDERID,
@CHANGEAGENTID,
@CURRENTAPPUSERID,
@EVENTID,
@CONSTITUENTID,
@REGISTRANTS,
@CURRENTDATE,
@MARKREGISTRANTSATTENDED,
@ALLOWPASTEVENTS;
--For daily sales, we want to return the ID of the top sales order item created for these tickets
if @SALESMETHODTYPECODE = 0
begin
select top 1 @ID = SALESORDERITEM.ID
from dbo.SALESORDERITEM
inner join dbo.SALESORDERITEMTICKET
on SALESORDERITEM.ID = SALESORDERITEMTICKET.ID
where
SALESORDERITEMTICKET.EVENTID = @EVENTID and
SALESORDERITEM.SALESORDERID = @SALESORDERID
end
end try
begin catch
exec dbo.USP_RAISE_ERROR;
return 1;
end catch
return 0;