/// <summary>
        /// Agrega un producto a la relación de detalles de la promoción.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void addProduct_Click(object sender, RoutedEventArgs e)
        {
            if (validarCamposDetalle())
            {
                Producto          producto          = new Producto();
                ProductoPromocion detalle_promocion = new ProductoPromocion();
                detalle_promocion.Promocion    = promocion.obtenerPorId(this.promocion.id);
                detalle_promocion.promocion_id = detalle_promocion.Promocion.id;
                detalle_promocion.Producto     = producto.obtener(cbxProductos.SelectedItem.ToString());
                detalle_promocion.producto_id  = detalle_promocion.Producto.id;
                detalle_promocion.cantidad     = Double.Parse(txtCantidadP.Text);

                if (tblProductos.SelectedItem == null)
                {
                    detalle_promocion.registrar(detalle_promocion);
                }
                else
                {
                    System.Data.DataRowView seleccion = (System.Data.DataRowView)tblProductos.SelectedItem;
                    detalle_promocion.id = Convert.ToInt32(seleccion.Row.ItemArray[0].ToString());
                    detalle_promocion.modificar(detalle_promocion);
                }
                cargarDetallePromocion();
                clearFieldDetalle();
            }
            else
            {
                MessageBox.Show("EXISTEN CAMPOS IMPORTANTES SIN INGRESAR");
            }
        }
 /// <summary>
 /// Detecta el evento en la tabla de productos y los pone en edición.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void tblProductos_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     System.Data.DataRowView seleccion = (System.Data.DataRowView)tblProductos.SelectedItem;
     if (seleccion != null)
     {
         ProductoPromocion detalle = new ProductoPromocion();
         detalle = detalle.obtener(Convert.ToInt32(seleccion.Row.ItemArray[0].ToString()));
         cbxProductos.SelectedItem = seleccion.Row.ItemArray[1].ToString();
         txtCantidadP.Text         = Convert.ToString(detalle.cantidad);
     }
 }
Esempio n. 3
0
        public void Put(int id, [FromBody] ProductoPromocion newObj)
        {
            var oldObj = db.ProductoPromocion.Find(id);

            if (oldObj == null)
            {
                return;
            }
            newObj.Id = oldObj.Id;
            db.Entry(oldObj).CurrentValues.SetValues(newObj);
            db.SaveChanges();
        }
        /// <summary>
        /// Carga cada uno de los productos que conforma la promoción.
        /// </summary>
        public void cargarDetallePromocion()
        {
            dtProductos.Rows.Clear();
            ProductoPromocion        detalle  = new ProductoPromocion();
            List <ProductoPromocion> detalles = detalle.obtenerTodos(this.promocion.id);
            double total = 0;

            foreach (var item in detalles)
            {
                dtProductos.Rows.Add(item.id, item.Producto.nombre, item.cantidad, item.Producto.ultimoPrecio * item.cantidad);
                string precio   = Convert.ToString(item.Producto.ultimoPrecio);
                string cantidad = Convert.ToString(item.cantidad);
                total += Double.Parse(cantidad) * Double.Parse(precio);
            }
            txtTotal.Text = "Total Promoción: $" + this.promocion.ultimoPrecio + ", Total En Producto: $" + total;
        }
        public ActionResult PromocionProducto(int productoId)
        {
            var producto = Uow.Productos.Obtener(productoId);

            if (producto == null)
            {
                producto = new Producto();
            }

            var promo = new ProductoPromocion()
            {
                Hijo       = producto,
                HijoId     = productoId,
                Identifier = Guid.NewGuid(),
            };

            return(PartialView(promo));
        }
 /// <summary>
 /// Elimina un producto en el detalle  de la promoción.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void eliminarProductoDePromocion_ItemClick_1(object sender, DevExpress.Xpf.Bars.ItemClickEventArgs e)
 {
     System.Data.DataRowView seleccion = (System.Data.DataRowView)tblProductos.SelectedItem;
     if (seleccion != null)
     {
         MessageBoxResult dialogResult = MessageBox.Show("¿ESTÁ SEGURO DE ELIMINAR EL PRODUCTO '" + seleccion.Row.ItemArray[1] + "' DE LA PROMOCIÓN?", "ELIMINACIÓN DE PRODUCTO DE ELIMINACIÓN", MessageBoxButton.YesNo);
         if (dialogResult == MessageBoxResult.Yes)
         {
             ProductoPromocion detalle = new ProductoPromocion();
             detalle.id = Convert.ToInt32(seleccion.Row.ItemArray[0].ToString());
             detalle.eliminar(detalle);
             cargarDetallePromocion();
             clearFieldDetalle();
         }
     }
     else
     {
         MessageBox.Show("EN NECESARIO QUE SELECCIONE EL PRODUCTO QUE DESEA ELIMINAR");
     }
 }
Esempio n. 7
0
 public void Post(ProductoPromocion sync)
 {
     db.ProductoPromocion.Add(sync);
     db.SaveChanges();
 }