You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
3.1 KiB

1 year ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_messageDisplay] Script Date: 7/4/2019 11:35:48 AM ******/
  4. DROP PROCEDURE [dbo].[proc_messageDisplay]
  5. GO
  6. /****** Object: StoredProcedure [dbo].[proc_messageDisplay] Script Date: 7/4/2019 11:35:48 AM ******/
  7. SET ANSI_NULLS ON
  8. GO
  9. SET QUOTED_IDENTIFIER ON
  10. GO
  11. CREATE PROC [dbo].[proc_messageDisplay]
  12. @flag VARCHAR(50) = NULL
  13. ,@userType VARCHAR(10) = NULL
  14. ,@countryId VARCHAR(50) = NULL
  15. ,@agentId VARCHAR(50) = NULL
  16. ,@branchId VARCHAR(50) = NULL
  17. ,@msgId VARCHAR(50) = NULL
  18. ,@user VARCHAR(50) = NULL
  19. AS
  20. SET NOCOUNT ON
  21. SET XACT_ABORT ON
  22. DECLARE @agentNature AS VARCHAR(50) = null
  23. if @agentId is not null
  24. SELECT @agentNature = agentRole FROM agentMaster with(nolock) where agentId = @agentId
  25. if @userType is null
  26. select @userType = userType, @countryId = countryId from applicationUsers with(nolock) where username=@user
  27. IF @flag='s'
  28. BEGIN
  29. if @userType='HO'
  30. begin
  31. SELECT TOP 10 datename(dw, createdDate)+', '+ convert(varchar(50),cast(createdDate as datetime)) msgDate,newsFeederMsg,msgId
  32. from [message] WITH(NOLOCK)
  33. where newsFeederMsg is not null
  34. --and isnull(countryId,@countryId) = @countryId
  35. and isnull(agentId,isnull(@agentId,'')) = isnull(@agentId,'')
  36. and isnull(branchId,isnull(@branchId,'')) = isnull(@branchId,'')
  37. and (userType = @userType or userType is null)
  38. and ISNULL(isDeleted,'N') = 'N'
  39. and isnull(isActive,'Active') = 'Active'
  40. order by createdDate desc
  41. return;
  42. end
  43. IF @agentNature = 'B'
  44. BEGIN
  45. select TOP 10 datename(dw, createdDate)+', '+ convert(varchar(50),cast(createdDate as datetime)) msgDate,newsFeederMsg ,msgId from [message] WITH(NOLOCK)
  46. where newsFeederMsg is not null
  47. and isnull(countryId,@countryId) = @countryId
  48. and isnull(agentId,@agentId) = @agentId
  49. and isnull(branchId,@branchId) = @branchId
  50. and isnull(usertype,@userType) = @userType
  51. and (msgType IN ('B', 'S', 'R'))
  52. and ISNULL(isDeleted,'N') = 'N'
  53. and isnull(isActive,'Active') = 'Active'
  54. order by createdDate DESC
  55. END
  56. ELSE
  57. BEGIN
  58. select TOP 10 datename(dw, createdDate)+', '+ convert(varchar(50),cast(createdDate as datetime)) msgDate,newsFeederMsg ,msgId from [message] WITH(NOLOCK)
  59. where newsFeederMsg is not null
  60. and isnull(countryId,@countryId) = @countryId
  61. and isnull(agentId,@agentId) = @agentId
  62. and isnull(branchId,@branchId) = @branchId
  63. and isnull(usertype,@userType) = @userType
  64. --and (msgType IN ('B', @agentNature))
  65. and ISNULL(isDeleted,'N') = 'N'
  66. and isnull(isActive,'Active') = 'Active'
  67. order by createdDate DESC
  68. END
  69. END
  70. IF @flag = 'getNewsfeederById'
  71. BEGIN
  72. select newsFeederMsg
  73. ,datename(dw, createdDate)+', '+ convert(varchar(50),cast(createdDate as datetime)) msgDate
  74. ,datename(dw, createdDate)+', '+ convert(varchar(50),cast(createdDate as datetime)) createdDate
  75. ,createdBy
  76. from [message] WITH(NOLOCK)
  77. where newsFeederMsg is not null
  78. and msgId = @msgId
  79. and ISNULL(isDeleted,'N') = 'N'
  80. and isnull(isActive,'Active') = 'Active'
  81. END
  82. GO