diff --git a/SHERPA.BBM.CORE/Controllers/BBMController.cs b/SHERPA.BBM.CORE/Controllers/BBMController.cs
index ee0f7bb..e4720c8 100644
--- a/SHERPA.BBM.CORE/Controllers/BBMController.cs
+++ b/SHERPA.BBM.CORE/Controllers/BBMController.cs
@@ -8,6 +8,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
+using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
namespace SHERPA.BBM.CORE.Controllers
{
@@ -1696,6 +1697,51 @@ namespace SHERPA.BBM.CORE.Controllers
return dbResult;
}
+ ///
+ /// Sposta negoziazione nel basket indicato
+ ///
+ ///
+ ///
+ ///
+ public bool NegotiationMoveBasket(int negotiationId, int basketId)
+ {
+ bool done = false;
+ using (SHERPABBMContext dbCtx = new SHERPABBMContext(_configuration))
+ {
+ try
+ {
+ var currData = dbCtx
+ .DbSetNegotiations
+ .Where(x => x.NegotiationId == negotiationId)
+ .FirstOrDefault();
+ if (currData != null)
+ {
+ // recupero eventuali ordini di questa negoziazione
+ var orderAssociated = dbCtx
+ .DbSetOrders
+ .Where(x => x.NegotiationId == currData.NegotiationId)
+ .ToList();
+ // aggiorno ordini al NUOVO basket!
+ foreach (var item in orderAssociated)
+ {
+ item.BasketId = basketId;
+ dbCtx.Entry(item).State = EntityState.Modified;
+ }
+
+ currData.BasketId = basketId;
+ dbCtx.Entry(currData).State = EntityState.Modified;
+ }
+ dbCtx.SaveChanges();
+ done = true;
+ }
+ catch (Exception exc)
+ {
+ LogException("Eccezione in NegotiationMoveBasket", exc);
+ }
+ }
+ return done;
+ }
+
public int NegotiationsCount()
{
int answ = 0;
diff --git a/SHERPA.BBM.UI/Components/NegotMovList.razor b/SHERPA.BBM.UI/Components/NegotMovList.razor
new file mode 100644
index 0000000..5fd0c7a
--- /dev/null
+++ b/SHERPA.BBM.UI/Components/NegotMovList.razor
@@ -0,0 +1,42 @@
+@using SHERPA.BBM.UI.Data
+
+@inject BBM_EFService BBMService
+@inject MessageService MessageService
+
+
+
+
+ |
+ Cod |
+ Descrizione |
+ Importo |
+ Fatturazione |
+
+
+
+ @foreach (var record in ListRecords)
+ {
+
+ |
+
+ |
+
+ @record.RagSoc
+ @record.CodNegotiation
+ @record.DataIns.ToString("ddd yyyy.MM.dd HH:mm")
+ |
+
+ @record.Descript
+ @record.NumDocs
+ |
+ @record.Importo.ToString("C2") |
+ @record.Fatturato.ToString("C2") |
+
+ }
+
+
+
+
+
+
+
diff --git a/SHERPA.BBM.UI/Components/NegotMovList.razor.cs b/SHERPA.BBM.UI/Components/NegotMovList.razor.cs
new file mode 100644
index 0000000..1c12da7
--- /dev/null
+++ b/SHERPA.BBM.UI/Components/NegotMovList.razor.cs
@@ -0,0 +1,176 @@
+using Microsoft.AspNetCore.Components;
+using SHERPA.BBM.CORE.DbModels;
+
+namespace SHERPA.BBM.UI.Components
+{
+ public partial class NegotMovList
+ {
+ #region Public Properties
+
+ [Parameter]
+ public int AnnoSel { get; set; } = 0;
+
+ [Parameter]
+ public int CustomerId { get; set; } = 0;
+
+ [Parameter]
+ public EventCallback MoveRequested { get; set; }
+
+ [Parameter]
+ public int BaskIdSour
+ {
+ get
+ {
+ return baskIdSour;
+ }
+
+ set
+ {
+ baskIdSour = value;
+ // condiziono visualizzazione...
+ var pUpd = Task.Run(async () => await ReloadAllData());
+ pUpd.Wait();
+ }
+ }
+
+ #endregion Public Properties
+
+ #region Public Methods
+
+ public string btnFromState(bool isActive)
+ {
+ string answ = isActive ? "btn-success" : "btn-outline-warning";
+ return answ;
+ }
+
+ public string checkSelect(int NegotId)
+ {
+ string answ = "";
+ if (currItem != null)
+ {
+ try
+ {
+ answ = (currItem.NegotiationId == NegotId) ? "table-info" : "";
+ }
+ catch
+ {
+ }
+ }
+
+ return answ;
+ }
+
+ public async void OnSeachUpdated()
+ {
+ await InvokeAsync(() =>
+ {
+ Task task = UpdateData();
+ StateHasChanged();
+ });
+ }
+
+ public string tooltipFromState(bool isActive)
+ {
+ string answ = isActive ? "Attivo" : "Imposta Attivo";
+ return answ;
+ }
+
+ #endregion Public Methods
+
+ #region Protected Fields
+
+ protected int totalCount = 0;
+
+ #endregion Protected Fields
+
+ #region Protected Methods
+
+ protected async Task ForceReload(int newNum)
+ {
+ numRecord = newNum;
+ await ReloadAllData();
+ }
+
+ protected async Task ForceReloadPage(int newNum)
+ {
+ currPage = newNum;
+ await ReloadAllData();
+ }
+
+ protected async Task Move(vNegotiationsDataModel currRecord)
+ {
+ // riporto richiesta spostamento
+ await MoveRequested.InvokeAsync(currRecord.NegotiationId);
+ }
+
+ protected override async Task OnInitializedAsync()
+ {
+ MessageService.ShowSearch = true;
+ MessageService.SearchVal = "";
+ MessageService.EA_SearchUpdated += OnSeachUpdated;
+ await ReloadAllData();
+ }
+
+ protected async Task ReloadAllData()
+ {
+ await updateTable();
+ }
+
+ protected void ResetData()
+ {
+ if (currItem != null)
+ {
+ BBMService.rollBackEdit(currItem);
+ }
+ currItem = null;
+ }
+
+ protected async Task UpdateData()
+ {
+ currItem = null;
+ await ReloadAllData();
+ }
+
+ protected async Task updateTable()
+ {
+ SearchRecords = await BBMService.NegotiationsGetAsync(AnnoSel, 0, CustomerId, BaskIdSour, MessageService.SearchVal);
+ totalCount = SearchRecords.Count();
+ ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
+ }
+
+ #endregion Protected Methods
+
+ #region Private Fields
+
+ private bool _showAllDoc = false;
+ private vNegotiationsDataModel? currItem = null;
+ private bool isLoading = false;
+ private List ListRecords = new List();
+ private List SearchRecords = new List();
+
+ #endregion Private Fields
+
+ #region Private Properties
+
+ private int baskIdSour { get; set; } = 0;
+ private int currPage { get; set; } = 1;
+
+ private int numRecord { get; set; } = 10;
+
+ private bool ShowAllDoc
+ {
+ get
+ {
+ return _showAllDoc;
+ }
+
+ set
+ {
+ _showAllDoc = value;
+ updateTable().ConfigureAwait(false);
+ }
+ }
+
+ #endregion Private Properties
+ }
+}
\ No newline at end of file
diff --git a/SHERPA.BBM.UI/Pages/NegotMover.razor b/SHERPA.BBM.UI/Pages/NegotMover.razor
new file mode 100644
index 0000000..1c8860b
--- /dev/null
+++ b/SHERPA.BBM.UI/Pages/NegotMover.razor
@@ -0,0 +1,150 @@
+@page "/NegotMover"
+
+@using SHERPA.BBM.UI.Components
+@using SHERPA.BBM.UI.Data
+@using CORE.DbModels
+@inject BBM_EFService BBMService
+
+
+
+
+ @if (isLoading)
+ {
+
+
+
+ }
+ else
+ {
+
+ }
+
+
+
+
diff --git a/SHERPA.BBM.UI/Pages/NegotMover.razor.cs b/SHERPA.BBM.UI/Pages/NegotMover.razor.cs
new file mode 100644
index 0000000..630fc0e
--- /dev/null
+++ b/SHERPA.BBM.UI/Pages/NegotMover.razor.cs
@@ -0,0 +1,280 @@
+using Microsoft.AspNetCore.Components;
+using SHERPA.BBM.CORE.DbModels;
+using SHERPA.BBM.UI.Data;
+
+namespace SHERPA.BBM.UI.Pages
+{
+ public partial class NegotMover : IDisposable
+ {
+ #region Public Methods
+
+ public void Dispose()
+ {
+ BBMService.ReloadRequest -= BBMService_ReloadRequest;
+ }
+
+ #endregion Public Methods
+
+ #region Protected Fields
+
+ protected int _dxBaskId = 1;
+ protected int _dxCustId = 1;
+ protected int _dxNegoId = 1;
+ protected int _sxBaskId = 1;
+ protected int _sxCustId = 1;
+ protected int _sxNegoId = 1;
+
+ #endregion Protected Fields
+
+ #region Protected Properties
+
+ [Inject]
+ protected MessageService MService { get; set; } = null!;
+
+ protected int YearSel
+ {
+ get => yearSel;
+ set
+ {
+ if (yearSel != value)
+ {
+ yearSel = value;
+ // condiziono visualizzazione...
+ var pUpd = Task.Run(async () => await ReloadAllData());
+ pUpd.Wait();
+ }
+ }
+ }
+
+ #endregion Protected Properties
+
+ #region Protected Methods
+
+ protected async Task moveLeft(int currIdx)
+ {
+ if (SelBasketIdSx > 0)
+ {
+ // eseguo spostamento...
+ await BBMService.NegotiationMoveBasket(currIdx, SelBasketIdSx);
+ }
+ }
+
+ protected async Task moveRight(int currIdx)
+ {
+ if (SelBasketIdDx > 0)
+ {
+ // eseguo spostamento...
+ await BBMService.NegotiationMoveBasket(currIdx, SelBasketIdDx);
+ }
+ }
+
+ protected override async Task OnInitializedAsync()
+ {
+ isLoading = true;
+ BBMService.ReloadRequest += BBMService_ReloadRequest;
+ await Task.Delay(1);
+ MService.NotifyHeadChanged();
+ await ReloadAllData();
+ isLoading = false;
+ }
+
+ protected async Task ReloadDataDx()
+ {
+ CustomersList = await BBMService.CustomersGetAll("");
+ BasketListDx = await BBMService.BasketsGetAsync(1, YearSel);
+ }
+
+ protected async Task ReloadDataSx()
+ {
+ CustomersList = await BBMService.CustomersGetAll("");
+ BasketListSx = await BBMService.BasketsGetAsync(1, YearSel);
+ }
+
+ #endregion Protected Methods
+
+ #region Private Fields
+
+ private List BasketListDx = new List();
+
+ private List BasketListSx = new List();
+
+ private List CustomersList = new List();
+ private int yearSel = 0;
+
+ private List yearsList = new List();
+
+ #endregion Private Fields
+
+ #region Private Properties
+
+ private string cssBtnResBaskDx
+ {
+ get => SelBasketIdDx == 1 ? "btn btn-secondary" : "btn btn-primary";
+ }
+
+ private string cssBtnResBaskSx
+ {
+ get => SelBasketIdSx == 1 ? "btn btn-secondary" : "btn btn-primary";
+ }
+
+ private string cssBtnResCustDx
+ {
+ get => SelCustomerIdDx == 1 ? "btn btn-secondary" : "btn btn-primary";
+ }
+
+ private string cssBtnResCustSx
+ {
+ get => SelCustomerIdSx == 1 ? "btn btn-secondary" : "btn btn-primary";
+ }
+
+ private string cssBtnResYear
+ {
+ get => YearSel == 0 ? "btn btn-secondary" : "btn btn-primary";
+ }
+
+ private bool isLoading { get; set; } = false;
+
+ private int SelBasketIdDx
+ {
+ get
+ {
+ return _dxBaskId;
+ }
+
+ set
+ {
+ _dxBaskId = value;
+ // condiziono visualizzazione...
+ var pUpd = Task.Run(async () => await ReloadDataDx());
+ pUpd.Wait();
+ }
+ }
+
+ private int SelBasketIdSx
+ {
+ get
+ {
+ return _sxBaskId;
+ }
+
+ set
+ {
+ _sxBaskId = value;
+ // condiziono visualizzazione...
+ var pUpd = Task.Run(async () => await ReloadDataSx());
+ pUpd.Wait();
+ }
+ }
+
+ private int SelCustomerIdDx
+ {
+ get
+ {
+ return _dxCustId;
+ }
+
+ set
+ {
+ _dxCustId = value;
+ // condiziono visualizzazione...
+ var pUpd = Task.Run(async () => await ReloadDataDx());
+ pUpd.Wait();
+ }
+ }
+
+ private int SelCustomerIdSx
+ {
+ get
+ {
+ return _sxCustId;
+ }
+
+ set
+ {
+ _sxCustId = value;
+ // condiziono visualizzazione...
+ var pUpd = Task.Run(async () => await ReloadDataSx());
+ pUpd.Wait();
+ }
+ }
+
+ #endregion Private Properties
+
+ #region Private Methods
+
+ private async void BBMService_ReloadRequest(object? sender, EventArgs e)
+ {
+ ReloadEventArgs currArgs = (ReloadEventArgs)e;
+ if (!string.IsNullOrEmpty(currArgs.ReloadMessage))
+ {
+ await ReloadAllData();
+ await InvokeAsync(StateHasChanged);
+ }
+ }
+
+ private async Task ReloadAllData()
+ {
+ yearsList = await BBMService.DocsYears();
+ await ReloadDataSx();
+ await ReloadDataDx();
+ }
+
+ private async Task ResetBasketDx()
+ {
+ if (SelBasketIdDx != 1)
+ {
+ SelBasketIdDx = 1;
+ await Task.Delay(1);
+ }
+ }
+
+ private async Task ResetBasketSx()
+ {
+ if (SelBasketIdSx != 1)
+ {
+ SelBasketIdSx = 1;
+ await Task.Delay(1);
+ }
+ }
+
+ private async Task ResetCustDx()
+ {
+ if (SelCustomerIdDx != 1)
+ {
+ SelCustomerIdDx = 1;
+ await Task.Delay(1);
+ }
+ }
+
+ private async Task ResetCustSx()
+ {
+ if (SelCustomerIdSx != 1)
+ {
+ SelCustomerIdSx = 1;
+ await Task.Delay(1);
+ }
+ }
+
+ private async Task ResetYear()
+ {
+ if (YearSel != 0)
+ {
+ YearSel = 0;
+ await Task.Delay(1);
+ }
+ }
+
+ private string trimTxt(string txtOrig, int maxChar)
+ {
+ string answ = txtOrig;
+ if (txtOrig.Length > maxChar)
+ {
+ answ = $"{txtOrig.Substring(0, maxChar - 3)}...";
+ }
+
+ return answ;
+ }
+
+ #endregion Private Methods
+ }
+}
\ No newline at end of file