Using transaction and show broken rules


Author
Message
Chan
Chan
Advanced StrataFrame User (725 reputation)Advanced StrataFrame User (725 reputation)Advanced StrataFrame User (725 reputation)Advanced StrataFrame User (725 reputation)Advanced StrataFrame User (725 reputation)Advanced StrataFrame User (725 reputation)Advanced StrataFrame User (725 reputation)Advanced StrataFrame User (725 reputation)Advanced StrataFrame User (725 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

I have code to update some tables (not visible on screen) upon Form.AfterSave() event fired using transaction as shown below.

1. Is it the "right way"?

2. I want show broken rules if failed. How should I show them? Any advice?

public SaveUndoResult SaveToTransfer()
{
  SaveUndoResult loReturn = SaveUndoResult.Success;
  try
  {
    //PushDataToTransfer();
    BusinessLayer.TransactionBegin("", IsolationLevel.ReadCommitted);
    if (loReturn == SaveUndoResult.Success)
    {
       loReturn = _TransfersBO.Save(true);
    }
    if (loReturn == SaveUndoResult.Success)
    {
       _TransferDetailsBO.Save(true);
    }
    if (loReturn == SaveUndoResult.Success)
    {
      _PInvoiceTransferBO.Save(true);
    }
  }
  catch (DataLayerSavingException ex)
  {
    throw ex;
  }
  catch (Exception ex)
  {
    throw new BusinessLayerException("An error occurred while saving the data to the server.", ex);
  }
  finally
  {
    if (loReturn == SaveUndoResult.Success)
    {
      BusinessLayer.TransactionCommit("");
    }
    else
    {
    BusinessLayer.TransactionRollback("");
    }
  }
  return loReturn;

}


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search