diff --git a/SHERPA.BBM.UI/Components/CountersEditor.razor b/SHERPA.BBM.UI/Components/CountersEditor.razor new file mode 100644 index 0000000..c9ff294 --- /dev/null +++ b/SHERPA.BBM.UI/Components/CountersEditor.razor @@ -0,0 +1,76 @@ +@using SHERPA.BBM.UI.Data +@using SHERPA.BBM.UI.Components; +@using DatabaseModels +@inject BBM_EFService BBMService + +
+
+ Modifica +
+
+ + + +
+
+
+ + +
+
+
+ + +
+
+ +
+
+ +
+
+
+
+
+ +@code { + + protected DatabaseModels.FluxCountersModel _currItem = new FluxCountersModel(); + + [Parameter] + public DatabaseModels.FluxCountersModel currItem + { + get + { + return _currItem = null; + } + set + { + _currItem = value; + } + } + + [Parameter] + public EventCallback DataReset { get; set; } + [Parameter] + public EventCallback DataUpdated { get; set; } + + private async Task saveUpdate() + { + if (_currItem != null) + { + BBMService.CounterUpdate(_currItem); + await DataUpdated.InvokeAsync(1); + } + else + { + Console.WriteLine("Counter null!"); + } + } + + private async Task cancelUpdate() + { + await DataReset.InvokeAsync(0); + } + +} \ No newline at end of file diff --git a/SHERPA.BBM.UI/Data/BBM_EFService.cs b/SHERPA.BBM.UI/Data/BBM_EFService.cs index 2abd83a..9f5775e 100644 --- a/SHERPA.BBM.UI/Data/BBM_EFService.cs +++ b/SHERPA.BBM.UI/Data/BBM_EFService.cs @@ -94,11 +94,27 @@ namespace SHERPA.BBM.UI.Data } } + public Task CounterGetAll() + { + return Task.FromResult(dbController.ContersGetAll().ToArray()); + } + public string CounterGetNext(string CodCounter, int numZeros) { return dbController.CounterGetNext(CodCounter, numZeros); } + public void CounterUpdate(DatabaseModels.FluxCountersModel currItem) + { + try + { + dbController.CounterUpdate(currItem); + } + catch + { + } + } + public Task DocGetByKeyAsync(int DocId) { return Task.FromResult(dbController.DocGetByKey(DocId)); diff --git a/SHERPA.BBM.UI/Pages/Counter.razor b/SHERPA.BBM.UI/Pages/Counter.razor deleted file mode 100644 index 8641f78..0000000 --- a/SHERPA.BBM.UI/Pages/Counter.razor +++ /dev/null @@ -1,16 +0,0 @@ -@page "/counter" - -

Counter

- -

Current count: @currentCount

- - - -@code { - private int currentCount = 0; - - private void IncrementCount() - { - currentCount++; - } -} diff --git a/SHERPA.BBM.UI/Pages/Counters.razor b/SHERPA.BBM.UI/Pages/Counters.razor new file mode 100644 index 0000000..e8ba9af --- /dev/null +++ b/SHERPA.BBM.UI/Pages/Counters.razor @@ -0,0 +1,115 @@ +@page "/counters" + +@using SHERPA.BBM.UI.Data +@using SHERPA.BBM.UI.Components + +@inject IJSRuntime JSRuntime +@inject BBM_EFService BBMService + +
+
+
+
+

Contatori

+
+
+
+
+
+
+ @if (currItem != null) + { + + } + @if (itemsList == null) + { +

Loading...

+ } + else + { + + + + + + + + + + @foreach (var record in itemsList) + { + + + + + + } + +
CodLastNum
@record.CodCounter@record.LastNum
+ } +
+
+
+ @**@ +
+ +@code { + + private DatabaseModels.FluxCountersModel currItem = null; + private DatabaseModels.FluxCountersModel[] itemsList; + + protected async Task updateTable() + { + itemsList = await BBMService.CounterGetAll(); + } + + protected async Task ReloadAllData() + { + await updateTable(); + } + + protected override async Task OnInitializedAsync() + { + await ReloadAllData(); + } + + protected void ResetData() + { + BBMService.rollBackEdit(currItem); + currItem = null; + } + + protected async Task UpdateData() + { + currItem = null; + await ReloadAllData(); + } + + protected void Edit(SHERPA.BBM.DatabaseModels.FluxCountersModel currRecord) + { + currItem = currRecord; + } + + public string checkSelect(string CodCounter) + { + string answ = ""; + if (currItem != null) + { + try + { + answ = (currItem.CodCounter == CodCounter) ? "table-info" : ""; + } + catch + { } + } + return answ; + } +} \ No newline at end of file diff --git a/SHERPA.BBM.UI/Pages/Utility.razor b/SHERPA.BBM.UI/Pages/Utility.razor new file mode 100644 index 0000000..d7e1f00 --- /dev/null +++ b/SHERPA.BBM.UI/Pages/Utility.razor @@ -0,0 +1,31 @@ +@page "/utility" + +@using SHERPA.BBM.UI.Components + +
+
+
+
+

Utility

+
+
+
+
+
+
+
+ + @**@ + @**@ + @**@ + @**@ + @**@ +
+
+
+
+
+ +@code { + +} \ No newline at end of file diff --git a/SHERPA.BBM/Controllers/BBMController.cs b/SHERPA.BBM/Controllers/BBMController.cs index 5a223bd..2a730b0 100644 --- a/SHERPA.BBM/Controllers/BBMController.cs +++ b/SHERPA.BBM/Controllers/BBMController.cs @@ -131,6 +131,24 @@ namespace SHERPA.BBM.Controllers return done; } + /// + /// Elenco Conunters + /// + /// + /// + public List ContersGetAll(string searchVal = "") + { + List dbResult = new List(); + + dbResult = dbCtx + .DbSetCounters + .Where(x => x.CodCounter.Contains(searchVal) || string.IsNullOrEmpty(searchVal)) + .OrderBy(x => x.CodCounter) + .ToList(); + + return dbResult; + } + public string CounterGetNext(string CodCounter, int numZeros) { string answ = $"{CodCounter}.0000"; @@ -163,6 +181,38 @@ namespace SHERPA.BBM.Controllers return answ; } + /// + /// Aggiorna un FluxCounter + /// + /// + /// + public bool CounterUpdate(DatabaseModels.FluxCountersModel updItem) + { + bool done = false; + try + { + var currData = dbCtx + .DbSetCounters + .Where(x => x.CodCounter == updItem.CodCounter) + .FirstOrDefault(); + if (currData != null) + { + dbCtx.Entry(updItem).State = System.Data.Entity.EntityState.Modified; + } + else + { + dbCtx + .DbSetCounters + .Add(updItem); + } + dbCtx.SaveChanges(); + done = true; + } + catch (Exception exc) + { } + return done; + } + public void Dispose() { // Clear database context diff --git a/SHERPA.BBM/DatabaseContext.cs b/SHERPA.BBM/DatabaseContext.cs index 4c2b94c..74edbf8 100644 --- a/SHERPA.BBM/DatabaseContext.cs +++ b/SHERPA.BBM/DatabaseContext.cs @@ -32,12 +32,13 @@ namespace SHERPA.BBM #endregion Public Constructors + // Aggiungere DbSet per ogni tipo di entità che si desidera includere nel modello. Per ulteriori informazioni + // sulla configurazione e sull'utilizzo di un modello Code, vedere http://go.microsoft.com/fwlink/?LinkId=390109. + #region Public Properties public virtual DbSet DbSetBaskets { get; set; } - // Aggiungere DbSet per ogni tipo di entità che si desidera includere nel modello. Per ulteriori informazioni - // sulla configurazione e sull'utilizzo di un modello Code, vedere http://go.microsoft.com/fwlink/?LinkId=390109. public virtual DbSet DbSetCounters { get; set; } public virtual DbSet DbSetDocs { get; set; } diff --git a/SHERPA.BBM/Precision.cs b/SHERPA.BBM/Precision.cs index 7ac15bd..9ad0ae6 100644 --- a/SHERPA.BBM/Precision.cs +++ b/SHERPA.BBM/Precision.cs @@ -7,6 +7,7 @@ namespace SHERPA.BBM /// /// The Precision class allows us to decorate our Entity Models with a Precision attribute /// to specify decimal precision values for the database column + /// https://github.com/CypressNorth/.NET-EF6-PrecisionAnnotation /// [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)] public class Precision : Attribute