Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ALTER proc [dbo].[Register_getTotal]
- @type int,
- @fromdate datetime,
- @todate datetime,
- @groupid int,
- @ledgerid int,
- @yearid int ,
- @invoiceNo nvarchar(max),
- @narration nvarchar(max),
- @pageNo int,
- @pagerow int
- as
- DECLARE @firstRecord int = (@pageNo - 1) * @pagerow + 1;
- DECLARE @lastRecord int = @firstRecord + @pagerow - 1;
- --Declare @Pages int =
- with totalTem as(
- select distinct MasterId,
- te.date, te.EntryDate,
- tlp.voucherTypeId, tlp.voucherNo, tlp.invoiceNo, totalAmount, te.narration, te.isImport,
- te.isfree, te.isvatPurchase, te.isfixedassests, te.userId, financialYearId, te.BranchID
- from tbl_EntryMaster te
- inner join tbl_ledgerposting tlp on tlp.entryMasterID = te.MasterId
- inner join tbl_AccountLedger tal on tal.ledgerId = tlp.ledgerId
- where
- tlp.voucherTypeId = @type
- and tlp.ledgerId = case when @ledgerid = 0 then tal.ledgerId else @ledgerid end
- and tal.accountGroupId = case when @groupid = 0 then tal.accountGroupId else @groupid end
- and convert(date, te.date) between convert(date, @fromdate) and convert(date, @todate)
- and te.financialYearId = @yearid
- and te.invoiceNo like @invoiceNo+'%'
- and isnull(te.narration,'') like '%'+@narration+'%'
- group by MasterId, te.date, te.EntryDate, tlp.voucherTypeId, tlp.voucherNo, tlp.invoiceNo, totalAmount, te.narration, te.isImport,
- te.isfree, te.isvatPurchase, te.isfixedassests, te.userId, financialYearId, te.BranchID
- )
- select @pagerow as pageRows , count (*) as totalRows, @firstRecord as firstRecord,
- case when count(*) > @pagerow then @lastRecord
- else @firstRecord + count(*) - 1 end
- as lastRecord, Ceiling(CONVERT(decimal,count(*))/@pagerow)
- as TotalPages, @pageNo as Currentpage from totalTem
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement