/// <summary>
        /// Actualiza un registro en la base de datos
        /// </summary>
        /// <param name="parent">Objeto padre</param>
        internal void Update(InventarioAlmacen parent)
        {
            // if we're not dirty then don't update the database
            if (!this.IsDirty)
            {
                return;
            }

            //Debe obtener la sesion del padre pq el objeto es padre a su vez
            SessionCode = parent.SessionCode;

            OidInventario = parent.Oid;

            try
            {
                ValidationRules.CheckRules();

                if (!IsValid)
                {
                    throw new iQValidationException(moleQule.Resources.Messages.GENERIC_VALIDATION_ERROR);
                }

                LineaInventarioRecord obj = parent.Session().Get <LineaInventarioRecord>(Oid);
                obj.CopyValues(this._base.Record);
                parent.Session().Update(obj);
            }
            catch (Exception ex)
            {
                iQExceptionHandler.TreatException(ex);
            }

            MarkOld();
        }
        /// <summary>
        /// Borra un registro de la base de datos.
        /// </summary>
        /// <param name="parent">Objeto padre</param>
        /// <remarks>Borrado inmediato<remarks/>
        internal void DeleteSelf(InventarioAlmacen 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 <LineaInventarioRecord>(Oid));
            }
            catch (Exception ex)
            {
                iQExceptionHandler.TreatException(ex);
            }

            MarkNew();
        }
        /// <summary>
        /// Realiza el Save de los objetos de la lista. Inserta, Actualiza o Borra en función
        /// de los flags de cada objeto de la lista
        /// </summary>
        /// <param name="parent">BusinessBaseEx padre de la lista</param>
        internal void Update(InventarioAlmacen parent)
        {
            this.RaiseListChangedEvents = false;

            // update (thus deleting) any deleted child objects
            foreach (LineaInventario obj in DeletedList)
            {
                obj.DeleteSelf(parent);
            }

            // now that they are deleted, remove them from memory too
            DeletedList.Clear();

            // add/update any current child objects
            foreach (LineaInventario obj in this)
            {
                if (!this.Contains(obj))
                {
                    if (obj.IsNew)
                    {
                        obj.Insert(parent);
                    }
                    else
                    {
                        obj.Update(parent);
                    }
                }
            }

            this.RaiseListChangedEvents = true;
        }
Exemplo n.º 4
0
        /// <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>
        /// Crea un nuevo objeto hijo
        /// </summary>
        /// <param name="parent">Objeto padre</param>
        /// <returns>Nuevo objeto creado</returns>
        internal static LineaInventario NewChild(InventarioAlmacen parent)
        {
            if (!CanAddObject())
            {
                throw new System.Security.SecurityException(moleQule.Resources.Messages.USER_NOT_ALLOWED);
            }

            return(new LineaInventario(parent));
        }
Exemplo n.º 6
0
        internal void CopyValues(InventarioAlmacen source)
        {
            if (source == null)
            {
                return;
            }

            _record.CopyValues(source._base.Record);
        }
Exemplo n.º 7
0
        /// <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);
            }
        }
        public static InventarioAlmacenList GetList(bool retrieve_childs)
        {
            CriteriaEx criteria = InventarioAlmacen.GetCriteria(InventarioAlmacen.OpenSession());

            criteria.Childs = retrieve_childs;

            //No criteria. Retrieve all de List

            if (nHManager.Instance.UseDirectSQL)
            {
                criteria.Query = InventarioAlmacenList.SELECT();
            }

            InventarioAlmacenList list = DataPortal.Fetch <InventarioAlmacenList>(criteria);

            CloseSession(criteria.SessionCode);
            return(list);
        }
 /// <summary>
 /// NO UTILIZAR DIRECTAMENTE. LO UTILIZA LA FUNCION DE CREACION DE LA LISTA DEL PADRE
 /// </summary>
 private LineaInventario(InventarioAlmacen parent)
 {
     OidInventario = parent.Oid;
     MarkAsChild();
 }
 public void CopyFrom(InventarioAlmacen source)
 {
     _base.CopyValues(source);
 }
 /// <summary>
 /// Crea un nuevo elemento y lo añade a la lista
 /// </summary>
 /// <returns>Nuevo item</returns>
 public LineaInventario NewItem(InventarioAlmacen parent)
 {
     base.NewItem(LineaInventario.NewChild(parent));
     return(this[Count - 1]);
 }
 public static string SELECT(InventarioAlmacen item)
 {
     return(SELECT(new QueryConditions {
         InventarioAlmacen = item.GetInfo()
     }));
 }
 public static string SELECT(QueryConditions conditions)
 {
     return(InventarioAlmacen.SELECT(conditions, false));
 }