USP_DATAFORMTEMPLATE_EDIT_PROGRAMPRICE
The save procedure used by the edit dataform template "Program Price Edit Form".
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | IN | The input ID parameter indicating the ID of the record being edited. |
@CHANGEAGENTID | uniqueidentifier | IN | Input parameter indicating the ID of the change agent invoking the procedure. |
@PRICELISTID | uniqueidentifier | IN | Price list |
@PRICES | xml | IN | Prices |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_PROGRAMPRICE(
@ID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier = null,
@PRICELISTID uniqueidentifier,
@PRICES xml
)
as
set nocount on;
if @CHANGEAGENTID is null
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output
declare @CURRENTDATE datetime
set @CURRENTDATE = getdate()
begin try
if @PRICELISTID is not null begin
if dbo.UFN_PRICELIST_ISEQUALTOPRICES(@PRICELISTID, @PRICES, 0) = 0 begin
update dbo.PROGRAM set
PRICELISTID = null,
CHANGEDBYID = @CHANGEAGENTID,
DATECHANGED = @CURRENTDATE
where ID = @ID;
end
end
exec dbo.USP_PROGRAM_GETPRICES_UPDATEFROMXML @ID, @PRICES, @CHANGEAGENTID, @CURRENTDATE;
if exists(
select 1
from dbo.[DAILYSALEITEMPROGRAM]
where
[DAILYSALEITEMPROGRAM].[PROGRAMID] = @ID and
not exists (
select 1
from dbo.[PROGRAMPRICE]
where
[PROGRAMPRICE].[PROGRAMID] = [DAILYSALEITEMPROGRAM].[PROGRAMID] and
[PROGRAMPRICE].[PRICETYPECODEID] = [DAILYSALEITEMPROGRAM].[PRICETYPECODEID]
)
)
raiserror('BBERR_DAILYSALEITEMWITHINVALIDPRICE.', 13, 1);
end try
begin catch
exec dbo.USP_RAISE_ERROR
return 1
end catch
return 0;