Aggiunta metodi get/set dell'ultimo RawItem usato
This commit is contained in:
@@ -253,6 +253,71 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
return newIdx;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Last RawItem used for Material
|
||||
/// </summary>
|
||||
/// <param name="updItem"></param>
|
||||
/// <returns>Returns 0 if not found</returns>
|
||||
public int LastRawItemGet(int MatId)
|
||||
{
|
||||
int RawItemIdLast = 0;
|
||||
using (DatabaseContext localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING))
|
||||
{
|
||||
try
|
||||
{
|
||||
var item2update = localDbCtx
|
||||
.MaterialsList
|
||||
.Where(x => (MatId > 0 && x.MatId == MatId))
|
||||
.SingleOrDefault();
|
||||
|
||||
if (item2update != null)
|
||||
{
|
||||
RawItemIdLast = item2update.RawItemIdLast;
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"EXCEPTION on Materials.LastRawItemGet: {Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return RawItemIdLast;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update Last RawItem used for Material record
|
||||
/// </summary>
|
||||
/// <param name="MatId">Id locale materiale</param>
|
||||
/// <param name="RawItemIdLast">Id del RawItem</param>
|
||||
/// <returns>Returns true if updated</returns>
|
||||
public bool LastRawItemSet(int MatId, int RawItemIdLast)
|
||||
{
|
||||
bool done = false;
|
||||
using (DatabaseContext localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING))
|
||||
{
|
||||
try
|
||||
{
|
||||
var item2update = localDbCtx
|
||||
.MaterialsList
|
||||
.Where(x => (MatId > 0 && x.MatId == MatId))
|
||||
.SingleOrDefault();
|
||||
|
||||
if (item2update != null)
|
||||
{
|
||||
item2update.RawItemIdLast = RawItemIdLast;
|
||||
localDbCtx.Entry(item2update).State = System.Data.Entity.EntityState.Modified;
|
||||
// Commit changes
|
||||
localDbCtx.SaveChanges();
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"EXCEPTION on Materials.LastRawItemSet: {Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce il primo materiale (se esiste) per MatCode (diretto o tramite Alias)
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user