Aggiunto controllo duplicati su remnant esistenti
This commit is contained in:
@@ -41,7 +41,7 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-2">
|
||||
<div class="input-group">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">
|
||||
L mm
|
||||
@@ -81,7 +81,14 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (!string.IsNullOrEmpty(alertMessage))
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col-12 text-danger">
|
||||
<span>@alertMessage</span>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="col-12 col-lg-2">
|
||||
<button type="button" class="btn btn-warning btn-block" value="Cancel" @onclick="cancelUpdate">Cancel <i class="fas fa-ban"></i></button>
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace REMAN.Components
|
||||
{
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
protected RemnantsModel _currItem = new RemnantsModel();
|
||||
protected RemnantsModel _currItem = new RemnantsModel();
|
||||
|
||||
|
||||
[Inject]
|
||||
@@ -69,19 +69,30 @@ namespace REMAN.Components
|
||||
//}
|
||||
}
|
||||
|
||||
protected string alertMessage = "";
|
||||
|
||||
private async Task saveUpdate()
|
||||
{
|
||||
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Are you sure to create new record?"))
|
||||
return;
|
||||
|
||||
if (_currItem != null)
|
||||
// verifico duplicato...
|
||||
bool duplicato = await DataService.RemnantsIsDupl(currItem);
|
||||
if (duplicato)
|
||||
{
|
||||
await DataService.RemnantsUpsert(currItem);
|
||||
await DataUpdated.InvokeAsync(0);
|
||||
alertMessage = "Error: dimension data duplicated, record already available.";
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Record null!");
|
||||
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Are you sure to create new record?"))
|
||||
return;
|
||||
|
||||
if (_currItem != null)
|
||||
{
|
||||
await DataService.RemnantsUpsert(currItem);
|
||||
await DataUpdated.InvokeAsync(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Record null!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -141,6 +141,16 @@ namespace REMAN.Data
|
||||
}
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
public async Task<bool> RemnantsIsDupl(RemnantsModel currItem)
|
||||
{
|
||||
bool answ = false;
|
||||
var rawList = dbController.RemnantsGetFilt(currItem.MatID, 0);
|
||||
var duplicati = rawList
|
||||
.Where(x => x.RemnID != currItem.RemnID && x.LMm == currItem.LMm && x.WMm == currItem.WMm && x.TMm == currItem.TMm)
|
||||
.ToList();
|
||||
answ = duplicati.Count > 0;
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
|
||||
public async Task<bool> RemnantsUpsert(RemnantsModel currItem)
|
||||
{
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace REMAN.Pages
|
||||
MatID = selRecord.MatID,
|
||||
DtMod = DateTime.Now,
|
||||
Location = selRecord.Location,
|
||||
QtyAvail = selRecord.QtyAvail,
|
||||
QtyAvail = 0,
|
||||
LMm = selRecord.LMm,
|
||||
TMm = selRecord.TMm,
|
||||
WMm = selRecord.WMm,
|
||||
@@ -136,15 +136,15 @@ namespace REMAN.Pages
|
||||
|
||||
protected async Task addQty(RemnantsModel selRecord)
|
||||
{
|
||||
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Confirm qtantity increase?"))
|
||||
return;
|
||||
//if (!await JSRuntime.InvokeAsync<bool>("confirm", "Confirm qtantity increase?"))
|
||||
// return;
|
||||
await DataService.RemnantsMovMag(selRecord, 1);
|
||||
await ReloadData();
|
||||
}
|
||||
protected async Task remQty(RemnantsModel selRecord)
|
||||
{
|
||||
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Confirm qtantity decrease?"))
|
||||
return;
|
||||
//if (!await JSRuntime.InvokeAsync<bool>("confirm", "Confirm qtantity decrease?"))
|
||||
// return;
|
||||
await DataService.RemnantsMovMag(selRecord, -1);
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user