220 lines
6.2 KiB
C#
220 lines
6.2 KiB
C#
using EgwCoreLib.Lux.Core;
|
|
using EgwCoreLib.Lux.Data.DbModel.Items;
|
|
using EgwCoreLib.Lux.Data.Services;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.JSInterop;
|
|
|
|
namespace Lux.UI.Components.Compo.Item
|
|
{
|
|
public partial class SellingItemMan
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public EventCallback<SellingItemModel?> EC_EditReq { get; set; }
|
|
|
|
[Parameter]
|
|
public List<ItemGroupModel> ListItemGroup { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public FiltSelect SelFilt { get; set; } = null!;
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Fields
|
|
|
|
protected List<SellingItemModel> AllRecords = new List<SellingItemModel>();
|
|
protected List<SellingItemModel> ListRecords = new List<SellingItemModel>();
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected DataLayerServices DLService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected IJSRuntime JSRuntime { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
/// <summary>
|
|
/// Clona articolo
|
|
/// </summary>
|
|
/// <param name="curRec"></param>
|
|
protected void DoClone(SellingItemModel curRec)
|
|
{
|
|
editRecord = new SellingItemModel()
|
|
{
|
|
Cost = curRec.Cost,
|
|
Description = $"{curRec.Description} - CLONE",
|
|
Envir = curRec.Envir,
|
|
ExtItemCode = curRec.ExtItemCode,
|
|
IsService = curRec.IsService,
|
|
ItemCode = curRec.ItemCode,
|
|
ItemSteps = curRec.ItemSteps,
|
|
JobID = curRec.JobID,
|
|
Margin = curRec.Margin,
|
|
SerStruct = curRec.SerStruct,
|
|
SourceType = curRec.SourceType,
|
|
SupplCode = curRec.SupplCode,
|
|
UM = curRec.UM
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// impossta record x eliminazione
|
|
/// </summary>
|
|
/// <param name="selRec"></param>
|
|
protected async Task DoDelete(SellingItemModel selRec)
|
|
{
|
|
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Sicuro di voler eliminare il record? Dettagli: {selRec.SellingItemID} | {selRec.Envir} | {selRec.ExtItemCode} | {selRec.Description}"))
|
|
return;
|
|
//// esegue eliminazione del record...
|
|
//await CDService.SellingItemDeleteAsync(selRec);
|
|
|
|
editRecord = null;
|
|
selRecord = null;
|
|
await ReloadData();
|
|
UpdateTable();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Edit articolo selezionato
|
|
/// </summary>
|
|
/// <param name="curRec"></param>
|
|
protected Task DoEdit(SellingItemModel curRec)
|
|
{
|
|
editRecord = curRec;
|
|
return EC_EditReq.InvokeAsync(editRecord);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Reset selezione
|
|
/// </summary>
|
|
protected Task DoReset()
|
|
{
|
|
editRecord = null;
|
|
return EC_EditReq.InvokeAsync(editRecord);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Selezione articolo x display info
|
|
/// </summary>
|
|
/// <param name="curRec"></param>
|
|
protected void DoSelect(SellingItemModel curRec)
|
|
{
|
|
selRecord = curRec;
|
|
}
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
if (!SelFilt.Equals(actFilt) || true)
|
|
{
|
|
actFilt = SelFilt;
|
|
await ReloadData();
|
|
UpdateTable();
|
|
}
|
|
}
|
|
|
|
protected void SaveNumRec(int newNum)
|
|
{
|
|
numRecord = newNum;
|
|
UpdateTable();
|
|
}
|
|
|
|
protected void SavePage(int newNum)
|
|
{
|
|
currPage = newNum;
|
|
UpdateTable();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private FiltSelect actFilt = new FiltSelect();
|
|
|
|
private int currPage = 1;
|
|
|
|
private SellingItemModel? editRecord = null;
|
|
|
|
private bool isLoading = false;
|
|
|
|
private int numRecord = 10;
|
|
|
|
private SellingItemModel? selRecord = null;
|
|
|
|
private int totalCount = 0;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Methods
|
|
|
|
#if false
|
|
private async Task DoCancel()
|
|
{
|
|
await ResetEdit();
|
|
UpdateTable();
|
|
}
|
|
#endif
|
|
|
|
private string doCloneCss(SellingItemModel item)
|
|
{
|
|
return item.SourceType == Enums.ItemSourceType.ND ? "btn-warning" : "btn-success";
|
|
}
|
|
|
|
#if false
|
|
private async Task DoSave(SellingItemModel currRec)
|
|
{
|
|
// salvo
|
|
await DLService.SellingItemUpsertAsync(currRec);
|
|
await ResetEdit();
|
|
UpdateTable();
|
|
}
|
|
#endif
|
|
|
|
private async Task ReloadData()
|
|
{
|
|
isLoading = true;
|
|
AllRecords = await DLService.SellingItemGetFiltAsync(actFilt.Envir, actFilt.SourceType);
|
|
// se ho ricerca testuale faccio filtro ulteriore...
|
|
if (!string.IsNullOrEmpty(actFilt.SearchVal))
|
|
{
|
|
AllRecords = AllRecords
|
|
.Where(x =>
|
|
x.Description.Contains(actFilt.SearchVal, StringComparison.InvariantCultureIgnoreCase) ||
|
|
x.ExtItemCode.Contains(actFilt.SearchVal, StringComparison.InvariantCultureIgnoreCase) ||
|
|
x.SupplCode.Contains(actFilt.SearchVal, StringComparison.InvariantCultureIgnoreCase))
|
|
.ToList();
|
|
}
|
|
totalCount = AllRecords.Count;
|
|
}
|
|
|
|
#if false
|
|
private Task ResetEdit()
|
|
{
|
|
// reset edit
|
|
editRecord = null;
|
|
return ReloadData();
|
|
}
|
|
#endif
|
|
|
|
/// <summary>
|
|
/// Filtro e paginazione
|
|
/// </summary>
|
|
private void UpdateTable()
|
|
{
|
|
// fix paginazione
|
|
ListRecords = AllRecords
|
|
.Skip(numRecord * (currPage - 1))
|
|
.Take(numRecord)
|
|
.ToList();
|
|
isLoading = false;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |