diff --git a/StockMan.CORE/Components/ItemList.razor b/StockMan.CORE/Components/ItemList.razor index a3d02d7..d1fb754 100644 --- a/StockMan.CORE/Components/ItemList.razor +++ b/StockMan.CORE/Components/ItemList.razor @@ -1,4 +1,11 @@ -@if (isLoading) +
+
+ + +
+ +
+@if (isLoading) { } @@ -8,10 +15,6 @@ } else { -
- - -
@@ -24,8 +27,11 @@ else - + - + - - }
DESC. ARTICOLO - GIACENZA + + COD. FORNITORE + + STOCK VALORE UNIT. @@ -47,27 +53,92 @@ else @item.CodInt + @item.Descr + @item.CodExt +
@item.QtaBatch
+ @($"{item.CurrValue:C2}") - @(item.CurrValue * item.QtaBatch) + + @($"{(item.CurrValue * item.QtaBatch):C2}") - +
- + + } \ No newline at end of file diff --git a/StockMan.CORE/Components/ItemList.razor.cs b/StockMan.CORE/Components/ItemList.razor.cs index 6837f6f..8ff0d51 100644 --- a/StockMan.CORE/Components/ItemList.razor.cs +++ b/StockMan.CORE/Components/ItemList.razor.cs @@ -28,6 +28,7 @@ namespace StockMan.CORE.Components public List? ListRecord { get; set; } = null; public List? SearchRecords { get; set; } = null; + public List? itemFamList { get; set; } = null; //protected override async Task OnInitializedAsync() //{ @@ -77,6 +78,8 @@ namespace StockMan.CORE.Components private IConfiguration Configuration { get; set; } = null!; protected bool isLoading = false; + protected bool isStockAscending = false; + protected bool isCodExtAscending = false; private async Task reloadData() { @@ -90,16 +93,80 @@ namespace StockMan.CORE.Components SearchRecords = await SDService.ItemsGetAll(); } totalCount = SearchRecords.Count; + if (isStockAscending) + { + SearchRecords = SearchRecords.OrderBy(x => x.QtaBatch).ToList(); + } + else if (!isStockAscending) + { + SearchRecords = SearchRecords.OrderByDescending(x => x.QtaBatch).ToList(); + } + else if (isCodExtAscending) + { + SearchRecords = SearchRecords.OrderBy(x => x.CodExt).ToList(); + } + else if (!isCodExtAscending) + { + SearchRecords = SearchRecords.OrderByDescending(x => x.CodExt).ToList(); + } ListRecord = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); + itemFamList = await SDService.ItemFamilyGetAll(); await Task.Delay(1); await InvokeAsync(() => StateHasChanged()); isLoading = false; } + private void selItemToDet(int selItem) { currItem = selItem; NavManager.NavigateTo(rawCode, true); } + + protected async Task orderByStock() + { + isStockAscending = !isStockAscending; + await reloadData(); + } + protected async Task orderByCodForn() + { + isCodExtAscending = !isCodExtAscending; + await reloadData(); + } + protected async Task addNewItem() + { + ItemModel newRec = new ItemModel() + { + Descr = descArt, + CodInt = codArt, + ItemFamilyId = famArt, + CodExt = codForn, + DescrExt = descForn, + QtaMin = minGiac, + QtaBatch = lottoGiac, + CurrValue = valoreUnit, + Um = uM + }; + var done = await SDService.ItemAdd(newRec); + if (done) + { + NavManager.NavigateTo(NavManager.Uri, true); + } + } + protected void dupItem(ItemModel itemDup) + { + if (itemDup != null) + { + codArt = itemDup.CodInt; + descArt = itemDup.Descr; + famArt = itemDup.ItemFamilyId; + codForn = itemDup.CodExt; + descForn = itemDup.DescrExt; + minGiac = itemDup.QtaMin; + lottoGiac = itemDup.QtaBatch; + valoreUnit = itemDup.CurrValue; + uM = itemDup.Um; + } + } protected int? _currItem; protected int? currItem { @@ -117,6 +184,89 @@ namespace StockMan.CORE.Components } } + protected string _descArt = ""; + protected string descArt + { + get => _descArt; + set + { + _descArt = value; + } + } + protected string _codArt = ""; + protected string codArt + { + get => _codArt; + set + { + _codArt = value; + } + } + protected string _famArt = ""; + protected string famArt + { + get => _famArt; + set + { + _famArt = value; + } + } + protected string _codForn = ""; + protected string codForn + { + get => _codForn; + set + { + _codForn = value; + } + } + protected string _descForn = ""; + protected string descForn + { + get => _descForn; + set + { + _descForn = value; + } + } + protected int _minGiac = 0; + protected int minGiac + { + get => _minGiac; + set + { + _minGiac = value; + } + } + protected int _lottoGiac = 0; + protected int lottoGiac + { + get => _lottoGiac; + set + { + _lottoGiac = value; + } + } + protected decimal _valoreUnit = 0; + protected decimal valoreUnit + { + get => _valoreUnit; + set + { + _valoreUnit = value; + } + } + protected string _uM = ""; + protected string uM + { + get => _uM; + set + { + _uM = value; + } + } + + protected string rawCode { diff --git a/StockMan.CORE/Components/ItemList.razor.css b/StockMan.CORE/Components/ItemList.razor.css index c0cc8d2..d212efc 100644 --- a/StockMan.CORE/Components/ItemList.razor.css +++ b/StockMan.CORE/Components/ItemList.razor.css @@ -23,7 +23,8 @@ background-color: rgba(254, 152, 83, 0.2); color: #fe9853; } -.btnDet { +.btnDet, +.btnAccept { border-radius: 50%; padding: 0.5rem; width: 2.8rem; @@ -34,4 +35,23 @@ 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; +} +.buttonNew { + border: none; + border-radius: 0.4rem; + padding: 0.2rem; + background-color: #27ae60; + color: #fff; } \ No newline at end of file diff --git a/StockMan.CORE/Components/ItemList.razor.less b/StockMan.CORE/Components/ItemList.razor.less index 63de663..94a1903 100644 --- a/StockMan.CORE/Components/ItemList.razor.less +++ b/StockMan.CORE/Components/ItemList.razor.less @@ -18,9 +18,22 @@ background-color: rgba(254,152,83,0.2); color: #fe9853; } - -.btnDet{ +.btnDet, .btnAccept { .buttonGlobal; background-color: rgba(86,184,167,0.2); color: #56b8a7; } + +.btnDecline { + .buttonGlobal; + background-color: rgba(192, 57, 43, 0.2); + color: #C0392B; +} + +.buttonNew { + border: none; + border-radius: 0.4rem; + padding: 0.2rem; + background-color: rgb(39, 174, 96); + color: #fff; +} \ No newline at end of file diff --git a/StockMan.CORE/Components/ItemList.razor.min.css b/StockMan.CORE/Components/ItemList.razor.min.css index fdd8cf0..e6c4ecb 100644 --- a/StockMan.CORE/Components/ItemList.razor.min.css +++ b/StockMan.CORE/Components/ItemList.razor.min.css @@ -1 +1 @@ -td{height:3.8rem;}.buttonGlobal{border-radius:50%;padding:.5rem;width:2.8rem;height:2.8rem;border:0;padding:0;text-align:center;margin-right:1rem;}.btnDup{border-radius:50%;padding:.5rem;width:2.8rem;height:2.8rem;border:0;padding:0;text-align:center;margin-right:1rem;background-color:rgba(254,152,83,.2);color:#fe9853;}.btnDet{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;} \ No newline at end of file +td{height:3.8rem;}.buttonGlobal{border-radius:50%;padding:.5rem;width:2.8rem;height:2.8rem;border:0;padding:0;text-align:center;margin-right:1rem;}.btnDup{border-radius:50%;padding:.5rem;width:2.8rem;height:2.8rem;border:0;padding:0;text-align:center;margin-right:1rem;background-color:rgba(254,152,83,.2);color:#fe9853;}.btnDet,.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;}.buttonNew{border:0;border-radius:.4rem;padding:.2rem;background-color:#27ae60;color:#fff;} \ No newline at end of file diff --git a/StockMan.CORE/Data/StockDataService.cs b/StockMan.CORE/Data/StockDataService.cs index c832869..e15e37b 100644 --- a/StockMan.CORE/Data/StockDataService.cs +++ b/StockMan.CORE/Data/StockDataService.cs @@ -125,7 +125,7 @@ namespace StockMan.CORE.Data /// - /// inserimento nuovo record + /// inserimento nuovo record famiglia item /// /// /// @@ -138,8 +138,23 @@ namespace StockMan.CORE.Data await Task.Delay(1); return dbResult; } + /// - /// inserimento nuovo record + /// inserimento nuovo record item + /// + /// + /// + public async Task ItemAdd(ItemModel newRec) + { + var dbResult = await dbController.ItemAdd(newRec); + // elimino cache redis... + RedisValue pattern = new RedisValue($"{rKeyItems}:*"); + bool answ = await ExecFlushRedisPattern(pattern); + await Task.Delay(1); + return dbResult; + } + /// + /// eliminazione record item family /// /// /// diff --git a/StockMan.Data/Controllers/StoManController.cs b/StockMan.Data/Controllers/StoManController.cs index f9621e1..776f040 100644 --- a/StockMan.Data/Controllers/StoManController.cs +++ b/StockMan.Data/Controllers/StoManController.cs @@ -150,7 +150,7 @@ namespace StockMan.Data.Controllers } /// - /// Lista Item Flux (ALL!) + /// Aggiunta famiglia di item /// /// public async Task ItemFamilyAdd(ItemFamilyModel newRec) @@ -185,6 +185,43 @@ namespace StockMan.Data.Controllers } return fatto; + } + /// + /// aggiunta item + /// + /// + public async Task ItemAdd(ItemModel newRec) + { + bool fatto = false; + List dbResult = new List(); + using (StockManContext localDbCtx = new StockManContext(_configuration)) + { + try + { + var currRec = localDbCtx + .DbSetItem + .Where(x => x.Id == newRec.Id) + .FirstOrDefault(); + if (currRec != null) + { + fatto = false; + } + else + { + localDbCtx + .DbSetItem + .Add(newRec); + } + await localDbCtx.SaveChangesAsync(); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante ItemAdd{Environment.NewLine}{exc}"); + } + } + return fatto; + } /// @@ -266,7 +303,7 @@ namespace StockMan.Data.Controllers { var risultato = localDbCtx .DbSetItem - .Where(x => ((x.Id.ToString()==searchVal)) || (x.CodInt.Contains(searchVal)) || (x.Descr.Contains(searchVal) || (x.CurrValue.ToString().Contains(searchVal)))) + .Where(x => ((x.Id.ToString()==searchVal)) || (x.CodInt.Contains(searchVal)) || (x.CodExt.Contains(searchVal)) || (x.Descr.Contains(searchVal) || (x.CurrValue.ToString().Contains(searchVal)))) .ToList(); if (risultato != null)