This commit is contained in:
2025-06-30 15:46:11 +02:00
parent 3f2b7a6bb5
commit 3ad3ec23f0
5 changed files with 54 additions and 35 deletions

View File

@@ -48,7 +48,7 @@ public class ManageDataService(LocalDbService localDb, IMapper mapper) : IManage
dto.Category = activity.CodAnag != null ? ActivityCategoryEnum.Interna : ActivityCategoryEnum.Memo; dto.Category = activity.CodAnag != null ? ActivityCategoryEnum.Interna : ActivityCategoryEnum.Memo;
} }
if (dto.Category == ActivityCategoryEnum.Interna && activity.CodAnag != null) if (dto.Category != ActivityCategoryEnum.Memo && activity.CodAnag != null)
{ {
string? ragSoc; string? ragSoc;

View File

@@ -9,7 +9,6 @@ using salesbook.Maui.Core.Services;
using salesbook.Shared; using salesbook.Shared;
using salesbook.Shared.Core.Helpers; using salesbook.Shared.Core.Helpers;
using salesbook.Shared.Core.Interface; using salesbook.Shared.Core.Interface;
using salesbook.Shared.Core.Messages.Activity;
using salesbook.Shared.Core.Messages.Activity.Copy; using salesbook.Shared.Core.Messages.Activity.Copy;
using salesbook.Shared.Core.Messages.Activity.New; using salesbook.Shared.Core.Messages.Activity.New;
using salesbook.Shared.Core.Messages.Back; using salesbook.Shared.Core.Messages.Back;

View File

@@ -1,4 +1,5 @@
@using salesbook.Shared.Core.Dto @using System.Threading.Channels
@using salesbook.Shared.Core.Dto
@using salesbook.Shared.Core.Entity @using salesbook.Shared.Core.Entity
@using salesbook.Shared.Core.Interface @using salesbook.Shared.Core.Interface
@inject IManageDataService ManageData @inject IManageDataService ManageData
@@ -26,7 +27,7 @@
<div class="form-container"> <div class="form-container">
<span>Inizio</span> <span>Inizio</span>
<MudTextField T="TimeSpan" InputType="InputType.Time" @bind-Value="EffectiveTime" /> <MudTextField T="TimeSpan" InputType="InputType.Time" @bind-Value="EffectiveTime" @bind-Value:after="OnAfterChangeTime"/>
</div> </div>
<div class="divider"></div> <div class="divider"></div>
@@ -34,7 +35,7 @@
<div class="form-container"> <div class="form-container">
<span>Fine</span> <span>Fine</span>
<MudTextField T="TimeSpan" InputType="InputType.Time" @bind-Value="EffectiveEndTime" /> <MudTextField T="TimeSpan" InputType="InputType.Time" @bind-Value="EffectiveEndTime" @bind-Value:after="OnAfterChangeTime" />
</div> </div>
</div> </div>
@@ -56,7 +57,7 @@
</div> </div>
<div class="button-section"> <div class="button-section">
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="CloseBottomSheet">Salva</MudButton> <MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="() => CloseBottomSheet(true)">Salva</MudButton>
</div> </div>
</div> </div>
</div> </div>
@@ -90,20 +91,44 @@
StateHasChanged(); StateHasChanged();
} }
private void CloseBottomSheet() private void CloseBottomSheet(bool save)
{ {
if (EffectiveDate != null) if (save)
{ {
ActivityModel.EffectiveTime = new DateTime(EffectiveDate!.Value.Year, EffectiveDate!.Value.Month, EffectiveDate!.Value.Day, if (EffectiveDate != null)
EffectiveTime.Hours, EffectiveTime.Minutes, EffectiveTime.Seconds); {
ActivityModel.EffectiveTime = new DateTime(EffectiveDate!.Value.Year, EffectiveDate!.Value.Month, EffectiveDate!.Value.Day,
EffectiveTime.Hours, EffectiveTime.Minutes, EffectiveTime.Seconds);
ActivityModel.EffectiveEndtime = new DateTime(EffectiveDate!.Value.Year, EffectiveDate!.Value.Month, EffectiveDate!.Value.Day, ActivityModel.EffectiveEndtime = new DateTime(EffectiveDate!.Value.Year, EffectiveDate!.Value.Month, EffectiveDate!.Value.Day,
EffectiveEndTime.Hours, EffectiveEndTime.Minutes, EffectiveEndTime.Seconds); EffectiveEndTime.Hours, EffectiveEndTime.Minutes, EffectiveEndTime.Seconds);
}
if (ActivityModel.ActivityResultId.IsNullOrEmpty())
{
Snackbar.Clear();
Snackbar.Configuration.PositionClass = Defaults.Classes.Position.TopCenter;
Snackbar.Add("Esito obbligatorio!", Severity.Error);
return;
}
} }
IsSheetVisible = false; IsSheetVisible = false;
IsSheetVisibleChanged.InvokeAsync(IsSheetVisible); IsSheetVisibleChanged.InvokeAsync(IsSheetVisible);
ActivityModelChanged.InvokeAsync(ActivityModel);
if (save)
{
ActivityModelChanged.InvokeAsync(ActivityModel);
}
}
private void CloseBottomSheet() => CloseBottomSheet(false);
private void OnAfterChangeTime()
{
if (EffectiveEndTime < EffectiveTime)
EffectiveEndTime = EffectiveTime + TimeSpan.FromHours(1);
} }
} }

View File

@@ -69,7 +69,7 @@
private TimeSpan? Durata { get; set; } private TimeSpan? Durata { get; set; }
protected override void OnInitialized() protected override void OnParametersSet()
{ {
Durata = Activity switch Durata = Activity switch
{ {

View File

@@ -1,4 +1,5 @@
@using System.Globalization @using System.Globalization
@using System.Text.RegularExpressions
@using CommunityToolkit.Mvvm.Messaging @using CommunityToolkit.Mvvm.Messaging
@using salesbook.Shared.Core.Dto @using salesbook.Shared.Core.Dto
@using salesbook.Shared.Components.Layout @using salesbook.Shared.Components.Layout
@@ -203,6 +204,8 @@
ActivityModel = ActivityCopied.Clone(); ActivityModel = ActivityCopied.Clone();
} }
await LoadCommesse();
if (IsNew) if (IsNew)
{ {
ActivityModel.EstimatedTime = DateTime.Today.Add(TimeSpan.FromHours(DateTime.Now.Hour)); ActivityModel.EstimatedTime = DateTime.Today.Add(TimeSpan.FromHours(DateTime.Now.Hour));
@@ -255,7 +258,6 @@
Clienti = await ManageData.GetTable<AnagClie>(x => x.FlagStato.Equals("A")); Clienti = await ManageData.GetTable<AnagClie>(x => x.FlagStato.Equals("A"));
Pros = await ManageData.GetTable<PtbPros>(); Pros = await ManageData.GetTable<PtbPros>();
ActivityType = await ManageData.GetTable<StbActivityType>(x => x.FlagTipologia.Equals("A")); ActivityType = await ManageData.GetTable<StbActivityType>(x => x.FlagTipologia.Equals("A"));
await LoadCommesse();
} }
private async Task LoadCommesse() => private async Task LoadCommesse() =>
@@ -281,31 +283,19 @@
private async Task OnClienteChanged() private async Task OnClienteChanged()
{ {
string? codAnag = null;
ActivityModel.CodJcom = null; ActivityModel.CodJcom = null;
var cliente = Clienti.LastOrDefault(x => ActivityModel.Cliente != null && x.RagSoc.Contains(ActivityModel.Cliente, StringComparison.OrdinalIgnoreCase)); if (ActivityModel.Cliente.IsNullOrEmpty()) return;
if (cliente is null)
{
var pros = Pros.LastOrDefault(x => ActivityModel.Cliente != null && x.RagSoc.Contains(ActivityModel.Cliente, StringComparison.OrdinalIgnoreCase));
if (pros is not null) var match = Regex.Match(ActivityModel.Cliente!, @"^\s*(\S+)\s*-\s*(.*)$");
{ if (!match.Success)
codAnag = pros.CodAnag; return;
}
}
else
{
codAnag = cliente.CodAnag;
}
ActivityModel.CodAnag = match.Groups[1].Value;
ActivityModel.Cliente = match.Groups[2].Value;
if (codAnag is not null) await LoadCommesse();
{ OnAfterChangeValue();
ActivityModel.CodAnag = codAnag;
await LoadCommesse();
OnAfterChangeValue();
}
} }
private async Task OnCommessaChanged() private async Task OnCommessaChanged()
@@ -320,6 +310,11 @@
{ {
LabelSave = !OriginalModel.Equals(ActivityModel) ? "Aggiorna" : null; LabelSave = !OriginalModel.Equals(ActivityModel) ? "Aggiorna" : null;
} }
if (ActivityModel.EstimatedEndtime <= ActivityModel.EstimatedTime)
{
ActivityModel.EstimatedEndtime = ActivityModel.EstimatedTime.Value.AddHours(1);
}
} }
private void OpenSelectEsito() private void OpenSelectEsito()