Completata prima integrazione lettura dati dal DB
This commit is contained in:
@@ -88,12 +88,62 @@ namespace MP.FileData.Controllers
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Elenco tabella Articoli (FILTRATO!!!)
|
||||
/// </summary>
|
||||
/// <param name="searchVal"></param>
|
||||
/// <param name="maxNum"></param>
|
||||
/// <returns></returns>
|
||||
public List<DatabaseModels.ArticoloModel> ArtGetFilt(string searchVal, int maxNum = 100)
|
||||
{
|
||||
maxNum = maxNum <= 0 ? 100 : maxNum;
|
||||
List<DatabaseModels.ArticoloModel> dbResult = new List<DatabaseModels.ArticoloModel>();
|
||||
|
||||
int totRecord = dbCtx
|
||||
.DbSetArticoli
|
||||
.Where(x => x.CodArticolo.Contains(searchVal) || x.DescArticolo.Contains(searchVal) || x.Disegno.Contains(searchVal))
|
||||
.Count();
|
||||
if (totRecord > maxNum)
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetArticoli
|
||||
.Where(x => x.CodArticolo.Contains(searchVal) || x.DescArticolo.Contains(searchVal) || x.Disegno.Contains(searchVal))
|
||||
.OrderBy(x => x.DescArticolo)
|
||||
.Take(maxNum)
|
||||
.ToList();
|
||||
dbResult.Add(new DatabaseModels.ArticoloModel() { CodArticolo = "#####", DescArticolo = $"... +{totRecord - maxNum} rec ..." });
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetArticoli
|
||||
.Where(x => x.CodArticolo.Contains(searchVal) || x.DescArticolo.Contains(searchVal) || x.Disegno.Contains(searchVal))
|
||||
.OrderBy(x => x.DescArticolo)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database context
|
||||
dbCtx.Dispose();
|
||||
}
|
||||
|
||||
public List<DatabaseModels.FileModel> FileGetFilt(string IdxMacchina, string CodArticolo, string SearchVal = "")
|
||||
{
|
||||
List<DatabaseModels.FileModel> dbResult = new List<DatabaseModels.FileModel>();
|
||||
|
||||
dbResult = dbCtx
|
||||
.DbSetProgFile
|
||||
.Where(x => ((x.IdxMacchina == IdxMacchina || IdxMacchina == "0") || (x.CodArticolo == CodArticolo || CodArticolo == "ND")) && (x.Name.Contains(SearchVal) || string.IsNullOrEmpty(SearchVal)))
|
||||
.OrderBy(x => x.Name)
|
||||
.ToList();
|
||||
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco tabella Macchine
|
||||
/// </summary>
|
||||
|
||||
@@ -185,12 +185,22 @@ namespace MP.Prog.Data
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public Task<List<MP.FileData.DatabaseModels.ArticoloModel>> ArticoliGetFilt(string SearchVal)
|
||||
{
|
||||
return Task.FromResult(dbController.ArtGetFilt(SearchVal, 20).ToList());
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database controller
|
||||
dbController.Dispose();
|
||||
}
|
||||
|
||||
public Task<List<MP.FileData.DatabaseModels.FileModel>> FileGetFilt(string IdxMacchina, string CodArticolo, string SearchVal)
|
||||
{
|
||||
return Task.FromResult(dbController.FileGetFilt(IdxMacchina, CodArticolo, SearchVal).ToList());
|
||||
}
|
||||
|
||||
public Task<List<MP.FileData.DatabaseModels.MacchinaModel>> MacchineGetAll()
|
||||
{
|
||||
return Task.FromResult(dbController.MacchineGetAll().ToList());
|
||||
|
||||
+53
-68
@@ -3,80 +3,65 @@
|
||||
<div class="card">
|
||||
<div class="card-header table-primary h3">
|
||||
<div class="row">
|
||||
<div class="col-6 col-lg-2 h3">
|
||||
<div class="col-12 col-md-3 col-lg-4 h3">
|
||||
Elenco Programmi
|
||||
</div>
|
||||
<div class="col-6 col-lg-2 text-right">
|
||||
<div class="d-flex justify-content-between">
|
||||
<div class="p-2">
|
||||
<div class="col-12 col-md-9 col-lg-8 text-right">
|
||||
<div class="form-row">
|
||||
<div class="col-1">
|
||||
<div class="form-group mb-0">
|
||||
<button id="btnReset" class="btn btn-info btn-sm btn-block" Clicked="ResetFilter" title="Reset Filter"><span class="oi oi-loop-circular"></span></button>
|
||||
<button id="btnForceCheck" class="btn btn-warning btn-sm btn-block" @onclick="() => ForceCheck()" title="Forza verifica archivio">
|
||||
<i class="far fa-folder-open"></i> <i class="fas fa-sync-alt"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<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="@SelIdxMacc" class="form-control form-control-sm">
|
||||
@if (MacList != null)
|
||||
{
|
||||
foreach (var item in MacList)
|
||||
{
|
||||
<option value="@item.IdxMacchina">@item.Descrizione (@item.CodMacchina)</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">
|
||||
<span class="fas fa-search" aria-hidden="true"></span>
|
||||
</span>
|
||||
</div>
|
||||
<input type="text" class="form-control form-control-sm" placeholder="Ricerca Articolo" @bind-value="@SearchArt" />
|
||||
<select @bind="@SelCodArt" class="form-control form-control-sm">
|
||||
@if (ArtList != null)
|
||||
{
|
||||
foreach (var item in ArtList)
|
||||
{
|
||||
<option value="@item.CodArticolo">@item.Disegno | @item.DescArticolo</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
<div class="input-group-append">
|
||||
<button id="searchReset" class="btn btn-sm btn-secondary" @onclick="() => ResetSearchArt()" title="Reset ricerca articolo"><i class="fas fa-ban"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-1">
|
||||
<div class="form-group mb-0">
|
||||
<button id="btnReset" class="btn btn-info btn-sm btn-block" @onclick="() => ResetFilter()" title="Reset Filter"><span class="oi oi-loop-circular"></span></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-lg-4 text-right">
|
||||
@*<div class="d-flex justify-content-between">
|
||||
<div class="p-2">
|
||||
<div class="input-group input-group-sm">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">inizio:</span>
|
||||
</div>
|
||||
<DateEdit class="form-control form-control-sm" TValue="DateTime?" Date="@DateStart" DateChanged="@OnDateStartChanged" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="p-2">
|
||||
<div class="input-group input-group-sm">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">fine:</span>
|
||||
</div>
|
||||
<DateEdit class="form-control form-control-sm" TValue="DateTime?" Date="@DateEnd" DateChanged="@OnDateEndChanged" />
|
||||
</div>
|
||||
</div>
|
||||
</div>*@
|
||||
</div>
|
||||
<div class="col-12 col-lg-4 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>
|
||||
</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>
|
||||
<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>*@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body p-1">
|
||||
@@ -87,7 +72,7 @@
|
||||
}
|
||||
@if (ListRecords == null)
|
||||
{
|
||||
@*<LoadingData></LoadingData>*@
|
||||
<LoadingData></LoadingData>
|
||||
}
|
||||
else if (totalCount == 0)
|
||||
{
|
||||
|
||||
@@ -21,6 +21,12 @@ namespace MP.Prog.Pages
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected string _SearchArt = "###";
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private int _currPage { get; set; } = 1;
|
||||
@@ -117,6 +123,33 @@ namespace MP.Prog.Pages
|
||||
[Inject]
|
||||
protected NavigationManager NavManager { get; set; }
|
||||
|
||||
protected string SearchArt
|
||||
{
|
||||
get
|
||||
{
|
||||
return _SearchArt;
|
||||
}
|
||||
set
|
||||
{
|
||||
isLoading = true;
|
||||
_SearchArt = value;
|
||||
// se son > 3 char... debounce...
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
_SearchArt = "###";
|
||||
}
|
||||
if (value.Length >= 3)
|
||||
{
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
ArtList = await DataService.ArticoliGetFilt(SearchArt);
|
||||
});
|
||||
pUpd.Wait();
|
||||
}
|
||||
isLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected int totalCount
|
||||
{
|
||||
get
|
||||
@@ -137,10 +170,8 @@ namespace MP.Prog.Pages
|
||||
private async Task ReloadData()
|
||||
{
|
||||
isLoading = true;
|
||||
#if false
|
||||
SearchRecords = await DataService.OrdersGetFilt(AppMService.Order_Filter);
|
||||
SearchRecords = await DataService.FileGetFilt(AppMService.File_Filter.IdxMacchina, AppMService.File_Filter.CodArticolo, AppMService.SearchVal);
|
||||
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
||||
#endif
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
@@ -157,6 +188,16 @@ namespace MP.Prog.Pages
|
||||
#endif
|
||||
}
|
||||
|
||||
protected async Task ForceCheck()
|
||||
{
|
||||
// !!!FARE
|
||||
currRecord = null;
|
||||
SearchRecords = null;
|
||||
ListRecords = null;
|
||||
AppMService.File_Filter = SelectData.Init(5, 10);
|
||||
await ReloadAllData();
|
||||
}
|
||||
|
||||
protected void ForceReload(int newNum)
|
||||
{
|
||||
numRecord = newNum;
|
||||
@@ -180,27 +221,10 @@ namespace MP.Prog.Pages
|
||||
protected async Task ReloadAllData()
|
||||
{
|
||||
isLoading = true;
|
||||
#if false
|
||||
SuppliersList = await DataService.SuppliersGetAll();
|
||||
SelIdxMacc = 0;
|
||||
PlantsList = null;
|
||||
await GetClaimsData();
|
||||
// se ho un plantId valido --> altrimenti non abilitato
|
||||
if (ClaimPlantId == 0)
|
||||
{
|
||||
PlantsList = await DataService.PlantsGetAll();
|
||||
}
|
||||
else if (ClaimPlantId > 0)
|
||||
{
|
||||
var rawData = await DataService.PlantsGetAll();
|
||||
PlantsList = rawData.Where(x => x.PlantId == ClaimPlantId).ToList();
|
||||
SelIdxMacc = ClaimPlantId;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlantsList = new List<PlantDTO>();
|
||||
}
|
||||
#endif
|
||||
MacList = await DataService.MacchineGetAll();
|
||||
SelIdxMacc = "0";
|
||||
ArtList = await DataService.ArticoliGetFilt(SearchArt);
|
||||
SelCodArt = "###";
|
||||
isLoading = false;
|
||||
await ReloadData();
|
||||
}
|
||||
@@ -217,9 +241,15 @@ namespace MP.Prog.Pages
|
||||
SearchRecords = null;
|
||||
ListRecords = null;
|
||||
AppMService.File_Filter = SelectData.Init(5, 10);
|
||||
SearchArt = "###";
|
||||
await ReloadAllData();
|
||||
}
|
||||
|
||||
protected void ResetSearchArt()
|
||||
{
|
||||
SearchArt = "###";
|
||||
}
|
||||
|
||||
protected void Select(FileModel selRecord)
|
||||
{
|
||||
// applico filtro da selezione
|
||||
|
||||
Reference in New Issue
Block a user