From c7e90634587b539e1adf812ec930e106f68caa37 Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Wed, 15 Feb 2023 09:36:40 +0100 Subject: [PATCH] fix ordinamento per codice fornitore --- StockMan.CORE/Components/ItemList.razor | 42 ++++++++++++++++++---- StockMan.CORE/Components/ItemList.razor.cs | 34 +++++++++++++++--- 2 files changed, 66 insertions(+), 10 deletions(-) diff --git a/StockMan.CORE/Components/ItemList.razor b/StockMan.CORE/Components/ItemList.razor index d1fb754..58d04c2 100644 --- a/StockMan.CORE/Components/ItemList.razor +++ b/StockMan.CORE/Components/ItemList.razor @@ -27,12 +27,42 @@ else DESC. ARTICOLO - - COD. FORNITORE - - - STOCK - + @if (orderType == orderTypeEnum.codExtAscending) + { + + COD. FORNITORE + + } + else if (orderType == orderTypeEnum.codExtDescending) + { + + COD. FORNITORE + + } + else + { + + COD. FORNITORE + + } + @if (orderType == orderTypeEnum.stockAscending) + { + + STOCK + + } + else if (orderType == orderTypeEnum.stockDescending) + { + + STOCK + + } + else + { + + STOCK + + } VALORE UNIT. diff --git a/StockMan.CORE/Components/ItemList.razor.cs b/StockMan.CORE/Components/ItemList.razor.cs index 8ff0d51..b56495e 100644 --- a/StockMan.CORE/Components/ItemList.razor.cs +++ b/StockMan.CORE/Components/ItemList.razor.cs @@ -78,6 +78,7 @@ namespace StockMan.CORE.Components private IConfiguration Configuration { get; set; } = null!; protected bool isLoading = false; + protected orderTypeEnum orderType = orderTypeEnum.none; protected bool isStockAscending = false; protected bool isCodExtAscending = false; @@ -93,19 +94,19 @@ namespace StockMan.CORE.Components SearchRecords = await SDService.ItemsGetAll(); } totalCount = SearchRecords.Count; - if (isStockAscending) + if ( orderType == orderTypeEnum.stockAscending) { SearchRecords = SearchRecords.OrderBy(x => x.QtaBatch).ToList(); } - else if (!isStockAscending) + else if (orderType == orderTypeEnum.stockDescending) { SearchRecords = SearchRecords.OrderByDescending(x => x.QtaBatch).ToList(); } - else if (isCodExtAscending) + else if (orderType == orderTypeEnum.codExtAscending) { SearchRecords = SearchRecords.OrderBy(x => x.CodExt).ToList(); } - else if (!isCodExtAscending) + else if (orderType == orderTypeEnum.stockDescending) { SearchRecords = SearchRecords.OrderByDescending(x => x.CodExt).ToList(); } @@ -122,14 +123,39 @@ namespace StockMan.CORE.Components NavManager.NavigateTo(rawCode, true); } + protected enum orderTypeEnum + { + none = 1, + stockAscending, + stockDescending, + codExtAscending, + codExtDescending + } + protected async Task orderByStock() { isStockAscending = !isStockAscending; + if (isStockAscending) + { + orderType = orderTypeEnum.stockAscending; + } + else + { + orderType = orderTypeEnum.stockDescending; + } await reloadData(); } protected async Task orderByCodForn() { isCodExtAscending = !isCodExtAscending; + if (isCodExtAscending) + { + orderType = orderTypeEnum.codExtAscending; + } + else + { + orderType = orderTypeEnum.codExtDescending; + } await reloadData(); } protected async Task addNewItem()