Esempio n. 1
0
        public virtual void LoadChilds(Type type, bool get_childs, bool throwStockException)
        {
            if (IsNew)
            {
                return;
            }

            if (type.Equals(typeof(Batch)))
            {
                if (_partidas.Count > 0)
                {
                    return;
                }

                _partidas = Batchs.GetChildList(this, get_childs);
            }
            else if (type.Equals(typeof(Stock)))
            {
                if (_stocks.Count > 0)
                {
                    return;
                }

                _stocks = Stocks.GetChildList(this, get_childs, throwStockException);
                UpdateStocks(throwStockException);
            }
        }
Esempio n. 2
0
        public virtual void RemoveStock(long oidStock, long oidPartida)
        {
            Stocks.Remove(oidStock);
            Batch partida = Partidas.GetItem(oidPartida);

            UpdateStocks(partida, true);
        }
Esempio n. 3
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();
        }
Esempio n. 4
0
 public virtual void LoadChildsFromList(Type type, string list, bool get_childs)
 {
     if (type.Equals(typeof(Batch)))
     {
         _partidas = Batchs.GetChildListFromList(this, list, get_childs);
     }
     else if (type.Equals(typeof(Stock)))
     {
         _stocks = Stocks.GetChildListByPartidaFromList(this, list, get_childs);
     }
 }
Esempio n. 5
0
        public virtual void LoadStockByProducto(long oid, bool childs, bool throwStockException)
        {
            if (_stocks.GetItemByProduct(oid) == null)
            {
                Stocks stocks = Stocks.GetChildListByProducto(this, oid, childs);

                foreach (Stock item in stocks)
                {
                    _stocks.AddItem(item);
                }

                _stocks.UpdateStocks(this, throwStockException);
            }
        }
Esempio n. 6
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);
            }
        }
Esempio n. 7
0
        public virtual bool CheckStock(ETipoFacturacion saleType, long oidProduct, decimal amount, decimal reserved_amount = 0)
        {
            Stocks product_stock = Stocks.GetByProductList(oidProduct);

            switch (saleType)
            {
            case ETipoFacturacion.Peso: return(product_stock.TotalKgs() + reserved_amount >= amount);

            case ETipoFacturacion.Unidad: return(product_stock.TotalUds() + reserved_amount >= amount);

            case ETipoFacturacion.Unitaria: return(product_stock.TotalUds() + reserved_amount >= amount);
            }

            return(false);
        }