Example #1
0
 public BUS()
 {
     if (db == null)
     {
         db = new eWorldEntities();
     }
 }
Example #2
0
        public List<Product> GetProduct(string CategoryID)
        {
            using (db = new eWorldEntities())
            {

                var tmp = from c in db.Categories
                          from p in db.Products
                          from pc in db.ProductInCategories
                          where c.CategoryID == pc.CategoryID && pc.ProductID == p.ProductID
                          && c.CategoryID.ToString().Contains(CategoryID) && p.Show == true
                          select p;
                var result = tmp.ToList<Product>();

                //Price
                int index = search_price.SelectedIndex;
                min_price = priceList[index];
                result = result.Where(p => p.Price >= min_price).ToList();

                //Vendor
                if (search_vendor.SelectedIndex != 0)
                {
                    vendor = search_vendor.SelectedItem.Text;
                    result = result.Where(p => p.Vendor.ToString() == vendor).ToList();
                }

                //Orderby
                orderbyasc = PriceOrders.SelectedIndex == 0 ? true : false;
                if (orderbyasc)
                    result = result.OrderBy(p => p.Price).ToList();
                else result = result.OrderByDescending(p => p.Price).ToList();

                return result;

            }
        }
Example #3
0
 public List<ShopInfo> GetShopInfo()
 {
     using (db = new eWorldEntities())
     {
         var tmp = from i in db.ShopInfoes
                   select i;
         var result = tmp.ToList<ShopInfo>();
         return result;
     }
 }
Example #4
0
        public int getnumImage_slide()
        {
            using (db = new eWorldEntities())
            {
                var tmp = from i in db.ImageSlides
                          select i;

                return tmp.ToList<ImageSlide>().Count;
            }
        }
Example #5
0
 public List<ImageSlide> getImage_slide()
 {
     using (db = new eWorldEntities())
     {
         var tmp = from i in db.ImageSlides
                   select i;
         var result = tmp.ToList<ImageSlide>();
         return result;
     }
 }
Example #6
0
 public List<ImageBanner> getImage_banner()
 {
     using (db = new eWorldEntities())
     {
         var tmp = from i in db.ImageBanners
                   select i;
         var result = tmp.ToList<ImageBanner>();
         return result;
     }
 }
Example #7
0
        public List<string> GetVendor_Category()
        {
            using (db = new eWorldEntities())
            {
                var tmp = from p in db.Products
                          select p.Vendor;

                var result = tmp.ToList();
                return result.Distinct().ToList();
            }
        }
Example #8
0
 public List<Category> GetCategories()
 {
     using (db = new eWorldEntities())
     {
         var tmp = from cm in db.CategoryMenus
                   from c in db.Categories
                   where cm.CategoryID == c.CategoryID
                   select c;
         var result = tmp.ToList<Category>();
         return result;
     }
 }
Example #9
0
 public string getURL(string keyword)
 {
     using (db = new eWorldEntities())
     {
         var tmp = from c in db.Categories
                   where c.KeyWord.Contains(keyword)
                   select c.CategoryID;
         var result = tmp.ToList();
         if (result.Count != 0)
             CateID = result[0].ToString();
         else CateID = null;
         return CateID;
     }
 }
Example #10
0
 public List<Product> GetProduct_Right(string CategoryName)
 {
     using (db = new eWorldEntities())
     {
         var tmp = from c in db.Categories
                   from p in db.Products
                   from pc in db.ProductInCategories
                   where c.CategoryID == pc.CategoryID && pc.ProductID == p.ProductID && c.Name.Contains(CategoryName)
                   select p;
         tmp.Take(3);
         var result = tmp.ToList<Product>();
         return result;
     }
 }
Example #11
0
        public List<string> GetVendor_Category(string CategoryID)
        {
            using (db = new eWorldEntities())
            {
                var tmp = from c in db.Categories
                          from p in db.Products
                          from pc in db.ProductInCategories
                          where c.CategoryID == pc.CategoryID && pc.ProductID == p.ProductID
                          && c.CategoryID.ToString() == CategoryID
                          select p;

                var result = tmp.Select(p => p.Vendor).ToList();
                result.Distinct();
                return result.Distinct().ToList();
            }
        }
Example #12
0
 public List<Product> GetProduct_Index(string keyword)
 {
     using (db = new eWorldEntities())
     {
         var tmp = from p in db.Products
                      from c in db.Categories
                      from pc in db.ProductInCategories
                      where p.ProductID == pc.ProductID && pc.CategoryID == c.CategoryID
                      && c.KeyWord.Contains(keyword) && p.Show == true
                      select p;
         int num = 4;
         tmp.Take<Product>(num);
         var result = tmp.ToList<Product>();
         return result;
     }
 }
Example #13
0
        protected void submit_Click(object sender, EventArgs e)
        {
            db = new eWorldEntities();

            using (usersShoppingCart = new ShoppingCartActions())
            {
                List<Cart> c = usersShoppingCart.GetCartItems();
                Order order = new Order();
                order.OrderDate = c[0].DateCreated;
                order.Email = HttpContext.Current.User.Identity.Name;
                order.Total = Convert.ToDouble(usersShoppingCart.GetTotal());
                order.paid = false;

                db.Orders.Add(order);
                db.SaveChanges();

                OrderDetail orderdetail;
                int num = c.Count;
                for (int i = 0; i < num; i++)
                {
                    orderdetail = new OrderDetail();

                    orderdetail.OrderID = order.OrderID;
                    orderdetail.ProductID = c[i].ProductID;
                    orderdetail.Quantity = c[i].Quantity;
                    orderdetail.UnitPrice = c[i].Product.Price;

                    db.OrderDetails.Add(orderdetail);
                    db.SaveChanges();
                }

                string ShoppingCartId = usersShoppingCart.GetCartId();
                var cartItems = db.Carts.Where(
                    ci => ci.CartID == ShoppingCartId);
                foreach (var cartItem in cartItems)
                {
                    db.Carts.Remove(cartItem);
                }
                // Save changes.
                db.SaveChanges();

                Response.Redirect("Checkout_success");

            }
        }
Example #14
0
        public bool AddProduct(string ProductName, string ProductDesc, string ProductDetail,
            string ProductPrice, string ProductReview, int Stock,
            string Gift, string Sale, string vendor, Boolean onsale, string oldprice,
            string ProductImagePath1, string ProductImagePath2, string ProductImagePath3,
            string ProductImagePath4, Boolean show, List<string> cat_id)
        {
            var myProduct = new Product();
            myProduct.ProductName = ProductName;
            myProduct.Description = ProductDesc;
            myProduct.Detail = ProductDetail;
            myProduct.Price = Double.Parse(ProductPrice);
            myProduct.Review = ProductReview;
            myProduct.StockID = Stock;
            myProduct.Gift = Gift;
            myProduct.Sale = Sale;
            myProduct.Vendor = vendor;
            myProduct.onSale = onsale;
            if (oldprice != "")
                myProduct.oldPrice = Double.Parse(oldprice);
            myProduct.ImagePath1 = ProductImagePath1;
            myProduct.ImagePath2 = ProductImagePath2;
            myProduct.ImagePath3 = ProductImagePath3;
            myProduct.ImagePath4 = ProductImagePath4;
            myProduct.Show = show;

            using (eWorldEntities db = new eWorldEntities())
            {
                // Add product to DB.
                db.Products.Add(myProduct);

                foreach (string id in cat_id)
                {
                    var cat = new ProductInCategory();
                    cat.CategoryID = Convert.ToInt32(id);
                    myProduct.ProductID = myProduct.ProductID;

                    db.ProductInCategories.Add(cat);
                }
                db.SaveChanges();
            }
            // Success.
            return true;
        }
Example #15
0
 protected string get_cateName()
 {
     using (db = new eWorldEntities())
     {
         string CategoryID = Request.QueryString["CategoryID"];
         var tmp = from c in db.Categories
                   where c.CategoryID.ToString() == CategoryID
                   select c;
         var result = tmp.ToList();
         cateName = result[0].Name.ToString();
         return cateName;
     }
 }