Ejemplo n.º 1
0
        protected void dgvDetalles_SelectedIndexChanged(object sender, EventArgs e)
        {
            GridViewRow gr = dgvDetalles.SelectedRow;

            VentaNegocio comNeg = new VentaNegocio();
            int          index;

            index = Convert.ToInt32(dgvDetalles.SelectedDataKey.Value.ToString());
            try
            {
                DetalleVentaNegocio DetallesNeg = new DetalleVentaNegocio();
                //int index = Convert.ToInt32(dgvDetalles.DataKeys[e.RowIndex].Value.ToString());
                //double PU = Convert.ToDouble((dgvDetalles.Rows[e.RowIndex].FindControl("LblTprod") as Label).Text);
                double Total = Convert.ToDouble(Session["TotalVenta"]);
                //Session["TotalVenta"] = Total - PU;
                List <DetalleVenta> lista = new List <DetalleVenta>();
                lista = (Session["DetalleVenta"] as List <DetalleVenta>);
                lista.RemoveAt(index);
                Session["DetalleVenta"] = lista;
                dgvDetalles.DataSource  = lista;
                dgvDetalles.DataBind();
                txbTotal.Text = Session["TotalVenta"].ToString();
            }
            catch (Exception ex)
            {
                lblCorrecto.Text   = "";
                lblIncorrecto.Text = ex.Message;
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            VentaNegocio       ventaNegocio       = new VentaNegocio();
            CarritoUserNegocio carritoUserNegocio = new CarritoUserNegocio();
            UsuarioNegocio     usuarioNegocio     = new UsuarioNegocio();
            EstadoNegocio      estadoNegocio      = new EstadoNegocio();

            try
            {
                venta                   = ventaNegocio.Listar().Find(v => v.ID == Convert.ToInt64(Request.QueryString["ID"]));
                venta.Usuario           = usuarioNegocio.ListarClientes().Find(u => u.ID == venta.Usuario.ID);
                venta.Carrito.Productos = carritoUserNegocio.CargarListaCarrito(venta.Carrito.ID);
                listaProductos          = venta.Carrito.Productos;
                if (!IsPostBack)
                {
                    dropDownEstado.DataSource     = estadoNegocio.Listar();
                    dropDownEstado.DataValueField = "ID";
                    dropDownEstado.DataTextField  = "Nombre";
                    dropDownEstado.SelectedIndex  = venta.Estado.ID - 1;
                    dropDownEstado.DataBind();
                }
            }
            catch (Exception ex)
            {
                Response.Redirect("Error.aspx");
            }
        }
Ejemplo n.º 3
0
        protected void GuardarVenta(object sender, EventArgs e)
        {
            VentaNegocio   negocioVenta   = new VentaNegocio();
            ClienteNegocio negocioCliente = new ClienteNegocio();
            List <Detalle> listaDetalle   = Session["listaDetalle"] != null? (List <Detalle>)Session["listaDetalle"] : null;
            string         response       = "";

            if (listaDetalle != null && listaDetalle.Count != 0)
            {
                ventaLocal         = new Venta();
                ventaLocal.Detalle = listaDetalle;
                ventaLocal.Fecha   = DateTime.Now;
                ventaLocal.Cliente = negocioCliente.traerCliente(ddlClientes.SelectedItem.Value);
                response           = negocioVenta.agregarVentaYDetalle(ventaLocal);
                if (response == "")
                {
                    Session["Exito"] = "Venta generada exitosamente!";
                    Response.Redirect("Exito.aspx");
                }
                else
                {
                    Session["Error"] = response;
                    Response.Redirect("Error.aspx");
                }
            }
            else
            {
                Alerta("Oops! No tienes ningun producto en tu lista de Venta!");
            }
        }
Ejemplo n.º 4
0
        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);
                }
            }
        }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            FavoritoNegocio favoritoNegocio = new FavoritoNegocio();
            VentaNegocio    ventaNegocio    = new VentaNegocio();

            try
            {
                usuario = (Usuario)Session["sesionUsuario"];

                if (usuario == null)
                {
                    Response.Redirect("Login.aspx");
                }

                listadoFavoritos = favoritoNegocio.Listar(usuario.IDFavorito);
                listadoVentas    = ventaNegocio.ListarVentasXUsuario(usuario.ID);


                txtBoxEmail.Text     = usuario.Contacto.Email;
                txtBoxUsuario.Text   = usuario.NombreUsuario;
                txtBoxDomicilio.Text = usuario.Contacto.Direccion.Calle + usuario.Contacto.Direccion.Numero;
                if (usuario.Contacto.Direccion.Piso != null)
                {
                    txtBoxDomicilio.Text += ", Piso: " + usuario.Contacto.Direccion.Piso;
                }
                if (usuario.Contacto.Direccion.Dpto != null)
                {
                    txtBoxDomicilio.Text += ". Dpto: " + usuario.Contacto.Direccion.Dpto;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 6
0
 private void BtnAnular_Click(object sender, EventArgs e)
 {
     if (dgvVentas.SelectedCells.Count > 0)
     {
         VentaNegocio           negV  = new VentaNegocio();
         ProductoVendidoNegocio negPV = new ProductoVendidoNegocio();
         Venta v = (Venta)dgvVentas.CurrentRow.DataBoundItem;
         try
         {
             using (var popup = new Confirmacion(@"anular la venta """ + v.ToString() + @""""))
             {
                 var R = popup.ShowDialog();
                 if (R == DialogResult.OK)
                 {
                     bool conf = popup.R;
                     if (v != null && conf == true)
                     {
                         negV.AnularVenta(v);
                         LlenarTabla();
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             Mensaje m = new Mensaje(ex.ToString()); m.ShowDialog();
         }
     }
     else
     {
         Mensaje m = new Mensaje("Ningun item seleccionado.");
         m.ShowDialog();
     }
 }
        void cargar()
        {
            VentaNegocio ventaNegocio = new VentaNegocio();

            listaVentas      = ventaNegocio.listarVentasEliminadas();
            tabla.DataSource = listaVentas;
            tabla.DataBind();
        }
Ejemplo n.º 8
0
        protected void btnRealizarCompra_Click(object sender, EventArgs e)
        {
            Usuario usuario = (Usuario)Session["userSession"];

            if ((List <ItemCarrito>)Session["carrito"] == null)
            {
                Session["error"] = "Error al intentar realizar la compra";
                Response.Redirect("Error.aspx");
            }
            else if (usuario == null)
            {
                Response.Redirect("IngresoUser.aspx", false);
            }
            else
            {
                carrito.listaItem = (List <ItemCarrito>)Session["carrito"];
                List <Venta> listaVentas  = new List <Venta>();
                Detalle      detalle      = new Detalle();
                Venta        venta        = new Venta();
                Produ        producto     = new Produ();
                VentaNegocio ventaNegocio = new VentaNegocio();
                venta.usuario      = new Usuario();
                detalle.idProducto = new Produ();
                detalle.idVenta    = new Venta();

                decimal totalCompra = carrito.SubTotal();
                venta.usuario.idUser = usuario.idUser;
                DateTime fechaCompra = DateTime.Now;
                venta.fecha     = fechaCompra;
                venta.formaPago = "1";
                ventaNegocio.AgregarVenta(venta);

                listaVentas = ventaNegocio.Listar();
                int idVenta = 0;

                foreach (var item in listaVentas)
                {
                    if (item.usuario.idUser == usuario.idUser)
                    {
                        idVenta = item.id;
                    }
                }
                venta.id = idVenta;

                foreach (var item in carrito.listaItem)
                {
                    detalle.precioUnitario     = item.producto.precio;
                    detalle.cantidad           = item.cantidad;
                    detalle.idProducto.idProdu = item.producto.idProdu;
                    detalle.idVenta.id         = idVenta;

                    ventaNegocio.AgregarDetalleVenta(detalle);
                }
                Response.Redirect("FinCompra.aspx");
            }
        }
Ejemplo n.º 9
0
        protected void btnSeguir_Click(object sender, EventArgs e)
        {
            Venta        venta      = new Venta();
            VentaNegocio negocio    = new VentaNegocio();
            List <Venta> listaVenta = new List <Venta>();
            Venta        aux        = new Venta();
            int          contador   = 0;

            cliente = (Usuario)Session[Session.SessionID + "Usuario"];
            if (Session[Session.SessionID + "Usuario"] == null)
            {
                Response.Redirect("Login.aspx");
            }
            if (cliente.direccion.Calle == "Sin datos")
            {
                Response.Redirect("AgregarDireccion.aspx");
            }
            else
            {
                venta.cliente = (Usuario)Session[Session.SessionID + "Usuario"];
                venta.carro   = (Carro)Session[Session.SessionID + "elemento"];
                venta.fecha   = DateTime.Now.Date;

                foreach (var item in venta.carro.Item)
                {
                    Articulo        producto        = new Articulo();
                    ArticuloNegocio negocioArticulo = new ArticuloNegocio();
                    producto = negocioArticulo.ListarArticulos().Find(k => k.Id == item.Id);
                    if (item.CantidadUnidades <= producto.Stock)
                    {
                        producto.Stock = producto.Stock - item.CantidadUnidades;
                        negocioArticulo.ModificarStockProducto(producto);
                        venta.producto = item;
                        if (contador == 0)
                        {
                            negocio.AgregarVenta(venta);
                            listaVenta = negocio.ListarVentas();

                            contador++;
                        }
                        aux      = listaVenta[listaVenta.Count - 1];
                        venta.Id = aux.Id;

                        negocio.AgregarProductos_Por_Ventas(venta);
                    }
                    else
                    {
                        Response.Redirect("Default.aspx");
                        break;
                    }
                }


                Response.Redirect("ClienteCompra.aspx");
            }
        }
Ejemplo n.º 10
0
        private void btnVerTodas_Click(object sender, EventArgs e)
        {
            VentaNegocio negocio = new VentaNegocio();

            ListalocalVentas = new List <Venta>();

            ListalocalVentas             = negocio.ListarVentas();
            dgvVentas.DataSource         = ListalocalVentas;
            dgvVentas.Columns[4].Visible = false;
        }
Ejemplo n.º 11
0
        private void cargarVentasHoy()
        {
            VentaNegocio negocio = new VentaNegocio();

            ListalocalVentas = new List <Venta>();

            ListalocalVentas             = negocio.ListarVentasHOY();
            dgvVentas.DataSource         = ListalocalVentas;
            dgvVentas.Columns[4].Visible = false;
        }
Ejemplo n.º 12
0
        private void btnModificar_Click(object sender, EventArgs e)
        {
            ProductoNegocio negocioP   = new ProductoNegocio();
            VentaNegocio    negocioV   = new VentaNegocio();
            MailNegocio     negocioM   = new MailNegocio();
            PedidoNegocio   negocioPed = new PedidoNegocio();

            local.Estado = cmbEstado.SelectedItem.ToString();
            if (local.Estado == "Entregado")
            {
                Venta ventaCombo = new Venta();
                ventaCombo.Detalle     = new List <DetalleVenta>();
                ventaCombo.Cliente     = local.Cliente;
                ventaCombo.Importe     = local.Combo.Precio;
                ventaCombo.Descripcion = local.Combo.Nombre;
                foreach (DetalleCombo item in local.Combo.Productos)
                {
                    DetalleVenta detalle = new DetalleVenta();
                    detalle.Cantidad       = item.Unidades;
                    detalle.Kilos          = item.Kilos;
                    detalle.Producto       = item.Producto;
                    detalle.PrecioUnitario = item.Producto.calcularPrecio();
                    detalle.PrecioParcial  = (detalle.PrecioUnitario * item.Unidades) + (detalle.PrecioUnitario * item.Kilos);
                    ventaCombo.Detalle.Add(detalle);
                    negocioP.descontarStock(item.Producto, item.Unidades, item.Kilos);
                }
                ventaCombo.Factura = new Factura();
                llenarFactura(ventaCombo, ventaCombo.Detalle);
                ventaCombo.ID = negocioV.agregarVenta(ventaCombo);
                foreach (DetalleVenta item in ventaCombo.Detalle)
                {
                    negocioV.agregarProductosXVenta(ventaCombo.ID, item.Producto.ID, item.Cantidad, item.Kilos);
                }
            }
            if (txtComentario.Enabled)
            {
                Cursor.Current = Cursors.WaitCursor;
                if (negocioM.mandarMail(local.Cliente.Mails[0].Direccion, local, txtComentario.Text))
                {
                    Cursor.Current = Cursors.Default;
                    MessageBox.Show("El mail ha sido enviado correctamente.", "Confirmación");
                    negocioPed.modificarPedido(local);
                }
                else
                {
                    if (MessageBox.Show("Hubo un error al enviar el mail.\n\nDesea modificar el pedido?", "Atención!", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        negocioPed.modificarPedido(local);
                    }
                }
            }
            Cursor.Current = Cursors.Default;
            this.Close();
        }
Ejemplo n.º 13
0
        private void btnListar_Click(object sender, EventArgs e)
        {
            btnFinalizar.Visible = false;
            VentaNegocio negocio = new VentaNegocio();

            dgvVentas.BringToFront();
            dgvVentas.Visible = true;
            listado           = negocio.listarVentas();
            listado.Reverse();
            dgvVentas.DataSource = listado;
            btnDetalles.Visible  = true;
        }
Ejemplo n.º 14
0
        public FrmVentas()
        {
            InitializeComponent();

            clienteNegocio  = new ClienteNegocio();
            empleadoNegocio = new EmpleadoNegocio();
            celularNegocio  = new CelularNegocio();
            tecladoNegocio  = new TecladoNegocio();
            ventaNegocio    = new VentaNegocio();

            Negocio.ListaVentas = new List <Venta>();
        }
Ejemplo n.º 15
0
        protected void btnGuardarVenta_Click(object sender, EventArgs e)
        {
            Venta        venta        = new Venta();
            VentaNegocio ventaNegocio = new VentaNegocio();

            venta.cliente      = new Cliente();
            venta.cliente.id   = Convert.ToInt64(ddlClientes.SelectedValue);
            venta.empleado     = new Empleado();
            venta.empleado.id  = Convert.ToInt64(ddlEmpleados.SelectedValue);
            venta.descripcion  = txbDesc.Text;
            venta.fechaPedido  = Convert.ToDateTime(txbPedido.Text);
            venta.fechaEntrega = Convert.ToDateTime(txbEntrega.Text);
            venta.estado       = (ddlEstados.SelectedValue).ToString();
            venta.formaPago    = (ddlFormaPago.SelectedValue).ToString();
            venta.detalle      = new List <DetalleVenta>();
            venta.detalle      = (Session["DetalleVenta"] as List <DetalleVenta>);
            venta.total        = Convert.ToDouble(txbTotal.Text);
            venta.seña         = Convert.ToDouble(txbSeña.Text);
            DetalleVentaNegocio detalleNeg = new DetalleVentaNegocio();

            if (venta.detalle != null)
            {
                int cantProductos = venta.detalle.Count; int cont = 0;
                foreach (DetalleVenta item in venta.detalle)
                {
                    detalleNeg.Agregar(item);
                    if (detalleNeg.VerificarStock(item))
                    {
                        cont++;
                    }
                }
                if (cont == cantProductos)
                {
                    venta.estado = ddlEstados.SelectedValue;
                }
                else
                {
                    venta.estado = "Pedido";
                }
                if (venta.estado.Equals("Entregado"))
                {
                    foreach (DetalleVenta item in venta.detalle)
                    {
                        detalleNeg.DisminuirStock(item);
                    }
                }
            }
            ventaNegocio.agregar(venta);
            Session["DetalleVenta"] = null;
            Session["Total"]        = null;
            Response.Redirect("NuevaVenta.aspx");
        }
Ejemplo n.º 16
0
        protected void agregar_Click(object sender, EventArgs e)
        {
            try
            {
                VentaNegocio   ventaNegocio = new VentaNegocio();
                FacturaNegocio facturaneg   = new FacturaNegocio();
                Venta          venta        = new Venta();
                venta = null;
                venta = ventaNegocio.BuscarxNumVenta(Convert.ToInt32(numero.Text));
                if (venta == null)
                {
                    venta                = new Venta();
                    venta.numeroVenta    = Convert.ToInt32(numero.Text);
                    venta.Fecha          = System.DateTime.Now;
                    venta.Cantidad       = Convert.ToInt32(cantidad.Text);
                    venta.Factura        = new Factura();
                    venta.Factura.Numero = Convert.ToInt32(factura.Text);
                    ClienteNegocio cnegocio = new ClienteNegocio();
                    venta.cliente          = new Cliente();
                    venta.cliente.Apellido = clientes.SelectedValue;
                    venta.cliente.DNI      = cnegocio.BuscarCodigo(clientes.SelectedValue);
                    venta.producto         = new Producto();
                    ProductoNegocio prodneg = new ProductoNegocio();
                    venta.producto.Nombre = producto.SelectedValue;
                    int Codigo = prodneg.buscarCodigo(producto.SelectedValue);
                    venta.producto        = prodneg.buscar(producto.SelectedValue);
                    venta.producto.Codigo = Codigo;
                    if (venta.Cantidad <= venta.producto.StockActual)
                    {
                        if (venta.producto.PorcentajeGanancia > 0)
                        {
                            venta.precio = (venta.producto.PrecioUnitario * venta.Cantidad) * (1 + venta.producto.PorcentajeGanancia);
                        }

                        venta.producto.StockActual = venta.producto.StockActual - venta.Cantidad;
                        prodneg.RestarStock(producto.SelectedValue, venta.producto.StockActual);
                        facturaneg.completarfactura(venta);
                        ventaNegocio.Vender(venta);
                        Response.Write("<script>alert('La venta se ha realizado correctamente.');</script>");
                    }
                    else
                    {
                        Response.Write("<script>alert('No hay stock suficiente para realizar la venta.');</script>");
                    }
                }
            }
            catch (Exception)
            {
                Session["Error" + Session.SessionID] = "Verifique que todos los campos esten completos.";
                Response.Redirect("PaginaError.aspx");
            }
        }
Ejemplo n.º 17
0
        private void btnSin_Click(object sender, EventArgs e)
        {
            VentaNegocio negocio = new VentaNegocio();

            try
            {
                local = negocio.ListarInformeBajas();
                dgvVentas.DataSource = local;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 18
0
        protected void btnActualizarEstado_Click(object sender, EventArgs e)
        {
            VentaNegocio ventaNegocio = new VentaNegocio();

            try
            {
                ventaNegocio.ActualizarEstado(venta.ID, Convert.ToInt32(dropDownEstado.SelectedValue));
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "modalActualizacion", "$('#modalActualizacion').modal();", true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 19
0
        private void cargarGrilla()
        {
            VentaNegocio negocio = new VentaNegocio();

            try
            {
                facturaLocal           = negocio.listarFacturas(Convert.ToInt64(txtId.Text));
                dgvFacturas.DataSource = facturaLocal;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 20
0
        private void GananciasHoy()
        {
            VentaNegocio negocio = new VentaNegocio();

            decimal totalRecaudacion;
            decimal Costos;

            totalRecaudacion = negocio.CalcularRecaudacionHOY();
            Costos           = negocio.traerCostoHOY();

            totalRecaudacion = totalRecaudacion - Costos;

            txtGananciasHoy.Text = totalRecaudacion.ToString();
        }
Ejemplo n.º 21
0
 private void btnAceptar_Click(object sender, EventArgs e)
 {
     if (txtFecha.Text == "")
     {
         MessageBox.Show("Debe seleccionar una fecha", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         VentaNegocio negocio = new VentaNegocio();
         ListalocalVentas             = new List <Venta>();
         ListalocalVentas             = negocio.listarVentasXFecha(txtFecha.Text);
         dgvVentas.DataSource         = ListalocalVentas;
         dgvVentas.Columns[4].Visible = false;
     }
 }
Ejemplo n.º 22
0
        private void BtnMod_Click(object sender, EventArgs e)
        {
            VentaNegocio           negV  = new VentaNegocio();
            ProductoVendidoNegocio negPV = new ProductoVendidoNegocio();

            try
            {
                if (v.IdVenta == 0)
                {
                    v.Cliente  = new Cliente();
                    v.Empleado = new Empleado();
                }

                v.Cliente    = (Cliente)BoxCliente.SelectedItem;
                v.Empleado   = (Empleado)BoxEmpleado.SelectedItem;
                v.FechaVenta = DateFecha.Value;
                v.Monto      = (float)Convert.ToDouble(TxtTotal.Text);

                if (v.IdVenta != 0)
                {
                    negV.Modificar(v);
                    negPV.EliminarProductosDeVenta(v.IdVenta);
                }
                else
                {
                    v.IdVenta = Convert.ToInt32(negV.Agregar(v));
                }

                foreach (ProductoVendido pv in v.LstProductosVendidos)
                {
                    pv.IdVenta = v.IdVenta;
                    pv.IdPxv   = negPV.Agregar(pv);
                    negPV.DescontarStock(pv);
                }

                Invoicer i = new Invoicer();
                i.Go(v);
                Mensaje m = new Mensaje("PDF Generado.");
                m.ShowDialog();

                this.Close();
            }
            catch (Exception ex)
            {
                Mensaje m = new Mensaje(ex.ToString()); m.ShowDialog();
            }
        }
Ejemplo n.º 23
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");
            }
        }
Ejemplo n.º 24
0
        private void btnIniciar_Click(object sender, EventArgs e)
        {
            int dniEmpleado, dniCliente;

            dniEmpleado = Convert.ToInt32(cboEmpleado.SelectedValue);
            dniCliente  = Convert.ToInt32(cboCliente.SelectedValue);
            VentaNegocio negocio = new VentaNegocio();

            txtId.Text          = negocio.IniciarVenta(dniEmpleado, dniCliente).ToString();
            cboCliente.Enabled  = false;
            cboEmpleado.Enabled = false;
            btnIniciar.Enabled  = false;
            txtCantidad.Enabled = true;
            btnAgregar.Enabled  = true;
            btnComprar.Enabled  = true;
            txtCantidad.Text    = "0";
        }
 private void Facturar()
 {
     try
     {
         VentaEntidad venta = FabricarCabecera();
         id_venta = VentaNegocio.GenerarVenta(venta);
         ProductoNegocio.ActualizarStock(venta.ListaDetalles);
         if (MessageBox.Show("Desea imprimir?", "FACTURA", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             ImprimirFactura();
         }
     }
     catch
     {
         MessageBox.Show("No se pudo generar la factura");
     }
 }
Ejemplo n.º 26
0
        protected void dgvVentas_SelectedIndexChanged(object sender, EventArgs e)
        {
            GridViewRow         gr         = dgvVentas.SelectedRow;
            DetalleVentaNegocio detNegocio = new DetalleVentaNegocio();
            VentaNegocio        ventaNeg   = new VentaNegocio();
            int id;

            id = Convert.ToInt32(dgvVentas.SelectedDataKey.Value.ToString());
            dgvDetalle.DataSource = detNegocio.Listar(id);
            dgvDetalle.DataBind();
            dgvDetalle.Visible   = true;
            dgvVentas.DataSource = ventaNeg.listar(id);
            dgvVentas.DataBind();
            Session["idCompra"] = id;
            CargarDetalle(id);
            btnAtras.Visible = true;
        }
Ejemplo n.º 27
0
        protected void Page_Load(object sender, EventArgs e)
        {
            VentaNegocio       ventaNegocio       = new VentaNegocio();
            CarritoUserNegocio carritoUserNegocio = new CarritoUserNegocio();
            UsuarioNegocio     usuarioNegocio     = new UsuarioNegocio();

            try
            {
                venta                   = ventaNegocio.Listar().Find(v => v.ID == Convert.ToInt64(Request.QueryString["ID"]));
                venta.Usuario           = usuarioNegocio.ListarClientes().Find(u => u.ID == venta.Usuario.ID);
                venta.Carrito.Productos = carritoUserNegocio.CargarListaCarrito(venta.Carrito.ID);
                listaProductos          = venta.Carrito.Productos;
            }
            catch (Exception)
            {
                Response.Redirect("Error.aspx");
            }
        }
Ejemplo n.º 28
0
        private void LlenarTabla()
        {
            VentaNegocio neg = new VentaNegocio();

            try
            {
                dgvVentas.DataSource = neg.Listar(activo, TxtBuscar.Text);
                dgvVentas.Columns["IdVenta"].HeaderText    = "ID";
                dgvVentas.Columns["FechaVenta"].HeaderText = "Fecha de Venta";
                dgvVentas.Columns["FechaRegistro"].Visible = false;
                dgvVentas.Columns["Activo"].Visible        = false;
                dgvVentas.Update();
                dgvVentas.Refresh();
            }
            catch (Exception ex)
            {
                Mensaje m = new Mensaje(ex.ToString()); m.ShowDialog();
            }
        }
Ejemplo n.º 29
0
        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;
            }
        }
Ejemplo n.º 30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    UsuarioNegocio  usuarioNegocio  = new UsuarioNegocio();
                    VentaNegocio    ventaNegocio    = new VentaNegocio();
                    ProductoNegocio productoNegocio = new ProductoNegocio();

                    listaUltimosUsuarios = usuarioNegocio.ListarUltimos();
                    listaUltimasVentas   = ventaNegocio.ListarUltimas();
                    listaMasVendidos     = productoNegocio.ListarMasVendidos();
                    listaMasLikeados     = productoNegocio.ListarMasLikeados();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }