From f46d83e0aa180e1a8f3285f02123a20cf35aef2f Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Tue, 28 Feb 2023 17:24:57 +0100 Subject: [PATCH 1/3] fix gestione descrizioni location in itemdetails --- StockMan.CORE/Components/Movimenti.razor | 4 ++-- StockMan.Data/Controllers/StoManController.cs | 2 ++ StockMan.Data/DbModels/ItemFluxModel.cs | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/StockMan.CORE/Components/Movimenti.razor b/StockMan.CORE/Components/Movimenti.razor index 746f039..0b169d2 100644 --- a/StockMan.CORE/Components/Movimenti.razor +++ b/StockMan.CORE/Components/Movimenti.razor @@ -36,10 +36,10 @@ @flux.DtMov.Date.ToString("yyyy/MM/dd") - @flux.LocationId + @flux.Location.Descr - @flux.ExtLocationId + @flux.ExtLocation.Descr @if (flux.Qta > 0) { diff --git a/StockMan.Data/Controllers/StoManController.cs b/StockMan.Data/Controllers/StoManController.cs index 5117b08..a5f2ba5 100644 --- a/StockMan.Data/Controllers/StoManController.cs +++ b/StockMan.Data/Controllers/StoManController.cs @@ -726,6 +726,8 @@ namespace StockMan.Data.Controllers { dbResult = localDbCtx .DbSetItemFlux + .Include(l=>l.Location) + .Include(e=>e.ExtLocation) .Where(x => x.ItemId == id) .OrderByDescending(x => x.Id) .ToList(); diff --git a/StockMan.Data/DbModels/ItemFluxModel.cs b/StockMan.Data/DbModels/ItemFluxModel.cs index 863bd96..6fc3919 100644 --- a/StockMan.Data/DbModels/ItemFluxModel.cs +++ b/StockMan.Data/DbModels/ItemFluxModel.cs @@ -37,8 +37,10 @@ namespace StockMan.Data.DbModels public DateTime? DtExport { get; set; } public string ModOperatorId { get; set; } = null!; + [ForeignKey("ExtLocationId")] public virtual LocationModel ExtLocation { get; set; } = null!; public virtual ItemModel Item { get; set; } = null!; + [ForeignKey("LocationId")] public virtual LocationModel Location { get; set; } = null!; public virtual OperatorModel ModOperator { get; set; } = null!; public virtual MovTypeModel MovType { get; set; } = null!; From 1a2b0e9406984a7c3cb11e9884168ec0130f1b11 Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Tue, 28 Feb 2023 18:12:53 +0100 Subject: [PATCH 2/3] pagina operatori --- StockMan.CORE/Data/StockDataService.cs | 69 ++++++++++++ StockMan.CORE/Pages/Operatori.razor | 97 ++++++++++++++++ StockMan.CORE/Pages/Operatori.razor.cs | 104 ++++++++++++++++++ StockMan.Data/Controllers/StoManController.cs | 76 +++++++++++++ 4 files changed, 346 insertions(+) create mode 100644 StockMan.CORE/Pages/Operatori.razor create mode 100644 StockMan.CORE/Pages/Operatori.razor.cs diff --git a/StockMan.CORE/Data/StockDataService.cs b/StockMan.CORE/Data/StockDataService.cs index 10d5f15..6307d34 100644 --- a/StockMan.CORE/Data/StockDataService.cs +++ b/StockMan.CORE/Data/StockDataService.cs @@ -2,6 +2,7 @@ using Newtonsoft.Json; using NLog; using StackExchange.Redis; +using StockMan.CORE.Pages; using StockMan.Data.Controllers; using StockMan.Data.DbModels; using System.Diagnostics; @@ -123,6 +124,34 @@ namespace StockMan.CORE.Data return dbResult; } /// + /// Aggiornamento record selezionato operatore + /// + /// + /// + public async Task OperatorMod(OperatorModel currRec) + { + var dbResult = await dbController.OperatorMod(currRec); + // elimino cache redis... + RedisValue pattern = new RedisValue($"{rKeyOperator}:*"); + bool answ = await ExecFlushRedisPattern(pattern); + await Task.Delay(1); + return dbResult; + } + /// + /// Aggiunta operatore + /// + /// + /// + public async Task OperatorAddNew(OperatorModel currRec) + { + var dbResult = await dbController.OperatorAddNew(currRec); + // elimino cache redis... + RedisValue pattern = new RedisValue($"{rKeyOperator}:*"); + bool answ = await ExecFlushRedisPattern(pattern); + await Task.Delay(1); + return dbResult; + } + /// /// Aggiornamento record selezionato item /// /// @@ -519,6 +548,46 @@ namespace StockMan.CORE.Data /// Lista Location /// /// + public async Task> OperatorsGetAll() + { + string source = "DB"; + List? dbResult = new List(); + string currKey = $"{rKeyOperator}:*"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbController.OperatorsGetAll(); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, LongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"OperatorsGetAll | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } + /// + /// Lista Location + /// + /// public async Task> LocationGetLocType() { string source = "DB"; diff --git a/StockMan.CORE/Pages/Operatori.razor b/StockMan.CORE/Pages/Operatori.razor new file mode 100644 index 0000000..5d157f9 --- /dev/null +++ b/StockMan.CORE/Pages/Operatori.razor @@ -0,0 +1,97 @@ +@page "/Operatori" + + +@if (isLoading) +{ + +} +else if (listOprAll == null) +{ +
Nessun record trovato
+} +else +{ +
+
+ Lista Operatori +
+
+ + + + + + + + + + + @foreach (var item in listOprAll) + { + + + + + + + } + +
+ Id esterno + + Cognome + + Nome + + +
+ @item.CodExt + + @item.LastName + + @item.FirstName + + +
+
+
+ + +} \ No newline at end of file diff --git a/StockMan.CORE/Pages/Operatori.razor.cs b/StockMan.CORE/Pages/Operatori.razor.cs new file mode 100644 index 0000000..757b530 --- /dev/null +++ b/StockMan.CORE/Pages/Operatori.razor.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Components; +using System.Net.Http; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Components.Authorization; +using Microsoft.AspNetCore.Components.Forms; +using Microsoft.AspNetCore.Components.Routing; +using Microsoft.AspNetCore.Components.Web; +using Microsoft.AspNetCore.Components.Web.Virtualization; +using Microsoft.JSInterop; +using EgwCoreLib.Razor; +using EgwCoreLib.Razor.Data; +using StockMan.CORE; +using StockMan.CORE.Data; +using StockMan.CORE.Shared; +using StockMan.Data.DbModels; +using StockMan.Data; + +namespace StockMan.CORE.Pages +{ + public partial class Operatori + { + protected List? listOprAll = null; + [Inject] + protected StockDataService SDService { get; set; } = null!; + [Inject] + protected NavigationManager NavManager{ get; set; } = null!; + public bool isLoading { get; set; } = false; + public OperatorModel? currOpr { get; set; } = null; + protected override async Task OnInitializedAsync() + { + isLoading = true; + listOprAll = await SDService.OperatorsGetAll(); + isLoading = false; + } + + protected async Task ModOpr() + { + OperatorModel currRecToMod = new OperatorModel() + { + CodExt = CodExt, + LastName = Cognome, + FirstName = Nome + }; + var done = await SDService.OperatorMod(currRecToMod); + if (done) + { + NavManager.NavigateTo(NavManager.Uri, true); + } + } + protected async Task addNewItem() + { + OperatorModel currRecToMod = new OperatorModel() + { + CodExt = CodExt, + LastName = Cognome, + FirstName = Nome + }; + var done = await SDService.OperatorAddNew(currRecToMod); + if (done) + { + NavManager.NavigateTo(NavManager.Uri, true); + } + } + protected async Task setCurrOpr(OperatorModel currRecToMod) + { + await Task.Delay(1); + CodExt = currRecToMod.CodExt; + Cognome = currRecToMod.LastName; + Nome = currRecToMod.FirstName; + } + + protected string _CodExt = ""; + protected string CodExt + { + get => _CodExt; + set + { + _CodExt = value; + } + } + protected string _Cognome = ""; + protected string Cognome + { + get => _Cognome; + set + { + _Cognome = value; + } + } + protected string _Nome= ""; + protected string Nome + { + get => _Nome; + set + { + _Nome = value; + } + } + } +} \ No newline at end of file diff --git a/StockMan.Data/Controllers/StoManController.cs b/StockMan.Data/Controllers/StoManController.cs index a5f2ba5..f209f44 100644 --- a/StockMan.Data/Controllers/StoManController.cs +++ b/StockMan.Data/Controllers/StoManController.cs @@ -148,6 +148,82 @@ namespace StockMan.Data.Controllers } return fatto; + } + /// + /// Aggiungi Operatore + /// + /// + public async Task OperatorAddNew(OperatorModel editRec) + { + bool fatto = false; + List dbResult = new List(); + using (StockManContext localDbCtx = new StockManContext(_configuration)) + { + try + { + var currRec = localDbCtx + .DbSetOperator + .Where(x => x.CodExt == editRec.CodExt) + .FirstOrDefault(); + if (currRec != null) + { + fatto = false; + } + else + { + localDbCtx + .DbSetOperator + .Add(editRec); + } + await localDbCtx.SaveChangesAsync(); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante OperatorMod{Environment.NewLine}{exc}"); + } + } + return fatto; + + } + /// + /// Modifica Operatore + /// + /// + public async Task OperatorMod(OperatorModel editRec) + { + bool fatto = false; + List dbResult = new List(); + using (StockManContext localDbCtx = new StockManContext(_configuration)) + { + try + { + var currRec = localDbCtx + .DbSetOperator + .Where(x => x.CodExt == editRec.CodExt) + .FirstOrDefault(); + if (currRec != null) + { + currRec.CodExt = editRec.CodExt; + currRec.LastName = editRec.LastName; + currRec.FirstName = editRec.FirstName; + } + else + { + localDbCtx + .DbSetOperator + .Add(editRec); + } + await localDbCtx.SaveChangesAsync(); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante OperatorMod{Environment.NewLine}{exc}"); + } + } + return fatto; + } /// /// Modifica item, From f5dcee77fd5131f0b9f0dde2d66f37353a94cfbf Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Wed, 1 Mar 2023 09:48:15 +0100 Subject: [PATCH 3/3] fix creazione nuovo operatore + fix grafici --- StockMan.CORE/Components/ItemFamList.razor | 144 +++++---- StockMan.CORE/Components/ItemList.razor | 288 +++++++++--------- StockMan.CORE/Pages/AnagraficaArticoli.razor | 9 +- StockMan.CORE/Pages/Operatori.razor | 13 +- StockMan.CORE/Pages/Operatori.razor.cs | 12 + StockMan.Data/Controllers/StoManController.cs | 2 +- 6 files changed, 251 insertions(+), 217 deletions(-) diff --git a/StockMan.CORE/Components/ItemFamList.razor b/StockMan.CORE/Components/ItemFamList.razor index d4905f8..711ec2d 100644 --- a/StockMan.CORE/Components/ItemFamList.razor +++ b/StockMan.CORE/Components/ItemFamList.razor @@ -8,75 +8,85 @@ } else { +
+
+
+ Famiglie Articoli +
+
+ +
+
+
+ + + + @if (!editMode) + { +
- - - - @if (!editMode) - { - - } - - - - + } + + + + - - - - @foreach (var item in ListRecord) - { - - @if (!editMode) + + + + + @foreach (var item in ListRecord) { - + + @if (!editMode) + { + + } + + + + + } - - - - - - } - -
- - - ID UNIVOCO - - CATEGORIA - - # ARTICOLI - + + ID UNIVOCO + + CATEGORIA + + # ARTICOLI + -
- - -
+ + + + @item.Id + + @if (editMode && (item.Id == currRowSel)) + { + + } + else + { +
+ @item.Descr +
+ } +
+ @item.NumItems + + @if (item.NumItems == 0 && !editMode) + { + + } + else if (editMode && (item.Id == currRowSel)) + { + + + } +
- @item.Id - - @if (editMode && (item.Id == currRowSel)) - { - - } - else - { -
- @item.Descr -
- } -
- @item.NumItems - - @if (item.NumItems == 0 && !editMode) - { - - } - else if (editMode && (item.Id == currRowSel)) - { - - - } -
- + +
+
+