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.

125 lines
6.2 KiB

1 year ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_TransactionviewLogs] Script Date: 9/27/2019 1:30:14 PM ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. CREATE proc [dbo].[proc_TransactionviewLogs]
  9. @flag VARCHAR(50)
  10. ,@Id BIGINT = NULL
  11. ,@tranViewType VARCHAR(50) = NULL
  12. ,@controlNumber VARCHAR(50) = NULL
  13. ,@agent VARCHAR(50) = NULL
  14. ,@AgentName VARCHAR(50) =NULL
  15. ,@user VARCHAR(30) = NULL
  16. ,@createdBy VARCHAR(30) = NULL
  17. ,@createdDate DATE = NULL
  18. ,@sortBy VARCHAR(50) = NULL
  19. ,@sortOrder VARCHAR(5) = NULL
  20. ,@pageSize INT = NULL
  21. ,@pageNumber INT = NULL
  22. ,@tranId BIGINT = NULL
  23. AS
  24. SET NOCOUNT ON;
  25. IF @flag = 's'
  26. BEGIN
  27. DECLARE
  28. @selectFieldList VARCHAR(MAX)
  29. ,@extraFieldList VARCHAR(MAX)
  30. ,@table VARCHAR(MAX)
  31. ,@sqlFilter VARCHAR(MAX)
  32. IF @sortBy IS NULL
  33. SET @sortBy = 'createdDate'
  34. IF @sortOrder IS NULL
  35. SET @sortOrder = 'DESC'
  36. SET @table = '(
  37. SELECT
  38. al.id
  39. ,case when al.tranId is not null then al.tranId else c.id end tranId
  40. ,case when al.controlNumber is null then
  41. dbo.FNADecryptString(RT.controlNo) else al.controlNumber end
  42. as controlNumber
  43. ,isnull(al.tranViewType, ''T'') as tranViewType
  44. ,A.agentName
  45. ,al.createdBy
  46. ,al.createdDate
  47. FROM tranViewHistory al WITH(NOLOCK)
  48. LEFT JOIN remitTran RT WITH(NOLOCK) ON al.tranId=RT.id
  49. LEFT JOIN agentMaster A ON al.agentId = A.agentId
  50. left join remitTran C with(nolock) on c.controlNo=al.controlNumber and c.paidby=al.createdBy
  51. WHERE 1=1
  52. '
  53. SET @sqlFilter = ''
  54. SET @selectFieldList = '
  55. id
  56. , tranId
  57. , controlNumber
  58. , tranViewType
  59. , createdBy
  60. , createdDate
  61. , agentName
  62. '
  63. IF @tranViewType IS NOT NULL
  64. SET @table = @table + ' AND tranViewType = ''' + @tranViewType + ''''
  65. IF @createdDate IS NOT NULL
  66. SET @table = @table + ' AND cast(al.createdDate as date) = ''' + cast(@createdDate as varchar(11)) + ''''
  67. IF @Id IS NOT NULL
  68. SET @table = @table + ' AND dataId = ''' + @Id + ''''
  69. IF @controlNumber IS NOT NULL
  70. SET @table = @table + ' AND controlNumber = ''' + dbo.FNAEncryptString(@controlNumber) + ''''
  71. IF @agent IS NOT NULL
  72. SET @table = @table + ' AND agentName LIKE ''' + @agent + '%'''
  73. IF @createdBy IS NOT NULL
  74. SET @table = @table + ' AND al.createdBy = ''' + @createdBy + ''''
  75. IF @tranId IS NOT NULL
  76. SET @table = @table + ' AND al.tranId = ''' + cast(@tranId as varchar)+ ''''
  77. IF (@tranViewType IS NULL
  78. and @createdBy IS NULL
  79. and @agent IS NULL
  80. and @createdDate IS NULL
  81. and @controlNumber IS NULL
  82. and @tranId IS NULL
  83. )
  84. begin
  85. SET @table = @table + ' and 1=2 '
  86. end
  87. SET @table = @table +') x '
  88. EXEC dbo.proc_paging
  89. @table
  90. ,@sqlFilter
  91. ,@selectFieldList
  92. ,@extraFieldList
  93. ,@sortBy
  94. ,@sortOrder
  95. ,@pageSize
  96. ,@pageNumber
  97. END
  98. GO