Ejemplo n.º 1
0
        private void FillPage()
        {
            try
            {
                if (!String.IsNullOrWhiteSpace(Request.QueryString["id"]))
                {
                    int id = Convert.ToInt32(Request.QueryString["id"]);
                    ProductModel productModel = new ProductModel();
                    Product product = productModel.GetProduct(id);

                    LabelPrice.Text = "Price <br/> " + product.Price;
                    LabelTitel.Text = product.Name;
                    LabelDescription.Text = product.Description;
                    lblItem.Text = id.ToString();
                    imgProduct.ImageUrl = "~/Images/Products/" + product.Image;

                    int[] amount = Enumerable.Range(1, 10).ToArray();
                    ddlAmount.DataSource = amount;
                    ddlAmount.AppendDataBoundItems = true;
                    ddlAmount.DataBind();

                }
            }
            catch (Exception e)
            {

                
                Response.Redirect("~/Pages/ErrorPages/Error.aspx");
            }
        }
Ejemplo n.º 2
0
        private void FillPage()
        {
            if (!String.IsNullOrWhiteSpace(Request.QueryString["id"]))
            {
                int id = Convert.ToInt32(Request.QueryString["id"]);
                ProductModel productModel = new ProductModel();
                List<Product> products = productModel.GetProductsByType(id);

                if (products != null)
                {
                    foreach (Product product in products)
                    {
                        Panel productPanel = new Panel();
                        ImageButton imageButton = new ImageButton();
                        Label lblName = new Label();
                        Label lblPrice = new Label();
                        Label lblShortDescription = new Label();

                        imageButton.ImageUrl = "~/Images/Products/" + product.Image;
                        imageButton.CssClass = "ProductImage";
                        imageButton.PostBackUrl = "~/Pages/ProductPage.aspx?id=" + product.Id;

                        lblName.Text = product.Name;
                        lblName.CssClass = "ProductName";

                        lblPrice.Text = product.Price + " kr ";
                        lblPrice.CssClass = "ProductPrice";

                        lblShortDescription.Text = product.ShortDescription;

                        productPanel.Controls.Add(imageButton);
                        productPanel.Controls.Add(new Literal { Text = "<br />" });
                        productPanel.Controls.Add(lblName);
                        productPanel.Controls.Add(new Literal { Text = "<br />" });
                        productPanel.Controls.Add(lblPrice);

                        productPanel.Controls.Add(new Literal { Text = "<br />" });
                        productPanel.Controls.Add(lblShortDescription);

                        PanelProduct.Controls.Add(productPanel);

                    }
                }

            }
            else
            {
                //If no products...
                PanelProduct.Controls.Add(new Literal { Text = "No Products found" });
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 更新產品資料
        /// </summary>
        /// <param name="products">產品資料</param>
        /// <returns>產品ID</returns>
        public int Update(Models.ProductModel products)
        {
            int intProductId           = -1;
            TransactionScope tranScope = new TransactionScope();

            try
            {
                intProductId = _productRepository.Update(products);
                //Todo:顧客扣款
                tranScope.Complete();
            }
            catch (Exception ex) {
                //Todo:回報問題
            };
            return(intProductId);
        }
Ejemplo n.º 4
0
        private void FillPage()
        {
            ProductModel productModel = new ProductModel();
            List<Product> products = productModel.GetProductsByRank();

            if (products != null)
            {
                foreach (Product product in products)
                {
                    Panel productPanel = new Panel();
                    ImageButton imageButton = new ImageButton();
                    Label lblName = new Label();
                    Label lblPrice = new Label();
                    Label lblShortDescription = new Label();

                    imageButton.ImageUrl = "~/Images/Products/" + product.Image;
                    imageButton.CssClass = "ProductImage";
                    imageButton.PostBackUrl = "~/Pages/ProductPage.aspx?id=" + product.Id;

                    lblName.Text = product.Name;
                    lblName.CssClass = "ProductName";

                    lblPrice.Text = product.Price + " kr";
                    lblPrice.CssClass = "ProductPrice";

                    lblShortDescription.Text = product.ShortDescription;

                    productPanel.Controls.Add(imageButton);
                    productPanel.Controls.Add(new Literal { Text = "<br />" });
                    productPanel.Controls.Add(lblName);
                    productPanel.Controls.Add(new Literal { Text = "<br />" });
                    productPanel.Controls.Add(lblPrice);
                    productPanel.Controls.Add(new Literal { Text = "<br />" });
                    productPanel.Controls.Add(lblShortDescription);

                    PanelProduct.Controls.Add(productPanel);

                }

            }
            else
            {
                //If no products...
                PanelProduct.Controls.Add(new Literal { Text = "No Products found" });
            }
        }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                productID = int.Parse(Request.QueryString["id"]);

                Models.ProductModel product = new Models.ProductModel();
                product = productDL.GetDetailProductWithId(productID);

                imgProduct.ImageUrl  = "Images/" + product.ProductImage;
                lblProductName.Text  = product.ProductName;
                lblProductPrice.Text = product.Price + " VND";
                lblContryMade.Text   = product.CountryMade;
                lblCarType.Text      = product.CatName;
                lblEngineenType.Text = product.EngineenType;
                lblGasCap.Text       = product.GasCapacity.ToString();
                lblIsUsed.Text       = product.Used ? "Used car" : "New car";
                lblMileage.Text      = product.MileAge.ToString();
                lblNumCap.Text       = product.NumberCapacity.ToString();
                lblYearMade.Text     = product.YearMade.ToString();
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 建立產品資料
 /// </summary>
 /// <param name="products">產品資料</param>
 /// <returns>產品ID</returns>
 public int CreateProduct(Models.ProductModel products)
 {
     return(_productRepository.Create(products));
 }
Ejemplo n.º 7
0
        protected void DiplayMiniData()
        {
            List<Cart> list = (List<Cart>) Session["cart"];
            ProductModel productModel = new ProductModel();

            string s = string.Empty;

            if (Session["cart"] != null)
            {
                foreach (var c in list)
                {
                    var p = productModel.GetProduct(c.ProductID);

                    ImageButton btnImage = new ImageButton()
                    {
                        ImageUrl = string.Format($"~/Images/Products/{p.Image}"),
                        //PostBackUrl = string.Format($"ProductPage.aspx?id={p.Id}")

                    };
                    btnImage.CssClass = "MiniImage";

                    //LinkButton lnkDelete = new LinkButton()
                    //{
                    //    PostBackUrl = string.Format($"Cart.aspx?productId={p.Id}"),
                    //    Text = "Del",
                    //    ID = "del" + p.Id
                    //};
                    //lnkDelete.Click += Delete_Item;


                    ImageButton delButton = new ImageButton()
                    {
                        ImageUrl = "~/Images/Web/less.png",
                        PostBackUrl = "",
                        ID = "del" + p.Id
                    };
                    delButton.Click += Delete_Item;

                    int[] amountArray = Enumerable.Range(1, 10).ToArray();
                    DropDownList ddlAmount = new DropDownList()
                    {
                        DataSource = amountArray,
                        AppendDataBoundItems = true,
                        AutoPostBack = true,
                        ID = p.Id.ToString()
                    };
                    ddlAmount.CssClass = "Miniddl";


                    ddlAmount.DataBind();
                    ddlAmount.SelectedValue = c.Amount.ToString();
                    ddlAmount.SelectedIndexChanged += ddlAmount_SelectedIndexChanged;

                    Table table = new Table() { CellSpacing = 120, CellPadding = 80 };
                    TableRow a = new TableRow();
                    TableRow b = new TableRow() { Width = 260 };


                    table.CssClass = "miniTable";

                    TableCell a1 = new TableCell() { RowSpan = 2, Width = 50 };
                    TableCell a2 = new TableCell() { };
                    TableCell a3 = new TableCell() { Text = string.Format($"<h4>{p.Name}</h4><br/>") };
                    TableCell a4 = new TableCell() { };//DropDown
                    TableCell a5 = new TableCell() { RowSpan = 2, Width = 50 };//RowSpan = 2, Width = 50,Text = p.Price + " kr" 
                    TableCell a6 = new TableCell() { RowSpan = 2, Width = 50 };//Delete


                    TableCell b1 = new TableCell() { };
                    TableCell b2 = new TableCell() { };
                    TableCell b3 = new TableCell() { RowSpan = 2, Width = 50, Text = Math.Round((double)(c.Amount * Convert.ToInt32(p.Price)), 2) + " skr" };
                    TableCell b4 = new TableCell() { };
                    TableCell b5 = new TableCell() { };
                    TableCell b6 = new TableCell() { };

                    a1.Controls.Add(btnImage);
                    a5.Controls.Add(ddlAmount);
                    b6.Controls.Add(delButton);


                    a.Cells.Add(a1);
                    a.Cells.Add(a2);
                    a.Cells.Add(a3);
                    a.Cells.Add(a4);
                    a.Cells.Add(a5);
                    a.Cells.Add(a6);

                    a.Cells.Add(b1);
                    a.Cells.Add(b2);
                    a.Cells.Add(b3);
                    a.Cells.Add(b4);
                    a.Cells.Add(b5);
                    a.Cells.Add(b6);

                    table.Rows.Add(a);
                    table.Rows.Add(b);



                    MiniPanel.Controls.Add(table);

                }


            }
            
        }
Ejemplo n.º 8
0
        protected void Button3_Click(object sender, EventArgs e)
        {
            
            //G2Entities db = new G2Entities();
            ProductModel productModel = new ProductModel();

            int categoryId = 0;
            if (DropDownCategory.SelectedValue == "Bikes")
                categoryId = 9;
                if (DropDownCategory.SelectedValue == "Clothing")
                categoryId = 16;
            if (DropDownCategory.SelectedValue == "Accessories")
                categoryId = 18;

            Product product = productModel.GetProduct(categoryId);
          



                XmlDocument xmldoc = new XmlDocument();
            if (DropDownAdChoice.SelectedValue == "Ad1")
            {
                xmldoc.Load(Server.MapPath("~/App_Data/XMLBanner.xml"));
            }
            if (DropDownAdChoice.SelectedValue == "Ad2")
            {
                xmldoc.Load(Server.MapPath("~/App_Data/XMLBanner2.xml"));
            }
            XmlElement parentElement = xmldoc.CreateElement("Ad");
           
            XmlElement ImageUrl = xmldoc.CreateElement("ImageUrl");
            ImageUrl.InnerText = "~/images/" + ItemImageAds.Text;
            XmlElement AlternateText = xmldoc.CreateElement("AlternateText");
            AlternateText.InnerText = txtAlternate.Text;
            XmlElement NavigateUrl = xmldoc.CreateElement("NavigateUrl");
            NavigateUrl.InnerText = "~/Pages/Bikes.aspx?id=" + categoryId;
            /*  NavigateUrl.InnerText = "~/Pages/ProductPage.aspx?id=" + product.Id;*///txtNavigate.Text;
            XmlElement Keywords = xmldoc.CreateElement("Keywords");
            Keywords.InnerText = txtKeywords.Text;
            XmlElement Impressions = xmldoc.CreateElement("Impressions");
            Impressions.InnerText = txtImpressions.Text;

            parentElement.AppendChild(ImageUrl);
            parentElement.AppendChild(AlternateText);
            parentElement.AppendChild(NavigateUrl);
            parentElement.AppendChild(Keywords);
            parentElement.AppendChild(Impressions);
            xmldoc.DocumentElement.AppendChild(parentElement);



            if (DropDownAdChoice.SelectedValue == "Ad1")
            {
                xmldoc.Save(Server.MapPath("~/App_Data/XMLBanner.xml"));
            }
            if (DropDownAdChoice.SelectedValue == "Ad2")
            {
                xmldoc.Save(Server.MapPath("~/App_Data/XMLBanner2.xml"));
            }
            ShowXmlData();
            txtAlternate.Text = string.Empty;
            txtKeywords.Text = string.Empty;
            txtImpressions.Text = string.Empty;
        }
Ejemplo n.º 9
0
        protected void ItemSubmit_Click(object sender, EventArgs e)
        {
            ProductModel productModel = new ProductModel();
            Product product = CreateProduct();

            LblItemResult.Text = productModel.InsertProduct(product);
            Response.Redirect(Request.RawUrl);
        }
Ejemplo n.º 10
0
        private void ListItems(List<Cart> carts)
        {
            List<Product> itemList = GetItemsInCart(carts);
            ProductModel model = new ProductModel();
            double subTotal = new double();
            Product p = new Product();
            foreach (Cart c in carts)
            {
                p = itemList[carts.IndexOf(c)];
                ImageButton btnImage = new ImageButton()
                {
                    ImageUrl = string.Format($"~/Images/Products/{p.Image}"),
                    PostBackUrl = string.Format($"ProductPage.aspx?id={p.Id}")
                };

                LinkButton lnkDelete = new LinkButton()
                {
                    PostBackUrl = "Cart.aspx",
                    Text = "Delete Item",
                    ID = "del" + p.Id
                };
                lnkDelete.Click += Delete_Item;

                int[] amountArray = Enumerable.Range(1, 10).ToArray();
                DropDownList ddlAmount = new DropDownList()
                {
                    DataSource = amountArray,
                    AppendDataBoundItems = true,
                    AutoPostBack = true,
                    ID = p.Id.ToString()
                };

                ddlAmount.DataBind();
                ddlAmount.SelectedValue = c.Amount.ToString();
                ddlAmount.SelectedIndexChanged += ddlAmount_SelectedIndexChanged;

                Table table = new Table();
                TableRow a = new TableRow();
                TableRow b = new TableRow();
                // ta bort denna komentar
                TableCell a1 = new TableCell() { RowSpan = 2, Width = 50 };
                TableCell a2 = new TableCell() { Text = string.Format($"<h4>{p.Name}</h4><br/>{"Item No: " + p.Id}<br/>In Stock") };
                TableCell a3 = new TableCell() { Text = "Unit Price<br/>" };
                TableCell a4 = new TableCell() { Text = "Quantity<br/>" };
                TableCell a5 = new TableCell() { Text = "Item Total<br/>" };
                TableCell a6 = new TableCell() { };

                TableCell b1 = new TableCell() { };
                TableCell b2 = new TableCell() { Text = p.Price + " skr" };
                TableCell b3 = new TableCell() { };
                TableCell b4 = new TableCell() { Text = Math.Round((double)(c.Amount * Convert.ToInt32(p.Price)), 2) + " skr" };
                TableCell b5 = new TableCell() { };
                TableCell b6 = new TableCell() { };

                a1.Controls.Add(btnImage);
                a6.Controls.Add(lnkDelete);
                b3.Controls.Add(ddlAmount);

                a.Cells.Add(a1);
                a.Cells.Add(a2);
                a.Cells.Add(a3);
                a.Cells.Add(a4);
                a.Cells.Add(a5);
                a.Cells.Add(a6);

                a.Cells.Add(b1);
                a.Cells.Add(b2);
                a.Cells.Add(b3);
                a.Cells.Add(b4);
                a.Cells.Add(b5);
                a.Cells.Add(b6);

                table.Rows.Add(a);
                table.Rows.Add(b);

                pnlCart.Controls.Add(table);

                subTotal += (c.Amount * Convert.ToInt32(p.Price));
            }
            litTotal.Text = Math.Round(subTotal, 2, MidpointRounding.AwayFromZero) + " skr";
            LitVat.Text = Math.Round(subTotal * 0.01, 2, MidpointRounding.AwayFromZero) + " skr";
            LitTotalAmount.Text = Math.Round(subTotal * 1.01 + 50, 2, MidpointRounding.AwayFromZero) + " skr";
        }
Ejemplo n.º 11
0
        //}


        private void RankAdd()
        {
            G2Entities db = new G2Entities();
            List<Cart> list = (List<Cart>)Session["cart"];
            ProductModel productModel = new ProductModel();

            if (Session["cart"] != null)
            {
                foreach (var c in list)
                {
                    var p = productModel.GetProduct(c.ProductID);
                    var b = db.Products.Find(c.ProductID);

                    p.Rank = b.Rank++;
                    db.SaveChanges();
                }
            }
        }
Ejemplo n.º 12
0
 public List<Product> GetItemsInCart(List<Cart> carts)
 {
     ProductModel pm = new ProductModel();
     List<Product> itemList = new List<Product>();
     foreach (Cart p in carts)
     {
         itemList.Add(pm.GetProduct(p.ProductID));
     }
     return itemList;
 }