From c409931138db2a5ae9fc787da7df01ecf3a404f4 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Fri, 14 May 2021 22:54:50 +0200 Subject: [PATCH] Fix negotiation --> cs --- SHERPA.BBM.UI/Pages/Negotiations.razor | 108 ----------------- SHERPA.BBM.UI/Pages/Negotiations.razor.cs | 140 ++++++++++++++++++++++ SHERPA.BBM.UI/SHERPA.BBM.UI.csproj | 2 +- 3 files changed, 141 insertions(+), 109 deletions(-) create mode 100644 SHERPA.BBM.UI/Pages/Negotiations.razor.cs diff --git a/SHERPA.BBM.UI/Pages/Negotiations.razor b/SHERPA.BBM.UI/Pages/Negotiations.razor index a40cacc..98aac05 100644 --- a/SHERPA.BBM.UI/Pages/Negotiations.razor +++ b/SHERPA.BBM.UI/Pages/Negotiations.razor @@ -1,15 +1,7 @@ @page "/negotiations" -@using SHERPA.BBM.UI.Data @using SHERPA.BBM.UI.Components -@inject IJSRuntime JSRuntime -@inject BBM_EFService BBMService -@inject BBM_SelectData SelectData -@inject NavigationManager NavManager -@inject MessageService MessageService -@implements IDisposable -
@@ -97,103 +89,3 @@
- -@code { - - public string checkSelect(int NegotiationId) - { - string answ = ""; - if (currNegotiation != null) - { - try - { - answ = (currNegotiation.NegotiationId == NegotiationId) ? "table-info" : ""; - } - catch - { } - } - return answ; - } - - private int numRecord { get; set; } = 10; - - private DatabaseModels.NegotiationsModel currNegotiation = null; - - private DatabaseModels.NegotiationsModel[] negotiations; - - public void Dispose() - { - MessageService.EA_SearchUpdated -= OnSeachUpdated; - } - - public void OnSeachUpdated() - { - InvokeAsync(() => - { - UpdateData(); - StateHasChanged(); - }); - } - protected override async Task OnInitializedAsync() - { - MessageService.EA_SearchUpdated += OnSeachUpdated; - negotiations = await BBMService.NegotiationsGetAsync(MessageService.SearchVal, numRecord); - } - - protected void CreateNew() - { - // recupero counter - string newCode = BBMService.CounterGetNext($"{SelectData.Company}.N.{DateTime.Today.Year}", 6); - DatabaseModels.NegotiationsModel newRecord = new DatabaseModels.NegotiationsModel() - { - CodNegotiation = newCode, - DataIns = DateTime.Now, - CustomerId = 1, - Descript = "Nuova Negoziazione", - BasePath = "", - Refer = "" - }; - currNegotiation = newRecord; - } - - protected async Task ForceReload(int newNum) - { - numRecord = newNum; - negotiations = await BBMService.NegotiationsGetAsync(MessageService.SearchVal, numRecord); - } - - protected void ResetData() - { - BBMService.rollBackEdit(currNegotiation); - currNegotiation = null; - } - - protected async Task UpdateData() - { - currNegotiation = null; - negotiations = await BBMService.NegotiationsGetAsync(MessageService.SearchVal, numRecord); - } - - protected void Edit(SHERPA.BBM.DatabaseModels.NegotiationsModel currRecord) - { - currNegotiation = currRecord; - } - protected async Task Delete(SHERPA.BBM.DatabaseModels.NegotiationsModel currRecord) - { - if (!await JSRuntime.InvokeAsync("confirm", $"Sicuro di voler eliminare la Negoziazione '{currRecord.CodNegotiation}'?")) - return; - - BBMService.NegotiationDelete(currRecord); - await UpdateData(); - } - - protected void ShowDocs(SHERPA.BBM.DatabaseModels.NegotiationsModel currRecord) - { - // salvo - SelectData.BasketId = 0; - SelectData.NegotiationId = currRecord.NegotiationId; - // rimando... - NavManager.NavigateTo("docs"); - } - -} \ No newline at end of file diff --git a/SHERPA.BBM.UI/Pages/Negotiations.razor.cs b/SHERPA.BBM.UI/Pages/Negotiations.razor.cs new file mode 100644 index 0000000..134bb5a --- /dev/null +++ b/SHERPA.BBM.UI/Pages/Negotiations.razor.cs @@ -0,0 +1,140 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; +using SHERPA.BBM.UI.Data; +using System; +using System.Threading.Tasks; + +namespace SHERPA.BBM.UI.Pages +{ + public partial class Negotiations : ComponentBase, IDisposable + { + #region Private Fields + + private DatabaseModels.NegotiationsModel currNegotiation = null; + + private DatabaseModels.NegotiationsModel[] negotiations; + + #endregion Private Fields + + #region Private Properties + + [Inject] + private BBM_EFService BBMService { get; set; } + + [Inject] + private IJSRuntime JSRuntime { get; set; } + + [Inject] + private MessageService MessageService { get; set; } + + [Inject] + private NavigationManager NavManager { get; set; } + + private int numRecord { get; set; } = 10; + + [Inject] + private BBM_SelectData SelectData { get; set; } + + #endregion Private Properties + + #region Public Methods + + public string checkSelect(int NegotiationId) + { + string answ = ""; + if (currNegotiation != null) + { + try + { + answ = (currNegotiation.NegotiationId == NegotiationId) ? "table-info" : ""; + } + catch + { } + } + return answ; + } + + public void Dispose() + { + MessageService.EA_SearchUpdated -= OnSeachUpdated; + } + + public void OnSeachUpdated() + { + InvokeAsync(() => + { + UpdateData(); + StateHasChanged(); + }); + } + + #endregion Public Methods + + #region Protected Methods + + protected void CreateNew() + { + // recupero counter + string newCode = BBMService.CounterGetNext($"{SelectData.Company}.N.{DateTime.Today.Year}", 6); + DatabaseModels.NegotiationsModel newRecord = new DatabaseModels.NegotiationsModel() + { + CodNegotiation = newCode, + DataIns = DateTime.Now, + CustomerId = 1, + Descript = "Nuova Negoziazione", + BasePath = "", + Refer = "" + }; + currNegotiation = newRecord; + } + + protected async Task Delete(SHERPA.BBM.DatabaseModels.NegotiationsModel currRecord) + { + if (!await JSRuntime.InvokeAsync("confirm", $"Sicuro di voler eliminare la Negoziazione '{currRecord.CodNegotiation}'?")) + return; + + BBMService.NegotiationDelete(currRecord); + await UpdateData(); + } + + protected void Edit(SHERPA.BBM.DatabaseModels.NegotiationsModel currRecord) + { + currNegotiation = currRecord; + } + + protected async Task ForceReload(int newNum) + { + numRecord = newNum; + negotiations = await BBMService.NegotiationsGetAsync(MessageService.SearchVal, numRecord); + } + + protected override async Task OnInitializedAsync() + { + MessageService.EA_SearchUpdated += OnSeachUpdated; + negotiations = await BBMService.NegotiationsGetAsync(MessageService.SearchVal, numRecord); + } + + protected void ResetData() + { + BBMService.rollBackEdit(currNegotiation); + currNegotiation = null; + } + + protected void ShowDocs(SHERPA.BBM.DatabaseModels.NegotiationsModel currRecord) + { + // salvo + SelectData.BasketId = 0; + SelectData.NegotiationId = currRecord.NegotiationId; + // rimando... + NavManager.NavigateTo("docs"); + } + + protected async Task UpdateData() + { + currNegotiation = null; + negotiations = await BBMService.NegotiationsGetAsync(MessageService.SearchVal, numRecord); + } + + #endregion Protected Methods + } +} \ No newline at end of file diff --git a/SHERPA.BBM.UI/SHERPA.BBM.UI.csproj b/SHERPA.BBM.UI/SHERPA.BBM.UI.csproj index 3c4f927..30aff2c 100644 --- a/SHERPA.BBM.UI/SHERPA.BBM.UI.csproj +++ b/SHERPA.BBM.UI/SHERPA.BBM.UI.csproj @@ -4,7 +4,7 @@ net5.0 60fcdaab-6c1e-4bec-9d88-f7727ef1c12c wwwroot\favicon.ico - 1.0.2105.2251 + 1.0.2105.2254