Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE PROCEDURE [dbo].[crud_humans_getItems]
- @filters CRUDFilterParameter READONLY,
- @sort sql_variant,
- @direction nvarchar(8),
- @page int,
- @pageSize int,
- @username nvarchar(32)
- AS
- BEGIN
- -- основная процедура настройки таблицы
- declare @result TABLE(
- id nvarchar(max),
- phone nvarchar(max),
- fio nvarchar(max),
- freelancer nvarchar(max),
- statusID nvarchar(max)
- )
- -- itemID - это отдел
- declare @filterItemID int
- select @filterItemID = try_cast(Value as int) from @filters where [Key] = 'itemID'
- insert into @result
- select
- id id,
- isnull(phone, '<i>Нет телефона</i>') phone,
- isnull(fio, '') fio,
- iif(freelancer=1, 1, 0) freelancer,
- isnull((select name from hr_statuses where id = statusID), '') statusID
- from hr_humans
- where (@filterItemID is null or @filterItemID=depID) -- если не задан itemID - то берем всех
- -- 1 SELECT - сами данные
- select * from @result
- order by
- case when @sort = 'fio' and @direction = 'down' then fio end desc,
- case when @sort = 'fio' and @direction = 'up' then fio end asc,
- case when @sort = 'statusID' and @direction = 'down' then statusID end desc,
- case when @sort = 'statusID' and @direction = 'up' then statusID end asc
- OFFSET @PageSize * (@Page - 1) ROWS
- FETCH NEXT @PageSize ROWS ONLY;
- -- 2 SELECT - кол-во в таблице
- select count(*) from @result
- -- 3 SELECT Дополнительные настройки таблицы
- /*Select '' Title,
- '' ToolbarAdditional,
- '' GroupOperationsToolbar,
- '' EmptyText,
- '' FastCreateLinkText, '' FastCreateDialogHeader, '' FastCreateDialogPlaceholder,
- 0 FastCreateSearch, 0 FastCreateTextarea,
- 0 HideTitleCount,
- 0 DisableCellTitle,
- '10px' FontSize,
- '{filterCode}' FilterMakeup,
- 1 InstantFilter,
- */
- --'gantt' ViewType,
- -- GanttScale, GanttNavigate, GanttItemForm, GanttItemFormTitle
- -- KanbanItemForm, KanbanItemFormTitle
- -- 4 SELECT Данные для подвала страницы или данные для Ганта/Канбана (если установлен ViewType в 3 SELECT)
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement