Ejemplo n.º 1
0
        protected void Button_FinCompra(object sender, EventArgs e)
        {
            HttpCookie cookie = Request.Cookies["damncookie"];

            if (check_caducidad())
            {
                ENUser user = new ENUser(0, "", "", cookie["username"], new DateTime(), "", "", "");

                if (user.ReadID())
                {
                    ENCart    cart  = new ENCart(0, user.userID, 0.0F, 0);
                    DataTable table = cart.ReadCart();
                    ENOrder   order = new ENOrder(user.userID, "Preparando", paga, DateTime.Now);
                    if (order.CreateOrder())
                    {
                        for (int i = 0; i < table.Rows.Count; i++)
                        {
                            ENProduct p = new ENProduct(Convert.ToInt32(table.Rows[i][0].ToString()), "", 0.0F, 0, "", "", "", "");
                            if (p.ReadProductFromCatalog())
                            {
                                p.stock -= Convert.ToInt32(table.Rows[i][3].ToString());
                            }
                            p.UpdateProduct();
                        }

                        cart.DeleteCart();
                    }
                }



                Response.Redirect("Default.aspx");
            }
        }
Ejemplo n.º 2
0
        }//end page load

        protected void AddCartButton_Click(object sender, EventArgs e)
        {
            HttpCookie cookie = Request.Cookies["damncookie"];

            if (cookie != null)
            {
                ENProduct producto = new ENProduct(0, "", 0.0F, 0, "", "", "", "");
                ENUser    usuario  = new ENUser(0, "", "", cookie["username"], new DateTime(), "", "", "");

                producto.id = Convert.ToInt32(Request.QueryString["id"]);
                usuario.ReadID();

                if (producto.ReadProductFromCatalog())
                {
                    ENCart carrito = new ENCart(producto.id, usuario.userID, producto.price, Convert.ToInt32(ProdAmount.Text));

                    if (carrito.CreateCart())
                    {
                        ProductAddedLabel.Visible = true;
                    }
                }
            }
            else
            {
                Response.Redirect("Login.aspx");
            }
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie cookie = Request.Cookies["damncookie"];

            if (cookie != null)
            {
                ENUser user = new ENUser(0, "", "", cookie["username"], new DateTime(), "", "", "");
                if (user.ReadUserPerfil())
                {
                    Direccion.Text = user.address;
                }
                ENCart    cart  = new ENCart(0, 0, 0.0F, 0);
                DataTable table = cart.ReadCart();

                for (int i = 0; i < table.Rows.Count; i++)
                {
                    paga = float.Parse(table.Rows[i][3].ToString()) * float.Parse(table.Rows[i][4].ToString()) + paga;
                }

                TotalPrice.Text = Convert.ToString(paga) + "€";
            }
        }