USP_DATAFORMTEMPLATE_VIEW_BILLINGITEM_FLATRATE

The load procedure used by the view dataform template "Flat Rate billing item profile view"

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN The input ID parameter used to load the fields defined on the form.
@DATALOADED bit INOUT Output parameter indicating whether or not data was actually loaded.
@NAME nvarchar(100) INOUT Name
@DESCRIPTION nvarchar(255) INOUT Description
@CURRENTCOST money INOUT Current cost
@ISINACTIVE bit INOUT Status
@CURRENTCOSTDEFINED bit INOUT Current cost

Definition

Copy


                CREATE procedure dbo.USP_DATAFORMTEMPLATE_VIEW_BILLINGITEM_FLATRATE
                (
                    @ID uniqueidentifier,
                    @DATALOADED bit = 0 output,
                    @NAME nvarchar(100) = null output,
                    @DESCRIPTION nvarchar(255)  = null output,
                    @CURRENTCOST money = null output,
                    @ISINACTIVE bit = null output,
                    @CURRENTCOSTDEFINED bit = null output
                )
                as
                    set nocount on;

                    declare @CURRENTDATE date;
                    set @CURRENTDATE = getdate();

                    -- be sure to set this, in case the select returns no rows

                    set @DATALOADED = 0;

                    -- populate the output parameters, which correspond to fields on the form.  Note that

                    -- we set @DATALOADED = 1 to indicate that the load was successful.  Otherwise, the system

                    -- will display a "no data loaded" message.

                    select @DATALOADED = 1,                                
                                 @NAME = NAME,
                                 @DESCRIPTION = DESCRIPTION,                                 
                                 @CURRENTCOST = (select TOP 1 PRICE from dbo.BILLINGITEMPRICE where BILLINGITEMID=@ID and (DATERANGETYPECODE=0 OR (STARTDATE<=@CURRENTDATE and (ENDDATE>=@CURRENTDATE or ENDDATE IS NULL))) order by STARTDATE asc),
                                 @ISINACTIVE = ISINACTIVE,
                                 @CURRENTCOSTDEFINED= case when exists(select PRICE from dbo.BILLINGITEMPRICE where BILLINGITEMID=@ID and (DATERANGETYPECODE=0 OR (STARTDATE<=@CURRENTDATE and (ENDDATE>=@CURRENTDATE or ENDDATE IS NULL)))) then 1 else 0 end
                    from dbo.BILLINGITEM                        
                    where BILLINGITEM.ID = @ID

                    return 0;