Esempio n. 1
0
        protected void product_wishlist_Click(object sender, EventArgs e)
        {
            Button       btn   = (Button)sender;
            RepeaterItem rItem = (RepeaterItem)btn.NamingContainer;

            ArrayList wishlist = (ArrayList)Session["Wishlist"];

            if (wishlist == null)
            {
                wishlist = new ArrayList();
            }
            Label productIDLabel = (Label)rItem.FindControl("product_id");
            int   productID      = Int32.Parse(productIDLabel.Text);

            wishlist.Add(productID);
            byte[] byteWishlist = SerializeItem(wishlist);
            int    userID       = Int32.Parse(Session["UserID"].ToString());

            ItemActions pxy    = new ItemActions();
            int         result = pxy.StoreWishlist(userID, byteWishlist);

            if (result != -1)
            {
                Session["Wishlist"] = wishlist;
                Response.Write("<script>alert('Item was sucesffully added to wishlist')</script>");
            }
            else
            {
                Response.Write("<script>alert('Something went wrong when adding item to wishlist')</script>");
            }
        }
Esempio n. 2
0
        public void RebindWishlist()
        {
            ArrayList   wishlist      = (ArrayList)Session["Wishlist"];
            ItemActions pxy           = new ItemActions();
            ArrayList   wishlistItems = pxy.GetWishlistItems(wishlist);

            rpt_items_wishlist.DataSource = null;
            rpt_items_wishlist.DataSource = wishlistItems;
            rpt_items_wishlist.DataBind();
        }
Esempio n. 3
0
        protected void category_music_Click(object sender, EventArgs e)
        {
            int         userID       = Int32.Parse(Session["UserID"].ToString());
            ItemActions pxy          = new ItemActions();
            ArrayList   tempItemList = pxy.getCategoryItems(userID, "Music");

            rpt_Items.DataSource = null;
            rpt_Items.DataSource = tempItemList;
            rpt_Items.DataBind();
            rpt_Items.Visible = true;
        }
Esempio n. 4
0
        protected void category_householdItems_Click(object sender, EventArgs e)
        {
            int         userID       = Int32.Parse(Session["UserID"].ToString());
            ItemActions pxy          = new ItemActions();
            ArrayList   tempItemList = pxy.getCategoryItems(userID, "Household Items");

            rpt_Items.DataSource = null;
            rpt_Items.DataSource = tempItemList;
            rpt_Items.DataBind();
            rpt_Items.Visible = true;

            test_main.Style.Add("margin-top", "5%");
        }
Esempio n. 5
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            ItemActions pxy        = new ItemActions();
            int         userID     = Int32.Parse(Session["UserID"].ToString());
            string      searchTerm = searchTxt.Text;

            ArrayList array = pxy.GetSearchItems(userID, searchTerm);

            rpt_Items.DataSource = null;
            rpt_Items.DataSource = array;
            rpt_Items.DataBind();
            rpt_Items.Visible = true;
            test_main.Style.Add("margin-top", "5%");
        }
Esempio n. 6
0
        public void StoreWishlist(ArrayList wishlist)
        {
            BinaryFormatter serializer = new BinaryFormatter();
            MemoryStream    memStream  = new MemoryStream();

            serializer.Serialize(memStream, wishlist);
            byte[] byteListArray;
            byteListArray = memStream.ToArray();

            int userID = Int32.Parse(Session["UserID"].ToString());

            ItemActions pxy = new ItemActions();

            pxy.StoreWishlist(userID, byteListArray);
        }
Esempio n. 7
0
        protected void sell_itemSubmit_Click(object sender, EventArgs e)
        {
            Item        tempItem = getItemDetails();
            int         userID   = Int32.Parse(Session["UserID"].ToString());
            ItemActions pxy      = new ItemActions();
            int         result   = pxy.sellItem(userID, tempItem);

            if (result != -1)
            {
                Response.Write("Item Listed!");
            }
            else
            {
                Response.Write("Problem Occured When Listing Your Item");
            }
        }
Esempio n. 8
0
        protected void profile_selling_Click(object sender, EventArgs e)
        {
            profile_subhead.Text       = "Selling";
            SellItem.Visible           = false;
            rpt_items_wishlist.Visible = false;
            rpt_items_other.Visible    = true;


            int         userID       = Int32.Parse(Session["UserID"].ToString());
            ItemActions pxy          = new ItemActions();
            ArrayList   sellingItems = pxy.GetSellingItems(userID);

            rpt_items_other.DataSource = null;
            rpt_items_other.DataSource = sellingItems;
            rpt_items_other.DataBind();
            rpt_items_other.Visible = true;
        }
Esempio n. 9
0
        public void FillPlaceholder()
        {
            ArrayList cart = new ArrayList();

            cart = (ArrayList)Session["Cart"];
            if (cart.Count > 0)
            {
                checkout_items_placeholder.Controls.Clear();

                Table tblRecords = new Table();
                checkout_items_placeholder.Controls.Add(tblRecords);

                ItemActions pxy        = new ItemActions();
                ArrayList   cartItems  = pxy.GetCartItems(cart);
                Decimal     totalPrice = 0;

                checkout_cart_header.Text = "Cart(" + cartItems.Count + ")";

                for (int i = 0; i < cartItems.Count; i++)
                {
                    Item tempItem = (Item)cartItems[i];

                    TableRow  row          = new TableRow();
                    TableCell productName  = new TableCell();
                    TableCell productPrice = new TableCell();

                    productName.Text  = tempItem.Name;
                    productPrice.Text = "$" + tempItem.Price.ToString();

                    totalPrice += tempItem.Price;

                    row.Cells.Add(productName);
                    row.Cells.Add(productPrice);

                    tblRecords.Rows.Add(row);
                }
                checkout_price.Text = "$" + totalPrice.ToString();
            }
            else
            {
                Response.Write("<script>alert('Cart is empty')</script>");
            }
        }
Esempio n. 10
0
        protected void checkout_submit_Click(object sender, EventArgs e)
        {
            int         userID = Int32.Parse(Session["UserID"].ToString());
            ArrayList   cart   = (ArrayList)Session["Cart"];
            ItemActions pxy    = new ItemActions();
            int         result = pxy.BuyItems(userID, cart);

            if (result == -1)
            {
                Response.Write("<script>alert('Something went wrong when ordering')</script>");
            }
            else if (result == 1)
            {
                ArrayList wishlist = (ArrayList)Session["Wishlist"];
                for (int i = 0; i < wishlist.Count; i++)
                {
                    for (int b = 0; b < cart.Count; b++)
                    {
                        if ((int)wishlist[i] == (int)cart[b])
                        {
                            wishlist.RemoveAt(i);
                        }
                    }
                    Session["Wishlist"] = wishlist;
                    StoreWishlist(wishlist);
                }
                cart.Clear();
                Session["Cart"] = cart;
                StoreCart(cart);
                Response.Redirect("Home.aspx");
            }
            else
            {
                Response.Write("<script>alert('Some items did not get checked out, modifying cart')</script>");
                for (int i = 0; i < result; i++)
                {
                    cart.RemoveAt(i);
                }
                Session["Cart"] = cart;
                StoreCart(cart);
            }
        }
Esempio n. 11
0
        public void Refresh()
        {
            rpt_Items.Visible = false;

            ArrayList cartlist = (ArrayList)Session["Cart"];

            if (cartlist == null)
            {
                Response.Write("Nothing is in your cart.");
            }
            else
            {
                ItemActions pxy       = new ItemActions();
                ArrayList   cartItems = pxy.GetCartItems(cartlist);
                rpt_Items.DataSource = null;
                rpt_Items.DataSource = cartItems;
                rpt_Items.DataBind();

                rpt_Items.Visible = true;
            }
        }
Esempio n. 12
0
        public void GetCreditCard()
        {
            int         userID   = Int32.Parse(Session["UserID"].ToString());
            ItemActions pxy      = new ItemActions();
            User        tempUser = pxy.GetCreditCard(userID);
            User        keyUser  = pxy.GetKeyVector(userID);

            Byte[] key    = keyUser.Key;
            Byte[] vector = keyUser.Vector;

            CreditCard tempCredit = DeserializeObject(tempUser.CreditCard);

            checkout_credit_name.Text = DecryptField(tempCredit.CreditName, key, vector);
            checkout_credit_num.Text  = DecryptField(tempCredit.CreditNum, key, vector);
            checkout_credit_cvv.Text  = DecryptField(tempCredit.Cvv, key, vector);
            string expirationDate = DecryptField(tempCredit.ExpirationDate, key, vector);

            String[] expirationDateArray = expirationDate.Split('/');

            checkout_payment_month.SelectedValue = expirationDateArray[0];
            checkout_payment_year.SelectedValue  = expirationDateArray[1];
        }
Esempio n. 13
0
        protected void profile_wishlist_Click(object sender, EventArgs e)
        {
            rpt_items_other.Visible = false;
            profile_subhead.Text    = "Wishlist";
            SellItem.Visible        = false;

            ArrayList wishlist = (ArrayList)Session["Wishlist"];

            if (wishlist == null)
            {
                Response.Write("Nothing is in wishlist");
            }
            else
            {
                ItemActions pxy           = new ItemActions();
                ArrayList   wishlistItems = pxy.GetWishlistItems(wishlist);
                rpt_items_wishlist.DataSource = null;
                rpt_items_wishlist.DataSource = wishlistItems;
                rpt_items_wishlist.DataBind();
                rpt_items_wishlist.Visible = true;
            }
        }