Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE PROCEDURE [dbo].[fm_clientQuestionaries_saveItem]
- @username nvarchar(256),
- @itemID int,
- @parameters ExtendedDictionaryParameter READONLY
- AS
- BEGIN
- declare
- @fieldchannel nvarchar(max) = '',
- @fieldlink nvarchar(max) = '',
- @fieldnegative nvarchar(max) = '',
- @fieldpositive nvarchar(max) = '',
- @fieldmostinteresting nvarchar(max) = '',
- @fieldnotenough nvarchar(max) = '',
- @fieldmoreinformation nvarchar(max) = '',
- @fieldalternative nvarchar(max) = '',
- @fieldpo nvarchar(max) = '',
- @fieldlike nvarchar(max) = '',
- @fieldemail nvarchar(max) = '',
- @fieldphone nvarchar(max) = '',
- @fieldaccess bit = 0
- declare @langID int
- select @langID = try_cast(Value as int) from @parameters where [Key] = 'langID'
- select @fieldchannel = value from @parameters where [key]='channel'
- select @fieldlink = value from @parameters where [key]='link'
- select @fieldnegative = value from @parameters where [key]='negative'
- select @fieldpositive = value from @parameters where [key]='positive'
- select @fieldmostinteresting = value from @parameters where [key]='mostinteresting'
- select @fieldnotenough = value from @parameters where [key]='notenough'
- select @fieldmoreinformation = value from @parameters where [key]='moreinformation'
- select @fieldalternative = value from @parameters where [key]='alternative'
- select @fieldpo = value from @parameters where [key]='po'
- select @fieldlike = value from @parameters where [key]='like'
- select @fieldemail = value from @parameters where [key]='email'
- select @fieldphone = value from @parameters where [key]='phone'
- select @fieldaccess = try_cast(value as bit) from @parameters where [key]='access'
- declare @percent decimal(18,2) = 0
- if len(@fieldchannel) > 5 set @percent = @percent + 2
- if len(@fieldlink) > 5 set @percent = @percent + 2
- if len(@fieldnegative) > 5 set @percent = @percent + 2
- if len(@fieldpositive) > 5 set @percent = @percent + 2
- if len(@fieldmostinteresting) > 0 set @percent = @percent + 2
- if len(@fieldnotenough) > 5 set @percent = @percent + 2
- if len(@fieldmoreinformation) > 5 set @percent = @percent + 2
- if len(@fieldalternative) > 5 set @percent = @percent + 2
- if len(@fieldpo) > 5 set @percent = @percent + 2
- if len(@fieldlike) > 0 set @percent = @percent + 2
- declare @userGuid uniqueidentifier
- select @userGuid = try_convert(uniqueidentifier, Value) from @parameters where [key] = 'falconGuid'
- declare @percentText nvarchar(16), @sumText nvarchar(16)
- select @percentText = cast(@percent as nvarchar)
- select @sumText = cast(cast(60000 * @percent/100 as decimal(18,0)) as nvarchar)
- if (select count(*) from falcon_clientQuestionaries where userGuid = @userGuid and question = 'percent') > 0
- update falcon_clientQuestionaries set answer = @percentText where userGuid = @userGuid and question = 'percent'
- else
- insert into falcon_clientQuestionaries (userGuid, question, answer) values (@userGuid, 'percent', @percentText)
- if (select count(*) from falcon_clientQuestionaries where userGuid = @userGuid and question = 'sum') > 0
- update falcon_clientQuestionaries set answer = @sumText where userGuid = @userGuid and question = 'sum'
- else
- insert into falcon_clientQuestionaries (userGuid, question, answer) values (@userGuid, 'sum', @sumText)
- declare @text nvarchar(max)
- select @text = iif(@langID=1, 'A discount is attached to your phone number. ' + @PercentText + '% discount for the purchase of a basic boxed solution is attached to your phone number.
- For additional questions, please contact via the chat on the website - at the bottom right. ', 'К номеру вашего телефона привязана скидка ' + @percentText + '% на покупку базового коробочного решения.
- По дополнительным вопросам обращайтесь пожалуйста через чат на сайте - справа внизу.' )
- select 1 Result, @text Msg, 0 HideFormAfterSubmit
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement