USP_DATAFORMTEMPLATE_ADD_DELIVERYMETHOD
The save procedure used by the add dataform template "Delivery Method Add 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. | 
| @NAME | nvarchar(100) | IN | Name | 
| @NAMEREQUIRED | bit | IN | Require name | 
| @ADDRESSREQUIRED | bit | IN | Require address | 
| @PHONEREQUIRED | bit | IN | Require phone number | 
| @EMAILREQUIRED | bit | IN | Require e-mail address | 
| @BLOCKDELIVERY | bit | IN | Block this delivery type | 
| @BLOCKTIMEVALUE | smallint | IN | Block this delivery time | 
| @BLOCKTIMEUNITCODE | tinyint | IN | before the event | 
| @PRINTCODE | tinyint | IN | Print sales documents | 
Definition
 Copy 
                                    
CREATE procedure dbo.USP_DATAFORMTEMPLATE_ADD_DELIVERYMETHOD
(
    @ID uniqueidentifier = null output,
    @CHANGEAGENTID uniqueidentifier = null,
    @NAME nvarchar(100) = null,
    @NAMEREQUIRED bit = null,
    @ADDRESSREQUIRED bit = null,
    @PHONEREQUIRED bit = null,
    @EMAILREQUIRED bit = null,
    @BLOCKDELIVERY bit = null,
    @BLOCKTIMEVALUE smallint = 1,
    @BLOCKTIMEUNITCODE tinyint = 1,
    @PRINTCODE tinyint = 0
)
as
    set nocount on;
    if @ID is null
        set @ID = newid()
    if @CHANGEAGENTID is null  
        exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output
    declare @CURRENTDATE datetime
    set @CURRENTDATE = getdate()
    --Don't count on the UI to set this.  Print at home requires an e-mail address.
    if @PRINTCODE = 2
        set @EMAILREQUIRED = 1
    begin try
        insert into dbo.DELIVERYMETHOD (
            ID,
            NAME,
            NAMEREQUIRED,
            ADDRESSREQUIRED,
            PHONEREQUIRED,
            EMAILREQUIRED,
            BLOCKDELIVERY,
            BLOCKTIMEVALUE,
            BLOCKTIMEUNITCODE,
            PRINTCODE,
            ADDEDBYID,
            CHANGEDBYID,
            DATEADDED,
            DATECHANGED
        )
        values (
            @ID,
            @NAME,
            @NAMEREQUIRED,
            @ADDRESSREQUIRED,
            @PHONEREQUIRED,
            @EMAILREQUIRED,
            @BLOCKDELIVERY,
            @BLOCKTIMEVALUE,
            @BLOCKTIMEUNITCODE,
            @PRINTCODE,
            @CHANGEAGENTID,
            @CHANGEAGENTID,
            @CURRENTDATE,
            @CURRENTDATE
        )
    end try
    begin catch
        exec dbo.USP_RAISE_ERROR
        return 1
    end catch
    return 0;