From b83731097b7729d2f215fe6ba83ba1d5e8080405 Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Thu, 2 Mar 2023 10:26:16 +0100 Subject: [PATCH] aggiunti paginatori vari + fix modifica posizioni --- StockMan.CORE/Components/ItemList.razor.cs | 2 +- StockMan.CORE/Components/ListPosizioni.razor | 93 ++++++++++++ .../Components/ListPosizioni.razor.cs | 138 ++++++++++++++++++ StockMan.CORE/Components/Location.razor | 36 +++-- StockMan.CORE/Components/Location.razor.cs | 78 +++++++++- StockMan.CORE/Data/LocDXSelectFilter.cs | 68 +++++++++ StockMan.CORE/Data/LocSXSelectFilter.cs | 68 +++++++++ StockMan.CORE/Data/PosizioniSelectFilter.cs | 68 +++++++++ StockMan.CORE/Data/StockDataService.cs | 40 +++++ StockMan.CORE/Pages/Posizioni.razor | 91 +----------- StockMan.CORE/Pages/Posizioni.razor.cs | 94 +++--------- StockMan.CORE/Pages/StatoMag.razor | 8 +- StockMan.CORE/Pages/StatoMag.razor.cs | 58 ++++++++ 13 files changed, 655 insertions(+), 187 deletions(-) create mode 100644 StockMan.CORE/Components/ListPosizioni.razor create mode 100644 StockMan.CORE/Components/ListPosizioni.razor.cs create mode 100644 StockMan.CORE/Data/LocDXSelectFilter.cs create mode 100644 StockMan.CORE/Data/LocSXSelectFilter.cs create mode 100644 StockMan.CORE/Data/PosizioniSelectFilter.cs diff --git a/StockMan.CORE/Components/ItemList.razor.cs b/StockMan.CORE/Components/ItemList.razor.cs index bb45d9b..3709b74 100644 --- a/StockMan.CORE/Components/ItemList.razor.cs +++ b/StockMan.CORE/Components/ItemList.razor.cs @@ -303,11 +303,11 @@ namespace StockMan.CORE.Components #region Private Properties - private int _totalCount { get; set; } = 0; [Inject] private IConfiguration Configuration { get; set; } = null!; + private int _totalCount { get; set; } = 0; private int currPage { get => actFilter.CurrPage; diff --git a/StockMan.CORE/Components/ListPosizioni.razor b/StockMan.CORE/Components/ListPosizioni.razor new file mode 100644 index 0000000..a43902b --- /dev/null +++ b/StockMan.CORE/Components/ListPosizioni.razor @@ -0,0 +1,93 @@ +@if (isLoading) +{ + +} +else if (listLocAll == null) +{ +
Nessun record trovato
+} +else +{ +
+
+
+ Lista Posizioni +
+
+ +
+
+
+ + + + + + + + + + @foreach (var item in listLocAll) + { + + + + + + } + +
+ Desc + + Tipo + +
+ @item.Descr + + @(item.LocTypeNav?.Descr ?? "") + + +
+
+
+ + +} \ No newline at end of file diff --git a/StockMan.CORE/Components/ListPosizioni.razor.cs b/StockMan.CORE/Components/ListPosizioni.razor.cs new file mode 100644 index 0000000..3e8e143 --- /dev/null +++ b/StockMan.CORE/Components/ListPosizioni.razor.cs @@ -0,0 +1,138 @@ +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.Components +{ + public partial class ListPosizioni + { + #region Public Properties + [Parameter] + public PosizioniSelectFilter actFilter { get; set; } = new PosizioniSelectFilter(); + [Parameter] + public EventCallback updateRecordCount { get; set; } + public LocationModel? currLoc { get; set; } = null; + public bool isLoading { get; set; } = false; + + #endregion Public Properties + + #region Protected Fields + + protected string _descr = ""; + protected string _ID = ""; + protected string _loctype = ""; + protected List? listLocAll = null; + protected List? searchRecord = null; + protected List? listLocTypes = null; + + #endregion Protected Fields + + #region Protected Properties + + protected string descr + { + get => _descr; + set { _descr = value; } + } + + protected string ID + { + get => _ID; + set { _ID = value; } + } + + protected string loctype + { + get => _loctype; + set { _loctype = value; } + } + + [Inject] + protected NavigationManager NavManager { get; set; } = null!; + + [Inject] + protected StockDataService SDService { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + private int _totalCount { get; set; } = 0; + private int currPage + { + get => actFilter.CurrPage; + set => actFilter.CurrPage = value; + } + + private int numRecord + { + get => actFilter.NumRec; + set => actFilter.NumRec = value; + } + + private int totalCount + { + get => _totalCount; + set + { + if (_totalCount != value) + { + _totalCount = value; + updateRecordCount.InvokeAsync(value); + } + } + } + + protected async Task ModLoc() + { + LocationModel currRecToMod = new LocationModel() + { + Id = ID, + Descr = descr, + LocTypeId = loctype + }; + var done = await SDService.LocationMod(currRecToMod); + if (done) + { + NavManager.NavigateTo(NavManager.Uri, true); + } + } + + protected override async Task OnParametersSetAsync() + { + isLoading = true; + listLocTypes = await SDService.LocTypeGetAll(); + searchRecord = await SDService.LocationGetAll(); + totalCount = searchRecord.Count; + listLocAll = searchRecord.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); + isLoading = false; + } + + protected async Task setCurrLoc(LocationModel currRecToMod) + { + await Task.Delay(1); + + ID = currRecToMod.Id; + descr = currRecToMod.Descr; + loctype = currRecToMod.LocTypeId; + } + + #endregion Protected Methods + } +} \ No newline at end of file diff --git a/StockMan.CORE/Components/Location.razor b/StockMan.CORE/Components/Location.razor index 1feb0e8..23742c5 100644 --- a/StockMan.CORE/Components/Location.razor +++ b/StockMan.CORE/Components/Location.razor @@ -55,27 +55,31 @@ else - @foreach (var item in listItemByLoc) + @if (listItemByLoc != null) { - - - - @item.ItemNav.Descr - - - @item.QtyConf - - - @($"{item.ItemNav.CurrValue:C2}") - @if (isSX) - { - - } - + @foreach (var item in listItemByLoc) + { + + + + @item.ItemNav.Descr + + + @item.QtyConf + + + @($"{item.ItemNav.CurrValue:C2}") + @if (isSX) + { + + } + + } } + } diff --git a/StockMan.CORE/Components/Location.razor.cs b/StockMan.CORE/Components/Location.razor.cs index cb415a6..539d66e 100644 --- a/StockMan.CORE/Components/Location.razor.cs +++ b/StockMan.CORE/Components/Location.razor.cs @@ -1,3 +1,4 @@ +using EgwCoreLib.Razor; using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; using StockMan.CORE.Data; @@ -36,10 +37,52 @@ namespace StockMan.CORE.Components [Parameter] public string locSX_ID { get; set; } = ""; - public int qty { get; set; } = 0; - [Parameter] public string UserName { get; set; } = ""; + [Parameter] + public LocSXSelectFilter actFilterSX { get; set; } = new LocSXSelectFilter(); + [Parameter] + public LocDXSelectFilter actFilterDX { get; set; } = new LocDXSelectFilter(); + [Parameter] + public EventCallback updateRecordCount { get; set; } + private int currPageSX + { + get => actFilterSX.CurrPage; + set => actFilterSX.CurrPage = value; + } + + private int numRecordSX + { + get => actFilterSX.NumRec; + set => actFilterSX.NumRec = value; + } + private int currPageDX + { + get => actFilterDX.CurrPage; + set => actFilterDX.CurrPage = value; + } + + private int numRecordDX + { + get => actFilterDX.NumRec; + set => actFilterDX.NumRec = value; + } + private int _totalCount = 0; + private int totalCount + { + get => _totalCount; + set + { + if (_totalCount != value) + { + _totalCount = value; + updateRecordCount.InvokeAsync(value); + } + } + } + public int qty { get; set; } = 0; + + protected DataPager? pagerLocation; #endregion Public Properties @@ -84,6 +127,7 @@ namespace StockMan.CORE.Components protected IJSRuntime JSRuntime { get; set; } = null!; protected List? listItemByLoc { get; set; } = null; + protected List? listSearch { get; set; } = null; protected string locSxoDx { @@ -110,6 +154,25 @@ namespace StockMan.CORE.Components #region Protected Methods + protected void ForceReloadSX(int newNum) + { + numRecordSX = newNum; + } + + protected void ForceReloadPageSX(int newNum) + { + currPageSX = newNum; + } + protected void ForceReloadDX(int newNum) + { + numRecordDX = newNum; + } + + protected void ForceReloadPageDX(int newNum) + { + currPageDX = newNum; + } + protected async Task Move() { bool done = false; @@ -168,7 +231,16 @@ namespace StockMan.CORE.Components protected async Task ReloadData() { isLoading = true; - listItemByLoc = await SDService.ItemsGetByLocation(currLoc); + listSearch = await SDService.ItemsGetByLocation(currLoc); + totalCount = listSearch.Count; + if (isSX) + { + listItemByLoc = listSearch.Skip(numRecordSX * (currPageSX - 1)).Take(numRecordSX).ToList(); + } + else + { + listItemByLoc = listSearch.Skip(numRecordDX * (currPageDX - 1)).Take(numRecordDX).ToList(); + } isLoading = false; } diff --git a/StockMan.CORE/Data/LocDXSelectFilter.cs b/StockMan.CORE/Data/LocDXSelectFilter.cs new file mode 100644 index 0000000..c4853de --- /dev/null +++ b/StockMan.CORE/Data/LocDXSelectFilter.cs @@ -0,0 +1,68 @@ +namespace StockMan.CORE.Data +{ + public class LocDXSelectFilter + { + #region Public Constructors + + public LocDXSelectFilter() + { } + + #endregion Public Constructors + + #region Public Properties + + public int CurrPage { get; set; } = 1; + + public int MaxRecord { get; set; } = 100; + + public int NumRec { get; set; } = 10; + + public int TotCount { get; set; } = 0; + + #endregion Public Properties + + #region Public Methods + + public LocDXSelectFilter clone() + { + LocDXSelectFilter clonedData = new LocDXSelectFilter() + { + CurrPage = this.CurrPage, + MaxRecord = this.MaxRecord, + NumRec = this.NumRec, + TotCount = this.TotCount, + }; + return clonedData; + } + + public override bool Equals(object? obj) + { + if (obj == null) + return false; + + if (!(obj is LocDXSelectFilter item)) + return false; + + if (MaxRecord != item.MaxRecord) + return false; + + if (NumRec != item.NumRec) + return false; + + if (TotCount != item.TotCount) + return false; + + if (CurrPage != item.CurrPage) + return false; + + return true; + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } + + #endregion Public Methods + } +} \ No newline at end of file diff --git a/StockMan.CORE/Data/LocSXSelectFilter.cs b/StockMan.CORE/Data/LocSXSelectFilter.cs new file mode 100644 index 0000000..6c7f572 --- /dev/null +++ b/StockMan.CORE/Data/LocSXSelectFilter.cs @@ -0,0 +1,68 @@ +namespace StockMan.CORE.Data +{ + public class LocSXSelectFilter + { + #region Public Constructors + + public LocSXSelectFilter() + { } + + #endregion Public Constructors + + #region Public Properties + + public int CurrPage { get; set; } = 1; + + public int MaxRecord { get; set; } = 100; + + public int NumRec { get; set; } = 10; + + public int TotCount { get; set; } = 0; + + #endregion Public Properties + + #region Public Methods + + public LocSXSelectFilter clone() + { + LocSXSelectFilter clonedData = new LocSXSelectFilter() + { + CurrPage = this.CurrPage, + MaxRecord = this.MaxRecord, + NumRec = this.NumRec, + TotCount = this.TotCount, + }; + return clonedData; + } + + public override bool Equals(object? obj) + { + if (obj == null) + return false; + + if (!(obj is LocSXSelectFilter item)) + return false; + + if (MaxRecord != item.MaxRecord) + return false; + + if (NumRec != item.NumRec) + return false; + + if (TotCount != item.TotCount) + return false; + + if (CurrPage != item.CurrPage) + return false; + + return true; + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } + + #endregion Public Methods + } +} \ No newline at end of file diff --git a/StockMan.CORE/Data/PosizioniSelectFilter.cs b/StockMan.CORE/Data/PosizioniSelectFilter.cs new file mode 100644 index 0000000..875c326 --- /dev/null +++ b/StockMan.CORE/Data/PosizioniSelectFilter.cs @@ -0,0 +1,68 @@ +namespace StockMan.CORE.Data +{ + public class PosizioniSelectFilter + { + #region Public Constructors + + public PosizioniSelectFilter() + { } + + #endregion Public Constructors + + #region Public Properties + + public int CurrPage { get; set; } = 1; + + public int MaxRecord { get; set; } = 100; + + public int NumRec { get; set; } = 10; + + public int TotCount { get; set; } = 0; + + #endregion Public Properties + + #region Public Methods + + public PosizioniSelectFilter clone() + { + PosizioniSelectFilter clonedData = new PosizioniSelectFilter() + { + CurrPage = this.CurrPage, + MaxRecord = this.MaxRecord, + NumRec = this.NumRec, + TotCount = this.TotCount, + }; + return clonedData; + } + + public override bool Equals(object? obj) + { + if (obj == null) + return false; + + if (!(obj is PosizioniSelectFilter item)) + return false; + + if (MaxRecord != item.MaxRecord) + return false; + + if (NumRec != item.NumRec) + return false; + + if (TotCount != item.TotCount) + return false; + + if (CurrPage != item.CurrPage) + return false; + + return true; + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } + + #endregion Public Methods + } +} \ No newline at end of file diff --git a/StockMan.CORE/Data/StockDataService.cs b/StockMan.CORE/Data/StockDataService.cs index 8c98842..bbee2bd 100644 --- a/StockMan.CORE/Data/StockDataService.cs +++ b/StockMan.CORE/Data/StockDataService.cs @@ -587,6 +587,46 @@ namespace StockMan.CORE.Data Log.Debug($"LocationGetAll | {source} in: {ts.TotalMilliseconds} ms"); return dbResult; } + /// + /// Lista Location + /// + /// + public async Task> LocTypeGetAll() + { + string source = "DB"; + List? dbResult = new List(); + string currKey = $"{rKeyLocType}:*"; + 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.LocTypeGetAll(); + 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($"LocTypeGetAll | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } /// /// Lista Location diff --git a/StockMan.CORE/Pages/Posizioni.razor b/StockMan.CORE/Pages/Posizioni.razor index cf027f5..09aaef4 100644 --- a/StockMan.CORE/Pages/Posizioni.razor +++ b/StockMan.CORE/Pages/Posizioni.razor @@ -1,91 +1,6 @@ @page "/Posizioni" +@using StockMan.CORE.Components; + -@if (isLoading) -{ - -} -else if (listLocAll == null) -{ -
Nessun record trovato
-} -else -{ -
-
-
- Lista Operatori -
-
- -
-
-
- - - - - - - - - - @foreach (var item in listLocAll) - { - - - - - - } - -
- Desc - - Tipo - -
- @item.Descr - - @(item.LocTypeNav?.Descr??"") - - -
-
-
- - -} \ No newline at end of file + \ No newline at end of file diff --git a/StockMan.CORE/Pages/Posizioni.razor.cs b/StockMan.CORE/Pages/Posizioni.razor.cs index 917383e..91b0077 100644 --- a/StockMan.CORE/Pages/Posizioni.razor.cs +++ b/StockMan.CORE/Pages/Posizioni.razor.cs @@ -6,96 +6,36 @@ namespace StockMan.CORE.Pages { public partial class Posizioni { - #region Public Properties - - public LocationModel? currLoc { get; set; } = null; - public bool isLoading { get; set; } = false; - - #endregion Public Properties - - #region Protected Fields - - protected string _descr = ""; - protected string _ID = ""; - protected string _loctype = ""; - protected List? listLocAll = null; - - #endregion Protected Fields - - #region Protected Properties - - protected string descr + protected int totalCount { get; set; } + public PosizioniSelectFilter currFilter { get; set; } = new PosizioniSelectFilter(); + protected void ForceReload(int newNum) { - get => _descr; - set { _descr = value; } + numRecord = newNum; + currPage = 1; } - protected string ID + protected void ForceReloadPage(int newNum) { - get => _ID; - set { _ID = value; } + currPage = newNum; } - protected string loctype + protected void UpdateTotCount(int newTotCount) { - get => _loctype; - set { _loctype = value; } + totalCount = newTotCount; } - [Inject] - protected NavigationManager NavManager { get; set; } = null!; - - [Inject] - protected StockDataService SDService { get; set; } = null!; - - #endregion Protected Properties - - #region Protected Methods - - protected async Task addNewItem() + private int currPage { - LocationModel currRecToMod = new LocationModel() - { - Descr = descr, - LocTypeId = loctype - }; - var done = await SDService.LocationAddNew(currRecToMod); - if (done) - { - NavManager.NavigateTo(NavManager.Uri, true); - } + get => currFilter.CurrPage; + set => currFilter.CurrPage = value; } - protected async Task ModOpr() + private bool isLoading { get; set; } = false; + + private int numRecord { - LocationModel currRecToMod = new LocationModel() - { - Descr = descr, - LocTypeId = loctype - }; - var done = await SDService.LocationMod(currRecToMod); - if (done) - { - NavManager.NavigateTo(NavManager.Uri, true); - } + get => currFilter.NumRec; + set => currFilter.NumRec = value; } - - protected override async Task OnInitializedAsync() - { - isLoading = true; - listLocAll = await SDService.LocationGetAll(); - isLoading = false; - } - - protected async Task setCurrLoc(LocationModel currRecToMod) - { - await Task.Delay(1); - - ID = currRecToMod.Id; - descr = currRecToMod.Descr; - loctype = currRecToMod.LocTypeId; - } - - #endregion Protected Methods } } \ No newline at end of file diff --git a/StockMan.CORE/Pages/StatoMag.razor b/StockMan.CORE/Pages/StatoMag.razor index f088838..747143f 100644 --- a/StockMan.CORE/Pages/StatoMag.razor +++ b/StockMan.CORE/Pages/StatoMag.razor @@ -21,9 +21,13 @@ else }
- + + +
- + + +
diff --git a/StockMan.CORE/Pages/StatoMag.razor.cs b/StockMan.CORE/Pages/StatoMag.razor.cs index cf1258e..f0872c8 100644 --- a/StockMan.CORE/Pages/StatoMag.razor.cs +++ b/StockMan.CORE/Pages/StatoMag.razor.cs @@ -53,6 +53,7 @@ namespace StockMan.CORE.Pages { await Task.Delay(1); isChanged = !isChanged; + currPageSX = 1; } protected override async Task OnInitializedAsync() @@ -67,7 +68,64 @@ namespace StockMan.CORE.Pages currLocId_DX = ""; currLocId_SX = ""; } + public LocSXSelectFilter currFilterSX { get; set; } = new LocSXSelectFilter(); + protected void ForceReloadSX(int newNum) + { + numRecordSX = newNum; + currPageSX = 1; + } + protected void ForceReloadPageSX(int newNum) + { + currPageSX = newNum; + } + + protected void UpdateTotCountSX(int newTotCount) + { + totalCountSX = newTotCount; + } + public int totalCountSX { get; set; } = 0; + private int currPageSX + { + get => currFilterSX.CurrPage; + set => currFilterSX.CurrPage = value; + } + + private bool isLoading { get; set; } = false; + + private int numRecordSX + { + get => currFilterSX.NumRec; + set => currFilterSX.NumRec = value; + } + public LocDXSelectFilter currFilterDX { get; set; } = new LocDXSelectFilter(); + protected void ForceReloadDX(int newNum) + { + numRecordDX = newNum; + currPageDX = 1; + } + + protected void ForceReloadPageDX(int newNum) + { + currPageDX = newNum; + } + + protected void UpdateTotCountDX(int newTotCount) + { + totalCountDX = newTotCount; + } + public int totalCountDX { get; set; } = 0; + private int currPageDX + { + get => currFilterDX.CurrPage; + set => currFilterDX.CurrPage = value; + } + + private int numRecordDX + { + get => currFilterDX.NumRec; + set => currFilterDX.NumRec = value; + } #endregion Protected Methods } } \ No newline at end of file