예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (!WebProfile.Current.IsAnonymous)
                {
                    cart = WebProfile.Current.Cart;
                    btn_SaveToProfile.Visible = true;

                    Repeater_cart.DataSource = cart.Items;
                    Repeater_cart.DataBind();

                    LoadProfileValues();

                    //Loads cartstatus
                    Label lbl_Cart = (Label)Master.FindControl("lbl_CartStatus");
                    if (lbl_Cart != null)
                    {
                        lbl_Cart.Text = WebProfile.Current.Cart.TotalPrice + "kr";
                    }
                }
                else
                {
                    btn_SaveToProfile.Visible = false;
                }
            }
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //cart = new ShoppingCart();
                cart = new ShoppingCart();

                if (!WebProfile.Current.IsAnonymous)
                {
                    cart = WebProfile.Current.Cart;

                    //Loads all values into the repeater
                    Repeater_cart.DataSource = cart.Items;
                    Repeater_cart.DataBind();

                    //LoadProfileValues();  //is not used anymore
                    lbl_TotalPrice.Text = cart.TotalPrice + "kr";
                    Label lbl_Cart = (Label)Master.FindControl("lbl_CartStatus");
                    if (lbl_Cart != null)
                    {
                        lbl_Cart.Text = cart.TotalPrice + "kr";
                    }

                    //If cart is empty, just hide button to go forth
                    if (cart.Items.Count > 0)
                    {
                        btn_CheckForOrder.Visible = true;
                    }
                    else
                    {
                        btn_CheckForOrder.Visible = false;
                    }
                }
                else
                {
                    ShoppingCart cartFromProduct = new ShoppingCart();
                    cartFromProduct = (ShoppingCart)Session["Cart"];

                    Label lbl_Cart = (Label)Master.FindControl("lbl_CartStatus");
                    if (lbl_Cart != null && cartFromProduct != null)
                    {
                        lbl_Cart.Text = cartFromProduct.TotalPrice + "kr";

                        Repeater_cart.DataSource = cartFromProduct.Items;
                        Repeater_cart.DataBind();
                    }
                }
            }
        }