modifica metodo update MachGroup x convert Part
This commit is contained in:
@@ -42,10 +42,11 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
{
|
||||
int BtlPartDbId = 0;
|
||||
|
||||
#if false
|
||||
var currProj = dbCtx
|
||||
.ProjList
|
||||
.Where(x => x.ProjId == ProjId)
|
||||
.FirstOrDefault();
|
||||
.ProjList
|
||||
.Where(x => x.ProjId == ProjId)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (currProj != null)
|
||||
{
|
||||
@@ -59,14 +60,47 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
BtlPartDbId = btlPart.BTLPartDbId;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
var btlPart = dbCtx
|
||||
.BTLPartList
|
||||
.Where(x => x.Project.ProjId == ProjId && x.PDN == PDN)
|
||||
.SingleOrDefault();
|
||||
|
||||
if (btlPart != null)
|
||||
{
|
||||
BtlPartDbId = btlPart.BTLPartDbId;
|
||||
}
|
||||
|
||||
return BtlPartDbId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get BtlPartDBId by ProjId + BtlPartId
|
||||
/// </summary>
|
||||
/// <param name="ProjId"></param>
|
||||
/// <param name="BtlPartId"></param>
|
||||
/// <returns></returns>
|
||||
protected int FindBtlPartByBPI(int ProjId, int BtlPartId)
|
||||
{
|
||||
int BtlPartDbId = 0;
|
||||
|
||||
var btlPart = dbCtx
|
||||
.BTLPartList
|
||||
.Where(x => x.Project.ProjId == ProjId && x.PartId == BtlPartId)
|
||||
.SingleOrDefault();
|
||||
|
||||
if (btlPart != null)
|
||||
{
|
||||
BtlPartDbId = btlPart.BTLPartDbId;
|
||||
}
|
||||
|
||||
return BtlPartDbId;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Conversion of base class to DB model class
|
||||
/// </summary>
|
||||
@@ -105,6 +139,50 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
#endif
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Conversion of base class to DB model class
|
||||
/// </summary>
|
||||
/// <param name="corePart"></param>
|
||||
/// <param name="currMachGroupDbId"></param>
|
||||
/// <returns></returns>
|
||||
public static PartModel ConvertFromCore(Core.PartM corePart, int currMachGroupDbId)
|
||||
{
|
||||
PartModel answ = new PartModel();
|
||||
if (corePart != null)
|
||||
{
|
||||
// int BTLPartId = man.FindBtlPart(corePart.nProjId, corePart.nPDN);
|
||||
int BTLPartId = man.FindBtlPartByBPI(corePart.nProjId, corePart.nBTLPartId);
|
||||
answ = new PartModel()
|
||||
{
|
||||
PartId = corePart.nPartId,
|
||||
PDN = corePart.nPDN,
|
||||
BTLPartDbId = BTLPartId,
|
||||
MachGroupDbId = currMachGroupDbId,
|
||||
State = Core.ItemState.Assigned,
|
||||
NAM = corePart.sNAM,
|
||||
W = corePart.dW,
|
||||
L = corePart.dL,
|
||||
H = corePart.dH,
|
||||
Material = corePart.sMATERIAL,
|
||||
DtStart = corePart.dtStartTime,
|
||||
DtEnd = corePart.dtEndTime,
|
||||
|
||||
//DO = corePart.bDO,
|
||||
//CNT = corePart.nCNT,
|
||||
//TBP = corePart.nTBP,
|
||||
//DON = corePart.nDON,
|
||||
ROT = corePart.nCALC_ROT,
|
||||
//GRP = corePart.sGRP,
|
||||
//UNT = corePart.nUNT,
|
||||
CALC_State = (int)corePart.nState
|
||||
};
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
|
||||
@@ -359,7 +359,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
.Where(x => x.ProdId == ProdId)
|
||||
.SingleOrDefault();
|
||||
|
||||
if(currProd != null)
|
||||
if (currProd != null)
|
||||
{
|
||||
currProd.Locked = Locked;
|
||||
|
||||
@@ -369,7 +369,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
.ToList();
|
||||
|
||||
currProj.ForEach(x => x.Locked = Locked);
|
||||
}
|
||||
}
|
||||
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
@@ -435,6 +435,10 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
|
||||
// elimino dal DB i MG
|
||||
dbCtx.MachGroupList.RemoveRange(itemsMG2del.ToList());
|
||||
|
||||
// Commit changes
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
// aggiungo le nuove
|
||||
dbCtx.MachGroupList.AddRange(itemsMG2add);
|
||||
|
||||
@@ -492,6 +496,10 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
|
||||
// elimino dal DB i MG
|
||||
dbCtx.MachGroupList.RemoveRange(itemsMG2del.ToList());
|
||||
|
||||
// Commit changes
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
// aggiungo le nuove
|
||||
dbCtx.MachGroupList.AddRange(itemsMG2add);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user