Esempio n. 1
0
 private void comboProducto_SelectedValueChanged(object sender, EventArgs e)
 {
     if (sender == comboProducto)
     {
         Producto productoSeleccionado = ProductoBO.BuscarPorId(((ComboBox)sender).SelectedValue.ToString());
         if (productoSeleccionado.Cantidad == 0)
         {
             MessageBox.Show(
                 string.Format("El producto: Código: {0} Nombre: {1} .\nNo tiene existencias en el almacen", productoSeleccionado.IdProducto, productoSeleccionado.Nombre)
                 );
             nudCantidad.Enabled = false;
         }
         else if (productoSeleccionado.Cantidad <= 10)
         {
             MessageBox.Show(
                 string.Format(@"Por favor comunicarse con el proveedor del producto de Código: {0} \nNombre: {1} ya que se están agotando las existencias. Quedan {2} existencias.", productoSeleccionado.IdProducto, productoSeleccionado.Nombre, productoSeleccionado.Cantidad)
                 );
             nudCantidad.Enabled = true;
         }
         else
         {
             nudCantidad.Enabled = true;
         }
         lblPrecio.Text      = productoSeleccionado.PrecioVenta.ToString();
         nudCantidad.Maximum = productoSeleccionado.Cantidad;
     }
 }
 private void gridProductos_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (!(e.RowIndex == -1))
     {
         string   a = gridProductos.Rows[e.RowIndex].Cells[0].Value.ToString();
         Producto p = ProductoBO.BuscarPorId(a);
         frmCrearEditarProducto fcep = new frmCrearEditarProducto(p);
         fcep.ShowDialog(this);
     }
 }
        private void frmCambiarCantidadProducto_Load(object sender, EventArgs e)
        {
            producto = ProductoBO.BuscarPorId(idProducto);

            lblNombreProducto.Text = producto.Nombre;

            txtCantidadAlmacen.Text = producto.Cantidad.ToString();

            txtCantidadActual.Text = cantidadActual.ToString();

            nudNuevaCantidad.Maximum = producto.Cantidad;
        }
Esempio n. 4
0
        void CargarProductos()
        {
            foreach (DetalleFactura detalles in Factura.Detalles)
            {
                string nombreProducto = (ProductoBO.BuscarPorId(detalles.IdProducto).Nombre);

                fseleccionar_ProductoSeleccionado(detalles.IdProducto, detalles.Cantidad);

                //dgvLineaCompra.Rows.Add(
                //    null,
                //    detalles.IdProducto,
                //    nombreProducto,
                //    detalles.PrecioUnidad,
                //    detalles.Cantidad,
                //    detalles.Cantidad * detalles.PrecioUnidad
                //    );
            }
        }
Esempio n. 5
0
        void fseleccionar_ProductoSeleccionado(string idProductoSeleccionada, int cantidadSeleccionada)
        {
            Producto productoAAgregar = ProductoBO.BuscarPorId(idProductoSeleccionada);

            foreach (DataGridViewRow fila in dgvLineaCompra.Rows)
            {
                //Si existe un producto en el DataGridView con el mismo Id
                //que el producto que estoy agregando
                if (fila.Cells["Id"].Value.ToString() == productoAAgregar.IdProducto)
                {
                    //Suma la cantidad que seleccionada a la que hay en el DataGridView
                    int tempCantidad = Convert.ToInt32(fila.Cells["Cantidad"].Value) + cantidadSeleccionada;

                    //Si la suma de las cantidades es mayor a las existencias del producto en el almacén
                    //Entonces lanzar una excepción
                    if (tempCantidad > productoAAgregar.Cantidad)
                    {
                        throw new Exception("No puedes agregar más unidades, la cantidad \nsobrepasa las existencias disponibles");
                    }

                    //Actualizar el campo Cantidad en el DataGridView
                    fila.Cells["Cantidad"].Value = tempCantidad.ToString();

                    decimal _subtotalProductoExistente = tempCantidad * productoAAgregar.PrecioVenta;

                    fila.Cells["Sub_Total"].Value = _subtotalProductoExistente.ToString();

                    //Actualizar el Subtotal global con el subtotal agregado
                    //SubTotal += cantidadSeleccionada * productoAAgregar.PrecioVenta;
                    SubTotal += _subtotalProductoExistente;

                    //Actualizar los itbis acumulados globales
                    //ItbisAcumulados += (productoAAgregar.PrecioVenta * cantidadSeleccionada) * Impuestos;
                    ItbisAcumulados += _subtotalProductoExistente * Impuestos;

                    //el return es para parar la ejecución aquí, si no se pone return
                    //entonces se duplicará el producto en el DataGridView
                    return;
                }
            }

            //Agregando el producto en el DataGridView
            dgvLineaCompra.Rows.Add(
                null,
                productoAAgregar.IdProducto,
                productoAAgregar.Nombre,
                productoAAgregar.PrecioVenta,
                cantidadSeleccionada,
                productoAAgregar.PrecioVenta * cantidadSeleccionada);
            //SubTotal += (productoAAgregar.PrecioVenta * cantidadSeleccionada);
            int indiceFila = 0;

            foreach (DataGridViewRow fila in dgvLineaCompra.Rows)
            {
                if (fila.Cells["Id"].Value.ToString() == productoAAgregar.IdProducto)
                {
                    indiceFila = fila.Index;
                }
            }
            decimal _subtotalProductoAgregado = Convert.ToDecimal(dgvLineaCompra.Rows[indiceFila].Cells["Sub_Total"].Value);

            SubTotal += _subtotalProductoAgregado;

            //ItbisAcumulados += (productoAAgregar.PrecioVenta * cantidadSeleccionada) * Impuestos;

            ItbisAcumulados += _subtotalProductoAgregado * Impuestos;
        }