Example #1
0
        private void txtBarCodeArticulo_TextChanged(object sender, EventArgs e)
        {
            String barcode = txtBarCodeArticulo.Text;
            //ClienteNEG bl = new ClienteNEG();
            Articulo a = ArticuloNEG.Instancia().ObtenerArticulo(barcode);

            txtNombreArticulo.Text     = a.Nombre;
            codigoArticuloSeleccionado = a.idArticulo;


            //DetalleIngresoAlmacen d = new DetalleIngresoAlmacen();
            //int stockFinal = IngresoAlmacenNEG.ObtenerStockActual(Convert.ToInt32(row.Cells["idArticulo"].Value));

            //DetalleStockTienda dStockFinal = StockTiendaNEG.Instancia().ObtenerStockActual(codigoArticuloSeleccionado);
            //txtStockActual.Text = dStockFinal.StockFinal.ToString();

            DetalleIngresoAlmacen dStockFinal = IngresoAlmacenNEG.Instancia().ObtenerStockActual(codigoArticuloSeleccionado);

            txtStockActual.Text = dStockFinal.CantidadFinal.ToString();

            DetalleIngresoAlmacen dPrecioActual = DetalleIngresoNEG.Instancia().obtenerPrecioVenta(codigoArticuloSeleccionado);

            txtPrecio.Text = dPrecioActual.PrecioVenta.ToString();

            //Cerrando el formulario
        }
        private void btnRegistrar_Click(object sender, EventArgs e)
        {
            if (txtCodigo.Text == "")
            {
                StockTienda c = new StockTienda();
                c.FechaIngresoTienda = dtpFechaIngreso.Value;
                //c.idCliente = codigoClienteSeleccionado;
                c.idUsuario = idUsuario;


                if (radActivo.Enabled == true)
                {
                    c.Estado = true;
                }
                else if (radInactivo.Enabled == true)
                {
                    c.Estado = false;
                }


                foreach (DataGridViewRow row in dgvDetalleStock.Rows)
                {
                    DetalleStockTienda de          = new DetalleStockTienda();
                    DetalleStockTienda dStockFinal = StockTiendaNEG.Instancia().ObtenerStockActual(Convert.ToInt32(row.Cells["idArticulo"].Value));


                    de.idArticulo = Convert.ToInt32(row.Cells["idArticulo"].Value);
                    DetalleIngresoAlmacen dPrecioActual = DetalleIngresoNEG.Instancia().obtenerPrecioVenta(de.idArticulo);
                    int cantidad = Convert.ToInt32(row.Cells["cantidad"].Value);
                    de.idDetalleIngresoAlmacen = dPrecioActual.idDetalleIngresoAlmacen;

                    de.StockInicial = Convert.ToInt32(row.Cells["cantidad"].Value);
                    de.StockFinal   = Convert.ToInt32(row.Cells["cantidad"].Value) + dStockFinal.StockFinal;
                    VentaNEG.Instancia().reducirStock(de.idArticulo, cantidad);
                    c.Lineas.Add(de);
                }



                StockTiendaNEG.RegistrarIngresoTienda(c);

                MessageBox.Show("El ingreso de Stock a Tienda fue exitoso.");
                this.Dispose();
            }

            else
            {
                if (radInactivo.Checked == true)
                {
                }

                this.Dispose();
            }
        }