Ejemplo n.º 1
0
        public int ModificarDetalleByID(string producto_cod_detalle, string producto_cod, int cant_min, int cant_actual, int valor)
        {
            int     resultado = 0;
            DETALLE detalle   = new DETALLE();
            Detalle d         = new Detalle();

            d.Producto_cod_detalle = producto_cod_detalle;
            d.Producto_cod         = producto_cod;
            d.Cantidad_minima      = cant_min;
            d.Cantidad_actual      = cant_actual;
            d.Valor = valor;
            detalle.PRODUCTO_COD_DETALLE = d.Producto_cod_detalle;
            detalle.PRODUCTO_COD         = d.Producto_cod;
            detalle.CANTIDAD_MINIMA      = d.Cantidad_minima;
            detalle.CANTIDAD_ACTUAL      = d.Cantidad_actual;
            detalle.VALOR = d.Valor;
            EntityKey key = ModeloEntidades.CreateEntityKey("SIAFEntities.DETALLE", detalle);
            Object    ActualizaDetalle; // se crea esta variable segun actualizacion, ahora es usuario, luego puede ser ActualizaProducto

            if (ModeloEntidades.TryGetObjectByKey(key, out ActualizaDetalle))
            {
                ModeloEntidades.ApplyCurrentValues(key.EntitySetName, detalle);
                resultado = ModeloEntidades.SaveChanges();
            }
            return(resultado);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Busca el registro que contiene el ID pasado por parametro y lo elimina.
        /// </summary>
        /// <param name="_ID_DetalleEliminar">Registro que se eliminará.</param>
        /// <param name="_InformacionDelError">Devuelve una cadena de texto con informacion para el usuario en caso de que el
        /// metodo devuelva null (debido a que ocurrio un error).</param>
        public int Borrar(int _ID_DetalleEliminar, ref string _InformacionDelError)
        {
            using (BDRestauranteEntities BBDD = new BDRestauranteEntities())
            {
                try
                {
                    Detalle ObjetoAEliminar = BBDD.Detalle.SingleOrDefault(Identificador => Identificador.ID_Detalle == _ID_DetalleEliminar);

                    if (ObjetoAEliminar != null)
                    {
                        BBDD.Detalle.Remove(ObjetoAEliminar);
                        return(BBDD.SaveChanges());
                    }
                    else
                    {
                        return(0);
                    }
                }
                catch (Exception Error)
                {
                    _InformacionDelError = $"OCURRIO UN ERROR INESPERADO AL INTENTAR LISTAR LA INFORMACIÓN: {Error.Message}\r\n\r\n" +
                                           $"ORIGEN DEL ERROR: {Error.StackTrace}\r\n\r\n" +
                                           $"OBJETO QUE GENERÓ EL ERROR: {Error.Data}\r\n\r\n\r\n" +
                                           $"ENVIE AL PROGRAMADOR UNA FOTO DE ESTE MENSAJE CON UNA DESCRIPCION DE LO QUE HIZO ANTES DE QUE SE GENERARÁ " +
                                           $"ESTE ERROR PARA QUE SEA ARREGLADO.";
                    return(0);
                }
            }
        }
Ejemplo n.º 3
0
        public void agregarDetalles(Detalle item, string remito)
        {
            SqlConnection conexion = new SqlConnection();
            SqlCommand    comando  = new SqlCommand();

            try
            {
                conexion.ConnectionString = AccesoDatosManager.cadenaConexion;
                comando.CommandType       = System.Data.CommandType.Text;
                //MSF-20190420: le agregué todas las columnas. Teniendo en cuenta inclusive lo que elegimos en el combo de selección..
                comando.CommandText  = "insert into DETALLES (idRemito,idProducto ,precioVenta, Cantidad,precioParcial,activo) values";
                comando.CommandText += "('" + remito.ToString() + "', '" + item.producto.id + "', '" + item.precioUnitario.ToString().Replace(",", ".") + "', '" + item.cantidadVendida + "', '" + item.precioParcial.ToString().Replace(",", ".") + "', '" + '1' + "')";
                comando.Connection   = conexion;
                conexion.Open();

                comando.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conexion.Close();
            }
        }
Ejemplo n.º 4
0
        public bool leerRemitocert(Certificado cert)
        {
            List <Detalle>     listado     = new List <Detalle>();
            AccesoDatosManager accesoDatos = new AccesoDatosManager();
            Detalle            det         = new Detalle();

            try
            {
                accesoDatos.setearConsulta("Select numeroCertificado from DETALLES");
                accesoDatos.abrirConexion();
                accesoDatos.ejecutarConsulta();
                while (accesoDatos.Lector.Read())
                {
                    if (!Convert.IsDBNull(accesoDatos.Lector["numeroCertificado"]))
                    {
                        det.numeroCertificado = accesoDatos.Lector["numeroCertificado"].ToString();
                    }

                    if (cert.numeroCertificado == det.numeroCertificado)
                    {
                        return(true);
                    }
                }

                return(false);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                accesoDatos.cerrarConexion();
            }
        }
Ejemplo n.º 5
0
        public void agregar(Detalle detalleVenta, string ClienteID, string VentaID)
        {
            SqlConnection conexion = new SqlConnection();
            SqlCommand    comando  = new SqlCommand();

            try
            {
                conexion.ConnectionString = AccesoDatosManager.cadenaConexion;
                comando.CommandType       = System.Data.CommandType.Text;
                comando.CommandText       = "  INSERT INTO [TPC_ESPINOLA].[dbo].[DetalleVentas] (ProductoID,VentaID,Cantidad,Precio) VALUES (@ProductoID,@VentaID,@Cantidad,@Precio)";
                comando.Parameters.Clear();
                comando.Parameters.AddWithValue("@ProductoID", detalleVenta.Producto.ID);
                comando.Parameters.AddWithValue("@VentaID", VentaID);
                comando.Parameters.AddWithValue("@Cantidad", detalleVenta.Cantidad);
                comando.Parameters.AddWithValue("@Precio", detalleVenta.Precio);
                comando.Connection = conexion;
                conexion.Open();
                comando.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conexion.Close();
            }
        }
Ejemplo n.º 6
0
        public void AgregarDetalleVenta(Detalle detalle)
        {
            try
            {
                acceso.setearSP("SP_AltaDetalleVenta");
                acceso.agregarParametro("@precio", detalle.precioUnitario);
                acceso.agregarParametro("@cantidad", detalle.cantidad);
                acceso.agregarParametro("@idProdu", detalle.idProducto.idProdu);
                acceso.agregarParametro("@idVenta", detalle.idVenta.id);

                acceso.ejecutarAccion();
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 7
0
        public List <Detalle> MostrarAllDetalle()
        {
            List <Detalle> lDetalle = new List <Detalle>();
            var            detalle  = ModeloEntidades.DETALLE;

            foreach (DETALLE de in detalle)
            {
                Detalle dd = new Detalle();
                dd.Producto_cod_detalle = de.PRODUCTO_COD_DETALLE;
                dd.Producto_cod         = de.PRODUCTO_COD;
                dd.Cantidad_minima      = Convert.ToInt32(de.CANTIDAD_MINIMA);
                dd.Cantidad_actual      = Convert.ToInt32(de.CANTIDAD_ACTUAL);
                dd.Valor = Convert.ToInt32(de.VALOR);
                lDetalle.Add(dd);
            }
            return(lDetalle);
        }
Ejemplo n.º 8
0
        public List <Detalle> listar(Pedido pedido)
        {
            List <Detalle> listado = new List <Detalle>();
            AccesoDatos    datos   = new AccesoDatos();
            Detalle        aux;

            try
            {
                datos.SetQuery("select * from DetallePedidos_VW where  IdPedido=@Idpedido");
                datos.comando.Parameters.Clear();
                datos.AgregarParametro("@Email", pedido.Usuario.Email);
                datos.AgregarParametro("@Idpedido", pedido.ID);
                datos.EjecutarLector();
                while (datos.lector.Read())
                {
                    aux                          = new Detalle();
                    aux.ID                       = (Int32)datos.lector["ID"];
                    aux.pedido                   = new Pedido();
                    aux.pedido.ID                = (Int64)datos.lector["IdPedido"];
                    aux.item                     = new ItemCarro();
                    aux.item.articulo            = new Articulo();
                    aux.item.articulo.IdArticulo = (Int64)datos.lector["IdArticulo"];
                    aux.item.articulo.Nombre     = (string)datos.lector["Articulo"];
                    aux.item.Color               = new Color();
                    aux.item.Color.Nombre        = (string)datos.lector["Color"];
                    aux.item.Cantidad            = (int)datos.lector["cantidad"];
                    //aux.pedido.Usuario = new Usuario();
                    //aux.pedido.Usuario.Email =(string)datos.lector["Email"];
                    aux.item.articulo.Precio = (decimal)datos.lector["Precio"];
                    listado.Add(aux);
                }

                return(listado);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                datos.CerrarConexion();
            }
        }
        public List <Detalle> listar(string CompraID)
        {
            SqlConnection  conexion = new SqlConnection();
            SqlCommand     comando  = new SqlCommand();
            SqlDataReader  lector;
            List <Detalle> listado = new List <Detalle>();
            Detalle        detalle;

            try
            {
                conexion.ConnectionString = AccesoDatosManager.cadenaConexion;
                comando.CommandType       = System.Data.CommandType.Text;
                //MSF-20190420: agregué todos los datos del heroe. Incluso su universo, que lo traigo con join.
                comando.CommandText = "SELECT * FROM [TPC_ESPINOLA].[dbo].[DetalleCompras] WHERE [TPC_ESPINOLA].[dbo].[DetalleCompras].CompraID = @IDCompra";
                comando.Connection  = conexion;
                comando.Parameters.AddWithValue("@IDCompra", CompraID);
                conexion.Open();
                lector = comando.ExecuteReader();
                ProductoNegocio negocioProducto = new ProductoNegocio();
                while (lector.Read())
                {
                    detalle          = new Detalle();
                    detalle.ID       = Convert.ToInt32(lector["ID"].ToString());
                    detalle.Producto = negocioProducto.traerProducto(lector["ProductoID"].ToString());
                    detalle.Cantidad = int.Parse(lector["Cantidad"].ToString());
                    detalle.Precio   = float.Parse(lector["Precio"].ToString());
                    detalle.SubTotal = int.Parse(lector["Cantidad"].ToString()) * float.Parse(lector["Precio"].ToString());

                    listado.Add(detalle);
                }

                return(listado);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conexion.Close();
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Crea un nuevo registro a partir de los datos que contiene el objeto pasado por parametro.
 /// </summary>
 /// <param name="_Detalle">Objeto que contiene los datos del nuevo registro que se creará.</param>
 ///<param name="_InformacionDelError">Devuelve una cadena de texto con informacion para el usuario en caso de que el
 /// metodo devuelva null (debido a que ocurrio un error).</param>
 public int Crear(Detalle _Detalle, ref string _InformacionDelError)
 {
     using (BDRestauranteEntities BBDD = new BDRestauranteEntities())
     {
         try
         {
             BBDD.Detalle.Add(_Detalle);
             return(BBDD.SaveChanges());
         }
         catch (Exception Error)
         {
             _InformacionDelError = $"OCURRIO UN ERROR INESPERADO AL INTENTAR LISTAR LA INFORMACIÓN: {Error.Message}\r\n\r\n" +
                                    $"ORIGEN DEL ERROR: {Error.StackTrace}\r\n\r\n" +
                                    $"OBJETO QUE GENERÓ EL ERROR: {Error.Data}\r\n\r\n\r\n" +
                                    $"ENVIE AL PROGRAMADOR UNA FOTO DE ESTE MENSAJE CON UNA DESCRIPCION DE LO QUE HIZO ANTES DE QUE SE GENERARÁ " +
                                    $"ESTE ERROR PARA QUE SEA ARREGLADO.";
             return(0);
         }
     }
 }
Ejemplo n.º 11
0
        public int AgregarDetalle(string PRODUCTO_COD_DETALLE, string PRODUCTO_COD, int CANTIDAD_MINIMA, int CANTIDAD_ACTUAL, int VALOR)
        {
            Detalle d  = new Detalle();
            DETALLE dd = new DETALLE();

            d.Producto_cod_detalle = PRODUCTO_COD_DETALLE;
            d.Producto_cod         = PRODUCTO_COD;
            d.Cantidad_minima      = CANTIDAD_MINIMA;
            d.Cantidad_actual      = CANTIDAD_ACTUAL;
            d.Valor = VALOR;

            dd.PRODUCTO_COD_DETALLE = d.Producto_cod_detalle;
            dd.PRODUCTO_COD         = d.Producto_cod;
            dd.CANTIDAD_MINIMA      = d.Cantidad_minima;
            dd.CANTIDAD_ACTUAL      = d.Cantidad_actual;
            dd.VALOR = d.Valor;

            ModeloEntidades.AddToDETALLE(dd);
            return(ModeloEntidades.SaveChanges());
        }
Ejemplo n.º 12
0
        public List <Detalle> listarDetalles(string remito)
        {
            List <Detalle>     listado     = new List <Detalle>();
            AccesoDatosManager accesoDatos = new AccesoDatosManager();
            Detalle            det         = new Detalle();

            try
            {
                accesoDatos.setearConsulta("Select p.descripcion,d.cantidad,d.precioVenta,d.precioParcial,d.idRemito from DETALLES as d inner join productos as p on p.id=d.idProducto where  d.idRemito=" + remito);
                accesoDatos.abrirConexion();
                accesoDatos.ejecutarConsulta();
                while (accesoDatos.Lector.Read())
                {
                    det                      = new Detalle();
                    det.producto             = new Producto();
                    det.producto.descripcion = accesoDatos.Lector["descripcion"].ToString();
                    det.numeroRemito         = accesoDatos.Lector["idRemito"].ToString();
                    det.cantidadVendida      = (int)accesoDatos.Lector["cantidad"];
                    if (!Convert.IsDBNull(accesoDatos.Lector["precioVenta"]))
                    {
                        det.precioUnitario = (decimal)accesoDatos.Lector["precioVenta"];
                    }
                    if (!Convert.IsDBNull(accesoDatos.Lector["precioParcial"]))
                    {
                        det.precioParcial = (decimal)accesoDatos.Lector["precioParcial"];
                    }

                    listado.Add(det);
                }

                return(listado);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                accesoDatos.cerrarConexion();
            }
        }
Ejemplo n.º 13
0
        public List <Detalle> listar(string VentaID)
        {
            SqlConnection  conexion = new SqlConnection();
            SqlCommand     comando  = new SqlCommand();
            SqlDataReader  lector;
            List <Detalle> listado = new List <Detalle>();
            Detalle        detalleVenta;

            try
            {
                conexion.ConnectionString = AccesoDatosManager.cadenaConexion;
                comando.CommandType       = System.Data.CommandType.Text;
                comando.CommandText       = "SELECT * FROM [TPC_ESPINOLA].[dbo].[DetalleVentas] WHERE [TPC_ESPINOLA].[dbo].[DetalleVentas].VentaID = @ID";
                comando.Connection        = conexion;
                comando.Parameters.AddWithValue("@ID", VentaID);
                conexion.Open();
                lector = comando.ExecuteReader();
                ProductoNegocio negocioProducto = new ProductoNegocio();
                while (lector.Read())
                {
                    detalleVenta          = new Detalle();
                    detalleVenta.ID       = Convert.ToInt32(lector["ID"].ToString());
                    detalleVenta.Precio   = float.Parse(lector["Precio"].ToString());
                    detalleVenta.Producto = negocioProducto.traerProducto(lector["ProductoID"].ToString());
                    detalleVenta.Cantidad = int.Parse(lector["Cantidad"].ToString());
                    detalleVenta.SubTotal = int.Parse(lector["Cantidad"].ToString()) * float.Parse(lector["Precio"].ToString());

                    listado.Add(detalleVenta);
                }

                return(listado);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conexion.Close();
            }
        }
Ejemplo n.º 14
0
        public void DescontarStock(Detalle detalle)
        {
            AccesoDatos datos = new AccesoDatos();

            try
            {
                datos.setearSP("DescontarStock_SP");
                datos.comando.Parameters.Clear();
                datos.AgregarParametro("@IdArticulo", detalle.item.articulo.IdArticulo);
                datos.AgregarParametro("@Cantidad", detalle.item.Cantidad);
                datos.EjecutarAccion();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                datos.CerrarConexion();
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Actualiza el registro mediente el ID que contiene el objeto proporcionado como parametro.
        /// </summary>
        /// <param name="_Detalle">Objeto que contiene los datos del registro al que se le van a actualizar los datos.</param>
        ///<param name="_InformacionDelError">Devuelve una cadena de texto con informacion para el usuario en caso de que el
        /// metodo devuelva null (debido a que ocurrio un error).</param>
        public int Actualizar(Detalle _Detalle, ref string _InformacionDelError)
        {
            using (BDRestauranteEntities BBDD = new BDRestauranteEntities())
            {
                try
                {
                    Detalle ObjetoActualizado = BBDD.Detalle.SingleOrDefault(Identificador => Identificador.ID_Detalle == _Detalle.ID_Detalle);

                    if (ObjetoActualizado != null)
                    {
                        ObjetoActualizado.ID_Detalle           = _Detalle.ID_Detalle;
                        ObjetoActualizado.ID_Pedido            = _Detalle.ID_Pedido;
                        ObjetoActualizado.ID_Articulo          = _Detalle.ID_Articulo;
                        ObjetoActualizado.ID_Chef              = _Detalle.ID_Chef;
                        ObjetoActualizado.Cantidad             = _Detalle.Cantidad;
                        ObjetoActualizado.Nota                 = _Detalle.Nota;
                        ObjetoActualizado.Precio               = _Detalle.Precio;
                        ObjetoActualizado.ID_EstadoDetalle     = _Detalle.ID_EstadoDetalle;
                        ObjetoActualizado.CantidadAgregada     = _Detalle.CantidadAgregada;
                        ObjetoActualizado.ID_ArticuloEntregado = _Detalle.ID_ArticuloEntregado;

                        return(BBDD.SaveChanges());
                    }
                    else
                    {
                        return(0);
                    }
                }
                catch (Exception Error)
                {
                    _InformacionDelError = $"OCURRIO UN ERROR INESPERADO AL INTENTAR LISTAR LA INFORMACIÓN: {Error.Message}\r\n\r\n" +
                                           $"ORIGEN DEL ERROR: {Error.StackTrace}\r\n\r\n" +
                                           $"OBJETO QUE GENERÓ EL ERROR: {Error.Data}\r\n\r\n\r\n" +
                                           $"ENVIE AL PROGRAMADOR UNA FOTO DE ESTE MENSAJE CON UNA DESCRIPCION DE LO QUE HIZO ANTES DE QUE SE GENERARÁ " +
                                           $"ESTE ERROR PARA QUE SEA ARREGLADO.";
                    return(0);
                }
            }
        }