コード例 #1
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");
            }
        }
コード例 #2
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;
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                ventasList = ventaNegocio.ListarVentas();
                if (!IsPostBack)
                {
                    dgvVentas.DataSource = ventasList;
                    dgvVentas.DataBind();
                    foreach (var user in ventasList)
                    {
                        if (aux != user.nombreUsuario)
                        {
                            aux = user.nombreUsuario;
                            if (!(usuariosList.Exists(k => k == aux)))
                            {
                                usuariosList.Add(aux);
                            }
                        }
                    }
                    ddlUsuario.Items.Add("--- Filtra por Username ---");
                    ddlUsuario.AppendDataBoundItems = true;
                    ddlUsuario.DataSource           = usuariosList;
                    ddlUsuario.DataBind();
                    ddlEstado.Items.Add("--- Filtrar por Estado ---");
                    ddlEstado.AppendDataBoundItems = true;
                    ddlEstado.Items.Add("Pendiente de Pago");
                    ddlEstado.Items.Add("Envio en Curso");
                    ddlEstado.Items.Add("Transaccion Completa");
                    ddlEstado.DataBind();
                    foreach (var item in ventasList)
                    {
                        cont++;
                    }
                    while (indexEstado < cont)
                    {
                        switch (dgvVentas.Rows[indexEstado].Cells[5].Text)
                        {
                        case "0":
                        {
                            dgvVentas.Rows[indexEstado].Cells[5].Text = "Pendiente de Pago";
                            break;
                        }

                        case "1":
                        {
                            dgvVentas.Rows[indexEstado].Cells[5].Text = "Envio en Curso";
                            break;
                        }

                        case "2":
                        {
                            dgvVentas.Rows[indexEstado].Cells[5].Text = "Transaccion Completa";
                            break;
                        }
                        }
                        indexEstado++;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }