/// <summary> /// Borra el registro de la base de datos /// </summary> /// <param name="parent">Lista padre</param> /// <remarks>La utiliza la BusinessListBaseEx correspondiente para borrar elementos<remarks/> internal void DeleteSelf(InventarioAlmacenes parent) { // if we're not dirty then don't update the database if (!this.IsDirty) { return; } // if we're new then don't update the database if (this.IsNew) { return; } try { SessionCode = parent.SessionCode; Session().Delete(Session().Get <InventarioAlmacenRecord>(Oid)); } catch (Exception ex) { iQExceptionHandler.TreatException(ex); } MarkNew(); }
/// <summary> /// Actualiza el registro en la base de datos /// </summary> /// <param name="parent">Lista padre</param> /// <remarks>La utiliza la BusinessListBaseEx correspondiente para actualizar elementos<remarks/> internal void Update(InventarioAlmacenes parent) { // if we're not dirty then don't update the database if (!this.IsDirty) { return; } try { ValidationRules.CheckRules(); if (!IsValid) { throw new iQValidationException(moleQule.Resources.Messages.GENERIC_VALIDATION_ERROR); } SessionCode = parent.SessionCode; InventarioAlmacenRecord obj = Session().Get <InventarioAlmacenRecord>(Oid); obj.CopyValues(this._base.Record); Session().Update(obj); } catch (Exception ex) { iQExceptionHandler.TreatException(ex); } MarkOld(); }
/// <summary> /// Inserta el registro en la base de datos /// </summary> /// <param name="parent">Lista padre</param> /// <remarks>La utiliza la BusinessListBaseEx correspondiente para insertar elementos<remarks/> internal void Insert(InventarioAlmacenes parent) { // if we're not dirty then don't update the database if (!this.IsDirty) { return; } try { ValidationRules.CheckRules(); if (!IsValid) { throw new iQValidationException(moleQule.Resources.Messages.GENERIC_VALIDATION_ERROR); } parent.Session().Save(Base.Record); } catch (Exception ex) { iQExceptionHandler.TreatException(ex); } MarkOld(); }
/// <summary> /// Construye el objeto y se encarga de obtener los /// hijos si los tiene y se solicitan /// </summary> /// <param name="source">DataReader fuente</param> private void Fetch(IDataReader source) { try { _base.CopyValues(source); if (Childs) { if (nHMng.UseDirectSQL) { InventarioAlmacen.DoLOCK(Session()); string query = InventarioAlmacenes.SELECT(this); IDataReader reader = nHMng.SQLNativeSelect(query, Session()); _inventarios = InventarioAlmacenes.GetChildList(reader, false); Batch.DoLOCK(Session()); query = Batchs.SELECT(this, true); reader = nHMng.SQLNativeSelect(query, Session()); _partidas = Batchs.GetChildList(SessionCode, reader, false); Stock.DoLOCK(Session()); query = Stocks.SELECT(this); reader = nHMng.SQLNativeSelect(query, Session()); _stocks = Stocks.GetChildList(SessionCode, reader, false); } } } catch (Exception ex) { iQExceptionHandler.TreatException(ex); } MarkOld(); }
/// <summary> /// Obtiene un registro de la base de datos /// </summary> /// <param name="criteria">Criterios de consulta</param> /// <remarks>Lo llama el DataPortal tras generar el objeto</remarks> private void DataPortal_Fetch(CriteriaEx criteria) { try { _base.Record.Oid = 0; SessionCode = criteria.SessionCode; Childs = criteria.Childs; if (nHMng.UseDirectSQL) { Almacen.DoLOCK(Session()); IDataReader reader = nHMng.SQLNativeSelect(criteria.Query, Session()); if (reader.Read()) { _base.CopyValues(reader); } if (Childs) { string query = string.Empty; InventarioAlmacen.DoLOCK(Session()); query = InventarioAlmacenes.SELECT(this); reader = nHMng.SQLNativeSelect(query, Session()); _inventarios = InventarioAlmacenes.GetChildList(reader); Batch.DoLOCK(Session()); query = Batchs.SELECT(this, true); reader = nHMng.SQLNativeSelect(query, Session()); _partidas = Batchs.GetChildList(SessionCode, reader, false); Stock.DoLOCK(Session()); query = Stocks.SELECT(this); reader = nHMng.SQLNativeSelect(query, Session()); _stocks = Stocks.GetChildList(SessionCode, reader, false); } } MarkOld(); } catch (Exception ex) { if (Transaction() != null) { Transaction().Rollback(); } iQExceptionHandler.TreatException(ex); } }