private void ProcessPayment(Boolean IsCorrection) { // start transaction using (TransactionScope TS = new TransactionScope()) { // process payment try { ClassCustomBinding.BindToObject("ModelTMSContainer." + SetName + "Set", KeyID, Controls, DataItem, ControlObjectContext); if (!IsCorrection) { (DataItem as RelationAdvancePayment).PayOut(ControlObjectContext, Common.CurrentClientDateTime(Session)); } else { (DataItem as RelationAdvancePayment).PayBack(ControlObjectContext, Common.CurrentClientDateTime(Session)); } ControlObjectContext.SaveChanges(SaveOptions.DetectChangesBeforeSave); // commit transaction TS.Complete(); } catch (Exception ex) { // rollback transaction TS.Dispose(); // inform user Common.InformUserOnTransactionFail(ex, Page); } } }
public void SaveDataIntoDataItemFromControls() { ClassCustomBinding.BindToObject("ModelTMSContainer." + SetName + "Set", KeyID, Controls, DataItem, ControlObjectContext); }