Beispiel #1
0
        public void Add(BuyableItem newItem)
        {
            bool itemAlreadyInBasket = false;

            foreach (BuyableItem item in content)
            {
                if (item.category == newItem.category && item.color == newItem.color && item.size == newItem.size)
                {
                    DialogResult result = MessageBox.Show("A bike with these features already exists. Do you still want to add it to basket?", "Cart Info", MessageBoxButtons.YesNo);
                    if (result == DialogResult.Yes)
                    {
                        item.quantity += newItem.quantity;
                        Console.WriteLine("Quantity Updated Successfully!");
                    }
                    itemAlreadyInBasket = true;
                    break;
                }
            }
            if (!itemAlreadyInBasket)
            {
                content.Add(newItem);
                Console.WriteLine("Item Added successfully!");
            }
            UpdateTotalItems();
            UpdateDeliveryTime();
            UpdatePrice();
        }
Beispiel #2
0
 private void removeBtn_Click(object sender, EventArgs e, BuyableItem item)
 {
     Bovelo.order.Remove(item);
     //MessageBox.Show("Item Removed");
     this.StatusLabel1.Text = "Item Removed";
     UpdateForm();
     CheckEmptyCart();
 }
Beispiel #3
0
 public void Remove(BuyableItem buyableItem)
 {
     content.Remove(buyableItem);
     Console.WriteLine("Item Removed");
     UpdateTotalItems();
     UpdateDeliveryTime();
     UpdatePrice();
 }
 private void addBasket_button(object sender, EventArgs e)
 {
     if (category_chosen != null && color_chosen != null && size_chosen != null && quantity_chosen >= 1)
     {
         BuyableItem newItem = new BuyableItem(category_chosen, color_chosen, size_chosen, quantity_chosen);
         Bovelo.order.Add(newItem);
     }
     else
     {
         MessageBox.Show("Not all features were selected");
     }
 }
Beispiel #5
0
 private void button_save_Click(object sender, EventArgs e)
 {
     if (comboBox_bike.SelectedItem != null && comboBox_color.SelectedItem != null && comboBox1.SelectedItem != null)
     {
         DialogResult result = MessageBox.Show($"Do you want to add {numericUpDown1.Value} {comboBox_color.Text} {comboBox_bike.Text} bike(s), size {comboBox1.Text} to the production ?", "Add to stocks", MessageBoxButtons.YesNo);
         if (result == DialogResult.Yes)
         {
             BuyableItem bike = new BuyableItem(comboBox_bike.Text, comboBox_color.Text, comboBox1.Text, Convert.ToInt32(numericUpDown1.Value));
             stock_order.Add(bike);
             stock_order.totalPrice = 0;
             stock_order.Save();
             add_to_Stock(Convert.ToInt32(numericUpDown1.Value)); //uses stocked procedure
             stock_order.client = get_stock_Client();             //Save method deletes current client
         }
         else
         {
         }
     }
 }
Beispiel #6
0
        private void quantity_scroll(object sender, EventArgs e, BuyableItem item)
        {
            NumericUpDown quantityBtn = sender as NumericUpDown;
            int           newQuantity = Decimal.ToInt32(quantityBtn.Value);

            if (newQuantity == 0)
            {
                Bovelo.order.Remove(item);
                //MessageBox.Show("Item Removed");
                this.StatusLabel1.Text = "Item Removed";
                UpdateForm();
            }
            else
            {
                item.quantity = newQuantity;
                //MessageBox.Show("New item quantity : " + item.quantity.ToString());
                this.StatusLabel1.Text = "New item quantity : " + item.quantity.ToString();
                Bovelo.order.UpdatePrice();
                showPrice();
                showDeliveryDate();
            }
            CheckEmptyCart();
        }