Fix gestione note offerta (inseribili dopo riga item)
This commit is contained in:
@@ -19,9 +19,35 @@ namespace EgwCoreLib.Lux.Data.Repository.Sales
|
||||
|
||||
public async Task<bool> AddAsync(OfferRowModel entity)
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
await dbCtx.DbSetOfferRow.AddAsync(entity);
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
await using var dbCtx = await CreateContextAsync(); await using var tx = await dbCtx.Database.BeginTransactionAsync();
|
||||
try
|
||||
{
|
||||
// SE ci fossero righe di indice pari o superiore le deve spostare...
|
||||
// 2. Recupero i record successivi da shiftare
|
||||
var list2Move = await dbCtx.DbSetOfferRow
|
||||
.Where(x => x.OfferID == entity.OfferID && x.RowNum >= entity.RowNum)
|
||||
.ToListAsync();
|
||||
|
||||
// aggiungo record
|
||||
await dbCtx.DbSetOfferRow.AddAsync(entity);
|
||||
foreach (var item in list2Move)
|
||||
{
|
||||
item.RowNum++;
|
||||
dbCtx.Entry(item).State = EntityState.Modified;
|
||||
}
|
||||
|
||||
bool done = await dbCtx.SaveChangesAsync() > 0;
|
||||
|
||||
if (done)
|
||||
await tx.CommitAsync();
|
||||
|
||||
return done;
|
||||
}
|
||||
catch
|
||||
{
|
||||
await tx.RollbackAsync();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteAsync(OfferRowModel entity)
|
||||
@@ -57,13 +83,13 @@ namespace EgwCoreLib.Lux.Data.Repository.Sales
|
||||
bool done = await dbCtx.SaveChangesAsync() > 0;
|
||||
|
||||
if (done)
|
||||
tx.Commit();
|
||||
await tx.CommitAsync();
|
||||
|
||||
return done;
|
||||
}
|
||||
catch
|
||||
{
|
||||
tx.Rollback();
|
||||
await tx.RollbackAsync();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@@ -125,13 +151,13 @@ namespace EgwCoreLib.Lux.Data.Repository.Sales
|
||||
bool done = await dbCtx.SaveChangesAsync() > 0;
|
||||
|
||||
if (done)
|
||||
tx.Commit();
|
||||
await tx.CommitAsync();
|
||||
|
||||
return done;
|
||||
}
|
||||
catch
|
||||
{
|
||||
tx.Rollback();
|
||||
await tx.RollbackAsync();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ else
|
||||
<button class="btn btn-sm btn-success" @onclick="() => DoSelectItem()">Prodotto a Catalogo <i class="fa-solid fa-plus"></i></button>
|
||||
</div>
|
||||
<div class="px-1">
|
||||
<button class="btn btn-sm btn-success" @onclick="() => DoAddNote()">Nota <i class="fa-solid fa-plus"></i></button>
|
||||
<button class="btn btn-sm @noteCss" @onclick="() => DoAddNote()">Nota <i class="fa-solid fa-plus"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@@ -120,7 +120,7 @@ else
|
||||
{
|
||||
bool isBuy = (item.SellingItemID > 2 && item.SellingItemID < 5);
|
||||
<tr class="@RowClass(item)">
|
||||
<td class="text-nowrap">
|
||||
<td class="text-nowrap">
|
||||
@if (DisplayMode == DisplayMode.Preview)
|
||||
{
|
||||
@if (isBuy)
|
||||
@@ -141,27 +141,27 @@ else
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="px-1">
|
||||
<button class="btn btn-sm btn-primary" @onclick="() => DoSelect(item)"><i class="fa-solid fa-magnifying-glass"></i></button>
|
||||
</span>
|
||||
@if (DisplayMode == DisplayMode.Edit)
|
||||
{
|
||||
if (CurrEditMode == EditMode.None)
|
||||
<span class="px-1">
|
||||
<button class="btn btn-sm btn-primary" @onclick="() => DoSelect(item)"><i class="fa-solid fa-magnifying-glass"></i></button>
|
||||
</span>
|
||||
@if (DisplayMode == DisplayMode.Edit)
|
||||
{
|
||||
<button class="btn btn-sm btn-info" @onclick="() => DoEdit(item)"><i class="fa-solid fa-pencil"></i></button>
|
||||
<button class="btn btn-sm btn-warning" @onclick="() => DoClone(item)"><i class="fa-solid fa-wand-magic" title="Duplica Articoo (Riga Offerta)"></i></button>
|
||||
if (CurrEditMode == EditMode.None)
|
||||
{
|
||||
<button class="btn btn-sm btn-info" @onclick="() => DoEdit(item)"><i class="fa-solid fa-pencil"></i></button>
|
||||
<button class="btn btn-sm btn-warning" @onclick="() => DoClone(item)"><i class="fa-solid fa-wand-magic" title="Duplica Articoo (Riga Offerta)"></i></button>
|
||||
}
|
||||
else
|
||||
{
|
||||
if (EditRecord != null && EditRecord.OfferRowID == item.OfferRowID)
|
||||
{
|
||||
<button class="btn btn-sm btn-success" title="Salva Modifiche" @onclick="() => DoSave(item)"><i class="fa-solid fa-floppy-disk"></i></button>
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (EditRecord != null && EditRecord.OfferRowID == item.OfferRowID)
|
||||
{
|
||||
<button class="btn btn-sm btn-success" title="Salva Modifiche" @onclick="() => DoSave(item)"><i class="fa-solid fa-floppy-disk"></i></button>
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@item.RowNum
|
||||
@item.RowNum
|
||||
}
|
||||
}
|
||||
</td>
|
||||
|
||||
@@ -6,7 +6,6 @@ using EgwCoreLib.Lux.Data.DbModel.Config;
|
||||
using EgwCoreLib.Lux.Data.DbModel.Sales;
|
||||
using EgwCoreLib.Lux.Data.DbModel.Utils;
|
||||
using EgwCoreLib.Lux.Data.Domains;
|
||||
using EgwCoreLib.Lux.Data.Services;
|
||||
using EgwCoreLib.Lux.Data.Services.Config;
|
||||
using EgwCoreLib.Lux.Data.Services.General;
|
||||
using EgwCoreLib.Lux.Data.Services.Items;
|
||||
@@ -418,6 +417,8 @@ namespace Lux.UI.Components.Compo
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private string noteCss => EditRecord == null ? "btn-success" : "btn-primary bg-gradient";
|
||||
|
||||
/// <summary>
|
||||
/// Effettua vera richiesta della BOM
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user