Completato sposta item tra Categorie
This commit is contained in:
@@ -1530,6 +1530,39 @@ namespace SHERPA.BBM.CORE.Controllers
|
||||
return numDone;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sposta Item nella categoria indicata
|
||||
/// </summary>
|
||||
/// <param name="ItemId">Item</param>
|
||||
/// <param name="ResTypeId">Categoria</param>
|
||||
/// <returns></returns>
|
||||
public bool ItemMoveResType(int itemId, int resTypeId)
|
||||
{
|
||||
bool done = false;
|
||||
using (SHERPABBMContext dbCtx = new SHERPABBMContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
var currData = dbCtx
|
||||
.DbSetItems
|
||||
.Where(x => x.ItemId == itemId)
|
||||
.FirstOrDefault();
|
||||
if (currData != null)
|
||||
{
|
||||
currData.ResTypeId = resTypeId;
|
||||
dbCtx.Entry(currData).State = EntityState.Modified;
|
||||
}
|
||||
dbCtx.SaveChanges();
|
||||
done = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
LogException("Eccezione in ItemMoveResType", exc);
|
||||
}
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Eliminazione record
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
@using SHERPA.BBM.UI.Data
|
||||
|
||||
@inject BBM_EFService BBMService
|
||||
@inject MessageService MessageService
|
||||
|
||||
<table class="table table-sm table-striped ">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Cod</th>
|
||||
<th>Descrizione</th>
|
||||
<th class="text-right">Importo</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var record in ListRecords)
|
||||
{
|
||||
<tr class="@checkSelect(@record.ItemId)">
|
||||
<td class="text-nowrap">
|
||||
<button class="btn btn-sm btn-info" @onclick="() => Move(record)"><span class="fas fa-arrows-alt-h"></span></button>
|
||||
</td>
|
||||
<td class="small">
|
||||
<div>@record.CodItem</div>
|
||||
<div>@record.UM</div>
|
||||
</td>
|
||||
<td>
|
||||
<div>@record.Descript</div>
|
||||
</td>
|
||||
<td class="text-right text-nowrap" title="Importo"><b>@record.UnitPrice.ToString("C2")</b></td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="small">
|
||||
<DataPager PageSize="numRecord" currPage="currPage" numRecordChanged="ForceReload" numPageChanged="ForceReloadPage" totalCount="totalCount" showLoading="isLoading" />
|
||||
</div>
|
||||
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using SHERPA.BBM.CORE.DbModels;
|
||||
|
||||
namespace SHERPA.BBM.UI.Components
|
||||
{
|
||||
public partial class ItemMovList
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
[Parameter]
|
||||
public int ResTypeId
|
||||
{
|
||||
get => baskIdSour;
|
||||
set
|
||||
{
|
||||
baskIdSour = value;
|
||||
// condiziono visualizzazione...
|
||||
var pUpd = Task.Run(async () => await ReloadAllData());
|
||||
pUpd.Wait();
|
||||
}
|
||||
}
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<int> MoveRequested { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public string btnFromState(bool isActive)
|
||||
{
|
||||
string answ = isActive ? "btn-success" : "btn-outline-warning";
|
||||
return answ;
|
||||
}
|
||||
|
||||
public string checkSelect(int ItemId)
|
||||
{
|
||||
string answ = "";
|
||||
if (currItem != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
answ = (currItem.ItemId == ItemId) ? "table-info" : "";
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
return answ;
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected int totalCount = 0;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected async Task ForceReload(int newNum)
|
||||
{
|
||||
numRecord = newNum;
|
||||
await ReloadAllData();
|
||||
}
|
||||
|
||||
protected async Task ForceReloadPage(int newNum)
|
||||
{
|
||||
currPage = newNum;
|
||||
await ReloadAllData();
|
||||
}
|
||||
|
||||
protected async Task Move(vItemsDataModel currRecord)
|
||||
{
|
||||
// riporto richiesta spostamento
|
||||
await MoveRequested.InvokeAsync(currRecord.ItemId);
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
MessageService.ShowSearch = true;
|
||||
MessageService.SearchVal = "";
|
||||
MessageService.EA_SearchUpdated += OnSeachUpdated;
|
||||
await ReloadAllData();
|
||||
}
|
||||
|
||||
protected async Task ReloadAllData()
|
||||
{
|
||||
await updateTable();
|
||||
}
|
||||
|
||||
protected void ResetData()
|
||||
{
|
||||
if (currItem != null)
|
||||
{
|
||||
BBMService.rollBackEdit(currItem);
|
||||
}
|
||||
currItem = null;
|
||||
}
|
||||
|
||||
protected async Task UpdateData()
|
||||
{
|
||||
currItem = null;
|
||||
await ReloadAllData();
|
||||
}
|
||||
|
||||
protected async Task updateTable()
|
||||
{
|
||||
SearchRecords = await BBMService.ItemsGetFilt(ResTypeId, MessageService.SearchVal);
|
||||
totalCount = SearchRecords.Count();
|
||||
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private bool _showAllDoc = false;
|
||||
private vItemsDataModel? currItem = null;
|
||||
private bool isLoading = false;
|
||||
private List<vItemsDataModel> ListRecords = new List<vItemsDataModel>();
|
||||
private List<vItemsDataModel> SearchRecords = new List<vItemsDataModel>();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private int baskIdSour { get; set; } = 0;
|
||||
private int currPage { get; set; } = 1;
|
||||
private int custId { get; set; } = 0;
|
||||
private int numRecord { get; set; } = 10;
|
||||
|
||||
private bool ShowAllDoc
|
||||
{
|
||||
get
|
||||
{
|
||||
return _showAllDoc;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_showAllDoc = value;
|
||||
updateTable().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Properties
|
||||
}
|
||||
}
|
||||
@@ -1069,6 +1069,27 @@ namespace SHERPA.BBM.UI.Data
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sposta Item nella categoria indicata
|
||||
/// </summary>
|
||||
/// <param name="ItemId">Item</param>
|
||||
/// <param name="ResTypeId">Categoria</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ItemMoveResType(int ItemId, int ResTypeId)
|
||||
{
|
||||
bool answ = false;
|
||||
try
|
||||
{
|
||||
answ = dbController.ItemMoveResType(ItemId, ResTypeId);
|
||||
await FlushRedisCache();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
LogException("Eccezione durante ItemMoveResType", exc);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Eliminazione record
|
||||
/// </summary>
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@* <NegotMovList AnnoSel="@YearSel" BaskIdSour="@SelResTypeIdSx" MoveRequested="moveRight" CustomerId="SelCustomerIdSx"></NegotMovList> *@
|
||||
<ItemMovList ResTypeId="@SelResTypeIdSx" MoveRequested="moveRight"></ItemMovList>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="d-flex flex-column small">
|
||||
@@ -83,7 +83,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@* <NegotMovList AnnoSel="@YearSel" BaskIdSour="@SelResTypeIdDx" MoveRequested="moveLeft" CustomerId="SelCustomerIdDx"></NegotMovList> *@
|
||||
<ItemMovList ResTypeId="@SelResTypeIdDx" MoveRequested="moveRight"></ItemMovList>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace SHERPA.BBM.UI.Pages
|
||||
if (SelResTypeIdSx > 0)
|
||||
{
|
||||
// eseguo spostamento...
|
||||
await BBMService.NegotiationMoveBasket(currIdx, SelResTypeIdSx);
|
||||
await BBMService.ItemMoveResType(currIdx, SelResTypeIdSx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace SHERPA.BBM.UI.Pages
|
||||
if (SelResTypeIdDx > 0)
|
||||
{
|
||||
// eseguo spostamento...
|
||||
await BBMService.NegotiationMoveBasket(currIdx, SelResTypeIdDx);
|
||||
await BBMService.ItemMoveResType(currIdx, SelResTypeIdDx);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user