Fix vari
This commit is contained in:
@@ -48,7 +48,7 @@ public class ManageDataService(LocalDbService localDb, IMapper mapper) : IManage
|
||||
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;
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ using salesbook.Maui.Core.Services;
|
||||
using salesbook.Shared;
|
||||
using salesbook.Shared.Core.Helpers;
|
||||
using salesbook.Shared.Core.Interface;
|
||||
using salesbook.Shared.Core.Messages.Activity;
|
||||
using salesbook.Shared.Core.Messages.Activity.Copy;
|
||||
using salesbook.Shared.Core.Messages.Activity.New;
|
||||
using salesbook.Shared.Core.Messages.Back;
|
||||
|
||||
@@ -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.Interface
|
||||
@inject IManageDataService ManageData
|
||||
@@ -26,7 +27,7 @@
|
||||
<div class="form-container">
|
||||
<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 class="divider"></div>
|
||||
@@ -34,7 +35,7 @@
|
||||
<div class="form-container">
|
||||
<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>
|
||||
|
||||
@@ -56,7 +57,7 @@
|
||||
</div>
|
||||
|
||||
<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>
|
||||
@@ -90,20 +91,44 @@
|
||||
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,
|
||||
EffectiveTime.Hours, EffectiveTime.Minutes, EffectiveTime.Seconds);
|
||||
if (EffectiveDate != null)
|
||||
{
|
||||
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,
|
||||
EffectiveEndTime.Hours, EffectiveEndTime.Minutes, EffectiveEndTime.Seconds);
|
||||
ActivityModel.EffectiveEndtime = new DateTime(EffectiveDate!.Value.Year, EffectiveDate!.Value.Month, EffectiveDate!.Value.Day,
|
||||
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;
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -69,7 +69,7 @@
|
||||
|
||||
private TimeSpan? Durata { get; set; }
|
||||
|
||||
protected override void OnInitialized()
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
Durata = Activity switch
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
@using System.Globalization
|
||||
@using System.Text.RegularExpressions
|
||||
@using CommunityToolkit.Mvvm.Messaging
|
||||
@using salesbook.Shared.Core.Dto
|
||||
@using salesbook.Shared.Components.Layout
|
||||
@@ -203,6 +204,8 @@
|
||||
ActivityModel = ActivityCopied.Clone();
|
||||
}
|
||||
|
||||
await LoadCommesse();
|
||||
|
||||
if (IsNew)
|
||||
{
|
||||
ActivityModel.EstimatedTime = DateTime.Today.Add(TimeSpan.FromHours(DateTime.Now.Hour));
|
||||
@@ -255,7 +258,6 @@
|
||||
Clienti = await ManageData.GetTable<AnagClie>(x => x.FlagStato.Equals("A"));
|
||||
Pros = await ManageData.GetTable<PtbPros>();
|
||||
ActivityType = await ManageData.GetTable<StbActivityType>(x => x.FlagTipologia.Equals("A"));
|
||||
await LoadCommesse();
|
||||
}
|
||||
|
||||
private async Task LoadCommesse() =>
|
||||
@@ -281,31 +283,19 @@
|
||||
|
||||
private async Task OnClienteChanged()
|
||||
{
|
||||
string? codAnag = null;
|
||||
ActivityModel.CodJcom = null;
|
||||
|
||||
var cliente = Clienti.LastOrDefault(x => ActivityModel.Cliente != null && x.RagSoc.Contains(ActivityModel.Cliente, StringComparison.OrdinalIgnoreCase));
|
||||
if (cliente is null)
|
||||
{
|
||||
var pros = Pros.LastOrDefault(x => ActivityModel.Cliente != null && x.RagSoc.Contains(ActivityModel.Cliente, StringComparison.OrdinalIgnoreCase));
|
||||
if (ActivityModel.Cliente.IsNullOrEmpty()) return;
|
||||
|
||||
if (pros is not null)
|
||||
{
|
||||
codAnag = pros.CodAnag;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
codAnag = cliente.CodAnag;
|
||||
}
|
||||
var match = Regex.Match(ActivityModel.Cliente!, @"^\s*(\S+)\s*-\s*(.*)$");
|
||||
if (!match.Success)
|
||||
return;
|
||||
|
||||
ActivityModel.CodAnag = match.Groups[1].Value;
|
||||
ActivityModel.Cliente = match.Groups[2].Value;
|
||||
|
||||
if (codAnag is not null)
|
||||
{
|
||||
ActivityModel.CodAnag = codAnag;
|
||||
await LoadCommesse();
|
||||
OnAfterChangeValue();
|
||||
}
|
||||
await LoadCommesse();
|
||||
OnAfterChangeValue();
|
||||
}
|
||||
|
||||
private async Task OnCommessaChanged()
|
||||
@@ -320,6 +310,11 @@
|
||||
{
|
||||
LabelSave = !OriginalModel.Equals(ActivityModel) ? "Aggiorna" : null;
|
||||
}
|
||||
|
||||
if (ActivityModel.EstimatedEndtime <= ActivityModel.EstimatedTime)
|
||||
{
|
||||
ActivityModel.EstimatedEndtime = ActivityModel.EstimatedTime.Value.AddHours(1);
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenSelectEsito()
|
||||
|
||||
Reference in New Issue
Block a user