Can someone please explain me why do I get (“The underlying provider failed on EnlistTransaction”) when I’m trying to do and update. and other times I get ("
Row has been modified by another user and couldn’t be updated."). I
I have put the below custom code on a postback method
:
Action<int, int, string, string> UpdateOrderRelease = (inOrderNumber, inOrderLine, inPlant, inWarehouseCode) =>
{
this.PublishInfoMessage(“Updating Line” + inOrderNumber.ToString() + " OrderLine" + inOrderLine.ToString(), Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, “”, “”);
// System.Transactions.TransactionScope
using (var txScope = IceDataContext.CreateDefaultTransactionScope())
{
var ordrResults =
(from ordr in Db.OrderRel
where ordr.Company == Session.CompanyID &&
ordr.OrderNum == inOrderNumber &&
ordr.OrderLine == inOrderLine
select ordr
).FirstOrDefault();
if (ordrResults != null)
{
if (ordrResults.Plant != inPlant )
{
ordrResults.Plant = "20";
}
}
//Db.Validate(ordrResults);
txScope.Complete();
}
};
/
////--------------------------------------------------------------------------------------------------------------------
////
// Created By: M TOLOZA
// Date Created : 5/10/2019
// Modifie Created : 5/10/2019
// Modifie Created : 9/06/2019 :::
////--------------------------------------------------------------------------------------------------------------------
// TABLES
// BEGIN TABLES
Erp.Tables.OrderHed OrderHed;
Erp.Tables.OrderDtl OrderDtl;
Erp.Tables.ShipTo ShipTo;
Erp.Tables.OrderRel OrderRel;
//// Declare LocalVariables
bool lUseOTS; /// Used to check whether the if this is a One Time Ship (OTS)
bool iOTSExcludedStates; /// Is one of th Excluded States. Do not Change when this is false
bool lUpdate = false;
string lPlant = “”;
string lWareHouseCode = “”;
//// END LOCAL VARIABLES
// END TABLES
//// this.PublishInfoMessage("'TEST ONE '" , Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "BEGIN BPM ", "BEGIN BPM ");
/// FORCE this BPM when something is added or change in the ttOrderHea.
/// HEADER
foreach (var OrderHeader_Iterator in (
from ttOrderHed_Row in ttOrderHed
select ttOrderHed_Row ))
{
var OrderHeaderXRow = OrderHeader_Iterator;
if (OrderHeaderXRow != null)
{
//// DETAIL
foreach (var OrderDetail_Iterator in (from OrderDet_Row in ttOrderDtl
where string.Compare(OrderHeaderXRow.Company, OrderDet_Row.Company, true) == 0 &&
OrderHeaderXRow.OrderNum == OrderDet_Row.OrderNum && OrderDet_Row.OrderLine != 0
select OrderDet_Row))
{
var OrderDetailXRow = OrderDetail_Iterator;
if (OrderDetailXRow != null)
{
//this.PublishInfoMessage("ttOrderDtl: ROWMOD :" + OrderDetailXRow.RowMod , Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "ttOrderDtl", "ttOrderDtl");
//// RELEASE
foreach (var OrderRel_iterator in (from OrderRel_Row in ttOrderRel
where string.Compare(OrderHeaderXRow.Company, OrderRel_Row.Company, true) == 0 &&
OrderHeaderXRow.OrderNum == OrderRel_Row.OrderNum &&
OrderDetailXRow.OrderLine == OrderRel_Row.OrderLine && OrderRel_Row.OrderLine != 0
select OrderRel_Row))
{
var OrderRelXRow = OrderRel_iterator;
if (OrderRelXRow != null)
{
foreach (var ShipTo_iterator in (from ShipTo_Row in Db.ShipTo
where string.Compare(OrderHeaderXRow.Company, ShipTo_Row.Company, true) == 0 &&
string.Compare(OrderHeaderXRow.ShipToNum, ShipTo_Row.ShipToNum, true) == 0 &&
OrderHeaderXRow.CustNum == ShipTo_Row.CustNum
select ShipTo_Row))
{
var ShipToXRow = ShipTo_iterator;
if (ShipToXRow != null)
{
lUpdate = false;
//// SECTION F ::::
//// REVERSE BACK TO NEW YORK
if( OrderHeaderXRow.UseOTS == false && (bool)OrderRelXRow["CheckBox17"] == false && (bool)ShipToXRow.CheckBox02 == false )
{
lPlant = "mfgsys";
lWareHouseCode = "PGC";
}
/// SECTION F
try{
///--- UPDATE Db.OrderHed because OrderHeaderXRow.CheckBox20 and OrderHeaderXRow.CheckBox19 are not present in the temporary table ttOrderHed
foreach (var ddDBOrderHed_iterator in (from ddDBOrderHed_Row in Db.OrderRel
where string.Compare(OrderHeaderXRow.Company, ddDBOrderHed_Row.Company, true) == 0 &&
OrderHeaderXRow.OrderNum == ddDBOrderHed_Row.OrderNum &&
OrderDetailXRow.OrderLine == ddDBOrderHed_Row.OrderLine
select ddDBOrderHed_Row))
{
var ddDBOrderHed = ddDBOrderHed_iterator;
if (ddDBOrderHed != null)
{
UpdateOrderRelease(ddDBOrderHed.OrderNum, ddDBOrderHed.OrderLine, lPlant, lWareHouseCode);
}
} /// END if (DBOrderHed != null)
}
catch (Exception ex) {
this.PublishInfoMessage(ex.Message, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, “”, “”);
}
} ///// END if (ShipToXRow != null)
} /// END foreach (var ShipTo_iterator in
//// END JOIN RECORDS SHIPTO
} /// END if (OrderRelXRow != null)
} /// END foreach (var OrderRel_iterator
} ///END if (OrderDetailXRow != null)
}/// END foreach (var OrderDetail_Iterator
//// END JOIN RECORDS TO DETAIL
} /// END if (OrderHeaderXRow!= null)
}/// END foreach (var OrderHeader_Iterator in (