From db784cbc425e1b802ca0bffdf3b5a76cc4c8bf85 Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Wed, 15 Feb 2023 17:04:59 +0100 Subject: [PATCH] aggiunta ricerca con campo libero e famiglia --- StockMan.CORE/Components/ItemFamList.razor.cs | 4 + StockMan.CORE/Components/ItemList.razor | 22 ++- StockMan.CORE/Components/ItemList.razor.cs | 14 +- StockMan.CORE/Data/ItemFamSelectFilter.cs | 2 +- StockMan.CORE/Data/ItemSelectFilter.cs | 7 +- StockMan.CORE/Data/StockDataService.cs | 74 ++++++- StockMan.CORE/Pages/ItemDetails.razor | 184 +++++++++++++++--- StockMan.CORE/Pages/ItemDetails.razor.cs | 102 +++++++++- StockMan.CORE/Pages/ItemDetails.razor.css | 57 +++++- StockMan.CORE/Pages/ItemDetails.razor.less | 38 +++- StockMan.CORE/Pages/ItemDetails.razor.min.css | 2 +- StockMan.CORE/Pages/_Layout.cshtml | 3 +- StockMan.Data/Controllers/StoManController.cs | 99 ++++++++-- 13 files changed, 534 insertions(+), 74 deletions(-) diff --git a/StockMan.CORE/Components/ItemFamList.razor.cs b/StockMan.CORE/Components/ItemFamList.razor.cs index aa08162..2581fc6 100644 --- a/StockMan.CORE/Components/ItemFamList.razor.cs +++ b/StockMan.CORE/Components/ItemFamList.razor.cs @@ -18,6 +18,9 @@ namespace StockMan.CORE.Components //public int CurrPage { get; set; } = 1; [Parameter] public ItemFamSelectFilter actFilter { get; set; } = new ItemFamSelectFilter(); + protected ItemSelectFilter itemFilter { get; set; } = new ItemSelectFilter(); + + [Inject] protected StockDataService SDService { get; set; } = null!; @@ -103,6 +106,7 @@ namespace StockMan.CORE.Components // await JSRuntime.InvokeVoidAsync("selectItem", id); //} currRowSel = item.Id; + itemFilter.Id = item.Id; currModel = item; await selectedItemFam.InvokeAsync(currModel); } diff --git a/StockMan.CORE/Components/ItemList.razor b/StockMan.CORE/Components/ItemList.razor index 58d04c2..37747d8 100644 --- a/StockMan.CORE/Components/ItemList.razor +++ b/StockMan.CORE/Components/ItemList.razor @@ -1,7 +1,23 @@ 
-
- - +
+
+ + + +
+
+ + +
diff --git a/StockMan.CORE/Components/ItemList.razor.cs b/StockMan.CORE/Components/ItemList.razor.cs index b56495e..8a70c96 100644 --- a/StockMan.CORE/Components/ItemList.razor.cs +++ b/StockMan.CORE/Components/ItemList.razor.cs @@ -85,9 +85,9 @@ namespace StockMan.CORE.Components private async Task reloadData() { isLoading = true; - if (searchVal != "") + if (searchVal != "" || searchFamily != "*") { - SearchRecords = await SDService.ItemsGetSearch(searchVal); + SearchRecords = await SDService.ItemsGetSearch(searchVal, searchFamily); } else { @@ -209,6 +209,16 @@ namespace StockMan.CORE.Components reloadData(); } } + //protected string _searchFamily = ""; + protected string searchFamily + { + get => actFilter.Id; + set + { + actFilter.Id = value; + reloadData(); + } + } protected string _descArt = ""; protected string descArt diff --git a/StockMan.CORE/Data/ItemFamSelectFilter.cs b/StockMan.CORE/Data/ItemFamSelectFilter.cs index e4ecccb..278e6d2 100644 --- a/StockMan.CORE/Data/ItemFamSelectFilter.cs +++ b/StockMan.CORE/Data/ItemFamSelectFilter.cs @@ -31,7 +31,7 @@ CurrPage = this.CurrPage, MaxRecord = this.MaxRecord, NumRec = this.NumRec, - TotCount = this.TotCount + TotCount = this.TotCount, }; return clonedData; } diff --git a/StockMan.CORE/Data/ItemSelectFilter.cs b/StockMan.CORE/Data/ItemSelectFilter.cs index 60c668b..17f8520 100644 --- a/StockMan.CORE/Data/ItemSelectFilter.cs +++ b/StockMan.CORE/Data/ItemSelectFilter.cs @@ -19,6 +19,7 @@ public int NumRec { get; set; } = 10; public int TotCount { get; set; } = 0; + public string Id { get; set; } = "*"; #endregion Public Properties @@ -31,7 +32,8 @@ CurrPage = this.CurrPage, MaxRecord = this.MaxRecord, NumRec = this.NumRec, - TotCount = this.TotCount + TotCount = this.TotCount, + Id = this.Id }; return clonedData; } @@ -56,6 +58,9 @@ if (CurrPage != item.CurrPage) return false; + if (Id != item.Id) + return false; + return true; } diff --git a/StockMan.CORE/Data/StockDataService.cs b/StockMan.CORE/Data/StockDataService.cs index e15e37b..a007e96 100644 --- a/StockMan.CORE/Data/StockDataService.cs +++ b/StockMan.CORE/Data/StockDataService.cs @@ -109,7 +109,7 @@ namespace StockMan.CORE.Data } /// - /// Aggiornamento record selezionato + /// Aggiornamento record selezionato famiglia item /// /// /// @@ -122,6 +122,20 @@ namespace StockMan.CORE.Data await Task.Delay(1); return dbResult; } + /// + /// Aggiornamento record selezionato item + /// + /// + /// + public async Task ItemMod(ItemModel currRec) + { + var dbResult = await dbController.ItemMod(currRec); + // elimino cache redis... + RedisValue pattern = new RedisValue($"{rKeyItems}:*"); + bool answ = await ExecFlushRedisPattern(pattern); + await Task.Delay(1); + return dbResult; + } /// @@ -330,6 +344,46 @@ namespace StockMan.CORE.Data Log.Debug($"ItemsGetAll | {source} in: {ts.TotalMilliseconds} ms"); return dbResult; } + /// + /// Lista Location + /// + /// + public async Task> LocationGetAll() + { + string source = "DB"; + List? dbResult = new List(); + string currKey = $"{rKeyLocation}:*"; + 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.LocationGetAll(); + 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($"LocationGetAll | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } ///// ///// Lista Articoli da ricerca @@ -375,15 +429,27 @@ namespace StockMan.CORE.Data /// Lista Articoli da ricerca /// /// - public async Task> ItemsGetSearch(string searcVal) + public async Task> ItemsGetSearch(string searcVal, string itemFamId) { string source = "DB"; List? dbResult = new List(); - string currKey = $"{rKeyItems}:Search:{searcVal}"; + string currKey = ""; + if (itemFamId != "*" && string.IsNullOrEmpty(searcVal)) + { + currKey = $"{rKeyItems}:Search:{searcVal}"; + } + else if(!string.IsNullOrEmpty(searcVal) && itemFamId == "*") + { + currKey = $"{rKeyItems}:Family:{itemFamId}"; + } + else + { + currKey = $"{rKeyItems}:Family:{itemFamId}:Search:{searcVal}"; + } Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); string? rawData = await redisDb.StringGetAsync(currKey); - dbResult = dbController.ItemsGetSearch(searcVal); + dbResult = dbController.ItemsGetSearch(searcVal, itemFamId); rawData = JsonConvert.SerializeObject(dbResult, JSSettings); await redisDb.StringSetAsync(currKey, rawData, LongCache); if (dbResult == null) diff --git a/StockMan.CORE/Pages/ItemDetails.razor b/StockMan.CORE/Pages/ItemDetails.razor index 67503eb..3b8c94d 100644 --- a/StockMan.CORE/Pages/ItemDetails.razor +++ b/StockMan.CORE/Pages/ItemDetails.razor @@ -5,53 +5,78 @@ {
-
-
- Dettagli articolo +
+
+
+ Dettagli articolo +
+ @if (!isMod) + { + + }
-
-
- +
+
+
- +
- +
- +
- +
-
- - +
+
+ + +
+
+ + +
-
- - -
-
- - -
-
- - +
+
+ + +
+
+ + +
+ @if (isMod) + { +
+ + +
+ }
-
-
+
+
Stock Giacenze
@@ -83,6 +108,113 @@ } +
+ + +
+
+ @if (!isCarico) + { + + } + else + { + + } + @if (!isScarico) + { + + } + else + { + + } + @if (!isRettifica) + { + + } + else + { + + } +
+ @if (isCarico || isScarico || isRettifica) + { + +
+
+ @if (isCarico) + { + + + } + else if (isScarico || isRettifica) + { + + + } +
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+ + +
+
+ + +
+
+
+ @if (!string.IsNullOrEmpty(fornitore) && !string.IsNullOrEmpty(pos)) + { + + } + +
+ }
diff --git a/StockMan.CORE/Pages/ItemDetails.razor.cs b/StockMan.CORE/Pages/ItemDetails.razor.cs index 2ee9944..27b0d34 100644 --- a/StockMan.CORE/Pages/ItemDetails.razor.cs +++ b/StockMan.CORE/Pages/ItemDetails.razor.cs @@ -31,6 +31,7 @@ namespace StockMan.CORE.Pages protected List itemFams { get; set; } = new List(); protected List itemFlux { get; set; } = new List(); protected List listItemsSearch { get; set; } = new List(); + protected List listLocation { get; set; } = new List(); protected override async Task OnInitializedAsync() { var uri = NavManager.ToAbsoluteUri(NavManager.Uri); @@ -43,7 +44,7 @@ namespace StockMan.CORE.Pages } private async Task reloadData() { - listItemsSearch = await SDService.ItemsGetSearch(ItemID.ToString()); + listItemsSearch = await SDService.ItemsGetSearch(ItemID.ToString(), "*"); if (listItemsSearch != null) { itemToDet = listItemsSearch.FirstOrDefault(); @@ -53,8 +54,107 @@ namespace StockMan.CORE.Pages itemFlux = await SDService.ItemFluxGetById(itemToDet.Id); + itemFams = await SDService.ItemFamilyGetAll(); + + listLocation = await SDService.LocationGetAll(); + await Task.Delay(1); } + private async Task setEditMode() + { + await Task.Delay(1); + isMod = true; + } protected int ItemID { get; set; } = 0; + protected bool isMod { get; set; } = false; + protected bool isCarico { get; set; } = false; + protected bool isScarico { get; set; } = false; + protected bool isRettifica { get; set; } = false; + protected async Task modItem() + { + var done = await SDService.ItemMod(itemToDet); + if (done) + { + NavManager.NavigateTo(NavManager.Uri, true); + } + } + protected void carico() + { + isScarico = false; + isRettifica = false; + isCarico = true; + } + protected void scarico() + { + isRettifica = false; + isCarico = false; + isScarico = true; + } + protected void rettifica() + { + isScarico = false; + isCarico = false; + isRettifica = true; + } + protected string enable + { + get => isMod ? "Background-color: #fff" : "pointer-events: none"; + } + protected string headerCss + { + get => (isCarico || isScarico || isRettifica) ? "bg-primary" : ""; + } + protected string cardCss + { + get => (isCarico || isScarico || isRettifica) ? "border border-primary" : ""; + } + protected string _fornitore { get; set; } = ""; + protected string fornitore + { + get => _fornitore; + set => _fornitore = value; + } + protected string _cliente{ get; set; } = ""; + protected string cliente + { + get => _cliente; + set => _cliente = value; + } + protected string _documento{ get; set; } = "RDA/DDT/FT"; + protected string documento + { + get => _documento; + set => _documento = value; + } + protected DateTime _dataDocumento{ get; set; } = DateTime.Now.Date; + protected DateTime dataDocumento + { + get => _dataDocumento; + set => _dataDocumento = value; + } + protected int _qta{ get; set; } = 0; + protected int qta + { + get => _qta; + set => _qta = value; + } + protected decimal _importo { get; set; } = 0.00M; + protected decimal importo + { + get => _importo; + set => _importo = value; + } + protected string _pos { get; set; } = ""; + protected string pos + { + get => _pos; + set => _pos = value; + } + protected string _note { get; set; } = ""; + protected string note + { + get => _note; + set => _note = value; + } } } \ No newline at end of file diff --git a/StockMan.CORE/Pages/ItemDetails.razor.css b/StockMan.CORE/Pages/ItemDetails.razor.css index 31fd4ba..d619180 100644 --- a/StockMan.CORE/Pages/ItemDetails.razor.css +++ b/StockMan.CORE/Pages/ItemDetails.razor.css @@ -1,11 +1,54 @@ -/*input, textarea{ - border: none; - border-bottom: 1px solid #000; -}*/ -input, -textarea { +.modItem input, +.modItem textarea, +.modItem select { font-size: 0.8rem; - width: 80%; + background-color: #e9ecef; +} +.buttonGlobal { + border-radius: 50%; + padding: 0.5rem; + width: 2.8rem; + height: 2.8rem; + border: none; + padding: 0; + text-align: center; + margin-right: 1rem; +} +.btnMod { + border-radius: 50%; + padding: 0.5rem; + width: 2.8rem; + height: 2.8rem; + border: none; + padding: 0; + text-align: center; + margin-right: 1rem; + background-color: rgba(52, 152, 219, 0.2); + color: #3498DB; +} +.btnAccept { + border-radius: 50%; + padding: 0.5rem; + width: 2.8rem; + height: 2.8rem; + border: none; + padding: 0; + text-align: center; + margin-right: 1rem; + background-color: rgba(86, 184, 167, 0.2); + color: #56b8a7; +} +.btnDecline { + border-radius: 50%; + padding: 0.5rem; + width: 2.8rem; + height: 2.8rem; + border: none; + padding: 0; + text-align: center; + margin-right: 1rem; + background-color: rgba(192, 57, 43, 0.2); + color: #C0392B; } /*label { font-weight: bold; diff --git a/StockMan.CORE/Pages/ItemDetails.razor.less b/StockMan.CORE/Pages/ItemDetails.razor.less index 9cbf7d4..a4c7142 100644 --- a/StockMan.CORE/Pages/ItemDetails.razor.less +++ b/StockMan.CORE/Pages/ItemDetails.razor.less @@ -1,14 +1,36 @@ -/*input, textarea{ - border: none; - border-bottom: 1px solid #000; -}*/ - - -input, textarea { +.modItem input, .modItem textarea, .modItem select { font-size: 0.8rem; - width: 80%; + background-color: #e9ecef; } +.buttonGlobal { + border-radius: 50%; + padding: 0.5rem; + width: 2.8rem; + height: 2.8rem; + border: none; + padding: 0; + text-align: center; + margin-right: 1rem; +} + +.btnMod { + .buttonGlobal; + background-color: rgba(52, 152, 219, 0.2); + color: #3498DB; +} + +.btnAccept { + .buttonGlobal; + background-color: rgba(86,184,167,0.2); + color: #56b8a7; +} + +.btnDecline { + .buttonGlobal; + background-color: rgba(192, 57, 43, 0.2); + color: #C0392B; +} /*label { font-weight: bold; font-size: 0.8rem; diff --git a/StockMan.CORE/Pages/ItemDetails.razor.min.css b/StockMan.CORE/Pages/ItemDetails.razor.min.css index 28ba5b5..9649098 100644 --- a/StockMan.CORE/Pages/ItemDetails.razor.min.css +++ b/StockMan.CORE/Pages/ItemDetails.razor.min.css @@ -1 +1 @@ -input,textarea{font-size:.8rem;width:80%;} \ No newline at end of file +.modItem input,.modItem textarea,.modItem select{font-size:.8rem;background-color:#e9ecef;}.buttonGlobal{border-radius:50%;padding:.5rem;width:2.8rem;height:2.8rem;border:0;padding:0;text-align:center;margin-right:1rem;}.btnMod{border-radius:50%;padding:.5rem;width:2.8rem;height:2.8rem;border:0;padding:0;text-align:center;margin-right:1rem;background-color:rgba(52,152,219,.2);color:#3498db;}.btnAccept{border-radius:50%;padding:.5rem;width:2.8rem;height:2.8rem;border:0;padding:0;text-align:center;margin-right:1rem;background-color:rgba(86,184,167,.2);color:#56b8a7;}.btnDecline{border-radius:50%;padding:.5rem;width:2.8rem;height:2.8rem;border:0;padding:0;text-align:center;margin-right:1rem;background-color:rgba(192,57,43,.2);color:#c0392b;} \ No newline at end of file diff --git a/StockMan.CORE/Pages/_Layout.cshtml b/StockMan.CORE/Pages/_Layout.cshtml index 0efba31..a83f5f0 100644 --- a/StockMan.CORE/Pages/_Layout.cshtml +++ b/StockMan.CORE/Pages/_Layout.cshtml @@ -6,7 +6,8 @@ - + @**@ + diff --git a/StockMan.Data/Controllers/StoManController.cs b/StockMan.Data/Controllers/StoManController.cs index 776f040..c1e40a4 100644 --- a/StockMan.Data/Controllers/StoManController.cs +++ b/StockMan.Data/Controllers/StoManController.cs @@ -93,26 +93,26 @@ namespace StockMan.Data.Controllers return dbResult; } - /// - /// Modifica Famiglie Articoli - /// - /// - public List ItemFamilyMod() - { - List dbResult = new List(); - using (StockManContext localDbCtx = new StockManContext(_configuration)) - { - dbResult = localDbCtx - .DbSetItemFamily - .OrderBy(x => x.Descr) - .ToList(); - } - return dbResult; + ///// + ///// Modifica Famiglie Articoli + ///// + ///// + //public List ItemFamilyMod() + //{ + // List dbResult = new List(); + // using (StockManContext localDbCtx = new StockManContext(_configuration)) + // { + // dbResult = localDbCtx + // .DbSetItemFamily + // .OrderBy(x => x.Descr) + // .ToList(); + // } + // return dbResult; - } + //} /// - /// Lista Item Flux (ALL!) + /// Modifica famiglia articoli /// /// public async Task ItemFamilyMod(ItemFamilyModel editRec) @@ -147,6 +147,43 @@ namespace StockMan.Data.Controllers } return fatto; + } + /// + /// Modifica item, + /// + /// + public async Task ItemMod(ItemModel editRec) + { + bool fatto = false; + List dbResult = new List(); + using (StockManContext localDbCtx = new StockManContext(_configuration)) + { + try + { + var currRec = localDbCtx + .DbSetItem + .Where(x => x.Id == editRec.Id) + .FirstOrDefault(); + if (currRec != null) + { + currRec = editRec; + } + else + { + localDbCtx + .DbSetItem + .Add(editRec); + } + await localDbCtx.SaveChangesAsync(); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante ItemMod{Environment.NewLine}{exc}"); + } + } + return fatto; + } /// @@ -294,12 +331,12 @@ namespace StockMan.Data.Controllers /// Lista Items da ricerca /// /// - public List ItemsGetSearch(string searchVal) + public List ItemsGetSearch(string searchVal, string itemFamId) { List dbResult = new List(); using (StockManContext localDbCtx = new StockManContext(_configuration)) { - if (!string.IsNullOrEmpty(searchVal)) + if (!string.IsNullOrEmpty(searchVal) && itemFamId == "*") { var risultato = localDbCtx .DbSetItem @@ -311,6 +348,30 @@ namespace StockMan.Data.Controllers dbResult = risultato; } } + else if(itemFamId != "*" && string.IsNullOrEmpty(searchVal)) + { + var risultato = localDbCtx + .DbSetItem + .Where(x => ((x.ItemFamilyId == itemFamId))) + .ToList(); + + if (risultato != null) + { + dbResult = risultato; + } + } + else if(itemFamId != "*" && !string.IsNullOrEmpty(searchVal)) + { + var risultato = localDbCtx + .DbSetItem + .Where(x => ((x.ItemFamilyId == itemFamId) && ((x.CodInt.Contains(searchVal)) || (x.CodExt.Contains(searchVal)) || (x.Descr.Contains(searchVal) || (x.CurrValue.ToString().Contains(searchVal)))))) + .ToList(); + + if (risultato != null) + { + dbResult = risultato; + } + } else { dbResult = localDbCtx