Filtro sul periodo NON ok, da riprendere...

This commit is contained in:
Samuele Locatelli
2021-06-03 19:53:06 +02:00
parent 5439878c68
commit 1753f49296
4 changed files with 120 additions and 105 deletions
+2 -2
View File
@@ -139,11 +139,11 @@ namespace GWMS.Data.Controllers
return dbResult;
}
public List<OrderModel> GetOrdersFilt(int PlantId, int SupplierId)
public List<OrderModel> 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)
+1 -1
View File
@@ -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));
+59 -43
View File
@@ -1,5 +1,6 @@
@page "/orders"
@using Blazorise.Components
@using GWMS.UI.Components
<div class="card">
@@ -9,65 +10,80 @@
Ordini
</div>
<div class="col-6 text-right">
<div class="d-flex justify-content-between">
<div class="p-2">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fas fa-gas-pump" aria-hidden="true"></span>
</span>
<EditForm Model="@SelFilter">
<div class="d-flex justify-content-between">
<div class="p-2">
<div class="form-group mb-0">
<label for="dtInizio" class="small">inizio:</label>
<InputDateTime id="dtInizio" class="form-control form-control-sm" @bind-Value="@DateStart"></InputDateTime>
</div>
<select @bind="@SelPlantId" class="form-control form-control-sm">
<option value="0">--- Tutti ---</option>
@if (PlantsList != null)
{
foreach (var item in PlantsList)
{
<option value="@item.PlantId">@item.PlantCode | @item.PlantDesc</option>
}
}
</select>
</div>
</div>
<div class="p-2">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fas fa-industry" aria-hidden="true"></span>
</span>
<div class="p-2">
<div class="form-group mb-0">
<label for="dtFine" class="small">fine:</label>
<InputDateTime id="dtFine" class="form-control form-control-sm" @bind-Value="@DateEnd"></InputDateTime>
</div>
<select @bind="@SelSupplierId" class="form-control form-control-sm">
<option value="0">--- Tutti ---</option>
@if (SuppliersList != null)
{
foreach (var item in SuppliersList)
{
<option value="@item.SupplierId">@item.SupplierCode | @item.SupplierDesc</option>
}
}
</select>
</div>
</div>
@*<div class="p-2">
<div class="p-2">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fas fa-truck-moving" aria-hidden="true"></span>
<span class="fas fa-gas-pump" aria-hidden="true"></span>
</span>
</div>
<select @bind="@SelTransporterId" class="form-control form-control-sm">
<select @bind="@SelPlantId" class="form-control form-control-sm">
<option value="0">--- Tutti ---</option>
@if (TransportersList != null)
@if (PlantsList != null)
{
foreach (var item in TransportersList)
foreach (var item in PlantsList)
{
<option value="@item.TransporterId">@item.TransporterCode | @item.TransporterDesc</option>
<option value="@item.PlantId">@item.PlantCode | @item.PlantDesc</option>
}
}
</select>
</div>
</div>*@
</div>
</div>
<div class="p-2">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fas fa-industry" aria-hidden="true"></span>
</span>
</div>
<select @bind="@SelSupplierId" class="form-control form-control-sm">
<option value="0">--- Tutti ---</option>
@if (SuppliersList != null)
{
foreach (var item in SuppliersList)
{
<option value="@item.SupplierId">@item.SupplierCode | @item.SupplierDesc</option>
}
}
</select>
</div>
</div>
@*<div class="p-2">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fas fa-truck-moving" aria-hidden="true"></span>
</span>
</div>
<select @bind="@SelTransporterId" class="form-control form-control-sm">
<option value="0">--- Tutti ---</option>
@if (TransportersList != null)
{
foreach (var item in TransportersList)
{
<option value="@item.TransporterId">@item.TransporterCode | @item.TransporterDesc</option>
}
}
</select>
</div>
</div>*@
</div>
</EditForm>
</div>
</div>
</div>
+58 -59
View File
@@ -23,10 +23,6 @@ namespace GWMS.UI.Pages
#endregion Private Fields
#if false
private List<TransporterModel> 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();
}