Esempio n. 1
0
        protected void cartClick(Object Sender, EventArgs e)
        {
            //whichever button is clicked with id = SKU
            Button theButton = (Button)Sender;

            int id = int.Parse(theButton.ID);

            ItemTier tier = new ItemTier();
            Item     item = tier.getItemByID(id);
            //create cart list
            List <Item> cart;


            //if empty session, create new list item
            if (Session["cart"] == null)
            {
                cart = new List <Item>();

                //add the item to the list
                cart.Add(item);

                //prevent this from being null which will empty your old list
                Session["cart"] = cart;

                Response.Write("<script>alert('Item added to cart')</script>");
            }
            //else open session where current list is and assign as current list
            else
            {
                bool exists = false;
                cart = (List <Item>)Session["cart"];
                for (int i = 0; i < cart.Count(); i++)
                {
                    if (id == cart[i].SKU)
                    {
                        exists = true;
                    }
                }

                if (exists == true)
                {
                    Response.Write("<script>alert('Item is already in cart')</script>");
                }
                else
                {
                    //add the item to the list
                    cart.Add(item);
                    Response.Write("<script>alert('Item added to cart')</script>");
                }

                //prevent this from being null which will empty your old list
                Session["cart"] = cart;
            }
        }
Esempio n. 2
0
        /*private void GetControl(ControlCollection controls)
         * {
         *  foreach (Control ctrl in controls)
         *  {
         *      Item item = new Item();
         *      if (ctrl.ID == item.SKU.ToString())
         *      {
         *          e = (Button)ctrl;
         *      }
         *
         *      if (ctrl.Controls != null)
         *          // call recursively this method to search nested control for the button
         *          GetControl(ctrl.Controls);
         *  }
         *
         * }
         *
         * protected void cartClick(Object Sender, EventArgs e)
         * {
         *  Button theButton = (Button)Sender;
         *
         * }*/

        protected void editClick(Object Sender, EventArgs e)
        {
            //whichever button is clicked with id = SKU
            Button theButton = (Button)Sender;

            int id = int.Parse(theButton.ID);

            ItemTier tier = new ItemTier();
            Item     item = tier.getItemByID(id);


            Session["ItemInfo"] = (Item)Session["ItemInfo"];
            Session["ItemInfo"] = item;

            //Redirect to edit page
            Response.Redirect("EditItem.aspx");
        }
Esempio n. 3
0
        protected void recClick(Object Sender, EventArgs e)
        {
            Button theButton = (Button)Sender;
            int    id        = int.Parse(theButton.ID);

            ItemTier tier = new ItemTier();
            Item     item = tier.getItemByID(id);

            ItemTier itemTier = new ItemTier();

            itemTier.itemRec(id, qty);
            OrderTier ordTier = new OrderTier();

            ordTier.orderRec(orderno);

            Session["OrderInfo"] = null;

            //Redirect to edit page
            Response.Redirect("PendingOrders.aspx");
        }
Esempio n. 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserID"] != null)
            {
                Users me = (Users)Session["UserID"];

                SaleTier    theTier = new SaleTier();
                List <Sale> sales   = theTier.getUserPurchase(me.user_id);
                if (sales == null)
                {
                    lblPurch.Text = "No items to display.";
                }
                else
                {
                    lblPurch.Text = " ";
                    Table theTable = null;
                    foreach (Sale order in sales)
                    {
                        Sale s = new Sale();
                        s.sales_no             = order.sales_no;
                        s.SKU                  = order.SKU;
                        s.user_id              = order.user_id;
                        Session["MyPurchases"] = s;

                        ItemTier aTier = new ItemTier();
                        Item     items = aTier.getItemByID(s.SKU);

                        //foreach (Item item in items)
                        //{
                        theTable = getItemTable(items);
                        pnlOut.Controls.Add(theTable);
                        //}
                    }
                }
            }
            else
            {
                Response.Redirect("UserProductList.aspx");
            }
        }
Esempio n. 5
0
        protected void ordClick(Object Sender, EventArgs e)
        {
            //whichever button is clicked with id = SKU
            Button theButton = (Button)Sender;
            int    id        = int.Parse(theButton.ID);

            ItemTier tier = new ItemTier();
            Item     item = tier.getItemByID(id);
            //create cart list
            List <Item> cart = (List <Item>)Session["cart"];

            if (Session["cart"] == null)
            {
                cart = new List <Item>();
            }
            else
            {
                for (int i = 0; i < cart.Count(); i++)
                {
                    if (cart[i].SKU == id)
                    {
                        cart = (List <Item>)Session["cart"];
                        //comments similar to userproductlist.aspx except this one removes
                        cart.RemoveAt(i);

                        Session["cart"] = null;

                        //count = -1;

                        Session["cart"] = cart;
                    }
                }
            }

            //Redirect to same page / refresh
            Response.Redirect("Cart.aspx");
        }