Fix editing ItemFlux... con conversione ordini/carichi
This commit is contained in:
@@ -368,8 +368,11 @@ namespace StockManMVC.Controllers
|
||||
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Edit([Bind(Include = "ID,ItemID,LocationID,MovTypeID,ExtLocationID,dtMov,Qta,TotValue,UnitVal,CodDoc,Note,dtExport,OperatorID")] ItemFlux itemFlux)
|
||||
public ActionResult Edit([Bind(Include = "ID,LocationID,ExtLocationID,dtMov,Qta,TotValue,UnitVal,CodDoc,Note,dtExport")] ItemFlux itemFlux)
|
||||
//public ActionResult Edit([Bind(Include = "ID,ItemID,LocationID,MovTypeID,ExtLocationID,dtMov,Qta,TotValue,UnitVal,CodDoc,Note,dtExport,OperatorID")] ItemFlux itemFlux)
|
||||
{
|
||||
// recupero vecchi valori...
|
||||
ItemFlux itemFluxOld = db.ItemFlux.Find(itemFlux.ID);
|
||||
// fix operatore modifica
|
||||
string currOpIDMod = "ND"; // default
|
||||
try
|
||||
@@ -382,6 +385,10 @@ namespace StockManMVC.Controllers
|
||||
{
|
||||
}
|
||||
itemFlux.ModOperatorID = currOpIDMod;
|
||||
// imposto valori vecchi x campi "bloccati" (articolo, tipo movimento, operatore iniziale...)
|
||||
itemFlux.ItemID = itemFluxOld.ItemID;
|
||||
itemFlux.MovTypeID = itemFluxOld.MovTypeID;
|
||||
if (itemFlux.OperatorID == null) itemFlux.OperatorID = itemFluxOld.OperatorID;
|
||||
// continuo
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
@@ -397,7 +404,9 @@ namespace StockManMVC.Controllers
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// indico che devo salvare!
|
||||
// sblocco vecchio item x non fare conflitto
|
||||
db.Entry(itemFluxOld).State = EntityState.Detached;
|
||||
// indico che devo salvare nuovo!
|
||||
db.Entry(itemFlux).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user