コード例 #1
0
        public void addToCart(int productId, decimal unitPrice, string productName, float productWeight)
        {
            // Get the matching cart and product instances
            if (items.Count() != 0)
            {
                var currentNode = items.First;
                while (currentNode != null)
                {
                    if (currentNode.Value.productId == productId)
                    {
                        currentNode.Value.count++;
                        currentNode.Value.setTotalPriceAndWeight();
                        break;
                    }

                    else
                    {
                        currentNode = currentNode.Next;
                        if (currentNode == null)
                        {
                            CartItem newItem = new CartItem(productId, unitPrice, productName, productWeight);
                            newItem.setTotalPriceAndWeight();
                            items.AddFirst(newItem);
                            break;
                        }
                    }
                }
            }

            else
            {
                CartItem newItem = new CartItem(productId, unitPrice, productName, productWeight);
                newItem.setTotalPriceAndWeight();
                items.AddFirst(newItem);
            }
        }
コード例 #2
0
ファイル: Order.cs プロジェクト: AistisT/WhiskyGaloreShop
        public void completeOrderProductContent(CartItem item)
        {
            using (MySqlConnection con = new MySqlConnection(con_str))
            {

                con.Open();
                using (MySqlCommand cmd = new MySqlCommand("completeOrderProduct", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    //Get TIMEstamp

                    cmd.Parameters.AddWithValue("@timeStamper", timeStamp);

                    //params for orderProduct
                    cmd.Parameters.AddWithValue("@product_productId", item.productId);
                    cmd.Parameters.AddWithValue("@units", item.count);
                    cmd.Parameters.AddWithValue("@price", item.totalPrice);
                    cmd.Parameters.AddWithValue("@weight", item.totalWeight);
                    cmd.Parameters.AddWithValue("@Shippers_shippersId", shippersId);

                    cmd.ExecuteNonQuery();

                    con.Close();
                }
            }
        }