115 lines
3.3 KiB
C#
115 lines
3.3 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.JSInterop;
|
|
using MP.Data.DbModels;
|
|
using MP.SPEC.Data;
|
|
|
|
namespace MP.SPEC.Components.ProdKit
|
|
{
|
|
public partial class KitComposer
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public string KeyFilt { get; set; } = "";
|
|
|
|
[Parameter]
|
|
public PODLExpModel? Rec2Add
|
|
{
|
|
get => currRec;
|
|
set
|
|
{
|
|
if (currRec != value)
|
|
{
|
|
currRec = value;
|
|
if (value != null)
|
|
{
|
|
// chiamo tentativo update!
|
|
WipSetupKitModel newRec = new WipSetupKitModel()
|
|
{
|
|
KeyFilt = KeyFilt,
|
|
CodArt = value.CodArticolo,
|
|
CodOrd = value.KeyRichiesta,
|
|
DescArt = value.DescArticolo,
|
|
Qta = value.NumPezzi,
|
|
DataIns = DateTime.Now
|
|
};
|
|
bool fatto = MDService.WipKitUpsert(newRec);
|
|
}
|
|
// rileggoi
|
|
ReloadData();
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected IJSRuntime JSRuntime { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected MpDataService MDService { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected async Task CleanupOld()
|
|
{
|
|
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler eliminare tutti i record temporanei della procedura di composizione KIT?"))
|
|
return;
|
|
|
|
// elimino TUTTO...
|
|
DateTime dtLimit = DateTime.Now;//.AddHours(-1);
|
|
var done = MDService.WipKitDeleteOlder(dtLimit);
|
|
ReloadData();
|
|
}
|
|
|
|
protected async Task DoDelete(WipSetupKitModel rec2del)
|
|
{
|
|
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Eliminazione riga KIT: sei sicuro di voler procedere?"))
|
|
return;
|
|
|
|
var done = MDService.WipKitDelete(rec2del);
|
|
ReloadData();
|
|
}
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
// calcolo codice temporaneo utente...da apertura KIT
|
|
if (string.IsNullOrEmpty(KeyFilt))
|
|
{
|
|
// elimino dati + vecchi di 2h...
|
|
DateTime dtLimit = DateTime.Now.AddHours(-2);
|
|
var done = MDService.WipKitDeleteOlder(dtLimit);
|
|
}
|
|
}
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
ReloadData();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private PODLExpModel? currRec = null;
|
|
private List<WipSetupKitModel> ListRecords = new List<WipSetupKitModel>();
|
|
|
|
private List<WipSetupKitModel> SearchRecord = new List<WipSetupKitModel>();
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Methods
|
|
|
|
private void ReloadData()
|
|
{
|
|
SearchRecord = MDService.WipKitFilt(KeyFilt);
|
|
ListRecords = SearchRecord.ToList();
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |