Exemplo n.º 1
0
        public void AddItem(CartItem item)
        {
            if (Items.Contains(item))
                return;

            Items.Add(item);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            LabelError.Text = "Products";
            string orderID = Request.QueryString["orderID"];

            if (orderID != null)
            {
                string connString = ConfigurationManager.ConnectionStrings["ShoppingCartConnectionString"].ConnectionString;
                using (SqlConnection conn = new SqlConnection(connString))
                {
                    SqlCommand com = new SqlCommand("DisplayOrderDetails", conn);
                    com.CommandType = System.Data.CommandType.StoredProcedure;
                    com.Parameters.Add(new SqlParameter("@OrderID", orderID.ToString()));

                    try
                    {
                        conn.Open();
                        SqlDataReader reader = com.ExecuteReader();
                        reader.Read();

                        lblOrderID.Text     = orderID.ToString();
                        lblOrderDate.Text   = reader["OrderDate"].ToString();
                        lblOrderStatus.Text = reader["OrderStatus"].ToString();

                        lblCustName.Text = reader["FirstName"].ToString() + " " + reader["LastName"].ToString();
                        lblCustAddr.Text = reader["CustAddress"].ToString() + "<br />" +
                                           reader["City"].ToString() + "," + reader["Province"].ToString() + "<br /> " +
                                           reader["PostalCode"].ToString() + "<br />";
                        lblCustPhone.Text   = reader["CustPhone"].ToString();
                        lblCustEmail.Text   = reader["CustEmail"].ToString();
                        lblPaymentType.Text = reader["PaymentType"].ToString();
                        lblTotal.Text       = (Convert.ToDecimal(reader["OrderTotal"])).ToString("C");

                        conn.Close();

                        SqlCommand com2 = new SqlCommand("DisplayOrderItems", conn);
                        com2.CommandType = System.Data.CommandType.StoredProcedure;
                        com2.Parameters.Add(new SqlParameter("@OrderID", orderID.ToString()));

                        conn.Open();
                        SqlDataReader   reader2       = com2.ExecuteReader();
                        List <CartItem> OrderItemList = new List <CartItem>();

                        while (reader2.Read())
                        {
                            CartItem Item = new CartItem();
                            Item.prod_id   = Convert.ToInt32(reader2["ItemProdID"]);
                            Item.prod_name = reader2["ItemProdName"].ToString();
                            Item.quantity  = Convert.ToInt32(reader2["ItemQuantity"]);
                            Item.price     = Convert.ToDecimal(reader2["ItemProdPrice"]);
                            Item.subtotal  = Item.quantity * Item.price;
                            OrderItemList.Add(Item);
                        }
                        conn.Close();


                        GridView1.DataSource = OrderItemList;
                        GridView1.DataBind();
                    }
                    catch (SqlException ex)
                    {
                        LabelError.Text = ex.ToString();
                    }
                }
            }
        }
Exemplo n.º 3
0
 public void RemoveItem(CartItem item)
 {
     Items.Remove(item);
 }
Exemplo n.º 4
0
 public virtual void Add(CartItem cartItem)
 {
     _cartItems.Add(cartItem);
 }
Exemplo n.º 5
0
        public void AddItem(Item item, int quantity)
        {
            CartItem c = new CartItem(item, quantity);

            cartItems.Add(c);
        }
Exemplo n.º 6
0
 public void SetUp()
 {
     _quantity = 2;
     _description = "Test Description";
     _unitPrice = 1.00m;
     _itemPrice = 2.00m;
     _newQuantity = 3;
     _discountAmount = 1.00m;
     _largeDiscount = 3.00m;
     _zero = 0m;
     _item = new CartItem(_quantity, _description, _unitPrice);
 }
Exemplo n.º 7
0
 public static void RemoveItem(CartItem ci)
 {
     Provider.Remove(ci);
 }
Exemplo n.º 8
0
 public static void AddItem(CartItem ci)
 {
     Provider.Add(ci);
 }
Exemplo n.º 9
0
 public void SetUp()
 {
     _cart = new Cart();
     _cartItem = new CartItem(2, "Test", 1.00m); // 2.00m
     _cartItem2 = new CartItem(3, "Test2", 2.00m); //6.00m
 }
Exemplo n.º 10
0
 public void Add(CartItem processor)
 {
     processor.level = Count++;
     list.Add(processor);
 }