OK edit classe liste

This commit is contained in:
Samuele Locatelli
2025-09-18 16:53:22 +02:00
parent 67d672a5ff
commit 184d536bb0
12 changed files with 390 additions and 179 deletions
+103 -34
View File
@@ -4,28 +4,21 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using static EgwCoreLib.Lux.Core.Enums;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace EgwCoreLib.Lux.Data.Controllers
{
public class LuxController
internal class LuxController
{
// manca costruttore parametrico contoller...
#region Public Methods
#region Internal Methods
/// <summary>
/// Elenco completo Customers da DB
/// </summary>
/// <returns></returns>
public List<CustomerModel> CustomersGetAll()
internal List<CustomerModel> CustomersGetAll()
{
List<CustomerModel> dbResult = new List<CustomerModel>();
//using (DataLayerContext dbCtx = new DataLayerContext(configuration))
@@ -49,7 +42,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
/// Elenco completo Dealers da DB
/// </summary>
/// <returns></returns>
public List<DealerModel> DealersGetAll()
internal List<DealerModel> DealersGetAll()
{
List<DealerModel> dbResult = new List<DealerModel>();
//using (DataLayerContext dbCtx = new DataLayerContext(configuration))
@@ -69,11 +62,47 @@ namespace EgwCoreLib.Lux.Data.Controllers
return dbResult;
}
/// <summary>
/// Esegue eliminazione + refresh cache
/// </summary>
/// <param name="selRec"></param>
/// <returns></returns>
internal async Task<bool> GenClassDeleteAsync(GenClassModel upsRec)
{
bool answ = false;
//using (DataLayerContext dbCtx = new DataLayerContext(configuration))
using (DataLayerContext dbCtx = new DataLayerContext())
{
try
{
var dbResult = dbCtx
.DbSetGenClass
.Where(x => x.ClassCod == upsRec.ClassCod)
.FirstOrDefault();
var numChild = dbCtx
.DbSetGenVal
.Count(x => x.ClassCod == upsRec.ClassCod);
// se trovato e NON HA record child --> elimino
if (dbResult != null && numChild == 0)
{
dbCtx.DbSetGenClass.Remove(dbResult);
await dbCtx.SaveChangesAsync();
}
}
catch (Exception exc)
{
Log.Error($"Eccezione durante GenClassDeleteAsync{Environment.NewLine}{exc}");
}
}
return answ;
}
/// <summary>
/// Elenco completo GenClass
/// </summary>
/// <returns></returns>
public async Task<List<GenClassModel>> GenClassGetAllAsync()
internal async Task<List<GenClassModel>> GenClassGetAllAsync()
{
List<GenClassModel> dbResult = new List<GenClassModel>();
//using (DataLayerContext dbCtx = new DataLayerContext(configuration))
@@ -83,6 +112,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
{
dbResult = await dbCtx
.DbSetGenClass
.Include(o => o.GenValNav)
.ToListAsync();
}
catch (Exception exc)
@@ -93,12 +123,51 @@ namespace EgwCoreLib.Lux.Data.Controllers
return dbResult;
}
/// <summary>
/// Upsert record GenClass
/// </summary>
/// <param name="upsRec"></param>
/// <returns></returns>
internal async Task<bool> GenClassUpsertAsync(GenClassModel upsRec)
{
bool answ = false;
//using (DataLayerContext dbCtx = new DataLayerContext(configuration))
using (DataLayerContext dbCtx = new DataLayerContext())
{
try
{
var currRec = dbCtx
.DbSetGenClass
.Where(x => x.ClassCod == upsRec.ClassCod)
.FirstOrDefault();
// se trovato --> aggiorno
if (currRec != null)
{
currRec.Description = upsRec.Description;
dbCtx.Entry(currRec).State = EntityState.Modified;
}
// se mancasse --> aggiungo
else
{
dbCtx.DbSetGenClass.Add(upsRec);
}
// salvo...
await dbCtx.SaveChangesAsync();
}
catch (Exception exc)
{
Log.Error($"Eccezione durante GenClassUpsertAsync{Environment.NewLine}{exc}");
}
}
return answ;
}
/// <summary>
/// Elenco valori x classe richiesta
/// </summary>
/// <param name="codClass"></param>
/// <returns></returns>
public async Task<List<GenValueModel>> GenValGetFiltAsync(string codClass)
internal async Task<List<GenValueModel>> GenValGetFiltAsync(string codClass)
{
List<GenValueModel> dbResult = new List<GenValueModel>();
if (!string.IsNullOrEmpty(codClass))
@@ -127,7 +196,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
/// </summary>
/// <param name="rec2del"></param>
/// <returns></returns>
public async Task<bool> ItemDeleteAsync(ItemModel rec2del)
internal async Task<bool> ItemDeleteAsync(ItemModel rec2del)
{
bool result = false;
//using (DataLayerContext dbCtx = new DataLayerContext(configuration))
@@ -157,7 +226,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
/// Elenco completo Items
/// </summary>
/// <returns></returns>
public List<ItemModel> ItemGetAll()
internal List<ItemModel> ItemGetAll()
{
List<ItemModel> dbResult = new List<ItemModel>();
//using (DataLayerContext dbCtx = new DataLayerContext(configuration))
@@ -183,7 +252,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
/// </summary>
/// <param name="ItemIdParent">ID parent (valido quindi >0)</param>
/// <returns></returns>
public List<ItemModel> ItemGetChild(int ItemIdParent)
internal List<ItemModel> ItemGetChild(int ItemIdParent)
{
List<ItemModel> dbResult = new List<ItemModel>();
if (ItemIdParent > 0)
@@ -213,7 +282,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
/// </summary>
/// <param name="ItemId">ID item corrente (valido quindi >0)</param>
/// <returns></returns>
public List<ItemModel> ItemGetAlt(int ItemId)
internal List<ItemModel> ItemGetAlt(int ItemId)
{
List<ItemModel> dbResult = new List<ItemModel>();
if (ItemId > 0)
@@ -264,7 +333,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
/// <param name="CodGroup"></param>
/// <param name="ItemType"></param>
/// <returns></returns>
public List<ItemModel> ItemGetFilt(string CodGroup, ItemClassType ItemType)
internal List<ItemModel> ItemGetFilt(string CodGroup, ItemClassType ItemType)
{
List<ItemModel> dbResult = new List<ItemModel>();
//using (DataLayerContext dbCtx = new DataLayerContext(configuration))
@@ -293,7 +362,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
/// <param name="ItemType"></param>
/// <param name="SearchVal"></param>
/// <returns></returns>
public List<ItemModel> ItemGetFilt(string CodGroup, ItemClassType ItemType, string SearchVal)
internal List<ItemModel> ItemGetFilt(string CodGroup, ItemClassType ItemType, string SearchVal)
{
List<ItemModel> dbResult = new List<ItemModel>();
//using (DataLayerContext dbCtx = new DataLayerContext(configuration))
@@ -327,7 +396,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
/// <param name="CodGroup"></param>
/// <param name="ItemType"></param>
/// <returns></returns>
public async Task<List<ItemModel>> ItemGetFiltAsync(string CodGroup, ItemClassType ItemType)
internal async Task<List<ItemModel>> ItemGetFiltAsync(string CodGroup, ItemClassType ItemType)
{
List<ItemModel> dbResult = new List<ItemModel>();
//using (DataLayerContext dbCtx = new DataLayerContext(configuration))
@@ -357,7 +426,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
/// <param name="ItemType"></param>
/// <param name="SearchVal"></param>
/// <returns></returns>
public async Task<List<ItemModel>> ItemGetFiltAsync(string CodGroup, ItemClassType ItemType, string SearchVal)
internal async Task<List<ItemModel>> ItemGetFiltAsync(string CodGroup, ItemClassType ItemType, string SearchVal)
{
List<ItemModel> dbResult = new List<ItemModel>();
//using (DataLayerContext dbCtx = new DataLayerContext(configuration))
@@ -389,7 +458,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
/// </summary>
/// <param name="SearchVal"></param>
/// <returns></returns>
public List<ItemModel> ItemGetSearch(string SearchVal)
internal List<ItemModel> ItemGetSearch(string SearchVal)
{
List<ItemModel> dbResult = new List<ItemModel>();
//using (DataLayerContext dbCtx = new DataLayerContext(configuration))
@@ -415,7 +484,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
/// </summary>
/// <param name="SearchVal"></param>
/// <returns></returns>
public async Task<List<ItemModel>> ItemGetSearchAsync(string SearchVal)
internal async Task<List<ItemModel>> ItemGetSearchAsync(string SearchVal)
{
List<ItemModel> dbResult = new List<ItemModel>();
//using (DataLayerContext dbCtx = new DataLayerContext(configuration))
@@ -440,7 +509,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
/// Elenco completo ItemGroup gestiti
/// </summary>
/// <returns></returns>
public List<ItemGroupModel> ItemGroupGetAll()
internal List<ItemGroupModel> ItemGroupGetAll()
{
List<ItemGroupModel> dbResult = new List<ItemGroupModel>();
//using (DataLayerContext dbCtx = new DataLayerContext(configuration))
@@ -464,7 +533,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
/// Elenco completo ItemGroup gestiti async
/// </summary>
/// <returns></returns>
public async Task<List<ItemGroupModel>> ItemGroupGetAllAsync()
internal async Task<List<ItemGroupModel>> ItemGroupGetAllAsync()
{
List<ItemGroupModel> dbResult = new List<ItemGroupModel>();
//using (DataLayerContext dbCtx = new DataLayerContext(configuration))
@@ -484,7 +553,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
return dbResult;
}
public bool ItemUpsert(ItemModel newRec)
internal bool ItemUpsert(ItemModel newRec)
{
bool answ = false;
//using (DataLayerContext dbCtx = new DataLayerContext(configuration))
@@ -529,7 +598,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
/// </summary>
/// <param name="currRec"></param>
/// <returns></returns>
public async Task<bool> ItemUpsertAsync(ItemModel currRec)
internal async Task<bool> ItemUpsertAsync(ItemModel currRec)
{
bool result = false;
//using (DataLayerContext dbCtx = new DataLayerContext(configuration))
@@ -576,7 +645,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
/// </summary>
/// <param name="bomList"></param>
/// <returns></returns>
public bool ItemUpsertFromBom(List<BomItemDTO> bomList)
internal bool ItemUpsertFromBom(List<BomItemDTO> bomList)
{
bool answ = false;
//using (DataLayerContext dbCtx = new DataLayerContext(configuration))
@@ -634,7 +703,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
/// Elenco completo offerte da DB
/// </summary>
/// <returns></returns>
public async Task<List<OfferModel>> OfferGetAll()
internal async Task<List<OfferModel>> OfferGetAll()
{
List<OfferModel> dbResult = new List<OfferModel>();
//using (DataLayerContext dbCtx = new DataLayerContext(configuration))
@@ -662,7 +731,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
/// </summary>
/// <param name="OfferID"></param>
/// <returns></returns>
public List<OfferRowModel> OfferRowGetByOffer(int OfferID)
internal List<OfferRowModel> OfferRowGetByOffer(int OfferID)
{
List<OfferRowModel> dbResult = new List<OfferRowModel>();
//using (DataLayerContext dbCtx = new DataLayerContext(configuration))
@@ -691,7 +760,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
/// <param name="OfferRowID">ID riga offerta da aggiornare</param>
/// <param name="newBomList">Bom aggiornata da salvare</param>
/// <returns></returns>
public async Task<bool> OffertRowUpdateBom(int OfferRowID, List<BomItemDTO> newBomList)
internal async Task<bool> OffertRowUpdateBom(int OfferRowID, List<BomItemDTO> newBomList)
{
bool answ = false;
//using (DataLayerContext dbCtx = new DataLayerContext(configuration))
@@ -749,7 +818,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
/// </summary>
/// <param name="OfferID"></param>
/// <returns></returns>
public async Task<bool> OffertUpdateCost(int OfferID)
internal async Task<bool> OffertUpdateCost(int OfferID)
{
bool answ = false;
//using (DataLayerContext dbCtx = new DataLayerContext(configuration))
@@ -864,7 +933,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
/// </summary>
/// <param name="uID"></param>
/// <param name="bomList"></param>
public bool OfferUpsertFromBom(string uID, List<BomItemDTO> bomList)
internal bool OfferUpsertFromBom(string uID, List<BomItemDTO> bomList)
{
bool answ = false;
//using (DataLayerContext dbCtx = new DataLayerContext(configuration))
@@ -917,7 +986,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
return answ;
}
#endregion Public Methods
#endregion Internal Methods
#region Private Fields
+13 -1
View File
@@ -20,7 +20,19 @@ namespace EgwCoreLib.Lux.Data.DbModel
/// Descrizione
/// </summary>
public string Description { get; set; } = "";
/// <summary>
/// Numero Item compresi
/// </summary>
[NotMapped]
public int NumChild
{
get => GenValNav?.Count ?? 0;
}
/// <summary>
/// Navigazione alle righe dei valori associati
/// </summary>
public virtual ICollection<GenValueModel> GenValNav { get; set; } = new List<GenValueModel>();
}
}
@@ -32,8 +32,8 @@ namespace EgwCoreLib.Lux.Data.Services
}
else
{
dbController = new LuxController();
//dbController = new Controllers.LuxController(configuration);
dbController = new LuxController();
StringBuilder sb = new StringBuilder();
sb.AppendLine($"DataLayerServices | LuxController OK");
Log.Info(sb.ToString());
@@ -42,12 +42,6 @@ namespace EgwCoreLib.Lux.Data.Services
#endregion Public Constructors
#region Public Properties
public static LuxController dbController { get; set; } = null!;
#endregion Public Properties
#region Public Methods
/// <summary>
@@ -148,6 +142,19 @@ namespace EgwCoreLib.Lux.Data.Services
return answ;
}
/// <summary>
/// Esegue eliminazione + refresh cache
/// </summary>
/// <param name="selRec"></param>
/// <returns></returns>
public async Task<bool> GenClassDeleteAsync(GenClassModel selRec)
{
bool result = await dbController.GenClassDeleteAsync(selRec);
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:GenClass");
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:GenVal:*");
return result;
}
/// <summary>
/// Elenco completo GenClass
/// </summary>
@@ -182,6 +189,19 @@ namespace EgwCoreLib.Lux.Data.Services
return result;
}
/// <summary>
/// Esegue Upsert del record ricevuto
/// </summary>
/// <param name="upsRec"></param>
/// <returns></returns>
public async Task<bool> GenClassUpsertAsync(GenClassModel upsRec)
{
bool result = await dbController.GenClassUpsertAsync(upsRec);
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:GenClass");
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:GenVal:*");
return result;
}
/// <summary>
/// Elenco valori x classe richiesta
/// </summary>
@@ -266,43 +286,6 @@ namespace EgwCoreLib.Lux.Data.Services
return result;
}
#if false
/// <summary>
/// Elenco item Child da ParentId (per sostituzione) async
/// </summary>
/// <param name="ItemId">ID corrente di cui cercare parent + fratelli</param>
/// <returns></returns>
public List<ItemModel> ItemGetChild(int ItemId)
{
string source = "DB";
Stopwatch sw = new Stopwatch();
sw.Start();
List<ItemModel>? result = new List<ItemModel>();
// cerco in redis...
string currKey = $"{redisBaseKey}:Item:ListChild:{ItemId}";
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
{
result = JsonConvert.DeserializeObject<List<ItemModel>>($"{rawData}");
source = "REDIS";
}
else
{
result = dbController.ItemGetChild(ItemId);
// serializzo e salvo con config x evitare loop...
rawData = JsonConvert.SerializeObject(result, JSSettings);
redisDb.StringSet(currKey, rawData, FastCache);
}
if (result == null)
{
result = new List<ItemModel>();
}
sw.Stop();
Log.Debug($"ItemGetChild | {source} | {sw.Elapsed.TotalMilliseconds}ms");
return result;
}
#endif
/// <summary>
/// Elenco item da ricerca completa Async
/// </summary>
@@ -801,5 +784,48 @@ namespace EgwCoreLib.Lux.Data.Services
private string redisBaseKey = "Lux:Cache";
#endregion Private Fields
#region Private Properties
private static LuxController dbController { get; set; } = null!;
#endregion Private Properties
#if false
/// <summary>
/// Elenco item Child da ParentId (per sostituzione) async
/// </summary>
/// <param name="ItemId">ID corrente di cui cercare parent + fratelli</param>
/// <returns></returns>
public List<ItemModel> ItemGetChild(int ItemId)
{
string source = "DB";
Stopwatch sw = new Stopwatch();
sw.Start();
List<ItemModel>? result = new List<ItemModel>();
// cerco in redis...
string currKey = $"{redisBaseKey}:Item:ListChild:{ItemId}";
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
{
result = JsonConvert.DeserializeObject<List<ItemModel>>($"{rawData}");
source = "REDIS";
}
else
{
result = dbController.ItemGetChild(ItemId);
// serializzo e salvo con config x evitare loop...
rawData = JsonConvert.SerializeObject(result, JSSettings);
redisDb.StringSet(currKey, rawData, FastCache);
}
if (result == null)
{
result = new List<ItemModel>();
}
sw.Stop();
Log.Debug($"ItemGetChild | {source} | {sw.Elapsed.TotalMilliseconds}ms");
return result;
}
#endif
}
}
+1 -1
View File
@@ -15,7 +15,7 @@
<tbody>
@foreach (var item in bomDict)
{
@if (item.Key == currIdx && EditRecord != null)
@if (EditRecord != null && item.Key == currIdx)
{
<tr class="table-info">
<td>@(item.Key + 1)</td>
+86 -14
View File
@@ -1,4 +1,50 @@
<table class="table table-sm table-striped">
@if (AddVisible)
{
<div class="modal" tabindex="-1" style="display:block; background-color: rgba(10,10,10,.6);" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<div class="modal-title fs-4">Aggiunta Classe Anagrafica</div>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close" @onclick="ToggleAdd">
</button>
</div>
<div class="modal-body">
@if (NewRecord != null)
{
<div class="row">
<div class="input-group mb-2">
<span class="input-group-text" id="basic-addon1">Codice</span>
<input type="text" class="form-control text-end" @bind="@NewRecord.ClassCod" />
</div>
</div>
<div class="row">
<div class="input-group mb-2">
<span class="input-group-text" id="basic-addon1">Descrizione</span>
<input type="text" class="form-control text-end" @bind="@NewRecord.Description" />
</div>
</div>
}
@if (!string.IsNullOrEmpty(ErrorMsg))
{
<div class="alert alert-danger my-3">
@ErrorMsg
</div>
}
<div class="row">
<div class="col">
<button class="btn btn-success w-100" @onclick="DoAdd"><i class="fa-solid fa-save"></i> Save</button>
</div>
<div class="col">
<button class="btn btn-warning w-100" @onclick="ToggleAdd">Cancel <i class="fa-solid fa-ban"></i></button>
</div>
</div>
</div>
</div>
</div>
</div>
}
<table class="table table-sm table-striped">
<thead>
<tr>
<th>
@@ -6,24 +52,50 @@
</th>
<th>Cod</th>
<th>Descrizione</th>
<th></th>
<th class="text-end"># Val</th>
<th class="text-end">
<button class="btn btn-sm btn-success" @onclick="ToggleAdd"><i class="fa-solid fa-plus"></i></button>
</th>
</tr>
</thead>
<tbody>
@foreach (var item in ListRecords)
{
<tr>
<td class="text-start text-nowrap">
<button class="btn btn-sm btn-primary" @onclick="() => DoSelect(item)"><i class="fa-solid fa-magnifying-glass"></i></button>
@* <button class="btn btn-sm btn-info" @onclick="() => DoEdit(item)"><i class="fa-solid fa-pencil"></i></button>
<button class="btn btn-sm btn-success" @onclick="() => DoClone(item)"><i class="fa-solid fa-clone"></i></button> *@
</td>
<td>@item.ClassCod</td>
<td>@item.Description</td>
<td>
@* <button class="btn btn-sm btn-danger" @onclick="() => DoDelete(item)"><i class="fa-solid fa-trash-can"></i></button> *@
</td>
<tr class="@checkSel(item)">
@if (EditRecord != null && item.ClassCod == EditRecord.ClassCod)
{
<td class="text-start text-nowrap">
<button class="btn btn-sm btn-success" @onclick="() => DoSave(item)"><i class="fa-solid fa-save"></i></button>
<button class="btn btn-sm btn-secondary opacity-50"><i class="fa-solid fa-pencil"></i></button>
</td>
<td>@item.ClassCod</td>
<td><input class="form-control form-control-sm" type="text" style="width: 12rem;" @bind="@item.Description" /></td>
<td class="text-end">@item.NumChild</td>
<td class="text-end">
<button class="btn btn-sm btn-warning" @onclick="DoReset"><i class="fa-solid fa-ban"></i></button>
</td>
}
else
{
<td class="text-start text-nowrap">
<button class="btn btn-sm btn-primary" @onclick="() => DoSelect(item)"><i class="fa-solid fa-magnifying-glass"></i></button>
<button class="btn btn-sm btn-info" @onclick="() => DoEdit(item)"><i class="fa-solid fa-pencil"></i></button>
@* <button class="btn btn-sm btn-success" @onclick="() => DoClone(item)"><i class="fa-solid fa-clone"></i></button> *@
</td>
<td>@item.ClassCod</td>
<td>@item.Description</td>
<td class="text-end">@item.NumChild</td>
<td class="text-end">
@if (item.NumChild > 0)
{
<button class="btn btn-sm btn-secondary opacity-50" disabled><i class="fa-solid fa-trash-can"></i></button>
}
else
{
<button class="btn btn-sm btn-danger" @onclick="() => DoDelete(item)"><i class="fa-solid fa-trash-can"></i></button>
}
</td>
}
</tr>
}
</tbody>
+92 -32
View File
@@ -1,13 +1,22 @@
using EgwCoreLib.Lux.Data.DbModel;
using EgwCoreLib.Lux.Data.Services;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.JSInterop;
using NLog.LayoutRenderers;
using System.Threading.Tasks;
namespace Lux.UI.Components.Compo
{
public partial class GenClassMan
{
#region Public Properties
[Parameter]
public EventCallback<string> EC_Selected { get; set; }
[Parameter]
public EventCallback<bool> EC_Updated { get; set; }
[Parameter]
public List<GenClassModel> ListGenClass { get; set; } = null!;
@@ -15,8 +24,7 @@ namespace Lux.UI.Components.Compo
[Parameter]
public string SearchVal { get; set; } = "";
[Parameter]
public EventCallback<string> EC_Selected { get; set; }
#endregion Public Properties
#region Protected Fields
@@ -37,6 +45,50 @@ namespace Lux.UI.Components.Compo
#region Protected Methods
protected void ToggleAdd()
{
AddVisible = !AddVisible;
NewRecord = new GenClassModel()
{
ClassCod = "NewClass",
Description = $"Descrizione-{DateTime.Now:yyyy.MM.dd-HH.mm.ss}"
};
}
private bool AddVisible = false;
private string ErrorMsg = "";
/// <summary>
/// Genera nuovo record e lo salva
/// </summary>
/// <exception cref="NotImplementedException"></exception>
protected async Task DoAdd()
{
if (NewRecord != null)
{
// verifico non sia duplicato...
var recExist = ListRecords.Count(x => x.ClassCod == NewRecord.ClassCod);
if (recExist > 0)
{
ErrorMsg = $"Errore: record già esistente con codice {NewRecord.ClassCod}";
}
else
{
ErrorMsg = "";
// faccio upsert record...
await DLService.GenClassUpsertAsync(NewRecord);
// segnalo update x reload
await EC_Updated.InvokeAsync(true);
NewRecord = null;
}
}
}
protected void DoCancel()
{
ResetEdit();
UpdateTable();
}
/// <summary>
/// Clona record
/// </summary>
@@ -59,34 +111,39 @@ namespace Lux.UI.Components.Compo
QtyMin = curRec.QtyMin,
QtyMax = curRec.QtyMax,
UM = curRec.UM
};
};
#endif
}
/// <summary>
/// impossta record x eliminazione
/// Eliminazione record
/// </summary>
/// <param name="selRec"></param>
protected async Task DoDelete(GenClassModel selRec)
{
// controlo che NON abbia child obj... altrimenti esco
if (selRec.NumChild > 0)
return;
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Sicuro di voler eliminare il record? Dettagli: {selRec.ClassCod} | {selRec.Description}"))
return;
//// esegue eliminazione del record...
//await DLService.ItemDeleteAsync(selRec);
editRecord = null;
selRecord = null;
ReloadData();
UpdateTable();
// esegue eliminazione del record...
await DLService.GenClassDeleteAsync(selRec);
// segnalo update x reload
await EC_Updated.InvokeAsync(true);
}
/// <summary>
/// Edit articolo selezionato
/// </summary>
/// <param name="curRec"></param>
protected void DoEdit(GenClassModel curRec)
protected async void DoEdit(GenClassModel curRec)
{
editRecord = curRec;
EditRecord = curRec;
SelRecord = curRec;
await EC_Selected.InvokeAsync(curRec.ClassCod);
}
/// <summary>
@@ -94,17 +151,26 @@ namespace Lux.UI.Components.Compo
/// </summary>
protected async void DoReset()
{
editRecord = null;
EditRecord = null;
SelRecord = null;
await EC_Selected.InvokeAsync("");
}
protected async Task DoSave(GenClassModel currRec)
{
// faccio upsert record...
await DLService.GenClassUpsertAsync(currRec);
// segnalo update x reload
await EC_Updated.InvokeAsync(true);
}
/// <summary>
/// Selezione articolo x display info
/// </summary>
/// <param name="curRec"></param>
protected async void DoSelect(GenClassModel curRec)
{
selRecord = curRec;
SelRecord = curRec;
await EC_Selected.InvokeAsync(curRec.ClassCod);
}
@@ -130,16 +196,16 @@ namespace Lux.UI.Components.Compo
#region Private Fields
private int currPage = 1;
private GenClassModel? editRecord = null;
private GenClassModel? EditRecord = null;
private GenClassModel? NewRecord = null;
private bool isLoading = false;
private int numRecord = 10;
private GenClassModel? selRecord = null;
private GenClassModel? SelRecord = null;
private int totalCount = 0;
@@ -147,21 +213,14 @@ namespace Lux.UI.Components.Compo
#region Private Methods
private void DoCancel()
private string checkSel(GenClassModel curRec)
{
ResetEdit();
UpdateTable();
}
private async Task DoSave(GenClassModel currRec)
{
// salvo
await Task.Delay(10);
#if false
await DLService.ItemUpsertAsync(currRec);
#endif
ResetEdit();
UpdateTable();
string answ = "";
if (SelRecord != null)
{
answ = curRec.ClassCod == SelRecord.ClassCod ? "table-info" : "";
}
return answ;
}
private void ReloadData()
@@ -183,7 +242,7 @@ namespace Lux.UI.Components.Compo
private void ResetEdit()
{
// reset edit
editRecord = null;
EditRecord = null;
ReloadData();
}
@@ -194,6 +253,7 @@ namespace Lux.UI.Components.Compo
{
// fix paginazione
ListRecords = AllRecords
.OrderBy(x => x.ClassCod)
.Skip(numRecord * (currPage - 1))
.Take(numRecord)
.ToList();
+13 -24
View File
@@ -8,24 +8,6 @@
<b>Anagrafiche Generiche</b>
</div>
<div class="px-0 d-flex justify-content-between">
<div class="px-0">
@if (!string.IsNullOrEmpty(SelCodGroup))
{
<button class="btn btn-sm btn-success" @onclick="DoAdd"><i class="fa-solid fa-plus"></i> Nuovo</button>
}
</div>
<div class="px-1">
<div class="input-group input-group-sm">
<span class="input-group-text">Gruppo</span>
<select @bind="@SelCodGroup" class="form-select">
<option value="">--- Sel. Gruppo ---</option>
@foreach (var item in ListGenClass)
{
<option value="@item.ClassCod">@item.Description</option>
}
</select>
</div>
</div>
<div class="px-1">
<div class="input-group input-group-sm" title="ricerca">
<span class="input-group-text"><i class="fas fa-search"></i></span>
@@ -38,12 +20,19 @@
</div>
<div class="card-body">
<div class="row">
<div class="col-4">
<GenClassMan ListGenClass="ListGenClass" EC_Selected="SaveSel"></GenClassMan>
</div>
<div class="col-8">
<GenValMan SelFilt="CurrFilt" ListGenClass="ListGenClass"></GenValMan>
</div>
@if (isLoading)
{
<LoadingData></LoadingData>
}
else
{
<div class="col-12 col-md-5 col-lg-4">
<GenClassMan ListGenClass="ListGenClass" EC_Selected="SaveSel" EC_Updated="() => ForceReloadAsync()"></GenClassMan>
</div>
<div class="col-12 col-md-7 col-lg-8">
<GenValMan SelFilt="CurrFilt" ListGenClass="ListGenClass"></GenValMan>
</div>
}
</div>
</div>
</div>
+8 -25
View File
@@ -2,6 +2,7 @@ using EgwCoreLib.Lux.Data.DbModel;
using EgwCoreLib.Lux.Data.Services;
using Lux.UI.Components.Compo;
using Microsoft.AspNetCore.Components;
using System.Threading.Tasks;
namespace Lux.UI.Components.Pages
{
@@ -49,35 +50,10 @@ namespace Lux.UI.Components.Pages
#region Protected Methods
protected void DoAdd()
{
editRecord = new ItemModel()
{
#if false
CodGroup = ListGenClass.FirstOrDefault()?.CodGroup ?? "",
#endif
ItemType = EgwCoreLib.Lux.Core.Enums.ItemClassType.ND,
IsService = false,
ItemCode = 0,
ExtItemCode = "NEW-ITEM",
SupplCode = "",
Description = $"Nuova Offerta {DateTime.Today:ddd yyyy.MM.dd}",
Cost = 0,
Margin = 0,
QtyMin = 0,
QtyMax = 0,
UM = "#"
};
}
protected override async Task OnInitializedAsync()
{
isLoading = true;
await ReloadBaseData();
#if false
await ReloadData();
UpdateTable();
#endif
}
protected void ResetSearch()
@@ -96,9 +72,16 @@ namespace Lux.UI.Components.Pages
#region Private Methods
private async Task ForceReloadAsync()
{
await ReloadBaseData();
}
private async Task ReloadBaseData()
{
isLoading = true;
ListGenClass = await DLService.GenClassGetAllAsync();
isLoading = false;
}
private void SaveSel(string codGroup)
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>aspnet-Lux.UI-a758c101-a2f4-4e38-977d-1c4887dbbd50</UserSecretsId>
<Version>0.9.2509.1813</Version>
<Version>0.9.2509.1816</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>LUX - Web Windows MES</i>
<h4>Versione: 0.9.2509.1813</h4>
<h4>Versione: 0.9.2509.1816</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
0.9.2509.1813
0.9.2509.1816
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>0.9.2509.1813</version>
<version>0.9.2509.1816</version>
<url>http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html</changelog>
<mandatory>false</mandatory>