示例#1
0
        public bool ClearCart()
        {
            SQLiteConnection sQLiteConnection = SQLLiteHelper.createInstance().sQLiteConnection;
            string           sqlCommand       = "delete from Cart;";
            var stt    = sQLiteConnection.Prepare(sqlCommand);
            var result = stt.Step();

            return(result == SQLiteResult.OK);
        }
示例#2
0
        public bool clearCart()
        {
            SQLiteConnection sQLiteConnection = SQLLiteHelper.createInstance().sQLiteConnection;
            var sqlString = "DELETE FROM Cart;";
            var stt       = sQLiteConnection.Prepare(sqlString);
            var result    = stt.Step();

            return(result == SQLiteResult.OK);
        }
示例#3
0
        public void deleteCartItem(int id)
        {
            SQLLiteHelper    sQLiteHelper     = SQLLiteHelper.createInstance();
            SQLiteConnection sQLiteConnection = sQLiteHelper.sQLiteConnection;
            var sqlString = "DELETE FROM Cart WHERE id = ?;";
            var stt       = sQLiteConnection.Prepare(sqlString);

            stt.Bind(1, id);
            stt.Step();
        }
示例#4
0
        /// <summary>
        /// The DeleteItem.
        /// </summary>
        /// <param name="item">The item<see cref="CartItem"/>.</param>
        /// <returns>The <see cref="bool"/>.</returns>
        public bool DeleteItem(CartItem item)
        {
            SQLiteConnection sQLiteConnection = SQLLiteHelper.createInstance().sQLiteConnection;
            string           sqlCommand       = "delete from CArt where id = ?;";
            var stt = sQLiteConnection.Prepare(sqlCommand);

            stt.Bind(1, item.id);
            var result = stt.Step();

            return(result == SQLiteResult.OK);
        }
示例#5
0
        public void deleteFavorite(int id)
        {
            SQLLiteHelper sQLiteHelper = SQLLiteHelper.createInstance();

            SQLiteConnection sQLiteConnection = sQLiteHelper.sQLiteConnection;
            var sqlString = "DELETE FROM Products WHERE id = ?";
            var stt       = sQLiteConnection.Prepare(sqlString);

            stt.Bind(1, id);
            stt.Step();
        }
示例#6
0
        public bool deleteCartItem(int id)
        {
            SQLLiteHelper    sQLiteHelper     = SQLLiteHelper.createInstance();
            SQLiteConnection sQLiteConnection = sQLiteHelper.sQLiteConnection;
            var sqlString = "DELETE FROM Cart WHERE id = ?;";
            var stt       = sQLiteConnection.Prepare(sqlString);

            stt.Bind(1, id);
            var result = stt.Step();

            return(result == SQLiteResult.OK);
        }
示例#7
0
        public void updateAmount(int id, int amount)
        {
            SQLLiteHelper sQLiteHelper = SQLLiteHelper.createInstance();

            SQLiteConnection sQLiteConnection = sQLiteHelper.sQLiteConnection;
            var sqlString = "update Cart set amount = ? where id = ?";
            var stt       = sQLiteConnection.Prepare(sqlString);

            stt.Bind(1, amount);
            stt.Bind(2, id);

            stt.Step();
        }
示例#8
0
        public void addItemToCart(food food, string amount)
        {
            SQLLiteHelper sQLiteHelper = SQLLiteHelper.createInstance();

            SQLiteConnection sQLiteConnection = sQLiteHelper.sQLiteConnection;
            var sqlString = "INSERT INTO Cart(name,image,amount,price,food_id) VALUES(?,?,?,?,?)";
            var stt       = sQLiteConnection.Prepare(sqlString);

            stt.Bind(1, food.name);
            stt.Bind(2, food.image);
            stt.Bind(3, Int32.Parse(amount));
            stt.Bind(4, food.price);
            stt.Bind(5, food.id);
            stt.Step();
        }
示例#9
0
        public void addFavorite(food food)
        {
            SQLLiteHelper sQLiteHelper = SQLLiteHelper.createInstance();

            SQLiteConnection sQLiteConnection = sQLiteHelper.sQLiteConnection;
            var sqlString = "INSERT INTO Products(id,name,image,description,price) VALUES(?,?,?,?,?)";
            var stt       = sQLiteConnection.Prepare(sqlString);

            stt.Bind(1, food.id);
            stt.Bind(2, food.name);
            stt.Bind(3, food.image);
            stt.Bind(4, food.description);
            stt.Bind(5, food.price);
            stt.Step();
        }
示例#10
0
        /// <summary>
        /// The AddToCart.
        /// </summary>
        /// <param name="item">The item<see cref="CartItem"/>.</param>
        /// <returns>The <see cref="bool"/>.</returns>
        public bool AddToCart(CartItem item)
        {
            SQLLiteHelper    sQLLiteHelper    = SQLLiteHelper.createInstance();
            SQLiteConnection sQLiteConnection = sQLLiteHelper.sQLiteConnection;
            string           sqlCommand       = "insert into Cart(id,name,image,price,qty) values(?,?,?,?,?)";
            var stt = sQLiteConnection.Prepare(sqlCommand);

            stt.Bind(1, item.id);
            stt.Bind(2, item.name);
            stt.Bind(3, item.image);
            stt.Bind(4, item.price);
            stt.Bind(5, item.qty);
            var result = stt.Step();

            return(result == SQLiteResult.OK);
        }
        private void BtnLike_Click(object sender, RoutedEventArgs e)
        {
            SQLLiteHelper sQLiteHelper = SQLLiteHelper.createInstance();

            SQLiteConnection sQLiteConnection = sQLiteHelper.sQLiteConnection;
            var sqlString = "INSERT INTO Products(id,name,image,description,price) VALUES(?,?,?,?,?)";
            var stt       = sQLiteConnection.Prepare(sqlString);

            stt.Bind(1, Detail.id);
            stt.Bind(2, Detail.name);
            stt.Bind(3, Detail.image);
            stt.Bind(4, Detail.description);
            stt.Bind(5, Detail.price);
            stt.Step();
            MainPage.mainFrame.Navigate(typeof(Favourite));
        }
示例#12
0
 /// <summary>
 /// The UpdateQty.
 /// </summary>
 /// <param name="item">The item<see cref="CartItem"/>.</param>
 /// <param name="newQty">The newQty<see cref="int"/>.</param>
 /// <returns>The <see cref="bool"/>.</returns>
 public bool UpdateQty(CartItem item, int newQty)
 {
     if (newQty > 0)
     {
         SQLiteConnection sQLiteConnection = SQLLiteHelper.createInstance().sQLiteConnection;
         string           sqlCommand       = "update Cart Set qty = ? where id = ?;";
         var stt = sQLiteConnection.Prepare(sqlCommand);
         stt.Bind(1, newQty);
         stt.Bind(2, item.id);
         var result = stt.Step();
         return(result == SQLiteResult.OK);
     }
     else
     {
         return(DeleteItem(item));
     }
 }
示例#13
0
        /// <summary>
        /// The GetCarts.
        /// </summary>
        /// <returns>The <see cref="List{CartItem}"/>.</returns>
        public List <CartItem> GetCarts()
        {
            SQLiteConnection sQLiteConnection = SQLLiteHelper.createInstance().sQLiteConnection;
            string           sqlCommand       = "select * from Cart;";
            var             stt  = sQLiteConnection.Prepare(sqlCommand);
            List <CartItem> list = new List <CartItem>();

            while (SQLiteResult.ROW == stt.Step())
            {
                int    id    = Convert.ToInt32(stt[0]);
                string name  = (string)stt[1];
                string image = (string)stt[2];
                int    price = Convert.ToInt32(stt[3]);
                int    qty   = Convert.ToInt32(stt[4]);
                list.Add(new CartItem(id, name, image, price, qty));
            }
            return(list);
        }
示例#14
0
        public List <CartItem> getCartItems()
        {
            cartItems.Clear();
            SQLLiteHelper    sQLiteHelper     = SQLLiteHelper.createInstance();
            SQLiteConnection sQLiteConnection = sQLiteHelper.sQLiteConnection;
            var sqlString = "SELECT * FROM Cart";
            var stt       = sQLiteConnection.Prepare(sqlString);

            while (SQLiteResult.ROW == stt.Step())
            {
                var id     = Convert.ToInt32(stt[0]);
                var name   = (string)stt[1];
                var image  = (string)stt[2];
                var amount = Convert.ToInt32(stt[3]);
                var price  = Convert.ToInt32(stt[4]);
                var foodId = Convert.ToInt32(stt[5]);
                cartItems.Add(new CartItem(id, name, image, price, amount, foodId));
            }
            return(cartItems);
        }
示例#15
0
        public bool updateAmount(int id, int amount)
        {
            if (amount > 0)
            {
                SQLLiteHelper sQLiteHelper = SQLLiteHelper.createInstance();

                SQLiteConnection sQLiteConnection = sQLiteHelper.sQLiteConnection;
                var sqlString = "update Cart set amount = ? where id = ?";
                var stt       = sQLiteConnection.Prepare(sqlString);
                stt.Bind(1, amount);
                stt.Bind(2, id);

                var result = stt.Step();
                return(result == SQLiteResult.OK);
            }
            else
            {
                return(true);
            }
        }
示例#16
0
        public List <food> GetFavourite()
        {
            favoriteList.Clear();
            SQLLiteHelper    sQLiteHelper     = SQLLiteHelper.createInstance();
            SQLiteConnection sQLiteConnection = sQLiteHelper.sQLiteConnection;
            var sqlString = "SELECT * FROM Products";
            var stt       = sQLiteConnection.Prepare(sqlString);

            while (SQLiteResult.ROW == stt.Step())
            {
                var id          = Convert.ToInt32(stt[0]);
                var name        = (string)stt[1];
                var image       = (string)stt[2];
                var description = (string)stt[3];
                var price       = Convert.ToInt32(stt[4]);

                favoriteList.Add(new food(id, name, image, description, price));
            }
            return(favoriteList);
        }
示例#17
0
        private void GetFavourite()
        {
            SQLLiteHelper    sQLiteHelper     = SQLLiteHelper.createInstance();
            SQLiteConnection sQLiteConnection = sQLiteHelper.sQLiteConnection;
            var            sqlString          = "SELECT * FROM Products";
            var            stt = sQLiteConnection.Prepare(sqlString);
            List <Product> arr = new List <Product>();

            while (SQLiteResult.ROW == stt.Step())
            {
                var id          = Convert.ToInt32(stt[0]);
                var name        = (string)stt[1];
                var image       = (string)stt[2];
                var description = (string)stt[3];
                var price       = Convert.ToInt32(stt[4]);

                arr.Add(new Product(id, name, image, description, price));
            }
            //Console.WriteLine(arr);
            //  var x = arr;
            ProductList.ItemsSource = arr;
        }