コード例 #1
0
ファイル: frmVentas.cs プロジェクト: KevinKusters/TPC-Kusters
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            Producto producto = new Producto();

            producto = (Producto)cmbProductos.SelectedItem;

            if (txtCosto.Text == "" || txtPrecio.Text == "" || txtFecha.Text == "" || txtCantidad.Text == "")
            {
                MessageBox.Show("Debe seleccionar un producto e ingresar la cantidad a vender", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (producto.stock == 0)
                {
                    MessageBox.Show("No hay stock disponible para este producto", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    VentaNegocio         negocio   = new VentaNegocio();
                    GananciasXMesNegocio ganancias = new GananciasXMesNegocio();
                    Venta nueva = new Venta();

                    nueva.producto    = (Producto)cmbProductos.SelectedItem;
                    nueva.Fecha       = DateTime.Parse(txtFecha.Text);
                    nueva.cantidad    = int.Parse(txtCantidad.Text);
                    nueva.PrecioVenta = decimal.Parse(txtPrecio.Text);
                    nueva.Costo       = decimal.Parse(txtCosto.Text);

                    negocio.reducirStock(nueva.producto, int.Parse(txtCantidad.Text));
                    negocio.CargarVenta(nueva);

                    MessageBox.Show("Venta registrada", "MENSAJE", MessageBoxButtons.OK);
                }
            }
        }
コード例 #2
0
ファイル: Compra.aspx.cs プロジェクト: sjflores01/TPC_Flores
        protected void btnAceptar_Click(object sender, EventArgs e)
        {
            VentaNegocio    ventaNegocio    = new VentaNegocio();
            ProductoNegocio productoNegocio = new ProductoNegocio();
            UsuarioNegocio  usuarioNegocio  = new UsuarioNegocio();

            try
            {
                ventaNegocio.CargarVenta(venta);
                productoNegocio.ImpactoStock(venta.Carrito.Productos);

                usuario = usuarioNegocio.ValidarUsuario(usuario);
                Session["sesionUsuario"] = usuario;

                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "modalCompraExitosa", "$('#modalCompraExitosa').modal();", true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }