Aggiunta modifica magazzino
This commit is contained in:
@@ -125,6 +125,42 @@ namespace MP.Data.Controllers
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// modifica di un record magazzino
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> UpdateMag(AnagMagModel magRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonPro_InveContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
var dbResult =
|
||||
dbCtx
|
||||
.DbAnagMag
|
||||
.AsNoTracking()
|
||||
.Where(x => x.MagID == magRec.MagID)
|
||||
.FirstOrDefault();
|
||||
if (dbResult != null)
|
||||
{
|
||||
if (dbResult.DescMag != magRec.DescMag)
|
||||
{
|
||||
dbResult.DescMag = magRec.DescMag.ToUpper();
|
||||
dbCtx.Entry(dbResult).State = EntityState.Modified;
|
||||
}
|
||||
}
|
||||
await dbCtx.SaveChangesAsync();
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante UpdateMag{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// delete magazzino
|
||||
/// </summary>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
@if (reqNew)
|
||||
{
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card mb-5">
|
||||
@@ -15,13 +16,27 @@
|
||||
<div class="col-4 pe-0">
|
||||
<div class="input-group input-group-sm">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">Codice magazzino</span>
|
||||
<input type="text" class="form-control" aria-label="Art search" aria-describedby="inputGroup-sizing-sm" @bind="@codMag">
|
||||
@if (mod)
|
||||
{
|
||||
<input type="text" class="form-control" aria-label="Art search" aria-describedby="inputGroup-sizing-sm" @bind-value="@currMag.CodMag">
|
||||
}
|
||||
else
|
||||
{
|
||||
<input type="text" class="form-control" aria-label="Art search" aria-describedby="inputGroup-sizing-sm" @bind="@codMag">
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4 pe-0">
|
||||
<div class="col-8 pe-0">
|
||||
<div class="input-group input-group-sm">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">Descrizione</span>
|
||||
<input type="text" class="form-control" aria-label="Art search" aria-describedby="inputGroup-sizing-sm" @bind="@desc">
|
||||
@if (mod)
|
||||
{
|
||||
<input type="text" class="form-control" aria-label="Art search" aria-describedby="inputGroup-sizing-sm" @bind-value="@currMag.DescMag">
|
||||
}
|
||||
else
|
||||
{
|
||||
<input type="text" class="form-control" aria-label="Art search" aria-describedby="inputGroup-sizing-sm" @bind="@desc">
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -42,6 +57,15 @@
|
||||
<button class="btn btn-success" @onclick="insertNewMag">Save <i class="bi bi-save"></i></button>
|
||||
</div>
|
||||
}
|
||||
@if (mod)
|
||||
{
|
||||
@if (!currMag.DescMag.Contains("NON USARE"))
|
||||
{
|
||||
<div class="d-grid gap-2">
|
||||
<button class="btn btn-success" @onclick="()=>modMag(currMag)">Save <i class="bi bi-save"></i></button>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -79,8 +103,8 @@
|
||||
@item.DescMag
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn btn-danger btn-sm" @onclick="()=>deleteMag(item)">
|
||||
<i class="fa-solid fa-trash-can"></i>
|
||||
<button class="btn btn-primary btn-sm" @onclick="()=>reqModMag(item)">
|
||||
<i class="fa-solid fa-pen-to-square"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -54,10 +54,13 @@ namespace MP.INVE.Components
|
||||
{
|
||||
reqNew = false;
|
||||
codMag = "";
|
||||
mod = false;
|
||||
desc = "";
|
||||
}
|
||||
private List<AnagMagModel>? elencoMagazzini;
|
||||
private List<AnagMagModel>? SearchRecords;
|
||||
private AnagMagModel currMag { get; set; } = null!;
|
||||
private bool mod { get; set; } = false;
|
||||
private async Task insertNewMag()
|
||||
{
|
||||
var alert = await JSRuntime.InvokeAsync<bool>("confirm", "Confermi di voler creare un nuovo magazzino?");
|
||||
@@ -95,15 +98,27 @@ namespace MP.INVE.Components
|
||||
await Task.Delay(1);
|
||||
isLoading = false;
|
||||
}
|
||||
private async Task deleteMag(AnagMagModel mag)
|
||||
private async Task modMag(AnagMagModel mag)
|
||||
{
|
||||
var alert = await JSRuntime.InvokeAsync<bool>("confirm", "Confermi di voler eliminare il magazzino selezionato?");
|
||||
var alert = await JSRuntime.InvokeAsync<bool>("confirm", "Confermi di voler modificare il magazzino selezionato?");
|
||||
if (alert)
|
||||
{
|
||||
await MIDataservice.DeleteMag(mag);
|
||||
NavManager.NavigateTo("Elencomagazzini", true);
|
||||
|
||||
await MIDataservice.UpdateMag(currMag);
|
||||
NavManager.NavigateTo(NavManager.Uri, true);
|
||||
await reloadData();
|
||||
}
|
||||
else
|
||||
{
|
||||
closeNew();
|
||||
}
|
||||
}
|
||||
private async Task reqModMag(AnagMagModel mag)
|
||||
{
|
||||
await Task.Delay(1);
|
||||
mod = true;
|
||||
reqNew = true;
|
||||
currMag = mag;
|
||||
}
|
||||
private bool reqNew
|
||||
{
|
||||
|
||||
@@ -113,6 +113,21 @@ namespace MP.INVE.Data
|
||||
return result;
|
||||
// aggiungo record al DB
|
||||
}
|
||||
public async Task<bool> UpdateMag(AnagMagModel Mag)
|
||||
{
|
||||
bool result = false;
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
result = await dbController.UpdateMag(Mag);
|
||||
// elimino cache redis...
|
||||
RedisValue pattern = new RedisValue($"{redisMagList}");
|
||||
bool answ = await ExecFlushRedisPattern(pattern);
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Debug($"UpdateMag | Codice magazzino: {Mag.CodMag} | Descrizione magazzino: {Mag.DescMag} | {ts.TotalMilliseconds}ms");
|
||||
return result;
|
||||
// aggiungo record al DB
|
||||
}
|
||||
public async Task<bool> DeleteMag(AnagMagModel Mag)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>MP.INVE</RootNamespace>
|
||||
<Version>6.16.2211.2110</Version>
|
||||
<Version>6.16.2211.2112</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MAPOINVE </i>
|
||||
<h4>Versione: 6.16.2211.2110</h4>
|
||||
<h4>Versione: 6.16.2211.2112</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
6.16.2211.2110
|
||||
6.16.2211.2112
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>6.16.2211.2110</version>
|
||||
<version>6.16.2211.2112</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-INVE/stable/LAST/MP.INVE.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-INVE/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
Reference in New Issue
Block a user