public void UpdateProduct(int productID)
        {
            WbsDAL wbs = new WbsDAL();

            wbs.OpenConnection($"Data Source=(local);Initial Catalog=WebbShop;Integrated Security=True");
            //wbs.UpdateProductAdmin(productID);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            ////////////////////////
            //  LOAD All Products //
            ////////////////////////

            int            number;
            string         markupHTML = "";
            List <Product> allProductWomansSweatshirtList = new List <Product>();
            WbsDAL         wbs = new WbsDAL();

            wbs.OpenConnection(ConfigurationManager.ConnectionStrings["WebbShopConnectionString"].ConnectionString);
            allProductWomansSweatshirtList = wbs.GetTShirtWoman();
            foreach (Product p in allProductWomansSweatshirtList)
            {
                number      = Decimal.ToInt32(p.PriceUnit);
                markupHTML += $"<div class=\"col-md-3 box\">" +
                              $"<div class =\"thumbnail\" >" +
                              $"<img src =\"/Images/{p.ImageURL}\" alt =\"Generic placeholder thumbnail\">" +
                              $"</div>" +
                              $"<div class=\"cover left\">" +
                              $"<div class = \"caption\">" +
                              $"<h3>{p.ProductBrand}</h3>" +
                              $"<h2 class=\"title\">{p.ProductBrand}</h2>" +
                              $"</div>" +
                              $"<div class=\"btn\">" +
                              $"<a href=\"ProductInformation.aspx?ProductID={p.ProductID}\">More Info<br />" +
                              $"{number}SEK" +
                              $"</a>" +
                              $"</div>" +
                              $"</div>" +
                              $"</div>";
            }
            InsertedProductsTs.InnerHtml = markupHTML;
        }
예제 #3
0
        protected void SearchField()
        {
            List <Product> searchedProduct = new List <Product>();
            WbsDAL         wbsdal          = new WbsDAL();

            wbsdal.OpenConnection(ConfigurationManager.ConnectionStrings["WebbShopConnectionString"].ConnectionString);
            searchedProduct            = wbsdal.GetSearchProduct(txtSearchbox.Text);
            Session["SearchedProduct"] = searchedProduct;
            Response.Redirect("~/SearchResult.aspx");
        }
        public IEnumerable <Product> GetBrands()
        {
            IEnumerable <Product> productList = new List <Product>();

            WbsDAL invDAL = new WbsDAL();

            invDAL.OpenConnection($"Data Source=(local); Integrated Security = true; Initial Catalog=WebbShop");

            productList = invDAL.GetProducts();
            productList.Select(x => new { x.ProductBrand }).Distinct();


            return(productList);
        }
        protected void _btnSubmitOrder_Click(object sender, EventArgs e)
        {
            WbsDAL wbsDAL = new WbsDAL();

            wbsDAL.OpenConnection(ConfigurationManager.ConnectionStrings["WebbShopConnectionString"].ConnectionString);
            string description = "Fine brand";//Check this
            string category    = _dropDownCategory.Text;
            string gender      = _dropDownGender.Text;
            string color       = _dropDownColor.Text;
            string size        = _dropDownSize.Text;
            int    quantity    = Int32.Parse(_txtBoxQuantity.Text);
            int    productID   = wbsDAL.GetProduct(description, category, gender, color, size);
            string userName    = (string)Session["UserName"];
            int    customerID  = wbsDAL.GetCustomerLoggedID(userName);

            //int orderID = wbsDAL.InsertOrderProductTable(productID, quantity, customerID);
            Response.Redirect("../OrderRec.aspx");
        }
        public IQueryable <Product> GetAllProducts([Control("productsDropDownList")] string productBrand = "")
        {
            List <Product> allProductsList = new List <Product>();
            WbsDAL         wbs             = new WbsDAL();

            wbs.OpenConnection($"Data Source=(local);Initial Catalog=WebbShop;Integrated Security=True");
            allProductsList = wbs.GetProducts();
            //Same solution as the one below
            //if (string.IsNullOrEmpty(productBrand))
            //{
            //    return wbs.GetProducts().AsQueryable();
            //}
            //else
            //{
            //    return wbs.GetProducts().Where(x => x.ProductBrand == productBrand).AsQueryable();
            //}
            return(string.IsNullOrEmpty(productBrand) ?
                   wbs.GetProducts().AsQueryable() :
                   wbs.GetProducts().Where(x => x.ProductBrand == productBrand).AsQueryable());
        }
예제 #7
0
        protected void ConfirmOrderShoppingCart_Click(object sender, EventArgs e) //TODO!!!!!!!
        {
            if ((string)Session["UserName"] != null)
            {
                List <ProductOrderInfoChartCart> orderList = new List <ProductOrderInfoChartCart>();
                WbsDAL wbsDAL = new WbsDAL();
                wbsDAL.OpenConnection(ConfigurationManager.ConnectionStrings["WebbShopConnectionString"].ConnectionString);
                List <Product> listChart = (List <Product>)Session["AddToChartCart"];
                foreach (Product p in listChart)
                {
                    string  imageURL           = p.ImageURL;
                    int     productID          = p.ProductID;
                    string  roductBrand        = p.ProductBrand;
                    decimal PriceUnit          = p.PriceUnit;
                    string  ProductDescription = p.ProductDescription;
                    string  Color = p.Color;
                    string  Size  = p.Size;
                }

                //Missing Code for Quantity

                string userName   = (string)Session["UserName"];
                int    customerID = wbsDAL.GetCustomerLoggedID(userName);
                int    orderID    = wbsDAL.InsertToOrderTbl(customerID);
                foreach (Product p in listChart)
                {
                    int productID = p.ProductID;

                    wbsDAL.InsertOrderProductTable(productID, orderID);
                }
            }

            else
            {
                Response.Redirect("~/Pages/ConfirmOrder");
            }
        }
        public void AddToCart(int ID)
        {
            WbsDAL wbs = new WbsDAL();

            wbs.OpenConnection(ConfigurationManager.ConnectionStrings["WebbShopConnectionString"].ConnectionString);

            CartItem cartItem = new CartItem();

            ShoppingCartID    = GetCartID();
            shoppingCartItems = (List <CartItem>)HttpContext.Current.Session["AddToChartCart"];
            foreach (CartItem c in shoppingCartItems)
            {
                if (c.CartID == ShoppingCartID && c.ProductID == ID)
                {
                    cartItem = c;
                }
                if (cartItem == null)
                {
                    shoppingCartItems.Add(new CartItem
                    {
                        ItemID      = Guid.NewGuid().ToString(),
                        CartID      = ShoppingCartID,
                        Quantity    = 1,
                        DateCreated = DateTime.Now,
                        ProductID   = ID,
                        Product     = (Product)shoppingCartItems.Where(p => p.ProductID == ID)
                    });
                    HttpContext.Current.Session["AddToChartCart"] = shoppingCartItems;
                }
                else
                {
                    cartItem.Quantity++;
                }
            }
            //var cartItem = (CartItem)shoppingCartItems.SingleOrDefault(c => c.CartID == ShoppingCartID && c.ProductID == ID);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //////////////////////////////////////////////////////////////////
            //  Request query string configured in all sites with product   //
            //////////////////////////////////////////////////////////////////

            //string productID = string.Empty;
            //if (!string.IsNullOrEmpty(Request.QueryString["ProductID"]))
            //{
            //   // ProductID = Request.QueryString["ProductID"];
            //}
            //else
            //{

            //}
            ////////////////////////
            //  LOAD Product //
            ////////////////////////

            int number;
            //string markupHTML = "";
            Product p   = new Product();
            WbsDAL  wbs = new WbsDAL();

            wbs.OpenConnection(ConfigurationManager.ConnectionStrings["WebbShopConnectionString"].ConnectionString);
            // p = wbs.ProductSelectToCart(ProductID);

            number = Decimal.ToInt32(p.PriceUnit);
            StringBuilder markupHTML = new StringBuilder("");

            markupHTML.Append("<div class=\"product group\">");
            markupHTML.Append("<div class =\"thumbnail\" >");
            markupHTML.Append("<img src =\"/Images/" + p.ImageURL + "\" alt=\"Generic placeholder thumbnail\">");
            markupHTML.Append("</div>");
            markupHTML.Append("<div class = \"caption\">");
            markupHTML.Append("<h3></h3>");
            markupHTML.Append("<span>" + p.Size + "</span");
            markupHTML.Append("<h2 class=\"title\">" + p.ProductBrand + "</h2>");
            markupHTML.Append("</div>");
            markupHTML.Append("<div class=\"col-1-2 product-info\">");
            markupHTML.Append("<h1>" + p.ProductBrand + "</h1>");
            markupHTML.Append("<br />");
            markupHTML.Append("" + p.ProductDescription + "");
            markupHTML.Append("<br />");
            markupHTML.Append("<h3>" + number + "SEK</h3>");
            markupHTML.Append("<br />");
            markupHTML.Append("<div class=\"add-btn\"  Text=\"Add to cart\"  OnClick=\"_btnAddToChart_Click\" runat=\"server\">");
            markupHTML.Append("</div>");
            markupHTML.Append("</div>");



            //InsertedProduct.InnerHtml = markupHTML.ToString();
            //    markupHTML += $"<div class=\"col-md-3 box\">" +
            //                         $"<div class =\"thumbnail\">" +
            //                            $"<img src =\"/Images/{p.ImageURL}\" alt =\"Generic placeholder thumbnail\">" +
            //                         $"</div>" +
            //                         $"<div class=\"cover left\">" +
            //                         $"<div class =\"caption\">" +
            //                            $"<h3>{p.ProductBrand}</h3>" +
            //                            $"<h2 class=\"title\">{p.ProductBrand}</h2>" +
            //                            $"{number}SEK" +
            //                         $"</div>" +
            //                         $"<a href=\"ProductInformation.aspx?ProductID={p.ProductID}\">" +
            //                         $"<div class=\"btn\">" +

            //                           $"More Info <br />" +
            //                           $"</div></a>" +
            //                           $"<div class=\"btn\">" +
            //                           $"<a href =\"AddToCart.aspx?ProductID={p.ProductID}\">Buy<br/></a>" +

            //                           $"</a>" +

            //                         $"</div>" +
            //                       $"</div>" +
            //                      $"</div>";
            //}
            //InsertedProduct.InnerHtml = markupHTML.ToString;

            string rawProductID = Request.QueryString["ProductID"];



            if (!string.IsNullOrEmpty(rawProductID))
            {
                ShoppingCartActions userShoppingCart = new ShoppingCartActions();
                int productID = Int32.Parse(rawProductID);
                userShoppingCart.AddToCart(productID);
            }
            else
            {
                throw new Exception("Error loading page without ID");
            }
            Response.Redirect("ShoppingCart.aspx");
        }