USP_DATAFORMTEMPLATE_ADD_DAILYSALESORDER_MEMBERSHIPRENEW
The save procedure used by the add dataform template "Daily Sales Order Item Membership Renew Add Data Form".
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | INOUT | The output parameter indicating the ID of the record added. |
@CHANGEAGENTID | uniqueidentifier | IN | Input parameter indicating the ID of the change agent invoking the procedure. |
@SALESORDERID | uniqueidentifier | IN | Input parameter indicating the context ID for the record being added. |
@MEMBERSHIPID | uniqueidentifier | IN | Membership |
@MEMBERSHIPPROGRAMID | uniqueidentifier | IN | Membership Program |
@MEMBERSHIPLEVELID | uniqueidentifier | IN | Membership Level |
@MEMBERSHIPLEVELTERMID | uniqueidentifier | IN | Membership Level Term |
@MEMBERSHIPLEVELTYPECODEID | uniqueidentifier | IN | Membership Level Type |
@NUMBEROFCHILDREN | smallint | IN | Number of Children |
@COMMENTS | nvarchar(1000) | IN | Comments |
@EXPIRATIONDATE | datetime | IN | Expiration date |
@GIVENBYID | uniqueidentifier | IN |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_ADD_DAILYSALESORDER_MEMBERSHIPRENEW
(
@ID uniqueidentifier = null output,
@CHANGEAGENTID uniqueidentifier = null,
@SALESORDERID uniqueidentifier,
@MEMBERSHIPID uniqueidentifier = null,
@MEMBERSHIPPROGRAMID uniqueidentifier = null,
@MEMBERSHIPLEVELID uniqueidentifier = null,
@MEMBERSHIPLEVELTERMID uniqueidentifier = null,
@MEMBERSHIPLEVELTYPECODEID uniqueidentifier = null,
@NUMBEROFCHILDREN smallint = 0,
@COMMENTS nvarchar(1000) = null,
@EXPIRATIONDATE datetime = null,
@GIVENBYID uniqueidentifier = null
)
as
set nocount on;
declare @MEMBERS xml;
declare @MEMBERSHIPCARDS xml;
declare @MEMBERSHIPPROGRAMADDON xml;
declare @ISGIFT bit;
declare @SENDRENEWALCODE tinyint;
declare @ADDONMEMBERCOUNT int;
exec dbo.USP_DAILYSALES_MEMBERSHIPRENEWAL_GETMEMBERSANDCARDS
@SALESORDERID,
@MEMBERSHIPID,
@MEMBERSHIPPROGRAMID,
@MEMBERSHIPLEVELID,
@MEMBERSHIPLEVELTERMID,
@MEMBERSHIPLEVELTYPECODEID,
@EXPIRATIONDATE,
@MEMBERS output,
@MEMBERSHIPCARDS output,
@MEMBERSHIPPROGRAMADDON output,
@ADDONMEMBERCOUNT output;
if @GIVENBYID is null
begin
set @ISGIFT = 0;
set @SENDRENEWALCODE = 1; -- Primary member
end
else
begin
select
@ISGIFT = 1,
@SENDRENEWALCODE = SENDRENEWALCODE
from
dbo.MEMBERSHIP
where
ID = @MEMBERSHIPID;
end
begin try
exec dbo.USP_SALESORDERITEMMEMBERSHIP_ADD2
@ID output,
@CHANGEAGENTID,
@SALESORDERID,
@MEMBERSHIPID,
@MEMBERSHIPPROGRAMID,
@MEMBERSHIPLEVELID,
@MEMBERSHIPLEVELTERMID,
@MEMBERSHIPLEVELTYPECODEID,
@NUMBEROFCHILDREN,
@COMMENTS,
@ISGIFT,
@SENDRENEWALCODE,
@EXPIRATIONDATE,
@MEMBERS,
@MEMBERSHIPCARDS,
@MEMBERSHIPPROGRAMADDON,
@GIVENBYID,
0,
null,
1,
@ADDONMEMBERCOUNT;
end try
begin catch
exec dbo.USP_RAISE_ERROR;
return 1;
end catch
return 0;