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); } }
/// <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(); }
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); } }
public virtual void LoadPartidasByAlbaranProveedor(long oid, bool childs) { Batchs partidas = Batchs.GetChildListByAlbaranRecibido(this, oid, childs); foreach (Batch item in partidas) { if ((Partidas.GetItem(item.Oid) == null) && (!Partidas.ContainsDeleted(item.Oid))) { Partidas.AddItem(item); } } }
public virtual void LoadPartidasByExpediente(long oid, bool childs) { Batchs partidas = Batchs.GetChildListByExpediente(this, oid, childs); foreach (Batch item in partidas) { if ((Partidas.GetItem(item.Oid) == null) && (!Partidas.ContainsDeleted(item.Oid))) { Partidas.AddItem(item); } } }
/// <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 decimal TotalGastosMermas(Batchs partidas) { decimal total = 0; Batch partida = null; foreach (Stock item in this) { if (item.ETipoStock != ETipoStock.Merma) { continue; } partida = partidas.GetItem(item.OidPartida); total += (partida.PrecioCompraKilo + partida.GastoKilo) * item.Kilos; } return(Math.Abs(total)); }
public decimal TotalAyudaMermas(Batchs partidas) { decimal total = 0; Batch partida = null; foreach (Stock item in this) { if (item.ETipoStock != ETipoStock.Merma) { continue; } partida = partidas.GetItem(item.OidPartida); total += partida.AyudaKilo * item.Kilos; } return(Math.Abs(total)); }
public static BatchList GetChildListByProducto(StoreInfo parent, long oidProducto, bool childs) { CriteriaEx criteria = Batch.GetCriteria(Batch.OpenSession()); criteria.Childs = childs; QueryConditions conditions = new QueryConditions { Almacen = parent, Producto = Product.New().GetInfo(false) }; conditions.Producto.Oid = oidProducto; criteria.Query = Batchs.SELECT(conditions); BatchList list = DataPortal.Fetch <BatchList>(criteria); list.CloseSession(); return(list); }