Fix negotiation --> cs

This commit is contained in:
Samuele E. Locatelli
2021-05-14 22:54:50 +02:00
parent 51b4cffcae
commit c409931138
3 changed files with 141 additions and 109 deletions
-108
View File
@@ -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
<div class="card">
<div class="card-header">
<div class="row">
@@ -97,103 +89,3 @@
</div>
</div>
</div>
@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<bool>("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");
}
}
+140
View File
@@ -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<bool>("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
}
}
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net5.0</TargetFramework>
<UserSecretsId>60fcdaab-6c1e-4bec-9d88-f7727ef1c12c</UserSecretsId>
<ApplicationIcon>wwwroot\favicon.ico</ApplicationIcon>
<Version>1.0.2105.2251</Version>
<Version>1.0.2105.2254</Version>
</PropertyGroup>
<ItemGroup>