modifica gestioen pagina docs x nuovo paginatore
This commit is contained in:
@@ -3,8 +3,8 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MP.Stats.Components;
|
||||
using MP.Stats.Data;
|
||||
using SHERPA.BBM.UI.Components;
|
||||
using SHERPA.BBM.UI.Data;
|
||||
|
||||
namespace MP.Stats.Components
|
||||
{
|
||||
|
||||
@@ -228,12 +228,9 @@ namespace SHERPA.BBM.UI.Data
|
||||
return Task.FromResult(dbController.DocGetLastDesc(numRec).ToArray());
|
||||
}
|
||||
|
||||
public Task<DatabaseModels.DocsModel[]> DocsGetAsync(int BasketId, int NegotiationId, int numRec)
|
||||
public Task<List<DatabaseModels.DocsModel>> DocsGetAsync(int BasketId, int NegotiationId, int numRec)
|
||||
{
|
||||
//using (Controllers.BBMController myController = new Controllers.BBMController(connString))
|
||||
//{
|
||||
return Task.FromResult(dbController.DocGetLastDesc(BasketId, NegotiationId, numRec).ToArray());
|
||||
//}
|
||||
return Task.FromResult(dbController.DocGetLastDesc(BasketId, NegotiationId, numRec).ToList());
|
||||
}
|
||||
|
||||
public void DocsUpdate(DatabaseModels.DocsModel currItem)
|
||||
@@ -412,6 +409,11 @@ namespace SHERPA.BBM.UI.Data
|
||||
dbController.rollBackEntity(item);
|
||||
}
|
||||
|
||||
public Task<double> SumTotDraft(int anno)
|
||||
{
|
||||
return Task.FromResult(dbController.SumTotDraft(anno));
|
||||
}
|
||||
|
||||
public Task<decimal> SumTotImporto(int anno)
|
||||
{
|
||||
return Task.FromResult(dbController.SumTotImporto(anno));
|
||||
@@ -432,11 +434,6 @@ namespace SHERPA.BBM.UI.Data
|
||||
return Task.FromResult(dbController.SumTotTrattato(anno));
|
||||
}
|
||||
|
||||
public Task<double> SumTotDraft(int anno)
|
||||
{
|
||||
return Task.FromResult(dbController.SumTotDraft(anno));
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -56,10 +56,14 @@
|
||||
{
|
||||
<DocsEditor currItem="@currItem" DataReset="ResetData" DataUpdated="UpdateData"></DocsEditor>
|
||||
}
|
||||
@if (itemsList == null)
|
||||
@if (ListRecords == null)
|
||||
{
|
||||
<p><em>Loading...</em></p>
|
||||
}
|
||||
else if (totalCount == 0)
|
||||
{
|
||||
<div class="alert alert-warning text-center display-4">Nessun record trovato</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table table-sm table-striped">
|
||||
@@ -77,7 +81,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var record in itemsList)
|
||||
@foreach (var record in SearchRecords)
|
||||
{
|
||||
<tr class="@checkSelect(@record.DocId)">
|
||||
<td><button class="btn btn-sm btn-info" @onclick="() => Edit(record)"><span class="oi oi-pencil"></span></button> <button class="btn btn-sm btn-warning" @onclick="() => NewRelease(record)" title="Clona"><span class="oi oi-fork"></span></button> <button class="btn btn-sm btn-success" @onclick="() => ShowResources(record)" title="Vai al dettaglio Risorse"><span class="oi oi-puzzle-piece"></span></button> <button class="btn btn-sm btn-primary" @onclick="() => ShowBills(record)" title="Vai al dettaglio Fatture"><span class="oi oi-envelope-open"></span></button></td>
|
||||
@@ -133,5 +137,4 @@
|
||||
|
||||
@code {
|
||||
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using SHERPA.BBM.UI.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -15,9 +16,9 @@ namespace SHERPA.BBM.UI.Pages
|
||||
|
||||
private DatabaseModels.DocsModel currItem = null;
|
||||
|
||||
private DatabaseModels.DocsModel[] itemsList;
|
||||
|
||||
private List<DatabaseModels.DocsModel> ListRecords;
|
||||
private DatabaseModels.NegotiationsModel[] negotiationList;
|
||||
private List<DatabaseModels.DocsModel> SearchRecords;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
@@ -26,6 +27,10 @@ namespace SHERPA.BBM.UI.Pages
|
||||
[Inject]
|
||||
private BBM_EFService BBMService { get; set; }
|
||||
|
||||
private int currPage { get; set; } = 1;
|
||||
|
||||
private bool isLoading { get; set; } = false;
|
||||
|
||||
[Inject]
|
||||
private IJSRuntime JSRuntime { get; set; }
|
||||
|
||||
@@ -81,50 +86,22 @@ namespace SHERPA.BBM.UI.Pages
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Public Methods
|
||||
#region Protected Properties
|
||||
|
||||
public string btnFromState(bool isActive)
|
||||
protected int totalCount
|
||||
{
|
||||
string answ = isActive ? "btn-success" : "btn-outline-warning";
|
||||
return answ;
|
||||
}
|
||||
|
||||
public string checkSelect(int DocId)
|
||||
{
|
||||
string answ = "";
|
||||
if (currItem != null)
|
||||
get
|
||||
{
|
||||
try
|
||||
int answ = 0;
|
||||
if (SearchRecords != null)
|
||||
{
|
||||
answ = (currItem.DocId == DocId) ? "table-info" : "";
|
||||
answ = SearchRecords.Count;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
MessageService.EA_SearchUpdated -= OnSeachUpdated;
|
||||
}
|
||||
|
||||
public void OnSeachUpdated()
|
||||
{
|
||||
InvokeAsync(() =>
|
||||
{
|
||||
UpdateData();
|
||||
StateHasChanged();
|
||||
});
|
||||
}
|
||||
|
||||
public string tooltipFromState(bool isActive)
|
||||
{
|
||||
string answ = isActive ? "Attivo" : "Imposta Attivo";
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
@@ -167,6 +144,12 @@ namespace SHERPA.BBM.UI.Pages
|
||||
await ReloadAllData();
|
||||
}
|
||||
|
||||
protected async Task ForceReloadPage(int newNum)
|
||||
{
|
||||
currPage = newNum;
|
||||
await ReloadAllData();
|
||||
}
|
||||
|
||||
protected async Task<decimal> getFatturato(int DocId)
|
||||
{
|
||||
decimal fatturato = 0;
|
||||
@@ -275,15 +258,63 @@ namespace SHERPA.BBM.UI.Pages
|
||||
|
||||
protected async Task updateTable()
|
||||
{
|
||||
itemsList = await BBMService.DocsGetAsync(SelBasketId, SelCodNegotiation, numRecord);
|
||||
SearchRecords = await BBMService.DocsGetAsync(SelBasketId, SelCodNegotiation, numRecord);
|
||||
// filtro solo attivi SE NON richiesto
|
||||
if (!ShowAllDoc)
|
||||
{
|
||||
var filtList = itemsList.Where(x => x.IsActive == true).ToList();
|
||||
itemsList = filtList.ToArray();
|
||||
var filtList = SearchRecords.Where(x => x.IsActive == true).Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public string btnFromState(bool isActive)
|
||||
{
|
||||
string answ = isActive ? "btn-success" : "btn-outline-warning";
|
||||
return answ;
|
||||
}
|
||||
|
||||
public string checkSelect(int DocId)
|
||||
{
|
||||
string answ = "";
|
||||
if (currItem != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
answ = (currItem.DocId == DocId) ? "table-info" : "";
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
MessageService.EA_SearchUpdated -= OnSeachUpdated;
|
||||
}
|
||||
|
||||
public async void OnSeachUpdated()
|
||||
{
|
||||
await InvokeAsync(() =>
|
||||
{
|
||||
Task task = UpdateData();
|
||||
StateHasChanged();
|
||||
});
|
||||
}
|
||||
|
||||
public string tooltipFromState(bool isActive)
|
||||
{
|
||||
string answ = isActive ? "Attivo" : "Imposta Attivo";
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user