Exemplo n.º 1
0
        protected void RemoveSelected(object sender, GridViewDeleteEventArgs e)
        {
            ArrayList cartList = (ArrayList)Session["cartList"];

            GridViewRow row = (GridViewRow)CartGrid.Rows[e.RowIndex];

            String name = row.Cells[0].Text;
            //String name = (string)CartGrid.DataKeys[e.RowIndex].Value;
            //String name = CartGrid.SelectedRow.Cells[1].Text;
            product temp = null;

            foreach (product p in cartList)
            {
                if (p.product_name.Equals(name))
                {
                    temp = p;
                }
            }

            if (temp != (null))
            {
                cartList.Remove(temp);
                Calc_Total();
            }


            CartGrid.DataBind();
        }
Exemplo n.º 2
0
        public List <Models.CartItem> UpdateCartItems()
        {
            using (Logic.ShoppingCartActions usersShoppingCart = new Logic.ShoppingCartActions())
            {
                string cartId = usersShoppingCart.GetCartId();

                Logic.ShoppingCartActions.ShoppingCartUpdates[] cartUpdates = new Logic.ShoppingCartActions.ShoppingCartUpdates[CartGrid.Rows.Count];
                for (int i = 0; i < CartGrid.Rows.Count; i++)
                {
                    //IOrderedDictionary rowValues = new OrderedDictionary();
                    IOrderedDictionary rowValues = GetValues(CartGrid.Rows[i]);
                    cartUpdates[i].ProductId = Convert.ToInt32(rowValues["ProductID"]);

                    //CheckBox cbRemove = new CheckBox();
                    CheckBox cbRemove = (CheckBox)CartGrid.Rows[i].FindControl("Remove");
                    cartUpdates[i].RemoveItem = cbRemove.Checked;

                    //TextBox quantityTextBox = new TextBox();
                    TextBox quantityTextBox = (TextBox)CartGrid.Rows[i].FindControl("PurchaseQuantity");
                    cartUpdates[i].PurchaseQuantity = Convert.ToInt16(quantityTextBox.Text.ToString());
                }
                usersShoppingCart.UpdateShoppingCartDatabase(cartId, cartUpdates);
                CartGrid.DataBind();
                lblTotal.Text = string.Format("{0:c}", usersShoppingCart.GetTotal());
                return(usersShoppingCart.GetCartItems());
            }
        }
Exemplo n.º 3
0
        void loadCart()
        {
            String connString = System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();

            conn = new MySql.Data.MySqlClient.MySqlConnection(connString);


            query = "SELECT * FROM ec_labs.cart WHERE username = '******' AND status = 'unpurchased'";

            conn.Open();
            MySqlDataAdapter sqlDa = new MySqlDataAdapter(query, conn);
            DataTable        dtbl  = new DataTable();

            sqlDa.Fill(dtbl);
            Console.WriteLine();
            CartGrid.DataSource = dtbl;
            CartGrid.DataBind();
        }
Exemplo n.º 4
0
        protected void AddToGridView()
        {
            ArrayList cartList = (ArrayList)Session["cartList"];

            //productName, description, unit, price

            /*
             * for(int i = 0; i < cartList.Count; i++)
             * {
             *  product p = (product)cartList[i];
             *  String pNameTemp = p.product_name;
             *  String descTemp = p.product_description;
             *  String unitTemp = p.unit;
             *
             *  productName.Text = pNameTemp;
             *  description.Text = descTemp;
             *  unit.Text = unitTemp;
             * }
             */

            CartGrid.DataSource = cartList;
            CartGrid.DataBind();
        }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            List <Order> Orders = null;

            Orders = Session["OrderList_Session"] as List <Order>;
            //Debug.Text = x.ToString()+x.GetType().ToString();

            //"SELECT \"food_name\" as \"Food Name\" ,\"menu_type\" as \"Availability\",\"price\" as \"Price(tk)\" FROM FOOD WHERE \"hotel_id\"= " + hotelID;

            /*string queryHotel = "SELECT \"food_id\" as \"ID\" ,\"food_name\" as \"Food Name\" ,\"menu_type\" as \"Availability\",\"price\" as \"Price(tk)\" FROM FOOD WHERE \"hotel_id\"= " + x;
             * FoodDataSource.SelectCommand = queryHotel;
             * FoodDataSource.SelectCommandType = SqlDataSourceCommandType.Text;
             * DataView foods = FoodDataSource.Select(DataSourceSelectArguments.Empty) as DataView;
             * */


            CartGrid.DataSource   = Orders;
            CartGrid.DataSourceID = null;
            CartGrid.DataBind();

            if (Orders != null)
            {
                int price = 0;
                foreach (Order x in Orders)
                {
                    price += x.Price * x.Quantity;
                }

                Total.Text = "Total Price = ";
                Price.Text = price.ToString();
                int OrderCount = CartGrid.Rows.Count;
                Session["count"] = OrderCount;
            }

            //DebugLabel.Text = OrderCount.ToString();
        }