Exemple #1
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (!string.IsNullOrWhiteSpace(Request.QueryString["id"]))
        {
            string userID = Context.User.Identity.GetUserId();

            if (userID != null)
            {
                int id     = Convert.ToInt32(Request.QueryString["id"]);
                int amount = Convert.ToInt32(ddlAmt.SelectedValue);

                Cart cart = new Cart

                {
                    Amount        = amount,
                    ClientID      = userID,
                    DatePurchased = DateTime.Now,
                    IsInCart      = true,
                    ProductID     = id
                };

                Cart_Model type = new Cart_Model();
                lblResults.Text = type.InsertCart(cart);
            }
            else
            {
                lblResults.Text = "Please log in to continue to order items";
            }
        }
    }
Exemple #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        List <Cart> carts = (List <Cart>)Session[User.Identity.GetUserId()];

        Cart_Model model = new Cart_Model();

        model.RecordOrdersAsPaidfor(carts);

        Session[User.Identity.GetUserId()] = null;
    }
Exemple #3
0
    private void Remove_Product(object sender, EventArgs e)
    {
        LinkButton highlightedLink = (LinkButton)sender;
        string     link            = highlightedLink.ID.Replace("no", "");
        int        cartId          = Convert.ToInt32(link);

        Cart_Model removemodel = new Cart_Model();

        removemodel.DeleteCart(cartId);

        Response.Redirect("~/Pages/Trolley.aspx");
    }
Exemple #4
0
    private void dropdownlistAmnt_SelectdIndxChang(object sender, EventArgs e)
    {
        //id of item that has quantity changed in ddl list
        DropDownList quantityList = (DropDownList)sender;
        int          cartId       = Convert.ToInt32(quantityList.ID);
        int          cartquantity = Convert.ToInt32(quantityList.SelectedValue);

        //Update purchase with new quantity and refresh page
        Cart_Model updatecart = new Cart_Model();

        updatecart.UpdateCartQuantity(cartId, cartquantity);
        Response.Redirect("~/Pages/Trolley.aspx");
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        lblShare.Text = "<a name=\"fb_share\" type=\"button\"></a>" +
                        "<script " +
                        "src=\"http://static.ak.fbcdn.net/connect.php/js/FB.Share\" " +
                        "type=\"text/javascript\"></script>";
        HtmlMeta tag = new HtmlMeta();

        tag.Name    = "title";
        tag.Content = "This is the page title";
        Page.Header.Controls.Add(tag);
        HtmlMeta tag1 = new HtmlMeta();

        tag.Name    = "description";
        tag.Content = "This is a page description.";
        Page.Header.Controls.Add(tag1);



        //////////////////////////////////////////////////////////////////////////
        var loggeduser = Context.User.Identity;

        if (loggeduser.IsAuthenticated)

        {
            linklogin.Visible    = false;
            linkRegister.Visible = false;

            literalstat.Visible   = true;
            btnLinklogout.Visible = true;

            Cart_Model model  = new Cart_Model();
            string     userId = HttpContext.Current.User.Identity.GetUserId();
            literalstat.Text = string.Format("{0} ({1})", Context.User.Identity.Name,
                                             model.ObtainAmtofOrders(userId));
        }
        else
        {
            linklogin.Visible    = true;
            linkRegister.Visible = true;

            literalstat.Visible   = false;
            btnLinklogout.Visible = false;
        }
    }
Exemple #6
0
    private void PullallSalestoTrolley(string userId)
    {
        //create page for each item in orderlist
        Cart_Model type     = new Cart_Model();
        double     AmtTotal = 0;

        List <Cart> orderList = type.ObtainCartOrders(userId);

        OrganiseCartWindow(orderList, out AmtTotal);

        //add amtTotal to page .. remember sumtotal is the total amt..
        // AmtTotal is just an amout for The item
        double tax      = AmtTotal * 0.2;
        double sumTotal = AmtTotal + tax + 20;

        //show total amt with a literal
        literaltot.Text    = "£" + AmtTotal;
        literalVat.Text    = "£" + tax;
        literalTotAmt.Text = "£" + sumTotal;
    }