예제 #1
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            if (txtCantidad.Text != "")
            {
                if (Convert.ToInt32(txtCantidad.Text) != 0)
                {
                    if (Convert.ToInt32(txtCantidad.Text) <= Maximo)
                    {
                        Factura factura = new Factura();
                        factura.Id       = Convert.ToInt32(txtId.Text);
                        factura.Producto = Convert.ToInt32(txtIdProd.Text);
                        factura.Costo    = Convert.ToInt32(txtCosto.Text);
                        factura.Cantidad = Convert.ToInt32(txtCantidad.Text);
                        factura.SubTotal = Convert.ToInt32(txtSubtotal.Text);

                        VentaNegocio negocio = new VentaNegocio();
                        negocio.AgregarFactura(factura);

                        cargarGrilla();

                        Total         = Total + factura.SubTotal;
                        txtTotal.Text = Total.ToString();

                        ProductoNegocio productoN = new ProductoNegocio();
                        Producto        prod      = new Producto();
                        prod.StockActual = Maximo - factura.Cantidad;
                        prod.Id          = Convert.ToInt64(txtIdProd.Text);
                        productoN.ModificarStock(prod);
                        cargarGrillaProductos();
                        Maximo = prod.StockActual;
                    }
                    else
                    {
                        MessageBox.Show("LA CANTIDAD NO PUEDE SER MAYOR AL STOCK ACTUAL");
                    }
                }
                else
                {
                    MessageBox.Show("COMPLETE LA CANTIDAD");
                }
            }
            else
            {
                MessageBox.Show("COMPLETE LA CANTIDAD");
            }
        }