From 1753f49296cbbf6b26dd29a8d39b46aefef4dcec Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 3 Jun 2021 19:53:06 +0200 Subject: [PATCH] Filtro sul periodo NON ok, da riprendere... --- GWMS.Data/Controllers/GWMSController.cs | 4 +- GWMS.UI/Data/GWMSDataService.cs | 2 +- GWMS.UI/Pages/Orders.razor | 102 ++++++++++++--------- GWMS.UI/Pages/Orders.razor.cs | 117 ++++++++++++------------ 4 files changed, 120 insertions(+), 105 deletions(-) diff --git a/GWMS.Data/Controllers/GWMSController.cs b/GWMS.Data/Controllers/GWMSController.cs index d01461f..969f4ee 100644 --- a/GWMS.Data/Controllers/GWMSController.cs +++ b/GWMS.Data/Controllers/GWMSController.cs @@ -139,11 +139,11 @@ namespace GWMS.Data.Controllers return dbResult; } - public List GetOrdersFilt(int PlantId, int SupplierId) + public List GetOrdersFilt(int PlantId, int SupplierId, DateTime DtStart, DateTime DtEnd) { var dbResult = dbCtx .DbSetOrders - .Where(x => (x.PlantId == PlantId || PlantId == 0) && (x.SupplierId == SupplierId || SupplierId == 0)) + .Where(x => (x.PlantId == PlantId || PlantId == 0) && (x.SupplierId == SupplierId || SupplierId == 0) && (x.DtOrder >= DtStart && x.DtOrder <= DtEnd)) .Include(p => p.Plant) .Include(s => s.Supplier) .Include(t => t.Transporter) diff --git a/GWMS.UI/Data/GWMSDataService.cs b/GWMS.UI/Data/GWMSDataService.cs index 050994b..d661dc8 100644 --- a/GWMS.UI/Data/GWMSDataService.cs +++ b/GWMS.UI/Data/GWMSDataService.cs @@ -171,7 +171,7 @@ namespace GWMS.UI.Data { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); - dbResult = dbController.GetOrdersFilt(CurrFilter.PlantId, CurrFilter.SupplierId); + dbResult = dbController.GetOrdersFilt(CurrFilter.PlantId, CurrFilter.SupplierId, CurrFilter.DateStart, CurrFilter.DateEnd); rawData = JsonConvert.SerializeObject(dbResult); redisDataList = Encoding.UTF8.GetBytes(rawData); await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt(true)); diff --git a/GWMS.UI/Pages/Orders.razor b/GWMS.UI/Pages/Orders.razor index b356e6c..ef3e40e 100644 --- a/GWMS.UI/Pages/Orders.razor +++ b/GWMS.UI/Pages/Orders.razor @@ -1,5 +1,6 @@ @page "/orders" +@using Blazorise.Components @using GWMS.UI.Components
@@ -9,65 +10,80 @@ Ordini
-
-
-
-
- - - + + +
+
+
+ +
-
-
-
-
-
- - - +
+
+ +
-
-
- @*
+
- +
- - @if (TransportersList != null) + @if (PlantsList != null) { - foreach (var item in TransportersList) + foreach (var item in PlantsList) { - + } }
-
*@ -
+
+
+
+
+ + + +
+ +
+
+ @*
+
+
+ + + +
+ +
+
*@ +
+
diff --git a/GWMS.UI/Pages/Orders.razor.cs b/GWMS.UI/Pages/Orders.razor.cs index 9d648cd..40b9768 100644 --- a/GWMS.UI/Pages/Orders.razor.cs +++ b/GWMS.UI/Pages/Orders.razor.cs @@ -23,10 +23,6 @@ namespace GWMS.UI.Pages #endregion Private Fields -#if false - private List TransportersList; -#endif - #region Private Properties private int _currPage { get; set; } = 1; @@ -63,20 +59,32 @@ namespace GWMS.UI.Pages } } + private SelectOrderData SelFilter + { + get + { + return MessageService.Order_Filter; + } + set + { + MessageService.Order_Filter = value; + } + } + private int SelPlantId { get { int answ = 0; - if (MessageService.Order_Filter != null) + if (SelFilter != null) { - answ = MessageService.Order_Filter.PlantId; + answ = SelFilter.PlantId; } return answ; } set { - MessageService.Order_Filter.PlantId = value; + SelFilter.PlantId = value; var pUpd = Task.Run(async () => await ReloadData()); pUpd.Wait(); } @@ -87,46 +95,19 @@ namespace GWMS.UI.Pages get { int answ = 0; - if (MessageService.Order_Filter != null) + if (SelFilter != null) { - answ = MessageService.Order_Filter.SupplierId; + answ = SelFilter.SupplierId; } return answ; } set { - MessageService.Order_Filter.SupplierId = value; - var pUpd = Task.Run(async () => - { -#if false - TransportersList = await DataService.TransportersGetFilt(SelTransporterId); -#endif - await ReloadData(); - }); - pUpd.Wait(); - } - } - -#if false - private int SelTransporterId - { - get - { - int answ = 0; - if (MessageService.Order_Filter != null) - { - answ = MessageService.Order_Filter.TransporterId; - } - return answ; - } - set - { - MessageService.Order_Filter.TransporterId = value; + SelFilter.SupplierId = value; var pUpd = Task.Run(async () => await ReloadData()); pUpd.Wait(); } } -#endif private bool ShowCharts { get; set; } = false; @@ -137,6 +118,44 @@ namespace GWMS.UI.Pages [Inject] protected GWMSDataService DataService { get; set; } + protected DateTime DateEnd + { + get + { + DateTime answ = DateTime.Today.AddDays(1); + if (SelFilter != null) + { + answ = SelFilter.DateEnd; + } + return answ; + } + set + { + SelFilter.DateEnd = value; + var pUpd = Task.Run(async () => await ReloadData()); + pUpd.Wait(); + } + } + + protected DateTime DateStart + { + get + { + DateTime answ = DateTime.Today.AddDays(-1); + if (SelFilter != null) + { + answ = SelFilter.DateStart; + } + return answ; + } + set + { + SelFilter.DateStart = value; + var pUpd = Task.Run(async () => await ReloadData()); + pUpd.Wait(); + } + } + [Inject] protected IJSRuntime JSRuntime { get; set; } @@ -161,29 +180,12 @@ namespace GWMS.UI.Pages #endregion Protected Properties - #region Public Properties - - [Parameter] - public SelectOrderData currFilter - { - get - { - return MessageService.Order_Filter; - } - set - { - MessageService.Order_Filter = value; - } - } - - #endregion Public Properties - #region Private Methods private async Task ReloadData() { isLoading = true; - SearchRecords = await DataService.OrdersGetFilt(currFilter); + SearchRecords = await DataService.OrdersGetFilt(SelFilter); ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); isLoading = false; } @@ -215,9 +217,6 @@ namespace GWMS.UI.Pages { PlantsList = await DataService.PlantsGetAll(); SuppliersList = await DataService.SuppliersGetAll(); -#if false - TransportersList = await DataService.TransportersGetFilt(SelTransporterId); -#endif await ReloadData(); } @@ -226,7 +225,7 @@ namespace GWMS.UI.Pages currRecord = null; SearchRecords = null; ListRecords = null; - currFilter = SelectOrderData.Init(5, 7); + SelFilter = SelectOrderData.Init(5, 7); await ReloadAllData(); }