예제 #1
0
        public int AddBrick(int pid, string BrickName, string BrickDesc, string BrickIncript, string BrickPrice, string BrickImagePath, string BrickJSPath, bool BrickIsVisible, string Brickshowhide , bool BrickisStandard, string text1, string text2, string text3)
        {
            //Debug.WriteLine("addbrick: js path is " + BrickJSPath);
            //Debug.WriteLine("addbrick: showhide is " + Brickshowhide);

            var myBrick = new Brick();
            //myBrick.BrickID = BrickID;
            myBrick.pid = pid;
            myBrick.BrickName = BrickName;
            myBrick.Description = BrickDesc;
            myBrick.Incription = BrickIncript;
            myBrick.UnitPrice = Convert.ToDouble(BrickPrice);
            myBrick.ImagePath = BrickImagePath;
            myBrick.JSPath = BrickJSPath;
            myBrick.isVisible = BrickIsVisible;
            myBrick.showhide = Brickshowhide;
            myBrick.isStandard = BrickisStandard;
            myBrick.tb1 = text1;
            myBrick.tb2 = text2;
            myBrick.tb3 = text3;

            using (ProductContext _db = new ProductContext())
            {
                _db.Bricks.Add(myBrick);
                _db.SaveChanges();
            }

            int id = myBrick.BrickID;
            return id;
        }
예제 #2
0
        protected void RemoveBrick(object sender, CommandEventArgs e)
        {
            int brickid = Int32.Parse(e.CommandArgument.ToString());
            var _db = new ZVerseBrickProject.Models.ProductContext();
            Brick thebrick;
            Product theproduct;
            thebrick = _db.Bricks.Find(brickid);
            theproduct = _db.Products.Find(thebrick.pid);

            _db.Bricks.Remove(thebrick);
            _db.Products.Remove(theproduct);
            _db.SaveChanges();
            Response.Redirect("AdminPage.aspx", false);
            Context.ApplicationInstance.CompleteRequest();
        }
예제 #3
0
        public int AddProduct(string ProductName, string ProductDesc, string ProductPrice, string ProductCategory, string ProductImagePath, string ProductIncript)
        {
            var myProduct = new Product();
            myProduct.ProductName = ProductName;
            myProduct.Description = ProductDesc;
            myProduct.UnitPrice = Convert.ToDouble(ProductPrice);
            myProduct.ImagePath = ProductImagePath;
            myProduct.CategoryID = Convert.ToInt32(ProductCategory);
            myProduct.Incription = ProductIncript;

            using (ProductContext _db = new ProductContext())
            {
                _db.Products.Add(myProduct);
                _db.SaveChanges();
            }

            int id = myProduct.ProductID;
            return id;
        }
예제 #4
0
        protected void lv_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            if (e.CommandName.Equals("testbrick"))
            {
                //TextBox t = bricklist.Items[Convert.ToInt32(e.CommandArgument)].FindControl("brickid") as TextBox;
                TextBox brickid = e.Item.FindControl("brickid") as TextBox;
                TextBox brickname = e.Item.FindControl("brickname") as TextBox;
                TextBox brickprice = e.Item.FindControl("brickprice") as TextBox;

                Debug.Print(brickid.Text + " " + brickname.Text + " " + brickprice.Text);
                int bid = Int32.Parse(brickid.Text);
                var _db = new ZVerseBrickProject.Models.ProductContext();
                Brick thebrick;
                thebrick = _db.Bricks.Find(bid);
                thebrick.BrickName = brickname.Text;
                thebrick.UnitPrice = Double.Parse(brickprice.Text);
                _db.SaveChanges();
                Response.Redirect("AdminPage.aspx", false);
                Context.ApplicationInstance.CompleteRequest();

            }
        }
예제 #5
0
 /* Update the quantity of an item in the database */
 public void UpdateItem(string updateCartID, int updateProductID, int quantity)
 {
     using (var _db = new ZVerseBrickProject.Models.ProductContext())
     {
         try
         {
             var myItem = (from c in _db.ShoppingCartItems where c.CartId == updateCartID && c.Product.ProductID == updateProductID select c).FirstOrDefault();
             if (myItem != null)
             {
                 myItem.Quantity = quantity;
                 _db.SaveChanges();
             }
         }
         catch (Exception exp)
         {
             throw new Exception("ERROR: Unable to Update Cart Item - " + exp.Message.ToString(), exp);
         }
     }
 }
예제 #6
0
        /* Remove an item from the cart in the databse */
        public void RemoveItem(string removeCartID, int removeProductID)
        {
            using (var _db = new ZVerseBrickProject.Models.ProductContext())
            {
                try
                {
                    var myItem = (from c in _db.ShoppingCartItems where c.CartId == removeCartID && c.Product.ProductID == removeProductID select c).FirstOrDefault();
                    if (myItem != null)
                    {
                        // Remove Item.
                        _db.ShoppingCartItems.Remove(myItem);

                        //remove custom models
                        if (removeProductID > 15)
                        {
                            Brick thebrick;
                            Product theproduct;
                            int brickid = (from b in _db.Bricks where b.pid == removeProductID select b.BrickID).FirstOrDefault();
                            thebrick = _db.Bricks.Find(brickid);
                            theproduct = _db.Products.Find(removeProductID);

                            _db.Bricks.Remove(thebrick);
                            _db.Products.Remove(theproduct);
                        }

                        _db.SaveChanges();
                    }
                }
                catch (Exception exp)
                {
                    throw new Exception("ERROR: Unable to Remove Cart Item - " + exp.Message.ToString(), exp);
                }
            }
        }
예제 #7
0
        //This function will set the brickmodel visible property to
        // be true/false to reveal the model on the dropdown and catalogue.
        protected void ShowHide(object sender, CommandEventArgs e)
        {
            int brickid = Int32.Parse(e.CommandArgument.ToString());
            var _db = new ZVerseBrickProject.Models.ProductContext();
            Brick thebrick;
            thebrick = _db.Bricks.Find(brickid);

            //toggle the visibility property
            if (thebrick.isVisible)
            {
                thebrick.isVisible = false;
                thebrick.showhide = "Show";
            }
            else
            {
                thebrick.isVisible = true;
                thebrick.showhide = "Hide";
            }
            _db.SaveChanges();
            Response.Redirect("AdminPage.aspx", false);
            Context.ApplicationInstance.CompleteRequest();
        }