Merge branch 'release/AddMoveItemCat'
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Version>2.0.2402.1217</Version>
|
||||
<Version>2.0.2402.1219</Version>
|
||||
<Copyright>Egalware 2021+</Copyright>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -1530,6 +1530,70 @@ 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>
|
||||
/// <param name="currRecord"></param>
|
||||
/// <returns></returns>
|
||||
public bool ItemResTypeDelete(ItemResTypeModel currRecord)
|
||||
{
|
||||
bool done = false;
|
||||
using (SHERPABBMContext dbCtx = new SHERPABBMContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
var item2del = dbCtx
|
||||
.DbSetItemResType
|
||||
.Where(x => x.ResTypeId == currRecord.ResTypeId)
|
||||
.FirstOrDefault();
|
||||
if (item2del != null)
|
||||
{
|
||||
dbCtx.DbSetItemResType.Remove(item2del);
|
||||
dbCtx.SaveChanges();
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
LogException("Eccezione in ItemResTypeDelete", exc);
|
||||
}
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco tipi risorse/item
|
||||
/// </summary>
|
||||
@@ -1541,12 +1605,51 @@ namespace SHERPA.BBM.CORE.Controllers
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetItemResType
|
||||
.Include(x => x.ItemNav)
|
||||
.OrderBy(x => x.Name)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update categoria su DB
|
||||
/// </summary>
|
||||
/// <param name="updItem"></param>
|
||||
/// <returns></returns>
|
||||
public bool ItemResTypeUpdate(ItemResTypeModel updItem)
|
||||
{
|
||||
bool done = false;
|
||||
using (SHERPABBMContext dbCtx = new SHERPABBMContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
var currData = dbCtx
|
||||
.DbSetItemResType
|
||||
.Where(x => x.ResTypeId == updItem.ResTypeId && updItem.ResTypeId > 0)
|
||||
.FirstOrDefault();
|
||||
if (currData != null)
|
||||
{
|
||||
currData.Name = updItem.Name;
|
||||
dbCtx.Entry(currData).State = EntityState.Modified;
|
||||
}
|
||||
else
|
||||
{
|
||||
dbCtx
|
||||
.DbSetItemResType
|
||||
.Add(updItem);
|
||||
}
|
||||
dbCtx.SaveChanges();
|
||||
done = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
LogException("Eccezione in ItemResTypeUpdate", exc);
|
||||
}
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
public int ItemsCount()
|
||||
{
|
||||
int answ = 0;
|
||||
@@ -2623,6 +2726,11 @@ namespace SHERPA.BBM.CORE.Controllers
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Eliminazione record dato ID
|
||||
/// </summary>
|
||||
/// <param name="tagId"></param>
|
||||
/// <returns></returns>
|
||||
public bool TagDelete(int tagId)
|
||||
{
|
||||
bool done = false;
|
||||
@@ -2646,6 +2754,11 @@ namespace SHERPA.BBM.CORE.Controllers
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Eliminazione record
|
||||
/// </summary>
|
||||
/// <param name="delItem"></param>
|
||||
/// <returns></returns>
|
||||
public bool TagItemDelete(TagItemModel delItem)
|
||||
{
|
||||
bool done = false;
|
||||
|
||||
@@ -18,6 +18,10 @@ namespace SHERPA.BBM.CORE.DbModels
|
||||
[Table("ResType")]
|
||||
public partial class ItemResTypeModel
|
||||
{
|
||||
public ItemResTypeModel()
|
||||
{
|
||||
ItemNav = new HashSet<ItemsModel>();
|
||||
}
|
||||
|
||||
[Key, Column("ResTypeId"), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int ResTypeId { get; set; }
|
||||
@@ -25,5 +29,6 @@ namespace SHERPA.BBM.CORE.DbModels
|
||||
[Column("Name"), MaxLength(250)]
|
||||
public string Name { get; set; } = "ND";
|
||||
|
||||
public virtual ICollection<ItemsModel> ItemNav { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,20 +20,6 @@ namespace SHERPA.BBM
|
||||
Licenza = 10000
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Tipo Risorsa BBM
|
||||
/// </summary>
|
||||
public enum BbmResType
|
||||
{
|
||||
ND = 0,
|
||||
HR = 1,
|
||||
License = 2,
|
||||
HW = 3,
|
||||
Service = 4
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Tipo Tag
|
||||
/// </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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<div class="card shadow">
|
||||
<div class="card-header bg-info text-light">
|
||||
<b>Modifica</b>
|
||||
</div>
|
||||
<div class="card-body small">
|
||||
<EditForm Model="@_currItem">
|
||||
<DataAnnotationsValidator />
|
||||
<ValidationSummary />
|
||||
<div class="row">
|
||||
<div class="col-12 col-lg-6">
|
||||
<div class="form-group">
|
||||
<label for="codTag">Codice:</label>
|
||||
<InputText id="codTag" @bind-Value="_currItem.Name" class="form-control form-control-sm" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 col-lg-3">
|
||||
<input type="submit" class="btn btn-success btn-block" value="Save" @onclick="saveUpdate" />
|
||||
</div>
|
||||
<div class="col-6 col-lg-3">
|
||||
<button type="button" class="btn btn-warning btn-block" value="Cancel" @onclick="cancelUpdate">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</EditForm>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using SHERPA.BBM.CORE.DbModels;
|
||||
using SHERPA.BBM.UI.Data;
|
||||
|
||||
namespace SHERPA.BBM.UI.Components
|
||||
{
|
||||
public partial class ResTypeEditor
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
[Parameter]
|
||||
public ItemResTypeModel currItem
|
||||
{
|
||||
get
|
||||
{
|
||||
return _currItem;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_currItem = value;
|
||||
}
|
||||
}
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<int> DataReset { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<int> DataUpdated { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected ItemResTypeModel _currItem = new ItemResTypeModel();
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected BBM_EFService BBMService { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private async Task cancelUpdate()
|
||||
{
|
||||
await DataReset.InvokeAsync(0);
|
||||
}
|
||||
|
||||
private async Task saveUpdate()
|
||||
{
|
||||
if (_currItem != null)
|
||||
{
|
||||
await BBMService.ItemResTypeUpdate(_currItem);
|
||||
await DataUpdated.InvokeAsync(1);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -1069,6 +1069,36 @@ 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>
|
||||
/// <returns></returns>
|
||||
public bool ItemResTypeDelete(ItemResTypeModel currRecord)
|
||||
{
|
||||
return dbController.ItemResTypeDelete(currRecord);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco tipi risorse/item
|
||||
/// </summary>
|
||||
@@ -1106,6 +1136,31 @@ namespace SHERPA.BBM.UI.Data
|
||||
return Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update Categoria
|
||||
/// </summary>
|
||||
/// <param name="currItem"></param>
|
||||
/// <returns></returns>
|
||||
public async Task ItemResTypeUpdate(ItemResTypeModel currItem)
|
||||
{
|
||||
try
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
bool fatto = dbController.ItemResTypeUpdate(currItem);
|
||||
if (fatto)
|
||||
{
|
||||
await FlushRedisCache();
|
||||
}
|
||||
stopWatch.Stop();
|
||||
LogDebug($"ItemResTypeUpdate", stopWatch.Elapsed);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
LogException("Eccezione in ItemResTypeUpdate", exc);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gestione items con cache redis x tipo...
|
||||
/// </summary>
|
||||
@@ -2066,18 +2121,22 @@ namespace SHERPA.BBM.UI.Data
|
||||
return Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
public void TagDelete(TagModel currRecord)
|
||||
/// <summary>
|
||||
/// Eliminazione record
|
||||
/// </summary>
|
||||
/// <param name="currRecord"></param>
|
||||
public bool TagDelete(TagModel currRecord)
|
||||
{
|
||||
dbController.TagDelete(currRecord.TagId);
|
||||
return dbController.TagDelete(currRecord.TagId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete Tag2Item
|
||||
/// </summary>
|
||||
/// <param name="currRecord"></param>
|
||||
public void TagItemDelete(TagItemModel currRecord)
|
||||
public bool TagItemDelete(TagItemModel currRecord)
|
||||
{
|
||||
dbController.TagItemDelete(currRecord);
|
||||
return dbController.TagItemDelete(currRecord);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
@page "/ItemMover"
|
||||
|
||||
@using SHERPA.BBM.UI.Components
|
||||
@using SHERPA.BBM.UI.Data
|
||||
@using CORE.DbModels
|
||||
@inject BBM_EFService BBMService
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h4><span class="fas fa-exchange-alt pr-3" aria-hidden="true"></span> Spostamento Item (in Categorie)</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@if (isLoading)
|
||||
{
|
||||
<div class="w-100">
|
||||
<LoadingData DisplayMode="LoadingData.SpinMode.Normal" DisplaySize="LoadingData.CtrlSize.Large"></LoadingData>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="d-flex flex-column small">
|
||||
<div class="py-1">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<label>Categoria:</label>
|
||||
<div class="input-group input-group-sm">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">
|
||||
<span class="fas fa-hashtag" aria-hidden="true"></span>
|
||||
</span>
|
||||
</div>
|
||||
<select @bind="@SelResTypeIdSx" class="form-control form-control">
|
||||
@* <option value="1">-- Tutti ---</option> *@
|
||||
@foreach (var item in ResTypeList)
|
||||
{
|
||||
<option value="@item.ResTypeId">@item.Name [@item.ResTypeId]</option>
|
||||
}
|
||||
</select>
|
||||
<div class="input-group-append">
|
||||
<button class="@cssBtnResBaskSx" @onclick="ResetResTypeSx"><i class="fas fa-undo"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ItemMovList ResTypeId="@SelResTypeIdSx" MoveRequested="moveRight"></ItemMovList>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="d-flex flex-column small">
|
||||
<div class="py-1">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<label>Categoria:</label>
|
||||
<div class="input-group input-group-sm">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">
|
||||
<span class="fas fa-hashtag" aria-hidden="true"></span>
|
||||
</span>
|
||||
</div>
|
||||
<select @bind="@SelResTypeIdDx" class="form-control form-control">
|
||||
@* <option value="1">--- Tutti ---</option> *@
|
||||
@if (ResTypeList != null)
|
||||
{
|
||||
@foreach (var item in ResTypeList)
|
||||
{
|
||||
<option value="@item.ResTypeId">@item.Name [@item.ResTypeId]</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
<div class="input-group-append">
|
||||
<button class="@cssBtnResBaskDx" @onclick="ResetResTypeDx"><i class="fas fa-undo"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ItemMovList ResTypeId="@SelResTypeIdDx" MoveRequested="moveRight"></ItemMovList>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using SHERPA.BBM.CORE.DbModels;
|
||||
using SHERPA.BBM.UI.Data;
|
||||
|
||||
namespace SHERPA.BBM.UI.Pages
|
||||
{
|
||||
public partial class ItemMover : IDisposable
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
BBMService.ReloadRequest -= BBMService_ReloadRequest;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected int _dxNegoId = 1;
|
||||
protected int _dxResTypeId = 0;
|
||||
protected int _sxNegoId = 1;
|
||||
protected int _sxResTypeId = 0;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected MessageService MService { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected async Task moveLeft(int currIdx)
|
||||
{
|
||||
if (SelResTypeIdSx > 0)
|
||||
{
|
||||
// eseguo spostamento...
|
||||
await BBMService.ItemMoveResType(currIdx, SelResTypeIdSx);
|
||||
}
|
||||
}
|
||||
|
||||
protected async Task moveRight(int currIdx)
|
||||
{
|
||||
if (SelResTypeIdDx > 0)
|
||||
{
|
||||
// eseguo spostamento...
|
||||
await BBMService.ItemMoveResType(currIdx, SelResTypeIdDx);
|
||||
}
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
isLoading = true;
|
||||
BBMService.ReloadRequest += BBMService_ReloadRequest;
|
||||
await Task.Delay(1);
|
||||
MService.NotifyHeadChanged();
|
||||
await ReloadAllData();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private List<ItemResTypeModel> ResTypeList = new List<ItemResTypeModel>();
|
||||
|
||||
private List<ItemResTypeModel> CatListSx = new List<ItemResTypeModel>();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private string cssBtnResBaskDx
|
||||
{
|
||||
get => SelResTypeIdDx == 0 ? "btn btn-secondary" : "btn btn-primary";
|
||||
}
|
||||
|
||||
private string cssBtnResBaskSx
|
||||
{
|
||||
get => SelResTypeIdSx == 0 ? "btn btn-secondary" : "btn btn-primary";
|
||||
}
|
||||
|
||||
private bool isLoading { get; set; } = false;
|
||||
|
||||
private int SelResTypeIdDx
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dxResTypeId;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_dxResTypeId = value;
|
||||
// condiziono visualizzazione...
|
||||
var pUpd = Task.Run(async () => await ReloadAllData());
|
||||
pUpd.Wait();
|
||||
}
|
||||
}
|
||||
|
||||
private int SelResTypeIdSx
|
||||
{
|
||||
get
|
||||
{
|
||||
return _sxResTypeId;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_sxResTypeId = value;
|
||||
// condiziono visualizzazione...
|
||||
var pUpd = Task.Run(async () => await ReloadAllData());
|
||||
pUpd.Wait();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private async void BBMService_ReloadRequest(object? sender, EventArgs e)
|
||||
{
|
||||
ReloadEventArgs currArgs = (ReloadEventArgs)e;
|
||||
if (!string.IsNullOrEmpty(currArgs.ReloadMessage))
|
||||
{
|
||||
await ReloadAllData();
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ReloadAllData()
|
||||
{
|
||||
ResTypeList = await BBMService.ItemResTypeGetAll();
|
||||
}
|
||||
|
||||
private async Task ResetResTypeDx()
|
||||
{
|
||||
if (SelResTypeIdDx != 1)
|
||||
{
|
||||
SelResTypeIdDx = 0;
|
||||
await Task.Delay(1);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ResetResTypeSx()
|
||||
{
|
||||
if (SelResTypeIdSx != 1)
|
||||
{
|
||||
SelResTypeIdSx = 0;
|
||||
await Task.Delay(1);
|
||||
}
|
||||
}
|
||||
|
||||
private string trimTxt(string txtOrig, int maxChar)
|
||||
{
|
||||
string answ = txtOrig;
|
||||
if (txtOrig.Length > maxChar)
|
||||
{
|
||||
answ = $"{txtOrig.Substring(0, maxChar - 3)}...";
|
||||
}
|
||||
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
@page "/ResType"
|
||||
|
||||
@using SHERPA.BBM.UI.Components
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="row">
|
||||
<div class="col-6 col-lg-3">
|
||||
<h3><span class="fas fa-hashtag" aria-hidden="true"></span> Categorie</h3>
|
||||
</div>
|
||||
<div class="col-6 col-lg-3">
|
||||
</div>
|
||||
<div class="col-6 col-lg-3">
|
||||
</div>
|
||||
<div class="col-6 col-lg-3">
|
||||
<button class="btn btn-block btn-success btn-sm" @onclick="CreateNew">NUOVO</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@if (currItem != null)
|
||||
{
|
||||
<ResTypeEditor currItem="@currItem" DataReset="ResetData" DataUpdated="UpdateData"></ResTypeEditor>
|
||||
}
|
||||
@if (ListRecords == null)
|
||||
{
|
||||
<LoadingData></LoadingData>
|
||||
}
|
||||
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">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Cod</th>
|
||||
<th>Nome</th>
|
||||
<th class="text-right"># rif</th>
|
||||
<th class="text-right"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var record in ListRecords)
|
||||
{
|
||||
<tr class="@checkSelect(@record.ResTypeId)">
|
||||
<td class="text-nowrap">
|
||||
<button class="btn btn-sm btn-info" @onclick="() => Edit(record)"><span class="fas fa-pen"></span></button>
|
||||
</td>
|
||||
<td>@record.ResTypeId</td>
|
||||
<td>@record.Name</td>
|
||||
<td class="text-right">@record.ItemNav?.Count()</td>
|
||||
<td class="text-right">
|
||||
@if (@record.ItemNav?.Count() == 0)
|
||||
{
|
||||
<button class="btn btn-sm btn-danger" @onclick="() => Delete(record)"><span class="oi oi-trash"></span></button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button class="btn btn-sm btn-secondary" disabled><span class="oi oi-trash"></span></button>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
<div class="card-footer py-1">
|
||||
<DataPager PageSize="numRecord" currPage="currPage" numRecordChanged="ForceReload" numPageChanged="ForceReloadPage" totalCount="totalCount" showLoading="isLoading" />
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,170 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using SHERPA.BBM.CORE.DbModels;
|
||||
using SHERPA.BBM.UI.Data;
|
||||
|
||||
namespace SHERPA.BBM.UI.Pages
|
||||
{
|
||||
public partial class ResType : ComponentBase, IDisposable
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
public string checkSelect(int resTypeId)
|
||||
{
|
||||
string answ = "";
|
||||
if (currItem != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
answ = (currItem.ResTypeId == resTypeId) ? "table-info" : "";
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
MService.EA_SearchUpdated -= OnSeachUpdated;
|
||||
}
|
||||
|
||||
public async void OnSeachUpdated()
|
||||
{
|
||||
await InvokeAsync(() =>
|
||||
{
|
||||
currPage = 1;
|
||||
Task task = UpdateData();
|
||||
StateHasChanged();
|
||||
});
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected BBM_EFService BBMService { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected IJSRuntime JSRuntime { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected MessageService MService { get; set; } = null!;
|
||||
|
||||
protected int totalCount
|
||||
{
|
||||
get
|
||||
{
|
||||
int answ = 0;
|
||||
if (SearchRecords != null)
|
||||
{
|
||||
answ = SearchRecords.Count;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected void CreateNew()
|
||||
{
|
||||
// recupero counter
|
||||
string newCode = BBMService.CounterGetNext($"ITEM", 6);
|
||||
ItemResTypeModel newRecord = new ItemResTypeModel()
|
||||
{
|
||||
Name = $"Nuova Categoria - {DateTime.Now:yyyy/mm/dd HH:mm:ss}"
|
||||
};
|
||||
currItem = newRecord;
|
||||
}
|
||||
|
||||
protected async Task Delete(ItemResTypeModel currRecord)
|
||||
{
|
||||
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Sicuro di voler eliminare la categoria '{currRecord.ResTypeId} - {currRecord.Name}'?"))
|
||||
return;
|
||||
|
||||
BBMService.ItemResTypeDelete(currRecord);
|
||||
await UpdateData();
|
||||
}
|
||||
|
||||
protected void Edit(ItemResTypeModel currRecord)
|
||||
{
|
||||
currItem = currRecord;
|
||||
}
|
||||
|
||||
protected async Task ForceReload(int newNum)
|
||||
{
|
||||
numRecord = newNum;
|
||||
await ReloadAllData();
|
||||
}
|
||||
|
||||
protected async Task ForceReloadPage(int newNum)
|
||||
{
|
||||
currPage = newNum;
|
||||
await ReloadAllData();
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
MService.NotifyHeadChanged();
|
||||
MService.ShowSearch = true;
|
||||
MService.SearchVal = "";
|
||||
MService.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.ItemResTypeGetAll();
|
||||
if (!string.IsNullOrEmpty(MService.SearchVal))
|
||||
{
|
||||
SearchRecords = SearchRecords.Where(x => x.Name.Contains(MService.SearchVal, StringComparison.InvariantCultureIgnoreCase)).ToList();
|
||||
}
|
||||
SearchRecords = SearchRecords.OrderBy(x => x.ResTypeId).ToList();
|
||||
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private ItemResTypeModel? currItem = null;
|
||||
|
||||
private List<ItemResTypeModel> ListRecords = new List<ItemResTypeModel>();
|
||||
private List<ItemResTypeModel> SearchRecords = new List<ItemResTypeModel>();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private string _SelUM { get; set; } = "";
|
||||
private int currPage { get; set; } = 1;
|
||||
|
||||
private bool isLoading { get; set; } = false;
|
||||
private int numRecord { get; set; } = 10;
|
||||
|
||||
#endregion Private Properties
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<UserSecretsId>60fcdaab-6c1e-4bec-9d88-f7727ef1c12c</UserSecretsId>
|
||||
<ApplicationIcon>wwwroot\favicon.ico</ApplicationIcon>
|
||||
<Version>2.0.2402.1217</Version>
|
||||
<Version>2.0.2402.1219</Version>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Copyright>Egalware 2021+</Copyright>
|
||||
|
||||
@@ -77,6 +77,14 @@
|
||||
</span>
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-2">
|
||||
<NavLink class="nav-link" href="ItemMover">
|
||||
<span title="Spostamento Items in categorie">
|
||||
<i class="fas fa-exchange-alt px-3" aria-hidden="true"></i>
|
||||
<span class="@hideText">Sposta Items</span>
|
||||
</span>
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-2">
|
||||
<NavLink class="nav-link" href="Orders">
|
||||
<span title="Gestione Ordini">
|
||||
@@ -93,6 +101,12 @@
|
||||
</span>
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-2">
|
||||
<NavLink class="nav-link" href="ResType">
|
||||
<i class="fas fa-hashtag pr-3" aria-hidden="true"></i>
|
||||
<span class="@hideText">Categorie Item</span>
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-2">
|
||||
<NavLink class="nav-link" href="Tags">
|
||||
<i class="fas fa-tags pr-3" aria-hidden="true"></i>
|
||||
|
||||
Reference in New Issue
Block a user