示例#1
0
        public void actualizarstock(Notaentradabean not)
        {
            SqlConnection objDB = null;
            String idalmacen = buscaralmacen(not.idCafeteria);
            IngredienteXalmacenBean productos = new IngredienteXalmacenBean();
            Ingredientedao ingredao = new Ingredientedao();
            productos = ingredao.obtenerlistadAlmacen(idalmacen);
            try
            {
                objDB = new SqlConnection(cadenaDB);
                objDB.Open();
                List<int> cantidades = new List<int>();
                for (int i = 0; i < not.detalleNotaEntrada.Count; i++)
                {
                    for (int j = 0; j < productos.listProdAlmacen.Count; j++)
                    {
                        if (not.detalleNotaEntrada[i].id == productos.listProdAlmacen[j].id)
                        {
                            int cant = not.detalleNotaEntrada[i].cantidadentrante + productos.listProdAlmacen[j].stockactual;
                            cantidades.Add(cant);
                        }
                    }
                }

                for (int i = 0; i < not.detalleNotaEntrada.Count; i++)
                {
                    String strQuery = "UPDATE Almacen_x_Producto SET stockactual=@stock " +
                                  "WHERE idIngrediente = @idingre and idAlmacen=@idalmacen ";

                    SqlCommand objQuery = new SqlCommand(strQuery, objDB);
                    Utils.agregarParametro(objQuery, "@stock", cantidades[i]);
                    Utils.agregarParametro(objQuery, "@idingre", not.detalleNotaEntrada[i].id);
                    Utils.agregarParametro(objQuery, "@idalmacen", idalmacen);
                    objQuery.ExecuteNonQuery();
                }

            }
            catch (Exception e)
            {
                log.Error("ListaIngredientes(EXCEPTION): ", e);
                throw (e);
            }
            finally
            {
                if (objDB != null)
                {
                    objDB.Close();
                }
            }
        }
示例#2
0
 public IngredienteXalmacenBean obtenerlistadAlmacen(string Idalmacen)
 {
     IngredienteXalmacenBean gg = new IngredienteXalmacenBean();
     gg = Ingredienteservice.obtenerlistadAlmacen(Idalmacen);
     return gg;
 }
示例#3
0
        public IngredienteXalmacenBean obtenerlistadAlmacen(string Idalmacen)
        {
            IngredienteXalmacenBean prod = new IngredienteXalmacenBean();

            SqlConnection objDB = null;
            try
            {
                objDB = new SqlConnection(cadenaDB);
                objDB.Open();
                String strQuery = "SELECT * FROM Almacen_x_Producto WHERE idAlmacen =@ID";
                SqlCommand objquery = new SqlCommand(strQuery, objDB);
                BaseDatos.agregarParametro(objquery, "@ID", Idalmacen);

                SqlDataReader objDataReader = objquery.ExecuteReader();

                prod.listProdAlmacen = new List<IngredienteAlmacen>();

                if (objDataReader.HasRows)
                {
                    while (objDataReader.Read())
                    {
                        IngredienteAlmacen prodalmacen = new IngredienteAlmacen();
                        prodalmacen.id = (String)objDataReader["idIngrediente"];
                        prodalmacen.stockminimo = (int)objDataReader["stockminimo"];
                        prodalmacen.stockactual = (int)objDataReader["stockactual"];
                        prodalmacen.stockmaximo = (int)objDataReader["stockmaximo"];
                        prod.listProdAlmacen.Add(prodalmacen);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("getIngrediente(EXCEPTION): ", ex);
                throw ex;
            }
            finally
            {
                if (objDB != null)
                {
                    objDB.Close();
                }
            }
            return prod;
        }