Fix metodi folder Offer

This commit is contained in:
Samuele Locatelli
2026-03-23 10:25:42 +01:00
parent 151224bc56
commit 84144b4beb
5 changed files with 285 additions and 310 deletions
+281 -306
View File
@@ -51,90 +51,10 @@ namespace Lux.UI.Components.Pages
}
}
[Inject]
protected IConfiguration Config { get; set; } = null!;
[Inject]
protected CalcRuidService CRService { get; set; } = null!;
protected string DivMainCss
{
get => SelRecord != null ? "col-6" : "col-12";
}
[Inject]
protected DataLayerServices DLService { get; set; } = null!;
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
[Inject]
protected ProdService PService { get; set; } = null!;
protected string txtState
{
get => allState ? "Tutte" : "Aperte";
}
#endregion Protected Properties
#region Protected Methods
protected string CheckSelect(OfferModel curRec)
{
string answ = "";
if (SelRecord != null)
{
answ = curRec.OfferID == SelRecord.OfferID ? "table-info" : "";
}
return answ;
}
protected void DoAdd()
{
EditRecord = new OfferModel()
{
RefYear = DateTime.Today.Year,
Description = $"Nuova Offerta {DateTime.Today:ddd yyyy.MM.dd}",
ValidUntil = DateTime.Today.AddMonths(1)
};
}
protected async Task DoClone(OfferModel rec2clone)
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Confermi di voler duplicare interamente l'offerta selezionata?{Environment.NewLine}---------------------------{Environment.NewLine}Env: {rec2clone.Envir} | {rec2clone.OfferCode}{Environment.NewLine}{rec2clone.Description}{Environment.NewLine}Articoli: {rec2clone.NumItems}{Environment.NewLine}---------------------------{Environment.NewLine}Importo: {rec2clone.TotalPrice:C2}"))
return;
// clona intera offerta + tutte le righe...
await OffService.CloneAsync(rec2clone);
await ReloadData();
UpdateTable();
}
protected void DoEdit(OfferModel curRec)
{
currStep = CompileStep.Header;
EditRecord = curRec;
}
protected async Task DoEsc(OfferModel? updRec)
{
EditRecord = null;
SelRecord = null;
// salvo record SE non è nullo
if (updRec != null)
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Vuoi salvare e chiudere l'Offerta?"))
return;
await OffService.UpsertAsync(updRec);
}
}
protected void DoSelect(OfferModel curRec)
{
SelRecord = curRec;
}
protected override async Task OnInitializedAsync()
{
// prendo il trim corrente + anno precedente...
@@ -147,25 +67,303 @@ namespace Lux.UI.Components.Pages
UpdateTable();
}
protected void SaveNumRec(int newNum)
#endregion Protected Methods
#region Private Fields
private List<EnvirParamModel> AllConfEnvir = new();
private List<OfferModel> AllRecords = new List<OfferModel>();
private bool allState = false;
/// <summary>
/// Base path x network share files
/// </summary>
private string basePath = "unsafe_uploads";
private int currPage = 1;
private CompileStep currStep = CompileStep.Draft;
private OfferModel? EditRecord = null;
private OfferModel? EditStateRec = null;
private bool isLoading = false;
private List<OfferModel> ListFilt = new List<OfferModel>();
private List<OfferModel> ListRecords = new List<OfferModel>();
private int numRecord = 10;
/// <summary>
/// Periodo selezionato attuale
/// </summary>
private EgwCoreLib.Utils.DtUtils.Periodo PeriodoSel = new EgwCoreLib.Utils.DtUtils.Periodo(EgwCoreLib.Utils.DtUtils.PeriodSet.ThisYear);
private string searchVal = "";
private OfferModel? SelRecord = null;
private int totalCount = 0;
private string txtStyle = "font-size: 1.2em; font-weight:bold; fill: white;";
#endregion Private Fields
#region Private Properties
[Inject]
private IConfiguration Config { get; set; } = null!;
[Inject]
private CalcRuidService CRService { get; set; } = null!;
private string DivMainCss
{
get => SelRecord != null ? "col-6" : "col-12";
}
[Inject]
private DataLayerServices DLService { get; set; } = null!;
[Inject]
private IEnvirParamService EPService { get; set; } = null!;
[Inject]
private IJSRuntime JSRuntime { get; set; } = null!;
private List<string> listBord01 { get; set; } = new();
[Inject]
private IOfferService OffService { get; set; } = default!;
[Inject]
private IOrderService OrdService { get; set; } = default!;
[Inject]
private IProductionItemService PIService { get; set; } = default!;
[Inject]
private ProdService PService { get; set; } = null!;
private string txtState
{
get => allState ? "Tutte" : "Aperte";
}
#endregion Private Properties
#region Private Methods
private void AdvStep(CompileStep newStep)
{
currStep = newStep;
}
private string ArrowBackCol(CompileStep arrowStep)
{
string answ = $"fill: #000000;";
if (arrowStep == currStep)
{
answ = $"fill: #123456;";
}
else if (arrowStep < currStep)
{
answ = $"fill: #456789;";
}
else
{
answ = $"fill: #89ABCD;";
}
return answ;
}
private string CheckSelect(OfferModel curRec)
{
string answ = "";
if (SelRecord != null)
{
answ = curRec.OfferID == SelRecord.OfferID ? "table-info" : "";
}
return answ;
}
private void ConfInit()
{
basePath = Config.GetValue<string>("ServerConf:FileSharePath") ?? "unsafe_uploads";
}
private void DoAction(string args)
{
if (args == "EditRow")
{
currStep = CompileStep.Rows;
EditRecord = SelRecord;
}
}
private void DoAdd()
{
EditRecord = new OfferModel()
{
RefYear = DateTime.Today.Year,
Description = $"Nuova Offerta {DateTime.Today:ddd yyyy.MM.dd}",
ValidUntil = DateTime.Today.AddMonths(1)
};
}
private async Task DoClone(OfferModel rec2clone)
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Confermi di voler duplicare interamente l'offerta selezionata?{Environment.NewLine}---------------------------{Environment.NewLine}Env: {rec2clone.Envir} | {rec2clone.OfferCode}{Environment.NewLine}{rec2clone.Description}{Environment.NewLine}Articoli: {rec2clone.NumItems}{Environment.NewLine}---------------------------{Environment.NewLine}Importo: {rec2clone.TotalPrice:C2}"))
return;
// clona intera offerta + tutte le righe...
await OffService.CloneAsync(rec2clone);
await ReloadData();
UpdateTable();
}
private void DoClose()
{
EditRecord = null;
}
private void DoEdit(OfferModel curRec)
{
currStep = CompileStep.Header;
EditRecord = curRec;
}
private async Task DoEsc(OfferModel? updRec)
{
EditRecord = null;
SelRecord = null;
// salvo record SE non è nullo
if (updRec != null)
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Vuoi salvare e chiudere l'Offerta?"))
return;
await OffService.UpsertAsync(updRec);
}
}
private void DoFilter()
{
// verifico eventuali filtri
ListFilt = AllRecords
.Where(x => x.OffertState == OfferStates.Open || allState)
.ToList();
if (!string.IsNullOrEmpty(searchVal))
{
ListFilt = ListFilt
.Where(x => x.Description.Contains(searchVal, StringComparison.InvariantCultureIgnoreCase) || x.OfferCode.Contains(searchVal, StringComparison.InvariantCultureIgnoreCase))
.ToList();
}
totalCount = ListFilt.Count();
}
/// <summary>
/// Salva record ed avanza compilazione
/// </summary>
/// <param name="updRec"></param>
/// <returns></returns>
private async Task DoSave(OfferModel updRec)
{
// salvo record
await OffService.UpsertAsync(updRec);
// cambio step
CompileStep nextStep = currStep < CompileStep.FinalCheck ? currStep + 1 : currStep;
AdvStep(nextStep);
}
private void DoSelect(OfferModel curRec)
{
SelRecord = curRec;
}
private void EditState(OfferModel? curRec)
{
EditStateRec = curRec;
}
/// <summary>
/// Path da parent record
/// </summary>
/// <param name="objID"></param>
/// <returns></returns>
private string FolderPath(int objID)
{
return $"SO-{objID:X8}";
}
/// <summary>
/// Rilegge tabella
/// </summary>
private async Task ForceReload()
{
isLoading = true;
await Task.Delay(50);
await ReloadData();
await Task.Delay(50);
UpdateTable();
await Task.Delay(50);
isLoading = false;
await Task.Delay(50);
}
/// <summary>
/// Rilettura info di base
/// </summary>
/// <returns></returns>
private async Task ReloadBaseData()
{
AllConfEnvir = await EPService.GetAllAsync();
}
/// <summary>
/// Legge i dati dei record completi
/// </summary>
private async Task ReloadData()
{
await OffService.CheckExpiredAsync();
AllRecords = await OffService.GetFiltAsync(PeriodoSel.Inizio, PeriodoSel.Fine);
DoFilter();
}
private void SaveNumRec(int newNum)
{
numRecord = newNum;
UpdateTable();
}
protected void SavePage(int newNum)
private void SavePage(int newNum)
{
currPage = newNum;
UpdateTable();
}
/// <summary>
/// Imposta periodo da filtro
/// </summary>
/// <param name="newPeriod"></param>
/// <returns></returns>
private async Task SetPeriodo(EgwCoreLib.Utils.DtUtils.Periodo newPeriod)
{
PeriodoSel = newPeriod;
await ReloadData();
UpdateTable();
}
/// <summary>
/// Imposta lo stato dell'offerta VERIFICANDO i vari casi di stato di artenza/arrivo...
/// </summary>
/// <param name="currRec"></param>
/// <param name="newStatus"></param>
/// <returns></returns>
protected async Task SetState(OfferModel currRec, OfferStates newStatus)
private async Task SetState(OfferModel currRec, OfferStates newStatus)
{
/* ---------------------------------
* se lo conferma: esegue step speciali come
@@ -285,204 +483,6 @@ namespace Lux.UI.Components.Pages
UpdateTable();
}
#endregion Protected Methods
#region Private Fields
private List<EnvirParamModel> AllConfEnvir = new();
private List<OfferModel> AllRecords = new List<OfferModel>();
private bool allState = false;
/// <summary>
/// Base path x network share files
/// </summary>
private string basePath = "unsafe_uploads";
private int currPage = 1;
private CompileStep currStep = CompileStep.Draft;
private OfferModel? EditRecord = null;
private OfferModel? EditStateRec = null;
private bool isLoading = false;
private List<OfferModel> ListFilt = new List<OfferModel>();
private List<OfferModel> ListRecords = new List<OfferModel>();
private int numRecord = 10;
/// <summary>
/// Periodo selezionato attuale
/// </summary>
private EgwCoreLib.Utils.DtUtils.Periodo PeriodoSel = new EgwCoreLib.Utils.DtUtils.Periodo(EgwCoreLib.Utils.DtUtils.PeriodSet.ThisYear);
private string searchVal = "";
private OfferModel? SelRecord = null;
private int totalCount = 0;
private string txtStyle = "font-size: 1.2em; font-weight:bold; fill: white;";
#endregion Private Fields
#region Private Properties
[Inject]
private IEnvirParamService EPService { get; set; } = null!;
private List<string> listBord01 { get; set; } = new();
[Inject]
private IOfferService OffService { get; set; } = default!;
[Inject]
private IOrderService OrdService { get; set; } = default!;
[Inject]
private IProductionItemService PIService { get; set; } = default!;
#endregion Private Properties
#region Private Methods
private void AdvStep(CompileStep newStep)
{
currStep = newStep;
}
private string ArrowBackCol(CompileStep arrowStep)
{
string answ = $"fill: #000000;";
if (arrowStep == currStep)
{
answ = $"fill: #123456;";
}
else if (arrowStep < currStep)
{
answ = $"fill: #456789;";
}
else
{
answ = $"fill: #89ABCD;";
}
return answ;
}
private void ConfInit()
{
basePath = Config.GetValue<string>("ServerConf:FileSharePath") ?? "unsafe_uploads";
}
private void DoAction(string args)
{
if (args == "EditRow")
{
currStep = CompileStep.Rows;
EditRecord = SelRecord;
}
}
private void DoClose()
{
EditRecord = null;
}
private void DoFilter()
{
// verifico eventuali filtri
ListFilt = AllRecords
.Where(x => x.OffertState == OfferStates.Open || allState)
.ToList();
if (!string.IsNullOrEmpty(searchVal))
{
ListFilt = ListFilt
.Where(x => x.Description.Contains(searchVal, StringComparison.InvariantCultureIgnoreCase) || x.OfferCode.Contains(searchVal, StringComparison.InvariantCultureIgnoreCase))
.ToList();
}
totalCount = ListFilt.Count();
}
/// <summary>
/// Salva record ed avanza compilazione
/// </summary>
/// <param name="updRec"></param>
/// <returns></returns>
private async Task DoSave(OfferModel updRec)
{
// salvo record
await OffService.UpsertAsync(updRec);
// cambio step
CompileStep nextStep = currStep < CompileStep.FinalCheck ? currStep + 1 : currStep;
AdvStep(nextStep);
}
private void EditState(OfferModel? curRec)
{
EditStateRec = curRec;
}
/// <summary>
/// Path da parent record
/// </summary>
/// <param name="objID"></param>
/// <returns></returns>
private string FolderPath(int objID)
{
return $"SO-{objID:X8}";
}
/// <summary>
/// Rilegge tabella
/// </summary>
private async Task ForceReload()
{
isLoading = true;
await Task.Delay(50);
await ReloadData();
await Task.Delay(50);
UpdateTable();
await Task.Delay(50);
isLoading = false;
await Task.Delay(50);
}
/// <summary>
/// Rilettura info di base
/// </summary>
/// <returns></returns>
private async Task ReloadBaseData()
{
AllConfEnvir = await EPService.GetAllAsync();
}
/// <summary>
/// Legge i dati dei record completi
/// </summary>
private async Task ReloadData()
{
await OffService.CheckExpiredAsync();
AllRecords = await OffService.GetFiltAsync(PeriodoSel.Inizio, PeriodoSel.Fine);
DoFilter();
}
/// <summary>
/// Imposta periodo da filtro
/// </summary>
/// <param name="newPeriod"></param>
/// <returns></returns>
private async Task SetPeriodo(EgwCoreLib.Utils.DtUtils.Periodo newPeriod)
{
PeriodoSel = newPeriod;
await ReloadData();
UpdateTable();
}
private void SetupArrows()
{
listBord01 = new();
@@ -505,30 +505,5 @@ namespace Lux.UI.Components.Pages
}
#endregion Private Methods
#if false
protected void SetNumRec(int newNum)
{
numRecord = newNum;
RefreshDisplay();
}
protected void SetPage(int newNum)
{
currPage = newNum;
RefreshDisplay();
}
protected void SortRequested(Sorter.SortCallBack e)
{
if (sortField == e.ParamName)
{
sortAsc = e.IsAscending;
}
sortField = e.ParamName;
RefreshDisplay();
}
#endif
}
}
+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>1.1.2603.2309</Version>
<Version>1.1.2603.2310</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>LUX - Web Windows MES</i>
<h4>Versione: 1.1.2603.2309</h4>
<h4>Versione: 1.1.2603.2310</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.1.2603.2309
1.1.2603.2310
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.1.2603.2309</version>
<version>1.1.2603.2310</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>