Exemple #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();
                }
            }
        }
Exemple #2
0
        public void guardarnotaentrada(Notaentradabean nota, string estado)
        {
            int cantidad2 = 0;

            for (int i = 0; i < nota.detalleNotaEntrada.Count; i++)
            {
                if (nota.detalleNotaEntrada[i].cantidadentrante > 0) cantidad2++;
            }
            if (cantidad2 > 0)
            {
                cambiarestado(nota.idOrdenCompra, estado);
                insertarnotaentrada(nota);
                insertardetallenota(nota);
            }
        }
        //idguiaremision, idordencompra
        public ActionResult DetallenotaEntrada(string id, string id2)
        {
            Notaentradabean nota = new Notaentradabean();

            nota.detalleNotaEntrada = comprfacade.obtenernotas(id);
            nota.idGuiaRemision = id;
            nota.idOrdenCompra = id2;
            OrdencompraBean ordencompra = comprfacade.buscarOrdenes(id2);
            nota.idCafeteria = ordencompra.idCafeteria;
            SucursalBean suc = admin.buscarSucursal(nota.idCafeteria);
            nota.nombreCafeteria = suc.nombre;

            /*********************/

            List<Notaentradabean> notas = comprfacade.listarnotasentrada(id2);

            for (int i = 0; i < notas.Count; i++)
            {
                if (notas[i].idGuiaRemision == id)
                {
                    nota.fechaEmitida = notas[i].fechaEmitida;
                }
            }

            OrdencompraBean orden = comprfacade.buscarOrdenes(id2);

            nota.idProveedor = orden.idProveedor;

            ProveedorBean proveedor = comprfacade.BuscarProveedor(nota.idProveedor);
            nota.nombreProveedor = proveedor.razonSocial;

            for (int i = 0; i < nota.detalleNotaEntrada.Count; i++)
            {
                IngredienteBean ingre = almafacade.buscaringrediente(nota.detalleNotaEntrada[i].id);
                nota.detalleNotaEntrada[i].nombre = ingre.nombre;
            }
            return View(nota);
        }
 public void guardarnotaentrada(Notaentradabean not, string stado)
 {
     notadao.guardarnotaentrada(not, stado);
 }
 public void actualizarstock(Notaentradabean not)
 {
     notadao.actualizarstock(not);
 }
Exemple #6
0
        public List<Notaentradabean> listarnotasentrada(string idordencompra)
        {
            SqlConnection objDB = null;
            try
            {
                objDB = new SqlConnection(cadenaDB);
                List<Notaentradabean> Listaordenes = new List<Notaentradabean>();
                objDB.Open();
                String strQuery = "SELECT * FROM Notaentrada where idOrdencompra= @id ";
                SqlCommand objQuery = new SqlCommand(strQuery, objDB);
                BaseDatos.agregarParametro(objQuery, "@id", idordencompra);
                SqlDataReader objDataReader = objQuery.ExecuteReader();
                if (objDataReader.HasRows)
                {
                    while (objDataReader.Read())
                    {

                        Notaentradabean orden = new Notaentradabean();

                        orden.idGuiaRemision = Convert.ToString(objDataReader["idNotaentrada"]);
                        orden.idOrdenCompra = Convert.ToString(objDataReader["idOrdencompra"]);
                        orden.fechaEmitida = Convert.ToString(objDataReader["fechaEntrega"]);
                        Listaordenes.Add(orden);
                    }
                }

                return Listaordenes;
            }
            catch (Exception e)
            {
                log.Error("Lista de ordenes de compra(EXCEPTION): ", e);
                throw (e);
            }
            finally
            {
                if (objDB != null)
                {
                    objDB.Close();
                }
            }
        }
        public ActionResult RegistrarNotaEntrada(string id)
        {
            Notaentradabean notaentrada = new Notaentradabean();

            OrdencompraBean ordencompra = comprfacade.buscarOrdenes(id);
            ProveedorBean proveedor = comprfacade.BuscarProveedor(ordencompra.idProveedor);
            ordencompra.nombreProveedor = proveedor.razonSocial;

            notaentrada.idCafeteria = ordencompra.idCafeteria;
            SucursalBean suc = admin.buscarSucursal(notaentrada.idCafeteria);
            notaentrada.nombreCafeteria = suc.nombre;
            notaentrada.nombreProveedor = proveedor.razonSocial;
            notaentrada.idOrdenCompra = id;
            notaentrada.idProveedor = ordencompra.idProveedor;
            notaentrada.fechaRegistradaOrdenCompra = ordencompra.fecha;
            notaentrada.detalleNotaEntrada = new List<Notaentrada>();
            notaentrada.estado = ordencompra.estado;

            for (int i = 0; i < ordencompra.detalle.Count; i++)
            {
                IngredienteBean ingre = almafacade.buscaringrediente(ordencompra.detalle[i].id);
                ordencompra.detalle[i].nombre = ingre.nombre;
            }

            for (int i = 0; i < ordencompra.detalle.Count; i++)
            {
                Notaentrada notas = new Notaentrada();
                notas.cantidadsolicitada = ordencompra.detalle[i].Cantidad;
                notas.id = ordencompra.detalle[i].id;
                notas.nombre = ordencompra.detalle[i].nombre;

                notaentrada.detalleNotaEntrada.Add(notas);

            }

            List<Notaentradabean> notas2 = comprfacade.listarnotasentrada(id); // lista de notas de entrada de uan orden de compra

            for (int i = 0; i < notas2.Count; i++)
            {
                List<Notaentrada> detallenotaentrada = comprfacade.obtenernotas(notas2[i].idGuiaRemision);
                for (int j = 0; j < detallenotaentrada.Count; j++)
                {
                    for (int k = 0; k < notaentrada.detalleNotaEntrada.Count; k++)
                    {
                        if (notaentrada.detalleNotaEntrada[k].id == detallenotaentrada[j].id)
                        {
                            notaentrada.detalleNotaEntrada[k].cantidadrecibida += detallenotaentrada[j].cantidadentrante;
                        }

                    }

                }
            }
            for (int i = 0; i < notaentrada.detalleNotaEntrada.Count; i++)
            {
                notaentrada.detalleNotaEntrada[i].cantidadfaltante = notaentrada.detalleNotaEntrada[i].cantidadsolicitada - notaentrada.detalleNotaEntrada[i].cantidadrecibida;
                if (notaentrada.detalleNotaEntrada[i].cantidadfaltante == 0)
                {
                    notaentrada.detalleNotaEntrada[i].estadonota = true;
                }
            }

            return View(notaentrada);
        }
        public ActionResult RegistrarNotaEntrada(Notaentradabean not)
        {
            for (int i = 0; i < not.detalleNotaEntrada.Count; i++)
            {
                int cantidad = not.detalleNotaEntrada[i].cantidadentrante - not.detalleNotaEntrada[i].cantidadfaltante;
                if (cantidad == 0)
                {
                    not.detalleNotaEntrada[i].estadonota = true;
                }
            }

            string estado = ""; // verificar las cantidades

            Boolean estado2 = true;
            for (int i = 0; i < not.detalleNotaEntrada.Count; i++)
            {
                estado2 = not.detalleNotaEntrada[i].estadonota && estado2;
            }

            if (estado2) estado = "Atendido"; else estado = "Parcialmente Atendido";

            almafacade.guardarnotaentrada(not, estado);
            almafacade.actualizarstock(not);//.. cambiar stock de producto
            return RedirectToAction("ListarNotaEntrada/" + not.idOrdenCompra, "Notaentrada");
        }
Exemple #9
0
 public void actualizarstock(Notaentradabean not)
 {
     notservice.actualizarstock(not);
 }
Exemple #10
0
        private void insertarnotaentrada(Notaentradabean nota)
        {
            SqlConnection objDB = null;
            int i = Utils.cantidad("Notaentrada") + 1;
            string ID = "NOTA00";//8caracteres-4letras-4#
            if (i < 10) nota.idGuiaRemision = ID + "0" + Convert.ToString(i);
            else nota.idGuiaRemision = ID + Convert.ToString(i);
            this.Idnotaentrada = nota.idGuiaRemision;

            try
            {
                objDB = new SqlConnection(cadenaDB);
                objDB.Open();
                String strQuery = "Insert into Notaentrada (idNotaentrada,idOrdencompra, fechaEntrega) values " +
                                   "(@id,@idorden,GETDATE())";

                SqlCommand objQuery = new SqlCommand(strQuery, objDB);
                Utils.agregarParametro(objQuery, "@id", nota.idGuiaRemision);
                Utils.agregarParametro(objQuery, "@idorden", nota.idOrdenCompra);
                objQuery.ExecuteNonQuery();

            }
            catch (Exception e)
            {
                log.Error("Registrar nota entrada(EXCEPTION): ", e);
                throw (e);
            }
            finally
            {
                if (objDB != null)
                {
                    objDB.Close();
                }
            }
        }
Exemple #11
0
        private void insertardetallenota(Notaentradabean nota)
        {
            SqlConnection objDB = null;
            try
            {
                objDB = new SqlConnection(cadenaDB);
                objDB.Open();
                for (int i = 0; i < nota.detalleNotaEntrada.Count; i++)
                {
                    if (nota.detalleNotaEntrada[i].cantidadentrante > 0)
                    {
                        String strQuery = "Insert Into  notaEntradaDetalle (idNotaentrada,idIngrediente, cantidadentrante) values( @idnota,@ID, @cant)";

                        SqlCommand objQuery = new SqlCommand(strQuery, objDB);
                        Utils.agregarParametro(objQuery, "@ID", nota.detalleNotaEntrada[i].id);
                        Utils.agregarParametro(objQuery, "@idnota", this.Idnotaentrada);
                        Utils.agregarParametro(objQuery, "@cant", nota.detalleNotaEntrada[i].cantidadentrante);
                        objQuery.ExecuteNonQuery();

                    }
                }

            }
            catch (Exception e)
            {
                log.Error("ListaIngredientes(EXCEPTION): ", e);
                throw (e);
            }

            finally
            {
                if (objDB != null)
                {
                    objDB.Close();
                }
            }
        }