Пример #1
0
        private void itemList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            itemNameLabel.Visible   = true;
            priceLabel.Visible      = true;
            qtyLabel.Visible        = true;
            qtyTextBox.Visible      = true;
            qtyTextBox.Text         = "";
            addToCartButton.Visible = true;
            stockLabel.Visible      = true;

            var    row = itemList.Rows[(itemList.SelectedCells[0].RowIndex)];
            string id  = row.Cells[0].Value.ToString();

            selectedItem = db.PRODUCTs.Single(p => p.prodID.ToString() == id);

            itemNameLabel.Text = selectedItem.prodName;
            priceLabel.Text    = string.Format("{0:C}", selectedItem.prodPrice);

            if (selectedItem.prodStock <= 0)
            {
                stockLabel.ForeColor = Color.Red;
                stockLabel.Text      = "Out of Stock";
            }
            else if (selectedItem.prodStock >= 20)
            {
                stockLabel.ForeColor = Color.ForestGreen;
                stockLabel.Text      = "In Stock 20+";
            }
            else
            {
                stockLabel.ForeColor = Color.ForestGreen;
                stockLabel.Text      = "In Stock";
            }
        }
 public void RemoveFromCart(PRODUCT p)
 {
     if (cartItems.ContainsKey(p))
     {
         cartTotal -= (p.prodPrice ?? 0) * cartItems[p];
         cartItems.Remove(p);
     }
 }
Пример #3
0
        private void removeItemButton_Click(object sender, EventArgs e)
        {
            string  id       = cartItemsDisplay.Rows[selectedCartRowIndex].Cells[0].Value.ToString();
            PRODUCT cartItem = db.PRODUCTs.FirstOrDefault(p => p.prodID == int.Parse(id)) ?? null;

            if (cartItem != null)
            {
                account.RemoveFromCart(cartItem);
                UpdateCartTabData();
            }
        }
 public void AddToCart(PRODUCT p, int qty)
 {
     if (cartItems.ContainsKey(p))
     {
         cartItems[p] += qty;
     }
     else
     {
         cartItems.Add(p, qty);
     }
     cartTotal += (p.prodPrice ?? 0) * qty;
 }
Пример #5
0
        private void cartItemsDisplay_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            selectedCartRowIndex      = e.RowIndex;
            cartItemNameLabel.Visible = true;
            removeItemButton.Visible  = true;

            string  id   = cartItemsDisplay.Rows[e.RowIndex].Cells[0].Value.ToString();
            PRODUCT prod = db.PRODUCTs.FirstOrDefault(p => p.prodID == int.Parse(id));

            cartItemNameLabel.Text  = cartItemsDisplay.Rows[e.RowIndex].Cells[1].Value.ToString();
            cartItemPriceLabel.Text = "Price: " + string.Format("{0:C}", prod.prodPrice);
            cartItemQtyLabel.Text   = "Quantity: " + cartItemsDisplay.Rows[e.RowIndex].Cells[2].Value.ToString();
        }
Пример #6
0
 partial void DeletePRODUCT(PRODUCT instance);
Пример #7
0
 partial void UpdatePRODUCT(PRODUCT instance);
Пример #8
0
 partial void InsertPRODUCT(PRODUCT instance);