/// <summary> /// Guarda en la base de datos todos los cambios del objeto. /// También guarda los cambios de los hijos si los tiene /// </summary> /// <returns>Objeto actualizado y con los flags reseteados</returns> public override Cash Save() { // Por la posible doble interfaz Root/Child if (IsChild) { throw new iQException(Library.Resources.Messages.CHILD_SAVE_NOT_ALLOWED); } if (IsDeleted && !CanDeleteObject()) { throw new System.Security.SecurityException(Library.Resources.Messages.USER_NOT_ALLOWED); } else if (IsNew && !CanAddObject()) { throw new System.Security.SecurityException(Library.Resources.Messages.USER_NOT_ALLOWED); } else if (!CanEditObject()) { throw new System.Security.SecurityException(Library.Resources.Messages.USER_NOT_ALLOWED); } try { ValidationRules.CheckRules(); } catch (iQValidationException ex) { iQExceptionHandler.TreatException(ex); return(this); } try { base.Save(); #if TRACE ControlerBase.AppControler.Timer.Record("Caja.Save"); #endif UpdateSaldo(); _lines.Update(this); #if TRACE ControlerBase.AppControler.Timer.Record("LineaCajas.Update"); #endif if (!SharedTransaction) { Transaction().Commit(); } return(this); } catch (Exception ex) { if (!SharedTransaction && Transaction() != null) { Transaction().Rollback(); } iQExceptionHandler.TreatException(ex); return(this); } finally { if (!SharedTransaction) { if (CloseSessions && (this.IsNew || Transaction().WasCommitted)) { CloseSession(); } else { BeginTransaction(); } } } }
/// <summary> /// Guarda en la base de datos todos los cambios del objeto. /// También guarda los cambios de los hijos si los tiene /// </summary> /// <returns>Objeto actualizado y con los flags reseteados</returns> public override CierreCaja Save() { // Por la posible doble interfaz Root/Child if (IsChild) { throw new iQException(Library.Resources.Messages.CHILD_SAVE_NOT_ALLOWED); } if (IsDeleted && !CanDeleteObject()) { throw new System.Security.SecurityException(Library.Resources.Messages.USER_NOT_ALLOWED); } else if (IsNew && !CanAddObject()) { throw new System.Security.SecurityException(Library.Resources.Messages.USER_NOT_ALLOWED); } else if (!CanEditObject()) { throw new System.Security.SecurityException(Library.Resources.Messages.USER_NOT_ALLOWED); } try { ValidationRules.CheckRules(); } catch (iQValidationException ex) { iQExceptionHandler.TreatException(ex); return(this); } try { base.Save(); _lineas.Update(this); Transaction().Commit(); return(this); } catch (Exception ex) { if (!SharedTransaction && Transaction() != null) { Transaction().Rollback(); } iQExceptionHandler.TreatException(ex); return(this); } finally { if (CloseSessions) { CloseSession(); } else { BeginTransaction(); } } }