Advertisement
hecrus

Demo1 Subtable

Oct 17th, 2020
1,075
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 2.46 KB | None | 0 0
  1. CREATE PROCEDURE [dbo].[crud_tst-customerOrders_getItems]
  2.     @filters CRUDFilterParameter READONLY,
  3.     @sort sql_variant,
  4.     @direction nvarchar(8),
  5.     @page int,
  6.     @pageSize int,
  7.     @username nvarchar(32)
  8. AS
  9. BEGIN
  10.     -- основная процедура настройки таблицы
  11.    
  12.     -- результирующая таблица (описываем здесь поля)
  13.     -- спецполя для нее: icon_age, prev_age, prevcolor_age, color_age, backcolor_age, desc_name, color, barPercent_age, barClass_age, badge_age  
  14.     declare @result TABLE(
  15.         id int,
  16.         product nvarchar(max),
  17.         created nvarchar(max),
  18.         cnt int,
  19.         note nvarchar(max),
  20.         total nvarchar(max)
  21.     )
  22.    
  23.     declare @langID int
  24.     select @langID = try_cast(Value as int) from @filters where [Key]='langID'
  25.  
  26.  
  27.     -- извлекаем доп параметры из URL
  28.     declare @filterItemID int
  29.     select @filterItemID = cast(Value as int) from @filters where [Key] = 'itemID'
  30.    
  31.  
  32.     insert into @result select
  33.         id id,
  34.         isnull((select name from tst_products where id = productID), '<span class="badge badge-secondary">'+iif(@langID=1,'no name', 'не указан')+'</span>') product,
  35.        
  36.         dbo.[as_timeDelay](datediff(minute, created, getdate())) +' назад' created,
  37.         isnull(cnt, 0) cnt,
  38.         isnull(note, '') note,
  39.         cast(isnull(price * cnt, 0) as nvarchar)+'р.' total
  40.     from tst_orders where customerID= @filterItemID
  41.  
  42.    
  43.     -- 1 SELECT - сами данные    
  44.     select * from @result
  45.     order by  id
  46.     OFFSET @PageSize * (@Page - 1) ROWS
  47.     FETCH NEXT @PageSize ROWS ONLY;
  48.    
  49.     -- 2 SELECT - кол-во в таблице
  50.     select count(*) from @result   
  51.  
  52.     -- 3 SELECT Дополнительные настройки таблицы
  53.     select 1 Compact, 1 HideTitleCount, '10px' FontSize, iif(@langID=1,'Client products', 'Товары клиента') Title  --, 1 ZoomCells
  54.     /*Select  '' Title,
  55.         '' ToolbarAdditional,
  56.         '' GroupOperationsToolbar,
  57.         '' FastCreateLinkText, '' FastCreateDialogHeader, '' FastCreateDialogPlaceholder,
  58.          0 HideTitleCount,
  59.          0 DisableCellTitle,
  60.          '10px' FontSize,
  61.          '{filterCode}' FilterMakeup,
  62.          1 InstantFilter,
  63.            */
  64.         --'gantt' ViewType,
  65.         -- GanttScale, GanttNavigate, GanttItemForm, GanttItemFormTitle
  66.         -- KanbanItemForm, KanbanItemFormTitle
  67.  
  68.  
  69.     -- 4 SELECT Данные для подвала страницы или данные для Ганта/Канбана (если установлен ViewType в 3 SELECT)
  70.  
  71. END
  72.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement